devilutionX icon indicating copy to clipboard operation
devilutionX copied to clipboard

Fix statting on death crash

Open kphoenix137 opened this issue 3 weeks ago • 3 comments

Fixes: https://github.com/diasurgical/DevilutionX/issues/8261

Prevents the player from statting while in the throes of death.

kphoenix137 avatar Dec 03 '25 10:12 kphoenix137

Do you know why the game crashes? Does it have something to do with _pmode?

StephenCWills avatar Dec 03 '25 23:12 StephenCWills

Do you know why the game crashes? Does it have something to do with _pmode?

It's a sprite rendering problem. I'm not sure exactly what causes it, but whatever functions are called are likely forcing the player sprite to update into an illegal state in combination with the death animation.

kphoenix137 avatar Dec 04 '25 01:12 kphoenix137

This doesn't happen in CalcPlrGraphics(), suggesting that there was an assumption the player would not be in a death state when this function is called.

Actually, upon reviewing StartPlayerKill(), it seems that CalcPlrInv() is explicitly called after dropping all the player's gear upon death, and this happens after setting _pmode to PM_DEATH. However, the loadgfx parameter is set to false in that case so the error is avoided. That means the assert should be something like:

assert(loadgfx && player._pmode == PM_DEATH); Or: assert(loadgfx && animWeaponId != PlayerWeaponGraphic::Unarmed && player._pmode == PM_DEATH);

But I also wonder if maybe we shouldn't just modify LoadPlrGfx() so that it forces the unarmed animation instead of loading no graphics at all. I can't imagine why you would prefer loading no animation and risking a probable game crash over loading what was almost certainly the intended animation given the player's current state.

StephenCWills avatar Dec 04 '25 04:12 StephenCWills