fix #H7667 - maybe_reset_pick(), other bad context

When deciding whether to discard interrupted lock/unlock context while
changing levels, maybe_reset_pick() checks whether xlock.box is being
carried.  But it was doing so after the old level had been saved and
memory for non-carried container there had been freed.

That led to a couple of other issues.  context.travelcc was using -1
for 'no cached value', but the fields of travelcc have type 'xchar' and
shouldn't be given negative values.  0 should be fine for 'no cache'.

Failed partial restore which occurred after old game's context had been
loaded would begin a new game with old game's stale context.  Restoring
goes out of its way to avoid that for 'flags' but didn't for 'context'.
This commit is contained in:
PatR
2018-12-04 17:10:15 -08:00
parent f6b7ce02d8
commit 36c2aec2ff
7 changed files with 39 additions and 41 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 hack.c $NHDT-Date: 1540591769 2018/10/26 22:09:29 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.194 $ */
/* NetHack 3.6 hack.c $NHDT-Date: 1543972190 2018/12/05 01:09:50 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.200 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -923,7 +923,7 @@ int mode;
u.dx = u.tx - u.ux;
u.dy = u.ty - u.uy;
nomul(0);
iflags.travelcc.x = iflags.travelcc.y = -1;
iflags.travelcc.x = iflags.travelcc.y = 0;
}
return TRUE;
}
@@ -1045,7 +1045,7 @@ int mode;
nomul(0);
/* reset run so domove run checks work */
context.run = 8;
iflags.travelcc.x = iflags.travelcc.y = -1;
iflags.travelcc.x = iflags.travelcc.y = 0;
}
return TRUE;
}