fix restore panic: relink_light_sources

Reported directly to devteam:  restoring a save file which was
made while the hero was polymorphed into a light emitting monster
would trigger a panic.

This was caused by an attempt to deal with corrupted save data,
which in turn was caused by attempting to use impossible() in a
situation where the game can't reliably continue.  If bad light
source data was ignored during restore, it would cause trouble
during next save.

Remove the check which was erroneously detecting invalid data
and also change two impossible() calls to panic().
This commit is contained in:
PatR
2024-09-17 14:55:01 -07:00
parent 93ff5e6409
commit 6b08e7758b
2 changed files with 24 additions and 30 deletions

View File

@@ -1,4 +1,4 @@
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1472 $ $NHDT-Date: 1725143669 2024/08/31 22:34:29 $
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1480 $ $NHDT-Date: 1726609530 2024/09/17 21:45:30 $
General Fixes and Modified Features
-----------------------------------
@@ -778,9 +778,8 @@ covetous monsters will teleport to downstairs or upstairs to heal
have fake player monsters use verbalize instead of pline when reacting to chat
fix mention_walls distinguishing unseen walls from solid stone
don't push unknown boulders when moving
in flush_screen, reorder the code slightly to complete the bot() and
timebot() calls prior to the window port call to place the cursor
on the hero
in flush_screen, reorder the code slightly to complete the bot() and timebot()
calls prior to the window port call to place the cursor on the hero
magic traps can toggle intrinsic invisibility
Death attacking a monster does drain life attack
add unique Rider revival messages
@@ -2031,6 +2030,9 @@ wizards were discovering unread spellbooks whenever any skill was advanced;
if tips were enabled, the getpos/farlook tip clobbered the initial prompt (at
least for tty's one line message window), so reissue the prompt after
the tip has been displayed
a post-3.6 change to try to cope with invalid light source data when restoring
corrupted save file caused "panic: relink_light_sources" for valid
save file if saved while hero was poly'd into a light emitting monster
Fixes to 3.7.0-x Platform and/or Interface Problems Exposed Via git Repository

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 light.c $NHDT-Date: 1710549969 2024/03/16 00:46:09 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.70 $ */
/* NetHack 3.7 light.c $NHDT-Date: 1726609514 2024/09/17 21:45:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.75 $ */
/* Copyright (c) Dean Luick, 1994 */
/* NetHack may be freely redistributed. See license for details. */
@@ -499,32 +499,24 @@ relink_light_sources(boolean ghostly)
for (ls = gl.light_base; ls; ls = ls->next) {
if (ls->flags & LSF_NEEDS_FIXUP) {
if (ls->type == LS_OBJECT || ls->type == LS_MONSTER) {
if (!ls->id.a_uint) {
/* it was possible to get stuck in this loop on bad
* savefile data load and repeatedly prompt the player
* for a key press after displaying an impossible message.
* Consider this bad data from a savefile and panic() */
panic("relink_light_sources: id = 0, type = %d",
(int) ls->type);
}
if (ghostly) {
if (!lookup_id_mapping(ls->id.a_uint, &nid))
impossible("relink_light_sources: no id mapping");
} else
nid = ls->id.a_uint;
if (ls->type == LS_OBJECT) {
which = 'o';
ls->id.a_obj = find_oid(nid);
} else {
which = 'm';
ls->id.a_monst = find_mid(nid, FM_EVERYWHERE);
}
if (!ls->id.a_monst)
impossible("relink_light_sources: can't find %c_id %d",
which, nid);
} else
impossible("relink_light_sources: bad type (%d)", ls->type);
nid = ls->id.a_uint;
if (ghostly && !lookup_id_mapping(nid, &nid))
panic("relink_light_sources: no id mapping");
which = '\0';
if (ls->type == LS_OBJECT) {
if ((ls->id.a_obj = find_oid(nid)) == 0)
which = 'o';
} else {
if ((ls->id.a_monst = find_mid(nid, FM_EVERYWHERE)) == 0)
which = 'm';
}
if (which != '\0')
panic("relink_light_sources: can't find %c_id %u",
which, nid);
} else {
panic("relink_light_sources: bad type (%d)", ls->type);
}
ls->flags &= ~LSF_NEEDS_FIXUP;
}
}