fix #K4189 - dorecover() bug

Restoring was hiding unhidden mimics and if that chose an object
other than boulder of gold pieces, it called mkobj() before an
array used by that routine was initialized.  The result was warning
"rnd(0) attempted" when NH_DEVEL_STATUS wasn't set to 'released' or
divide by 0 crash if it was set to that.

Restore should not be catching up for lost time when unpacking a
save file into individual level files, and if it hadn't done that
it wouldn't hide mimics who aren't currently hidden.

In addition to avoiding that, this also moves the initialization of
the offending mkobj array sooner.

[3.6 didn't use that array so wasn't susceptible to this.  It is
hiding unhidden mimics during what should be a strictly bookkeeping
operation though.]
This commit is contained in:
PatR
2024-06-08 13:34:12 -07:00
parent d02028fe66
commit d7008f8fe5
3 changed files with 19 additions and 9 deletions

View File

@@ -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 {