]> granicus.if.org Git - nethack/commitdiff
tweak for #914 - attacking nothing
authorPatR <rankin@nethack.org>
Sun, 30 Oct 2022 06:48:46 +0000 (23:48 -0700)
committerPatR <rankin@nethack.org>
Sun, 30 Oct 2022 06:48:46 +0000 (23:48 -0700)
In the code that checks for attacking the edge of the map, the m_at()
that was just introduced isn't at risk of using <0,0> because of the
way 'glyph' is initialized.  But guard against future changes.

And I omitted this when checking the PR #914 commit in:
Closes #914

src/hack.c
src/uhitm.c

index f2a25503bccd1a2ffd3d7a13ca7579a3c685e284..9449529cd08c0c0ca4ba0d978e6fc90b08be7a7c 100644 (file)
@@ -1684,7 +1684,10 @@ domove_bump_mon(struct monst *mtmp, int glyph)
    sets displaceu, if hero and monster could swap places instead.
 */
 static boolean
-domove_attackmon_at(struct monst *mtmp, coordxy x, coordxy y, boolean *displaceu)
+domove_attackmon_at(
+    struct monst *mtmp,
+    coordxy x, coordxy y,
+    boolean *displaceu)
 {
     /* only attack if we know it's there */
     /* or if we used the 'F' command to fight blindly */
@@ -1899,9 +1902,10 @@ domove_fight_empty(coordxy x, coordxy y)
     int glyph = !off_edge ? glyph_at(x, y) : GLYPH_UNEXPLORED;
 
     if (off_edge)
-        x = y = 0; /* for forcefight against the edge of the map; make
-                    * sure 'bad' coordinates are within array bounds in
-                    * case a bounds check gets overlooked */
+        x = 0, y = 1; /* for forcefight against the edge of the map; make
+                       * sure 'bad' coordinates are within array bounds in
+                       * case a bounds check gets overlooked; avoid <0,0>
+                       * because m_at() might find a vault guard there */
 
     /* specifying 'F' with no monster wastes a turn */
     if (g.context.forcefight
index bd8e6c2a35819525d6eefbd3a62479a664e5d7eb..b2a0374dfebb05653f71ce0821b22f8985c59e7c 100644 (file)
@@ -160,7 +160,7 @@ attack_checks(
 
     /* cache the shown glyph;
        cases which might change it (by placing or removing
-       'rembered, unseen monster' glyph or revealing a mimic)
+       'remembered, unseen monster' glyph or revealing a mimic)
        always return without further reference to this */
     glyph = glyph_at(g.bhitpos.x, g.bhitpos.y);