From 8047d6a5f87caf11c12d32b855971ab2aff1c565 Mon Sep 17 00:00:00 2001 From: cohrs Date: Tue, 28 Dec 2010 19:43:01 +0000 Subject: [PATCH] H2162 - topten handling of long names reported that being killed by a monster with a long name can result in nethack going into an infinte loop printing spaces. Handle this by detecting attempts to wrap the topten output on a word that is too long and just inserting breaks in the middle of the word in this case. --- doc/fixes34.4 | 1 + src/topten.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/fixes34.4 b/doc/fixes34.4 index 71287b93b..6010d94be 100644 --- a/doc/fixes34.4 +++ b/doc/fixes34.4 @@ -391,6 +391,7 @@ documentation tidbit: change Guidebook and in-game help for pickup_burden writing while blind no longer possible for books, might fail for scrolls blanking items in pools while blind shouldn't reveal new obj description for ones which had been seen before becoming blind +avoid infinite loop in topten output when killed by long-named monster Platform- and/or Interface-Specific Fixes diff --git a/src/topten.c b/src/topten.c index 74a596679..f78d341c1 100644 --- a/src/topten.c +++ b/src/topten.c @@ -681,10 +681,15 @@ boolean so; !(*bp == ' ' && (bp-linebuf < hppos)); bp--) ; + /* special case: word is too long, wrap in the middle */ + if (linebuf+15 >= bp) bp = linebuf + hppos - 1; /* special case: if about to wrap in the middle of maximum dungeon depth reached, wrap in front of it instead */ if (bp > linebuf + 5 && !strncmp(bp - 5, " [max", 5)) bp -= 5; - Strcpy(linebuf3, bp+1); + if (*bp != ' ') + Strcpy(linebuf3, bp); + else + Strcpy(linebuf3, bp+1); *bp = 0; if (so) { while (bp < linebuf + (COLNO-1)) *bp++ = ' ';