]> granicus.if.org Git - nethack/commitdiff
fix m-prefix movement into warning symbol (pr573)
authorMichael Meyer <me@entrez.cc>
Tue, 10 Aug 2021 14:28:07 +0000 (10:28 -0400)
committernhmall <nhmall@nethack.org>
Sat, 16 Oct 2021 14:50:54 +0000 (10:50 -0400)
https://github.com/NetHack/NetHack/pull/573 by entrez
Pull request comment states:
"Moving into a position containing a warning symbol with m-<direction> to
'safely' move would still attack as though the 'm' prefix was not
specified.  Ensure warning symbols are counted as 'detected' monsters
for this purpose, to avoid falling through to do_attack()."

Closes #573

doc/fixes37.0
src/hack.c

index 4e629fcb3f0ab6708d0c07dcc7f135e66334fbc9..aeba135e118d292c40f8b635d668205ab6c07372 100644 (file)
@@ -1298,7 +1298,8 @@ delete extra lines in Guidebook.mn (pr #590 by argrath)
 supply missing changes on Guidebook.tex (pr #591 by argrath)
 fix out-of-bounds access of xdir and ydir in farlook (pr #592 by copperwater)
 variation of imp's period-speak (pr #602 by Vivit-R)
-
+fix m-prefix movement into warning symbol (pr #573 by entrez)
 
 Code Cleanup and Reorganization
 -------------------------------
index d0b4e59776c030d30d3de34e122c88ade8935f12..b5abee6cbd6adf7347924a8a685daf8d94682ba1 100644 (file)
@@ -1487,7 +1487,7 @@ domove_core(void)
     register struct rm *tmpr;
     register xchar x, y;
     struct trap *trap = NULL;
-    int wtcap;
+    int wtcap, glyph;
     boolean on_ice;
     xchar chainx = 0, chainy = 0,
           ballx = 0, bally = 0;         /* ball&chain new positions */
@@ -1705,6 +1705,7 @@ domove_core(void)
     g.bhitpos.x = x;
     g.bhitpos.y = y;
     tmpr = &levl[x][y];
+    glyph = glyph_at(x, y);
 
     /* attack monster */
     if (mtmp) {
@@ -1729,7 +1730,8 @@ domove_core(void)
          * different message and makes the player remember the monster.
          */
         if (g.context.nopick && !g.context.travel
-            && (canspotmon(mtmp) || glyph_is_invisible(levl[x][y].glyph))) {
+            && (canspotmon(mtmp) || glyph_is_invisible(glyph)
+                || glyph_is_warning(glyph))) {
             if (M_AP_TYPE(mtmp) && !Protection_from_shape_changers
                 && !sensemon(mtmp))
                 stumble_onto_mimic(mtmp);
@@ -1782,11 +1784,10 @@ domove_core(void)
     /* specifying 'F' with no monster wastes a turn */
     if (g.context.forcefight
         /* remembered an 'I' && didn't use a move command */
-        || (glyph_is_invisible(levl[x][y].glyph) && !g.context.nopick)) {
+        || (glyph_is_invisible(glyph) && !g.context.nopick)) {
         struct obj *boulder = 0;
         boolean explo = (Upolyd && attacktype(g.youmonst.data, AT_EXPL)),
                 solid = !accessible(x, y);
-        int glyph = glyph_at(x, y); /* might be monster */
         char buf[BUFSZ];
 
         if (!Underwater) {