From fcb86ad7096dd1f238238566212bced61b9a2097 Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Thu, 11 May 2023 01:43:06 +0100 Subject: [PATCH] Fix "while helpless" showing up for some characters who weren't helpless If the game ended while the player was in the middle of a repeated command (that was not cancelled), this would spuriously cause a "while helpless" to appear in the death message and logfile entry. This bug is hard to observe because most things that can kill the character also cause repeated commands to stop repeating, but is easy to reproduce by command-repeating the #offer command that's used to ascend (as "n20#offer" or "20#offer" depending on the control scheme): doing so produced "ascended, while helpless" prior to this patch. --- src/topten.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/topten.c b/src/topten.c index d86fdcc7e..6877e55db 100644 --- a/src/topten.c +++ b/src/topten.c @@ -146,7 +146,7 @@ formatkiller( } *buf = '\0'; - if (incl_helpless && gm.multi) { + if (incl_helpless && gm.multi < 0) { /* X <= siz: 'sizeof "string"' includes 1 for '\0' terminator */ if (gm.multi_reason && strlen(gm.multi_reason) + sizeof ", while " <= siz) @@ -359,7 +359,7 @@ writexlentry(FILE *rfile, struct toptenentry *tt, int how) Fprintf(rfile, "%s%cname=%s%cdeath=%s", buf, /* (already includes separator) */ XLOG_SEP, gp.plname, XLOG_SEP, tmpbuf); - if (gm.multi) + if (gm.multi < 0) Fprintf(rfile, "%cwhile=%s", XLOG_SEP, gm.multi_reason ? gm.multi_reason : "helpless"); Fprintf(rfile, "%cconduct=0x%lx%cturns=%ld%cachieve=0x%lx", XLOG_SEP,