fix "Bad fruit #N" warnings when saving bones

savebones() sets all the fruit indices negative, then resets to the
normal positive value for each fruit it actually writes into the bones
file.  But if 'perm_invent' is enabled and something triggers an
update_inventory() while bones saving is in progress, object formatting
for the inventory display won't be able to find any fruits, resulting
in impossible "Bad fruit #N".  Fix is to turn off 'perm_invent' when
the game ends, so it won't be On when bones are written.  Disclosure
uses a popup for inventory so persistent window is obsolete by then
anyway.

[I don't know what is triggering update_inventory() while savebones()
is executing.  Also, I don't see where the fruits whose index stayed
negative--because there aren't any on level being saved--get purged.
Maybe when those bones are loaded by another game?]
This commit is contained in:
PatR
2019-06-24 15:11:51 -07:00
parent ed08938ada
commit cfc8599e69
2 changed files with 11 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 end.c $NHDT-Date: 1559675615 2019/06/04 19:13:35 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.176 $ */
/* NetHack 3.6 end.c $NHDT-Date: 1561414303 2019/06/24 22:11:43 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.178 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1044,6 +1044,12 @@ done_object_cleanup()
/* placebc(); */
lift_covet_and_placebc(override_restriction);
}
/* persistent inventory window now obsolete since disclosure uses
a normal popup one; avoids "Bad fruit #n" when saving bones */
if (iflags.perm_invent) {
iflags.perm_invent = FALSE;
update_inventory(); /* make interface notice the change */
}
return;
}
@@ -1223,6 +1229,8 @@ int how;
deal with ball and chain possibly being temporarily off the map */
if (!program_state.panicking)
done_object_cleanup();
/* in case we're panicking; normally cleared by done_object_cleanup() */
iflags.perm_invent = FALSE;
/* remember time of death here instead of having bones, rip, and
topten figure it out separately and possibly getting different