reset travel cache when changing levels
When travel fails to reach its destination, it remembers the target spot to use as default next time. But that spot is only meaningful on the current level. Discard last travel destination when moving to a different level. Also, discard unlocking context when changing level unless the context is for a container being brought along (after having been picked up since you can't unlock a carried box). Previously, a door pointer on the new level could happen to match the last one being unlocked on the old level. Discard trap setting context when changing level even if the trap object is brought along. Somehow the code for applying a touchstone got inserted in between two sections of code for applying a trap (ages ago; probably since touchstone was first introduced however many versions back), so clean that up.
This commit is contained in:
13
src/do.c
13
src/do.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 do.c $NHDT-Date: 1454033599 2016/01/29 02:13:19 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.153 $ */
|
||||
/* NetHack 3.6 do.c $NHDT-Date: 1464487100 2016/05/29 01:58:20 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.156 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -1523,13 +1523,20 @@ boolean at_stairs, falling, portal;
|
||||
save_currentstate();
|
||||
#endif
|
||||
|
||||
if ((annotation = get_annotation(&u.uz)))
|
||||
if ((annotation = get_annotation(&u.uz)) != 0)
|
||||
You("remember this level as %s.", annotation);
|
||||
|
||||
/* assume this will always return TRUE when changing level */
|
||||
(void) in_out_region(u.ux, u.uy);
|
||||
(void) pickup(1);
|
||||
context.polearm.hitmon = NULL;
|
||||
|
||||
/* discard context which applied to previous level */
|
||||
maybe_reset_pick(); /* for door or for box not accompanying hero */
|
||||
reset_trapset(); /* even if to-be-armed trap obj is accompanying hero */
|
||||
iflags.travelcc.x = iflags.travelcc.y = -1; /* travel destination cache */
|
||||
context.polearm.hitmon = (struct monst *) 0; /* polearm target */
|
||||
/* digging context is level-aware and can actually be resumed if
|
||||
hero returns to the previous level without any intervening dig */
|
||||
}
|
||||
|
||||
STATIC_OVL void
|
||||
|
||||
Reference in New Issue
Block a user