diff --git a/doc/fixes5-0-1.txt b/doc/fixes5-0-1.txt index e324c0502..7dd6d9c30 100644 --- a/doc/fixes5-0-1.txt +++ b/doc/fixes5-0-1.txt @@ -338,3 +338,5 @@ switch to using LUA_VERSION_NUM instead of LUA_VERSION_RELEASE_NUM for Lua version checking include a set of decals (petmark and pilemark) in win/share/decals.txt and adjust tile processing to include it +preserve inactive level timestamps across saving and restoring so that + monster catch-up, including tameness loss, retains time spent away diff --git a/src/save.c b/src/save.c index 7eb7f5eb6..dea871d54 100644 --- a/src/save.c +++ b/src/save.c @@ -31,7 +31,7 @@ staticfn void save_gamelog(NHFILE *); staticfn void savegamestate(NHFILE *); staticfn void savelev_core(NHFILE *, xint8); staticfn void save_msghistory(NHFILE *); -staticfn void save_adjust_levelflags(void); +staticfn void save_adjust_levelflags(long); #if defined(HANGUPHANDLING) #define HUP if (!program_state.done_hup) #else @@ -484,6 +484,7 @@ savelev_core(NHFILE *nhfp, xint8 lev) short tlev; #endif int i, c, r; + long timestamp; coord *tmpc; program_state.saving++; /* even if current mode is FREEING */ @@ -541,14 +542,17 @@ savelev_core(NHFILE *nhfp, xint8 lev) Sfo_schar(nhfp, &svl.lastseentyp[c][r], "lastseentyp"); } } - /* svm.moves will actually be read back into svo.omoves on restore */ - Sfo_long(nhfp, &svm.moves, "lev-timestmp"); + /* preserve idle time when copying levels; match getlev()'s + monster catch-up guard */ + timestamp = (!u.uz.dlevel || program_state.restoring == REST_LEVELS) + ? svo.omoves : svm.moves; + Sfo_long(nhfp, ×tamp, "lev-timestmp"); save_stairs(nhfp); Sfo_dest_area(nhfp, &svu.updest, "lev-updest"); Sfo_dest_area(nhfp, &svd.dndest, "lev-dndest"); - save_adjust_levelflags(); + save_adjust_levelflags(timestamp); Sfo_levelflags(nhfp, &svl.level.flags, "lev-level_flags"); - rest_adjust_levelflags(0L); + rest_adjust_levelflags(svm.moves - timestamp); Sfo_int(nhfp, &svd.doors_alloc, "lev-doors_alloc"); /* don't rely on underlying write() behavior to write @@ -596,10 +600,10 @@ savelev_core(NHFILE *nhfp, xint8 lev) } void -save_adjust_levelflags(void) +save_adjust_levelflags(long timestamp) { - /* adjust any timestamps */ - moves_to_relative_time(&svl.level.flags.stasis_until); + /* use the same time base as lev-timestmp */ + svl.level.flags.stasis_until -= timestamp; } staticfn void