auc42x Posted July 28, 2023 Share Posted July 28, 2023 (edited) I would like to request help on debugging strategies to figure out a crashing problem that I'm having with modded BG2. I'm not an expert modder, since I tend to replay the game every few years and have to relearn it every time, but I'm generally a technical person. Unfortunately, I've reached the end of my Google-Fu on this one. I've found other references to the same problem (including a 2008 G3 thread), but the links that they cite have long since gone dead, even with the Wayback machine. It also doesn't help that Spellhold Studios is going through one of its dead periods, so I can't access anything there. I'm using the original BG2 + ToB, patched, with a relative handful of mods. Specifically: TobEx (v26), BG2Fixpack (v13), Unfinished Business (v28), Widescreen (v3.08), BG2 GUI (v5.6), Rogue Rebalancing (v4.92), Sword Coast Stratagems (v34.3) and Tweaks Anthology (v16). I can post the full WeiDU log if needed, of course, although I'm primarily looking for debugging strategies to diagnose the problem. Specifically, that problem is: I am getting a crash with the message of "An Assertion failed in CCGameEffect.cpp at line number 1536" upon resting. I discovered the problem only several hours into my new game (which I had thought was stable), but I discovered that I can cause the crash in earlier saves, and can prevent the crash in my current save, by perturbing the game state in various ways (see below). The trouble is, I can't figure out the root cause of the bug, which is almost certainly a mod component. I'm not adverse to starting over if I have to, but I don't want to take a guess as to what is wrong, be incorrect, and only find out after several more hours of play. This thread from 2008 describes my problem almost exactly (although the original poster found it on their first rest, as opposed to several rests in), and it appeared to manifest in Tweaks Anthology: https://www.gibberlings3.net/forums/topic/12895-assertion-failed-in-ccgameeffectcpp-at-line-number-1536/ One of the responses said "Any time you see a CGameEffect assertion at L:1536, it's a bugged item or spell", which I accept as a working hypothesis. Following up on that, I have discovered that I can prevent the crash by removing characters from my party, or by unselecting spells to be memorized. I can induce a crash by adding other party members. What I cannot do is discover one single cause. For example, I first encountered the crash when I had a party of CHARNAME, Yoshimo, Aerie, and Keldorn. I can prevent the crash by: Removing Keldorn from the party, but keeping all others. Removing Aerie from the party, but keeping all others. De-selecting all L4 priest spells that Aerie is set to memorize that night, but keeping all characters in the party. And various other perturbations. On the other hand, I can create a crash by going back to previous saves and adding various other spellcasters (priest or mage) to the party and resting, with or without Yoshimo/Keldorn/Aerie. My feeling is that the problem is with a spell (or spells), which I understand includes pretty much all abilities, but I can't narrow it down further than that. Various spells/abilities and items are added by the above mods, and I suspect that a few of them modify each other in turn. None of them are especially important to me individually, and I could probably solve the problem by dropping that mod component... if I can only figure out where the problem lies. Therefore, I am looking for help on how to debug this properly. I've run the G3 debugging suite, but it spits out ~2700 spell errors and ~800 item errors (not uncommon in debugging tools of any sort), none of which look especially "unusual" compared to the others. The 2008 thread had a reference to various utilities like an "old index checker" and a link to a "Nyuthrun's Fix" (which apparently worked, but it was located at a home.comcast.net account that is no longer there). I've tried running Near Infinity checks for mis-indexed effects (from the 2008 thread: "This is almost certainly another effects index error"), but no dice. I don't see any useful log results (TobEx just reports the failed assertion, etc.). Is there any advice on what/how to check next? Thanks. [Editing this post to add a "solved" tag to the topic line; no other changes]. Edited July 29, 2023 by auc42x Quote Link to comment
Bubb Posted July 28, 2023 Share Posted July 28, 2023 That assert is tripped when the engine decodes an invalid opcode. You can try using Near Infinity's advanced search to check if all .SPL, .EFF, .ITM, and .CRE files have valid opcodes. In vanilla oBG2 0-60, 62-259, 261-311, and 313-317 don't trigger the assert. ToBEx might add 318 as well. Quote Link to comment
auc42x Posted July 29, 2023 Author Share Posted July 29, 2023 20 hours ago, Bubb said: That assert is tripped when the engine decodes an invalid opcode. You can try using Near Infinity's advanced search to check if all .SPL, .EFF, .ITM, and .CRE files have valid opcodes. In vanilla oBG2 0-60, 62-259, 261-311, and 313-317 don't trigger the assert. ToBEx might add 318 as well. Thank you, this did let me find the error! And since I like to be one of those people that leaves behind useful information for the next person who goes searching for an answer, I'll write up the details. By searching with Near Infinity, I found four spells that had an invalid opcode of 61: GHAST1.spl, SPPR426.SPL (Cause Serious Wounds), SPPR524.SPL (Cause Critical Wounds), and SPPR740.SPL (Wither). It looks like these come from the Sword Coast Stratagems mod, from the IWD spells component. I didn't find any creatures, items, or effects with any invalid opcodes. Digging into it a bit, I see that 61 isn't a valid opcode for original BG2, as you said (https://gibberlings3.github.io/iesdp/opcodes/bg2tob.htm#op61), but it is valid in BG2EE (https://gibberlings3.github.io/iesdp/opcodes/bgee.htm#op61)! Specifically, it is a creature RGB color fade effect, and I can see how that would be used in the spells listed above. To verify, I tried casting one of the spells, and indeed it crashed as soon as the spell casting animation completed. I have to admit that I don't know why one of those spells would be triggering on a rest, as per my experimentation from the last post, but I know that odd things can happen behind the scenes. As a "blunt hammer" experimental fix, I tried removing those four spells from the override directory, and sure enough the crashes stopped. (Removing SPPR426.SPL was actually enough to stop the crashing). Removing those four spells outright would probably work well enough to keep going with the game, but it is a little inelegant. The BG2EE opcodes documentation notes that it is similar to opcodes 8, 9, and 50. The BG2 "native" version of the "Cause Serious Wounds" spell uses opcode 50 ("Color: Glow by RGB (Brief)"). Therefore, using Near Infinity, I edited the four spells above to change all instances of opcode 61 to opcode 50 (there were 56 changes needed in the end, because of lots of nested effects in three of the four spells). Eyeballing the values that resulted, I think it looks reasonable, and it probably isn't a problem if a temporary color change goes a bit wacky, anyway. And now, no more crashes. At least so far, trying all the tests that were causing crashes the last two days. So for the benefit of anyone who has this problem in the future in unmodified BG2, the problem can be narrowed down by using Near Infinity, and doing an advanced search for opcodes 61, 260, 312, and 318+ on the CRE, EFF, ITM, and SPL resource types. (Or, if using TobEx, 318 is indeed valid, and you can search for 319+ instead). That will let you find the offending files, and hopefully narrow it down to the mod with the problem. The actual fix will be dependent on the exact problem. In this case, I could change opcode 61 to opcode 50 by editing the files, and it's relatively innocuous because 61 was used for a genuine EE effect. Removing the files from your override directory is the "blunt hammer" approach and might work, though removing files that exist only in override usually makes me nervous. (It is a bit safer to remove files that have a "base" version, but not necessarily totally safe). Uninstalling the mod component should also work, needless to say. If my editing trick didn't work, I probably would have started over without that component. I'm a little surprised that this bug is present in SCS and that I couldn't find anything on it through searching; surely I'm not the only one to try install IWD spells in an original BG2 version? I'll toddle off to the appropriate forum to make a bug report in a minute. Quote Link to comment
Morgoth Posted July 29, 2023 Share Posted July 29, 2023 You betrayed the essence of internet; you should have written "thank you! solved", then disconnected from the forum permanently. Quote Link to comment
auc42x Posted July 30, 2023 Author Share Posted July 30, 2023 22 hours ago, Morgoth said: You betrayed the essence of internet; you should have written "thank you! solved", then disconnected from the forum permanently. Aww. I don't want to be "that guy"! Doing that really is the cruelest version. By not saying anything, the next person might just think "they never solved it; I'll keep looking". But seeing that it was solved, they keep thinking "something in here is enough to fix the problem!" and spin their wheels for a while. Not that I speak from personal experience, or anything. As a bit of extra detail for the benefit of any future readers, the bug discussion is here: https://www.gibberlings3.net/forums/topic/37026-bug-invalid-bg2-opcode-in-iwd-spells-component/ Summary: the current SCS version IWD spells component only works properly for Enhanced Edition, but it should be fixed in a future release. And the author of Near Infinity has added functionality to search for invalid opcodes, which will make this diagnosis easier in the future! Quote Link to comment
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.