]> granicus.if.org Git - nethack/commitdiff
avoid new "where are we?" panic
authorPatR <rankin@nethack.org>
Sat, 30 Apr 2022 06:00:51 +0000 (23:00 -0700)
committerPatR <rankin@nethack.org>
Sat, 30 Apr 2022 06:00:51 +0000 (23:00 -0700)
savelev() gets run to clean up memory even if the player quits before
level 1 is created, and a change made yesterday panicked if it couldn't
figure out what level the hero is on.  Caught by entrez, again....

If not actually writing a level's file, don't panic if both u.uz and
g.uz_save are 0.  Having one of those be non-zero is only essential
when the level being processed is the Plane of Water or Plane of Air.

doc/fixes3-7-0.txt
src/save.c

index 6d4fa18a3003547ed3e1e6ae0a4b579b6fc8c64e..ee2bcf2c7cfaa5735afe70a2d4574d21abacea55 100644 (file)
@@ -1,4 +1,4 @@
-HDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.902 $ $NHDT-Date: 1651297020 2022/04/30 05:37:00 $
+HDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.903 $ $NHDT-Date: 1651298443 2022/04/30 06:00:43 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -1196,6 +1196,7 @@ force-fight against furniture covered by an object described the attack as
 using #wizmakemap on Plane of Water added a new set of air bubbles each time
        it was run and eventually replaced just about all the water; likewise
        with clouds on Plane of Air
+avoid new "where are we?" panic if player quits during character selection
 
 curses: 'msg_window' option wasn't functional for curses unless the binary
        also included tty support
index 89516275a7b74607835eb7f0e6437521d81ac0f9..d0354573abe315ed58fe131ee22c610dedab514a 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 save.c  $NHDT-Date: 1644524061 2022/02/10 20:14:21 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.181 $ */
+/* NetHack 3.7 save.c  $NHDT-Date: 1651298444 2022/04/30 06:00:44 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.186 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Michael Allison, 2009. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -463,8 +463,10 @@ savelev(NHFILE *nhfp, xchar lev)
     boolean set_uz_save = (g.uz_save.dnum == 0 && g.uz_save.dlevel == 0);
 
     /* caller might have already set up g.uz_save and zeroed u.uz;
-       if not, we need to set it for save_bubbles() */
-    if (set_uz_save) {
+       if not, we need to set it for save_bubbles(); caveat: if the
+       player quits during character selection, u.uz won't be set yet
+       but we'll be called during run-down */
+    if (set_uz_save && perform_bwrite(nhfp)) {
         if (u.uz.dnum == 0 && u.uz.dlevel == 0) {
             g.program_state.something_worth_saving = 0;
             panic("savelev: where are we?");