diff --git a/src/do.c b/src/do.c index 54cfd5960..ea55197d7 100644 --- a/src/do.c +++ b/src/do.c @@ -1376,7 +1376,9 @@ save_currentstate(void) { NHFILE *nhfp; - if (!program_state.something_worth_saving) + if (!program_state.something_worth_saving + || program_state.in_self_recover + || program_state.in_checkpoint) return; program_state.in_checkpoint++; diff --git a/src/mon.c b/src/mon.c index c67785325..aca835286 100644 --- a/src/mon.c +++ b/src/mon.c @@ -3432,6 +3432,9 @@ set_ustuck(struct monst *mtmp) u.uswallow = 0; u.uswldtim = 0; } +#ifdef INSURANCE + save_currentstate(); +#endif } void diff --git a/src/save.c b/src/save.c index bd2696e6c..d31e23148 100644 --- a/src/save.c +++ b/src/save.c @@ -284,6 +284,13 @@ savegamestate(NHFILE *nhfp) urealtime.start_timing); Sfo_long(nhfp, &svw.wreserve, "wreserve"); Sfo_int32(nhfp, &svw.wtreserved, "wtreserved"); + /* + * It is critical to ensure that u.ustuck_mid and u.usteed_mid + * hold current and correct data, in case this is needed by + * recover. + */ + u.ustuck_mid = (u.ustuck) ? u.ustuck->m_id : 0; + u.usteed_mid = (u.usteed) ? u.usteed->m_id : 0; Sfo_you(nhfp, &u, "gamestate-you"); Sfo_char(nhfp, yyyymmddhhmmss(ubirthday), "gamestate-ubirthday", 14); Sfo_long(nhfp, &urealtime.realtime, "gamestate-realtime"); @@ -354,6 +361,9 @@ savestateinlock(void) char whynot[BUFSZ]; NHFILE *nhfp; + if (!program_state.something_worth_saving || program_state.in_self_recover) + return; + program_state.saving++; /* inhibit status and perm_invent updates */ /* When checkpointing is on, the full state needs to be written * on each checkpoint. When checkpointing is off, only the pid