avoid new "where are we?" panic

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.
This commit is contained in:
PatR
2022-04-29 23:00:51 -07:00
parent 0efa1d60b7
commit 140077b163
2 changed files with 7 additions and 4 deletions

View 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

View 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?");