No, I should have been clearer. That's how I first got the crash. I could then immediately re-open SCICompanion, hover over the lines I specified, and watch it crash again.
Hmm... maybe I haven't fixed the issue then. Did you decompile all the scripts in the game? I can see the issue still happening if User.sc wasn't decompiled, but if you decompiled everything and it still is happening, then I might not have the right repro... hmm...
So let me see if I understand this: each script keeps a lookup table of index numbers for each procedure/method in it. SCICompanion will automatically generate that lookup table based on the order each procedure appears (a perfectly logical approach). The Classic Sierra compiler generated that lookup table based on some other reference (likely some sort of text file), the consequence of which is that lookup indexes will not necessarily be in order.
Any script (A) that includes a reference to another script's (B) procedures does so by referencing (B)'s lookup table index. So my recompiled 414 script failed to work because it was referencing procedure index 5 in SCICompanion's compiled 999.scr, when it needed to reference index 6 in Classic Sierra compiled 999.scr.
That's the general gist of it, but this is specific to species indices - it has nothing to do with procedures or methods. Each class (or species) has a number associated with it.
When SCI Companion encounters this line:
(identify state: 4 seconds: 0 cycles: 0)
It looks and sees that (defined in the same file, script 414) "identify" is an instance of the "Script" class. It then tries to validate that
state,
seconds and
cycles are all properties or methods on Script.
To do so, it needs to find the species number of the class. It looks at the included .sco files (which are generated by the compiler or decompiler when compiling or decompiling a script).
It sees that "Script" is the 5th class in Obj.sco (for script resource 999). It then looks at vocab.996, which tells us that the 5th class defined in script 999 has species index 5. So the compiler goes "ok, I need to look up properties on species index 5".
Then it goes back to the .sco file and says "ok, give me info about the class that says it's species 5". And in the .sco file, that's EventHandler that says it's species 5 (which is correct). So we compare against the methods and properties of EventHandler (instead of "Script") and fail.
Listing the details of it out like this make me think I can fix how we obtain the species index (italicized above). The .sco file actually has information about which species each class is already inside it - I don't need to touch the vocab.996 resource. Need to think about this a bit more. At any rate, this would require a fix in SCI Companion, so it's of no use to you now.
I wonder how prevalent missing procedures are in Sierra games in general... I've already seen Colonel's Bequest has a couple. Heck, there's a whole missing script file referenced in there (984).
Well I've decompiled a lot of games, and this is the first I've seen of it that I can remember. Although I think there are still some mysterious compile errors in decompiled games that I haven't had time to look into - so perhaps this was the cause of those too.
Soon as I get the chance I'll try the dummy filler method. I'll have to compile 999 for SCICompanion's benefit, but I shouldn't have to include that if I wanted to patch a vanilla copy of LB1, should I?
Correct, it shouldn't need to be included. Compiling 999 should generate an 999.sco and a vocab.996 resource that makes everything consistent for the compiler - i.e. compiling other scripts that reference 999 will now reference valid species numbers.
btw, I hope you're not making a patch to remove the fingerprint "copy protection".