curses: fix "---" separators in ^P output
This one has me baffled, first how/when it happened and then why no
one reported it. The line
current_mesg->turn = g.moves;
vanished from mesg_add_line() at some point. It is visible in diff
context of commit 99ed00012e from March,
2019 but I can't find any commit since that time which removed it.
[I've been using
git log --no-min-parents --no-max-parents --patch win/curses/cursmesg.c
and then searching within the pager. Maybe that's flaky, but if so,
things wouldn't be any less strange.]
The missing line resulted in mesg->turn being uninitialized, so when
^P compared consecutive messages to decide whether they were issued on
the same turn, arbitrary junk made them all seem to be from different
turns so "---" got inserted before every message. I suppose that if
someone uses a malloc that zeroes the memory it hands out, mesg->turn
field would always be 0 and ^P would behave as if all messages were
from the same turn, so not show any "---" separators. Then players
might not be aware that "---" between groups of messages was intended.
[The messages ought to be grouped by move rather than by turn, but
that's something the core would have to provide.]
This commit is contained in:
@@ -950,6 +950,10 @@ curses: line input that doesn't take place on the bottom line of the message
|
||||
curses: menu headings didn't use default text color
|
||||
curses: #perminv changes disabled menu_headings attribute for persistent
|
||||
inventory window headings; reinstate that
|
||||
curses: messages were tagged by turn in 3.6.x so that ^P can place a separator
|
||||
between groups of messages; somehow the line of code that recorded
|
||||
the turn vanished so ^P behaved as if every message came on its own
|
||||
distinct turn, resulting in lots of "---" separators
|
||||
Qt: at Xp levels above 20 with 'showexp' On, the combined status field
|
||||
"Level:NN/nnnnnnnn" was too big and truncated by a char at each end
|
||||
Qt: searching a text window for something that wasn't found and then searching
|
||||
|
||||
@@ -372,13 +372,14 @@ curses_prev_mesg(void)
|
||||
|
||||
for (count = 0; count < num_messages; ++count) {
|
||||
mesg = get_msg_line(do_lifo, count);
|
||||
if (turn != mesg->turn && count != 0) {
|
||||
curses_add_menu(wid, &nul_glyphinfo, &Id, 0, 0,
|
||||
A_NORMAL, "---", MENU_ITEMFLAGS_NONE);
|
||||
if (mesg->turn != turn) {
|
||||
if (count > 0) /* skip separator for first line */
|
||||
curses_add_menu(wid, &nul_glyphinfo, &Id, 0, 0,
|
||||
A_NORMAL, "---", MENU_ITEMFLAGS_NONE);
|
||||
turn = mesg->turn;
|
||||
}
|
||||
curses_add_menu(wid, &nul_glyphinfo, &Id, 0, 0,
|
||||
A_NORMAL, mesg->str, MENU_ITEMFLAGS_NONE);
|
||||
turn = mesg->turn;
|
||||
}
|
||||
if (!count)
|
||||
curses_add_menu(wid, &nul_glyphinfo, &Id, 0, 0,
|
||||
@@ -787,6 +788,7 @@ mesg_add_line(const char *mline)
|
||||
current_mesg->str = dupstr(mline);
|
||||
}
|
||||
}
|
||||
current_mesg->turn = g.moves;
|
||||
|
||||
if (num_messages == 0) {
|
||||
/* very first message; set up head */
|
||||
|
||||
Reference in New Issue
Block a user