]> granicus.if.org Git - nethack/commitdiff
H2162 - topten handling of long names
authorcohrs <cohrs>
Tue, 28 Dec 2010 19:43:01 +0000 (19:43 +0000)
committercohrs <cohrs>
Tue, 28 Dec 2010 19:43:01 +0000 (19:43 +0000)
<Someone> 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
src/topten.c

index 71287b93b4eb327bbfbe844847c14d296d3fdbfb..6010d94be50e587e9ad1c03c33a7f7ea18816cfe 100644 (file)
@@ -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
index 74a59667941a3d0261b95e9f965c8b2bb1cd49cc..f78d341c1b2b58c195bd9b101606a02791dc288f 100644 (file)
@@ -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++ = ' ';