NitroHack icon indicating copy to clipboard operation
NitroHack copied to clipboard

vpline() fails to detect repeated lines properly

Open tung opened this issue 13 years ago • 0 comments

From libnitrohack/src/pline.c line 29 (emphasis mine):

static void vpline(const char *line, va_list the_args)
{
    char pbuf[BUFSZ];

    if (!line || !*line) return;
    if (strchr(line, '%')) {
        vsprintf(pbuf,line,the_args);
        line = pbuf;
    }
    if (no_repeat && !strcmp(line, toplines[curline])) /* <<< 1 */
        return;
    if (vision_full_recalc)
        vision_recalc(0);
    if (u.ux)
        flush_screen();

    strcpy(toplines[curline++], line); /* <<< 2 */
    curline %= MSGCOUNT;
    print_message(moves, line);
}

The line marked 2 always sets curline to the next position in toplines[] to be used, which makes the check at the line marked 1 incorrectly do a string comparison one ahead of the line it should check. This causes Norep() to fail to detect repeated lines when it should.

tung avatar Aug 30 '12 03:08 tung