]> granicus.if.org Git - nethack/commitdiff
reset travel cache when changing levels
authorPatR <rankin@nethack.org>
Sun, 29 May 2016 02:54:19 +0000 (19:54 -0700)
committerPatR <rankin@nethack.org>
Sun, 29 May 2016 02:54:19 +0000 (19:54 -0700)
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.

doc/fixes36.1
include/extern.h
src/apply.c
src/do.c
src/lock.c

index 9b40d87f629c515b3b0d2a3dbddde6cebfd26e5b..cdfdb46e2eec6f7b42d3e2fb463cf11faf8646f5 100644 (file)
@@ -53,6 +53,7 @@ dipping fruit juice into enlightenment gave different result than the inverse
 make travel walk up to a trap and stop when the trap blocks the only
        way forward, instead of trying to go straight line
 travel will displace pets rather than stop
+discard travel cache when moving to a different dungeon level
 do not autopickup unpaid items in shops
 death due an unseen gas spore's explosion resulted in "killed by a died"
 allow optional parameter "true", "yes", "false", or "no" for boolean options
index 3d9c6c5f452791a5d692767699e7832fcf17808b..1a20b24f2d6f98bc2413087f828fb0a2360b7844 100644 (file)
@@ -1013,6 +1013,7 @@ E boolean FDECL(picking_lock, (int *, int *));
 E boolean FDECL(picking_at, (int, int));
 E void FDECL(breakchestlock, (struct obj *, BOOLEAN_P));
 E void NDECL(reset_pick);
+E void NDECL(maybe_reset_pick);
 E int FDECL(pick_lock, (struct obj *));
 E int NDECL(doforce);
 E boolean FDECL(boxlock, (struct obj *, struct obj *));
index 24db211d39ab1d827fbdd068d53d3287ca8edc90..544619b946ecc9df7097a62610320007aab372f1 100644 (file)
@@ -2179,20 +2179,6 @@ struct obj *obj;
     update_inventory();
 }
 
-static struct trapinfo {
-    struct obj *tobj;
-    xchar tx, ty;
-    int time_needed;
-    boolean force_bungle;
-} trapinfo;
-
-void
-reset_trapset()
-{
-    trapinfo.tobj = 0;
-    trapinfo.force_bungle = 0;
-}
-
 /* touchstones - by Ken Arnold */
 STATIC_OVL void
 use_stone(tstone)
@@ -2322,6 +2308,20 @@ struct obj *tstone;
     return;
 }
 
+static struct trapinfo {
+    struct obj *tobj;
+    xchar tx, ty;
+    int time_needed;
+    boolean force_bungle;
+} trapinfo;
+
+void
+reset_trapset()
+{
+    trapinfo.tobj = 0;
+    trapinfo.force_bungle = 0;
+}
+
 /* Place a landmine/bear trap.  Helge Hafting */
 STATIC_OVL void
 use_trap(otmp)
index 5efa0da87bd343f8ccc3dad70a5670f758b3cb6f..2cbfa36604028c55e2aa0ee46604c5c6b06c6a3b 100644 (file)
--- a/src/do.c
+++ b/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
index 16f1c63b1412e379b4098ea4879380bfb4eb181e..f899f9a0b2b53796d2bf53eb66a421a8789c72e6 100644 (file)
@@ -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