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.
This commit is contained in:
Alex Smith
2023-05-11 01:43:06 +01:00
parent 65debc1adb
commit fcb86ad709

View File

@@ -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,