Opened 19 months ago
Closed 19 months ago
#14493 closed defect (fixed)
XEEN: Coin of Daily &use magic items crashes game
Reported by: | IvoryTower33 | Owned by: | dreammaster |
---|---|---|---|
Priority: | normal | Component: | Engine: MM: Xeen |
Version: | Keywords: | ||
Cc: | Game: | Might and Magic: World of Xeen |
Description (last modified by )
edited: actually, the game crashes frequently when trying to use either of those items, both wand of daily protection and coin of daily sorcery. Not sure why this happens.
Attachments (1)
Change History (8)
comment:1 by , 19 months ago
Component: | --Unset-- → Engine: Xeen |
---|---|
Priority: | high → normal |
Summary: | Coin of Daily sorcery cassts wrong spell → XEEN: Coin of Daily sorcery casts wrong spell |
by , 19 months ago
Attachment: | xeen bug savefile.rar added |
---|
comment:2 by , 19 months ago
Owner: | set to |
---|---|
Resolution: | → fixed |
Status: | new → closed |
comment:3 by , 19 months ago
I've set it up correctly, meaning the extra path and such, but now when I try to use the item it crashes my game I'm afraid.
I've experienced this issue before with the "day of protection" wand, which I fixed by reloading another game. Not entirely sure what might be happening.
EDIT: casting recharge item on the "coin of daily sorcery" seems to have fixed the issue : O
comment:4 by , 19 months ago
actually, the game crashes frequently when trying to use either of those items, both wand of daily protection and coin of daily sorcery. Not sure why this happens.
comment:5 by , 19 months ago
Description: | modified (diff) |
---|---|
Resolution: | fixed |
Status: | closed → new |
Summary: | XEEN: Coin of Daily sorcery casts wrong spell → XEEN: Coin of Daily &use magic items crashes game |
comment:6 by , 19 months ago
Tested with master c77e9f8cae261673478fbf071401c767995a3b24.
This seems to be caused by a stale pointer dereference when a item spell uses combat._oldCharacter.
dialogs/dialogs_items.cpp:
int ItemsDialog::doItemOptions(...) { ... _oldCharacter = &c; // FIXME: Some spells use combat._oldCharacter, and it may not be set // if an item is used directly after the game is started if (!combat._oldCharacter) combat._oldCharacter = &c; ... }
If combat._oldCharacter was set before and a new game is loaded the check will fail and it will not be reset. A possible fix would be to reset combat._oldCharacter to nullptr when loading a game (e.g. in Combat::setupCombatParty()).
To reproduce:
- Load slot 23: "dasd" (from the provided save)
- Use the "Coin of daily sorcerery" (sic)
- Load slot 23 again
- Use the coin again
This should either trigger a crash or an invalid memory access when using an address sanitizer like Valgrind.
comment:7 by , 19 months ago
Description: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | new → closed |
You're right. I dug a bit deeper, and Combat._oldCharacter is set all the time when a character casts a spell (so it would really be more appropriate if it were a general global). So it was proper to always properly set the field to the character whose item is being used, no matter what mode the game is in. I've now committed an appropriate fix.
Fixed, thanks for noticing the problem.
Just a heads-up, if you decide to test out the fix.. daily builds right now don't have compiled data needed for Xeen. In order to run it, you need a downloaded copy of the ScummVM source, and from the Launcher, select the game's Game Options, go to the Paths tab, and point the Extra Path to /devtools/create_mm folder of the ScummVM source.