]> granicus.if.org Git - nethack/commitdiff
fix pull request #340 - untrap steed sanity
authorPatR <rankin@nethack.org>
Mon, 27 Apr 2020 18:48:55 +0000 (11:48 -0700)
committerPatR <rankin@nethack.org>
Mon, 27 Apr 2020 18:48:55 +0000 (11:48 -0700)
When a failed #untrap attempt while mounted caused hero to be moved
onto the trap, it neglected to set the steed's coordinates to match.
If 'sanity_check' was On, that would trigger warnings about steed's
anomalous position.  Eventually a normal move would put steed's
coordinates back in sync with the hero's.

The pull request code set u.usteed->{mx,my} directly.  I've used
u_on_newpos() instead.  I also replaced some direct manipulations of
u.{ux,uy} with u_on_newpos() so that if clipping is in effect it will
be updated.

Fixes #340

doc/fixes37.0
src/hack.c
src/trap.c

index c8260d6b859ebf10797379cc15d8263914bcb9a1..b043ae7074d19edd5a13083bee78ecbcebdda852 100644 (file)
@@ -164,6 +164,8 @@ some monster code was checking whether pets or engulfers were eating green
        slime by checking for green slime corpse instead of glob
 change light radius of stack of candles to square root
 could get redundate "mon hits other-mon" messages when mon wields an artifact
+failed untrap while mounted that moved hero onto the trap would leave steed
+       with stale coordinates, triggering warnings if 'sanity_check' is On
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index fa221844fbeab4c7ec8344231b2ccfd94168c6e7..b5a92d4b247bce50394ae27e164264d69dd78cdc 100644 (file)
@@ -1416,8 +1416,8 @@ domove_core()
     }
     if (u.uswallow) {
         u.dx = u.dy = 0;
-        u.ux = x = u.ustuck->mx;
-        u.uy = y = u.ustuck->my;
+        x = u.ustuck->mx, y = u.ustuck->my;
+        u_on_newpos(x, y); /* set u.ux,uy and handle CLIPPING */
         mtmp = u.ustuck;
     } else {
         if (Is_airlevel(&u.uz) && rn2(4) && !Levitation && !Flying) {
@@ -1777,15 +1777,15 @@ domove_core()
     if (!in_out_region(x, y))
         return;
 
-    /* now move the hero */
     mtmp = m_at(x, y);
+    /* tentaively move the hero plus steed; leave CLIPPING til later */
     u.ux += u.dx;
     u.uy += u.dy;
-    /* Move your steed, too */
     if (u.usteed) {
         u.usteed->mx = u.ux;
         u.usteed->my = u.uy;
-        exercise_steed();
+        /* [if move attempt ends up being blocked, should training count?] */
+        exercise_steed(); /* train riding skill */
     }
 
     /*
@@ -1911,10 +1911,15 @@ domove_core()
 
         if (didnt_move) {
             u.ux = u.ux0, u.uy = u.uy0; /* didn't move after all */
+            /* could skip this bit since we're about to call u_on_newpos() */
             if (u.usteed)
                 u.usteed->mx = u.ux, u.usteed->my = u.uy;
         }
     }
+    /* tentative move above didn't handle CLIPPING, in case there was a
+       monster in the way and the move attempt ended up being blocked;
+       do a full re-position now, possibly back to where hero started */
+    u_on_newpos(u.ux, u.uy);
 
     reset_occupations();
     if (g.context.run) {
index c810af652b530cf482ca860208d9c71bc2ed9fa9..b94f2c7cd366b147683580b687ea11870e77ab50 100644 (file)
@@ -4035,7 +4035,8 @@ struct trap *ttmp;
     if (!Punished
         || drag_ball(x, y, &bc, &bx, &by, &cx, &cy, &unused, TRUE)) {
         u.ux0 = u.ux, u.uy0 = u.uy;
-        u.ux = x, u.uy = y;
+        /* set u.ux,u.uy and u.usteed->mx,my plus handle CLIPPING */
+        u_on_newpos(x, y);
         u.umoved = TRUE;
         newsym(u.ux0, u.uy0);
         vision_recalc(1);