DanielT / NitroHack

A fork of NetHack 3.4.3
nitrohack.org
21 stars 2 forks source link

vpline() fails to detect repeated lines properly #32

Open tung opened 12 years ago

tung commented 12 years ago

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.