From: Michael Meyer Date: Sat, 19 Mar 2022 19:33:13 +0000 (-0400) Subject: Fix: repeated 'hit with a wielded weapon' logging X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fb512bac4f5a857d32299d9bb633cbb6bf7f7b6d;p=nethack Fix: repeated 'hit with a wielded weapon' logging 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. --- diff --git a/src/uhitm.c b/src/uhitm.c index b99db0cfa..51923d3c1 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -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... */