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:
11
src/lock.c
11
src/lock.c
@@ -75,7 +75,8 @@ STATIC_PTR int
|
||||
picklock(VOID_ARGS)
|
||||
{
|
||||
if (xlock.box) {
|
||||
if ((xlock.box->ox != u.ux) || (xlock.box->oy != u.uy)) {
|
||||
if (xlock.box->where != OBJ_FLOOR
|
||||
|| xlock.box->ox != u.ux || xlock.box->oy != u.uy) {
|
||||
return ((xlock.usedtime = 0)); /* you or it moved */
|
||||
}
|
||||
} else { /* door */
|
||||
@@ -228,6 +229,14 @@ reset_pick()
|
||||
xlock.box = 0;
|
||||
}
|
||||
|
||||
/* level change; don't reset if hero is carrying xlock.box with him/her */
|
||||
void
|
||||
maybe_reset_pick()
|
||||
{
|
||||
if (!xlock.box || !carried(xlock.box))
|
||||
reset_pick();
|
||||
}
|
||||
|
||||
/* for doapply(); if player gives a direction or resumes an interrupted
|
||||
previous attempt then it costs hero a move even if nothing ultimately
|
||||
happens; when told "can't do that" before being asked for direction
|
||||
|
||||
Reference in New Issue
Block a user