From 2413ac2be7f1551b7e52c93d0ce548534eda5aad Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Wed, 13 Dec 2023 01:33:24 +0000 Subject: [PATCH] Fix crash during restore when mounted The new "riding blocks stealth" code was reading u.usteed at an early point in the restore process, before its value was reliable (dorecover()->restgamestate()->set_uasmon()->steed_vs_stealth()); because restgamestate() happens prior to restlevelstate(), the value of u.usteed will be a stale pointer from some previous game, and attempting to determine whether the steed is flying will crash the game. steed_vs_stealth() doesn't actually need to be called during the restore process (because BStealth is saved in the save file), so this can be easily fixed by omitting the call to it during the restore. --- src/polyself.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/polyself.c b/src/polyself.c index 0895ee1e5..807e5ef8c 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -105,7 +105,12 @@ set_uasmon(void) PROPSET(BLINDED, !haseyes(mdat)); #undef PROPSET - float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */ + /* whether the player is flying/floating depends on their steed, + which won't be known during the restore process: but BFlying + and BStealth should be set correctly already in that case, so + there's nothing to do */ + if (!gp.program_state.restoring) + float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */ polysense(); #ifdef STATUS_HILITES