Fix statting on death crash
Fixes: https://github.com/diasurgical/DevilutionX/issues/8261
Prevents the player from statting while in the throes of death.
Do you know why the game crashes? Does it have something to do with _pmode?
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.
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.