From 333735863fe1bb91185c46ba8781ed68bf734478 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 29 Oct 2022 23:48:46 -0700 Subject: [PATCH] tweak for #914 - attacking nothing 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 | 12 ++++++++---- src/uhitm.c | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/hack.c b/src/hack.c index f2a25503b..9449529cd 100644 --- a/src/hack.c +++ b/src/hack.c @@ -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 diff --git a/src/uhitm.c b/src/uhitm.c index bd8e6c2a3..b2a0374df 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -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);