]> granicus.if.org Git - nethack/commitdiff
Fix: repeated 'hit with a wielded weapon' logging
authorMichael Meyer <me@entrez.cc>
Sat, 19 Mar 2022 19:33:13 +0000 (15:33 -0400)
committerPatR <rankin@nethack.org>
Sun, 20 Mar 2022 01:10:11 +0000 (18:10 -0700)
The "hit with a wielded weapon for the first time" livelog line could be
produced repeatedly: it was triggered by hitting a monster with a
wielded object of any sort, but the u.uconduct.weaphit counter was only
incremented if hitting with an actual 'weapon' (a WEAPON_CLASS or
is_weptool item).  As a result, if a non-weapon-using hero whipped out a
non-weapon item -- a cockatrice corpse, for example -- and started going
to town on some monsters, the livelog message would be repeated with
every hit.

src/uhitm.c

index b99db0cfaa8f724260198b3a21bd91111fb9b08a..51923d3c1f812fcc532dff9c3e54f4a77879fd54 100644 (file)
@@ -1323,6 +1323,8 @@ hmon_hitmon(
 
     if (!already_killed) {
         if (obj && (obj == uwep || (obj == uswapwep && u.twoweap))
+            /* known_hitum 'what counts as a weapon' criteria */
+            && (obj->oclass == WEAPON_CLASS || is_weptool(obj))
             && (thrown == HMON_MELEE || thrown == HMON_APPLIED)
             /* note: caller has already incremented u.uconduct.weaphit
                so we test for 1; 0 shouldn't be able to happen here... */