diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index a3c1cf925..52a3614db 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1,4 +1,4 @@ -NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1442 $ $NHDT-Date: 1717570484 2024/06/05 06:54:44 $ +NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1443 $ $NHDT-Date: 1717878584 2024/06/08 20:29:44 $ General Fixes and Modified Features ----------------------------------- @@ -1954,6 +1954,8 @@ on medusa-4, Medusa and the downstairs were located in different chambers on medusa-3 and medusa-4, Perseus's statue was located in a different chamber from Medusa omit "a" from "drowned in a limitless water" when drowning on Plane of Water +restoring a save file could trigger impossible "rnd(0) attempted" if it tried + to make an unhidden mimic hide an an object Fixes to 3.7.0-x Platform and/or Interface Problems Exposed Via git Repository diff --git a/include/hack.h b/include/hack.h index 1a1702e74..b385fc37f 100644 --- a/include/hack.h +++ b/include/hack.h @@ -1,4 +1,4 @@ -/* NetHack 3.7 hack.h $NHDT-Date: 1713334806 2024/04/17 06:20:06 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.253 $ */ +/* NetHack 3.7 hack.h $NHDT-Date: 1717878594 2024/06/08 20:29:54 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.257 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Pasi Kallinen, 2017. */ /* NetHack may be freely redistributed. See license for details. */ @@ -727,8 +727,9 @@ struct restore_info { }; enum restore_stages { - REST_GSTATE = 1, /* restoring current level and game state */ - REST_LEVELS = 2, /* restoring remainder of dungeon */ + REST_GSTATE = 1, /* restoring game state + first pass of current level */ + REST_LEVELS = 2, /* restoring remainder of dungeon */ + REST_CURRENT_LEVEL = 3, /* final pass of restoring current level */ }; struct rogueroom { diff --git a/src/restore.c b/src/restore.c index 7ff379117..4d587ce9f 100644 --- a/src/restore.c +++ b/src/restore.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 restore.c $NHDT-Date: 1686726258 2023/06/14 07:04:18 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.211 $ */ +/* NetHack 3.7 restore.c $NHDT-Date: 1717878585 2024/06/08 20:29:45 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.228 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2009. */ /* NetHack may be freely redistributed. See license for details. */ @@ -709,6 +709,8 @@ restlevelstate(void) return; } +/* after getlev(), put current level into a level/lock file; + essential when splitting a save file into individual level files */ /*ARGSUSED*/ staticfn int restlevelfile(xint8 ltmp) @@ -718,8 +720,8 @@ restlevelfile(xint8 ltmp) nhfp = create_levelfile(ltmp, whynot); if (!nhfp) { - /* BUG: should suppress any attempt to write a panic - save file if file creation is now failing... */ + /* failed to create a new file; don't attempt to make a panic save */ + gp.program_state.something_worth_saving = 0; panic("restlevelfile: %s", whynot); } bufon(nhfp->fd); @@ -756,6 +758,9 @@ dorecover(NHFILE *nhfp) gp.program_state.restoring = 0; return 0; } + /* after restgamestate() -> restnames() so that 'bases[]' is populated */ + init_oclass_probs(); /* recompute go.oclass_prob_totals[] */ + restlevelstate(); #ifdef INSURANCE savestateinlock(); @@ -825,6 +830,9 @@ dorecover(NHFILE *nhfp) (void) validate(nhfp, (char *) 0, FALSE); get_plname_from_file(nhfp, gp.plname); + /* not 0 nor REST_GSTATE nor REST_LEVELS */ + gp.program_state.restoring = REST_CURRENT_LEVEL; + getlev(nhfp, 0, (xint8) 0); close_nhfile(nhfp); restlevelstate(); @@ -836,7 +844,6 @@ dorecover(NHFILE *nhfp) assign_graphics(ROGUESET); reset_glyphmap(gm_levelchange); max_rank_sz(); /* to recompute gm.mrank_sz (botl.c) */ - init_oclass_probs(); /* recompute go.oclass_prob_totals[] */ if ((uball && !uchain) || (uchain && !uball)) { impossible("restgamestate: lost ball & chain"); @@ -1133,7 +1140,7 @@ getlev(NHFILE *nhfp, int pid, xint8 lev) } /* regenerate monsters while on another level */ - if (!u.uz.dlevel) + if (!u.uz.dlevel || gp.program_state.restoring == REST_LEVELS) continue; if (ghostly) { /* reset peaceful/malign relative to new character;