Merge branch 'NetHack-3.6.2-beta01' into NetHack-3.6.2

This commit is contained in:
nhmall
2019-02-07 20:05:02 -05:00
6 changed files with 95 additions and 52 deletions

View File

@@ -1,4 +1,4 @@
$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.249 $ $NHDT-Date: 1549334449 2019/02/05 02:40:49 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.251 $ $NHDT-Date: 1549586901 2019/02/08 00:48:21 $
This fixes36.2 file is here to capture information about updates in the 3.6.x This fixes36.2 file is here to capture information about updates in the 3.6.x
lineage following the release of 3.6.1 in April 2018. Please note, however, lineage following the release of 3.6.1 in April 2018. Please note, however,
@@ -437,6 +437,11 @@ tty: fix leftover display artifact when the last field on the row got placed
X11: its use of genl_status_update exposed a negative index use that could X11: its use of genl_status_update exposed a negative index use that could
lead to a segfault lead to a segfault
X11: rollback disabling of keystroke input for PICK_NONE menus (for scrolling) X11: rollback disabling of keystroke input for PICK_NONE menus (for scrolling)
curses: catch up with tty to not put dolook/whatis autodescribe feedback into
^P message recall (multi-digit count feedback was already handled)
curses: if the interface code ran out of memory, it would crash rather than
attempt a controlled panic (which is fairly likely crash anyway if
done when there's no memory available)
Platform- and/or Interface-Specific Fixes or Features Platform- and/or Interface-Specific Fixes or Features

View File

@@ -478,7 +478,7 @@ curses_create_nhmenu(winid wid)
return; return;
} }
new_menu = malloc(sizeof (nhmenu)); new_menu = (nhmenu *) alloc((signed) sizeof (nhmenu));
new_menu->wid = wid; new_menu->wid = wid;
new_menu->prompt = NULL; new_menu->prompt = NULL;
new_menu->entries = NULL; new_menu->entries = NULL;
@@ -524,7 +524,7 @@ curses_add_nhmenu_item(winid wid, int glyph, const ANY_P * identifier,
new_str = curses_copy_of(str); new_str = curses_copy_of(str);
curses_rtrim((char *) new_str); curses_rtrim((char *) new_str);
new_item = malloc(sizeof (nhmenu_item)); new_item = (nhmenu_item *) alloc((unsigned) sizeof (nhmenu_item));
new_item->wid = wid; new_item->wid = wid;
new_item->glyph = glyph; new_item->glyph = glyph;
new_item->identifier = *identifier; new_item->identifier = *identifier;
@@ -630,7 +630,8 @@ curses_display_nhmenu(winid wid, int how, MENU_ITEM_P ** _selected)
curses_destroy_win(win); curses_destroy_win(win);
if (num_chosen > 0) { if (num_chosen > 0) {
selected = (MENU_ITEM_P *) malloc(num_chosen * sizeof (MENU_ITEM_P)); selected = (MENU_ITEM_P *) alloc((unsigned)
(num_chosen * sizeof (MENU_ITEM_P)));
count = 0; count = 0;
menu_item_ptr = current_menu->entries; menu_item_ptr = current_menu->entries;

View File

@@ -20,8 +20,9 @@ struct window_procs curses_procs = {
#if defined(STATUS_HILITES) #if defined(STATUS_HILITES)
| WC2_HILITE_STATUS | WC2_HILITE_STATUS
#endif #endif
| WC2_HITPOINTBAR | WC2_FLUSH_STATUS | WC2_HITPOINTBAR | WC2_FLUSH_STATUS
| WC2_TERM_SIZE | WC2_WINDOWBORDERS | WC2_PETATTR | WC2_GUICOLOR), | WC2_TERM_SIZE | WC2_WINDOWBORDERS | WC2_PETATTR | WC2_GUICOLOR
| WC2_SUPPRESS_HIST),
curses_init_nhwindows, curses_init_nhwindows,
curses_player_selection, curses_player_selection,
curses_askname, curses_askname,
@@ -377,10 +378,19 @@ Attributes
void void
curses_putstr(winid wid, int attr, const char *text) curses_putstr(winid wid, int attr, const char *text)
{ {
int curses_attr = curses_convert_attr(attr); int mesgflags, curses_attr;
/* We need to convert NetHack attributes to curses attributes */ mesgflags = attr & (ATR_URGENT | ATR_NOHISTORY);
curses_puts(wid, curses_attr, text); attr &= ~mesgflags;
if (wid == WIN_MESSAGE && (mesgflags & ATR_NOHISTORY) != 0) {
/* display message without saving it in recall history */
curses_count_window(text);
} else {
/* We need to convert NetHack attributes to curses attributes */
curses_attr = curses_convert_attr(attr);
curses_puts(wid, curses_attr, text);
}
} }
/* Display the file named str. Complain about missing files /* Display the file named str. Complain about missing files
@@ -442,7 +452,10 @@ curses_add_menu(winid wid, int glyph, const ANY_P * identifier,
CHAR_P accelerator, CHAR_P group_accel, int attr, CHAR_P accelerator, CHAR_P group_accel, int attr,
const char *str, BOOLEAN_P presel) const char *str, BOOLEAN_P presel)
{ {
int curses_attr = curses_convert_attr(attr); int curses_attr;
attr &= ~(ATR_URGENT | ATR_NOHISTORY);
curses_attr = curses_convert_attr(attr);
if (inv_update) { if (inv_update) {
curses_add_inv(inv_update, glyph, accelerator, curses_attr, str); curses_add_inv(inv_update, glyph, accelerator, curses_attr, str);

View File

@@ -50,10 +50,20 @@ curses_message_win_puts(const char *message, boolean recursed)
int border_space = 0; int border_space = 0;
static long suppress_turn = -1; static long suppress_turn = -1;
#if 1
/*
* Handled by core's use of putstr(WIN_MESSAGE,ATR_NOHISTORY,message)
* for intermediate counts, but get_count() also uses putmsghistory()
* for the final count, to remember that without showing it. But
* curses is using genl_putmsghistory() which just delivers the text
* via a normal pline(). This hides that at cost of not having in
* it ^P recall and being out of sync with DUMPLOG's message history.
*/
if (strncmp("Count:", message, 6) == 0) { if (strncmp("Count:", message, 6) == 0) {
curses_count_window(message); curses_count_window(message);
return; return;
} }
#endif
if (suppress_turn == moves) { if (suppress_turn == moves) {
return; return;
@@ -73,7 +83,9 @@ curses_message_win_puts(const char *message, boolean recursed)
linespace = ((width + border_space) - 3) - mx; linespace = ((width + border_space) - 3) - mx;
if (strcmp(message, "#") == 0) { /* Extended command or Count: */ if (strcmp(message, "#") == 0) { /* Extended command or Count: */
if ((strcmp(toplines, "#") != 0) && (my >= (height - 1 + border_space)) && (height != 1)) { /* Bottom of message window */ if ((strcmp(toplines, "#") != 0)
/* Bottom of message window */
&& (my >= (height - 1 + border_space)) && (height != 1)) {
scroll_window(MESSAGE_WIN); scroll_window(MESSAGE_WIN);
mx = width; mx = width;
my--; my--;
@@ -89,7 +101,8 @@ curses_message_win_puts(const char *message, boolean recursed)
} }
if (linespace < message_length) { if (linespace < message_length) {
if (my >= (height - 1 + border_space)) { /* bottom of message win */ if (my >= (height - 1 + border_space)) {
/* bottom of message win */
if ((turn_lines > height) || (height == 1)) { if ((turn_lines > height) || (height == 1)) {
/* Pause until key is hit - Esc suppresses any further /* Pause until key is hit - Esc suppresses any further
messages that turn */ messages that turn */
@@ -124,8 +137,8 @@ curses_message_win_puts(const char *message, boolean recursed)
if (height > 1) { if (height > 1) {
curses_toggle_color_attr(win, NONE, A_BOLD, OFF); curses_toggle_color_attr(win, NONE, A_BOLD, OFF);
} }
curses_message_win_puts(tmpstr = curses_str_remainder(message, (width - 2), 1), tmpstr = curses_str_remainder(message, (width - 2), 1);
TRUE); curses_message_win_puts(tmpstr, TRUE);
free(tmpstr); free(tmpstr);
} else { } else {
mvwprintw(win, my, mx, "%s", message); mvwprintw(win, my, mx, "%s", message);
@@ -217,7 +230,7 @@ curses_clear_unhighlight_message_window()
/* Reset message window cursor to starting position, and display most /* Reset message window cursor to starting position, and display most
recent messages. */ recent messages. */
void void
curses_last_messages() curses_last_messages()
@@ -236,7 +249,7 @@ curses_last_messages()
for (i = (num_messages - 1); i > 0; i--) { for (i = (num_messages - 1); i > 0; i--) {
mesg = get_msg_line(TRUE, i); mesg = get_msg_line(TRUE, i);
if (mesg && mesg->str && strcmp(mesg->str, "")) if (mesg && mesg->str && *mesg->str)
curses_message_win_puts(mesg->str, TRUE); curses_message_win_puts(mesg->str, TRUE);
} }
curses_message_win_puts(toplines, TRUE); curses_message_win_puts(toplines, TRUE);
@@ -274,7 +287,7 @@ curses_prev_mesg()
wid = curses_get_wid(NHW_MENU); wid = curses_get_wid(NHW_MENU);
curses_create_nhmenu(wid); curses_create_nhmenu(wid);
identifier = malloc(sizeof (anything)); identifier = (anything *) alloc((unsigned) sizeof (anything));
identifier->a_void = NULL; identifier->a_void = NULL;
for (count = 0; count < num_messages; count++) { for (count = 0; count < num_messages; count++) {
@@ -293,8 +306,10 @@ curses_prev_mesg()
} }
/* Shows Count: at the bottom of the message window, /* Display at the bottom of the message window without remembering the
popup_dialog is not currently implemented for this function */ line for ^P recall. Used for putstr(WIN_MESSAGE,ATR_NOHISTORY,text)
which core currently uses for 'Count: 123' and dolook's autodescribe.
popup_dialog is not currently implemented for this function. */
void void
curses_count_window(const char *count_text) curses_count_window(const char *count_text)
@@ -303,13 +318,12 @@ curses_count_window(const char *count_text)
int messageh, messagew; int messageh, messagew;
static WINDOW *countwin = NULL; static WINDOW *countwin = NULL;
if ((count_text == NULL) && (countwin != NULL)) { if (!count_text) {
delwin(countwin); if (countwin)
countwin = NULL; delwin(countwin), countwin = NULL;
counting = FALSE; counting = FALSE;
return; return;
} }
counting = TRUE; counting = TRUE;
curses_get_window_xy(MESSAGE_WIN, &winx, &winy); curses_get_window_xy(MESSAGE_WIN, &winx, &winy);
@@ -322,18 +336,14 @@ curses_count_window(const char *count_text)
winy += messageh - 1; winy += messageh - 1;
if (countwin == NULL) {
#ifndef PDCURSES
countwin = newwin(1, 25, winy, winx);
#endif /* !PDCURSES */
}
#ifdef PDCURSES #ifdef PDCURSES
else { if (countwin)
curses_destroy_win(countwin); curses_destroy_win(countwin), countwin = NULL;
}
countwin = newwin(1, 25, winy, winx);
#endif /* PDCURSES */ #endif /* PDCURSES */
/* this used to specify a width of 25; that was adequate for 'Count: 123'
but not for dolook's autodescribe when it refers to a named monster */
if (!countwin)
countwin = newwin(1, messagew, winy, winx);
startx = 0; startx = 0;
starty = 0; starty = 0;
@@ -370,13 +380,13 @@ curses_message_win_getline(const char *prompt, char *answer, int buffer)
maxy = height - 1 + border_space; maxy = height - 1 + border_space;
maxx = width - 1 + border_space; maxx = width - 1 + border_space;
tmpbuf = (char *)malloc(strlen(prompt) + buffer + 2); tmpbuf = (char *) alloc((unsigned) ((int) strlen(prompt) + buffer + 2));
maxlines = buffer / width * 2; maxlines = buffer / width * 2;
strcpy(tmpbuf, prompt); strcpy(tmpbuf, prompt);
strcat(tmpbuf, " "); strcat(tmpbuf, " ");
nlines = curses_num_lines(tmpbuf,width); nlines = curses_num_lines(tmpbuf,width);
maxlines += nlines * 2; maxlines += nlines * 2;
linestarts = (char **)malloc(sizeof(char*) * maxlines); linestarts = (char **) alloc((unsigned) (sizeof (char *) * maxlines));
p_answer = tmpbuf + strlen(tmpbuf); p_answer = tmpbuf + strlen(tmpbuf);
linestarts[0] = tmpbuf; linestarts[0] = tmpbuf;
@@ -563,7 +573,8 @@ static void
mesg_add_line(char *mline) mesg_add_line(char *mline)
{ {
nhprev_mesg *tmp_mesg = NULL; nhprev_mesg *tmp_mesg = NULL;
nhprev_mesg *current_mesg = malloc(sizeof (nhprev_mesg)); nhprev_mesg *current_mesg = (nhprev_mesg *) alloc((unsigned)
(sizeof (nhprev_mesg)));
current_mesg->str = curses_copy_of(mline); current_mesg->str = curses_copy_of(mline);
current_mesg->turn = moves; current_mesg->turn = moves;

View File

@@ -220,12 +220,12 @@ curses_copy_of(const char *s)
{ {
if (!s) if (!s)
s = ""; s = "";
return strcpy((char *) alloc((unsigned) (strlen(s) + 1)), s); return dupstr(s);
} }
/* Determine the number of lines needed for a string for a dialog window /* Determine the number of lines needed for a string for a dialog window
of the given width */ of the given width */
int int
curses_num_lines(const char *str, int width) curses_num_lines(const char *str, int width)
@@ -588,7 +588,7 @@ curses_view_file(const char *filename, boolean must_exist)
wid = curses_get_wid(NHW_MENU); wid = curses_get_wid(NHW_MENU);
curses_create_nhmenu(wid); curses_create_nhmenu(wid);
identifier = malloc(sizeof (anything)); identifier = (anything *) alloc(sizeof (anything));
identifier->a_void = NULL; identifier->a_void = NULL;
while (dlb_fgets(buf, BUFSZ, fp) != NULL) { while (dlb_fgets(buf, BUFSZ, fp) != NULL) {
@@ -632,7 +632,7 @@ curses_get_count(int first_digit)
current_count = LARGEST_INT; current_count = LARGEST_INT;
} }
pline("Count: %ld", current_count); custompline(SUPPRESS_HISTORY, "Count: %ld", current_count);
current_char = curses_read_char(); current_char = curses_read_char();
} }
@@ -647,13 +647,17 @@ curses_get_count(int first_digit)
/* Convert the given NetHack text attributes into the format curses /* Convert the given NetHack text attributes into the format curses
understands, and return that format mask. */ understands, and return that format mask. */
int int
curses_convert_attr(int attr) curses_convert_attr(int attr)
{ {
int curses_attr; int curses_attr;
/* first, strip off control flags masked onto the display attributes
(caller should have already done this...) */
attr &= ~(ATR_URGENT | ATR_NOHISTORY);
switch (attr) { switch (attr) {
case ATR_NONE: case ATR_NONE:
curses_attr = A_NORMAL; curses_attr = A_NORMAL;

View File

@@ -79,7 +79,8 @@ curses_create_window(int width, int height, orient orientation)
height += 2; height += 2;
if ((width > term_cols) || (height > term_rows)) { if ((width > term_cols) || (height > term_rows)) {
impossible("curses_create_window: Terminal too small for dialog window"); impossible(
"curses_create_window: Terminal too small for dialog window");
width = term_cols; width = term_cols;
height = term_rows; height = term_rows;
} }
@@ -193,7 +194,8 @@ WINDOW *
curses_get_nhwin(winid wid) curses_get_nhwin(winid wid)
{ {
if (!is_main_window(wid)) { if (!is_main_window(wid)) {
impossible("curses_get_nhwin: wid %d out of range. Not a main window.", wid); impossible("curses_get_nhwin: wid %d out of range. Not a main window.",
wid);
return NULL; return NULL;
} }
@@ -212,7 +214,8 @@ curses_add_nhwin(winid wid, int height, int width, int y, int x,
int real_height = height; int real_height = height;
if (!is_main_window(wid)) { if (!is_main_window(wid)) {
impossible("curses_add_nhwin: wid %d out of range. Not a main window.", wid); impossible("curses_add_nhwin: wid %d out of range. Not a main window.",
wid);
return; return;
} }
@@ -266,7 +269,7 @@ curses_add_wid(winid wid)
nethack_wid *new_wid; nethack_wid *new_wid;
nethack_wid *widptr = nhwids; nethack_wid *widptr = nhwids;
new_wid = malloc(sizeof (nethack_wid)); new_wid = (nethack_wid *) alloc((unsigned) sizeof (nethack_wid));
new_wid->nhwid = wid; new_wid->nhwid = wid;
new_wid->next_wid = NULL; new_wid->next_wid = NULL;
@@ -305,7 +308,8 @@ curses_del_nhwin(winid wid)
} }
if (!is_main_window(wid)) { if (!is_main_window(wid)) {
impossible("curses_del_nhwin: wid %d out of range. Not a main window.", wid); impossible("curses_del_nhwin: wid %d out of range. Not a main window.",
wid);
return; return;
} }
@@ -396,7 +400,9 @@ void
curses_get_window_xy(winid wid, int *x, int *y) curses_get_window_xy(winid wid, int *x, int *y)
{ {
if (!is_main_window(wid)) { if (!is_main_window(wid)) {
impossible("curses_get_window_xy: wid %d out of range. Not a main window.", wid); impossible(
"curses_get_window_xy: wid %d out of range. Not a main window.",
wid);
*x = 0; *x = 0;
*y = 0; *y = 0;
return; return;
@@ -451,8 +457,9 @@ int
curses_get_window_orientation(winid wid) curses_get_window_orientation(winid wid)
{ {
if (!is_main_window(wid)) { if (!is_main_window(wid)) {
impossible impossible(
("curses_get_window_orientation: wid %d out of range. Not a main window.", wid); "curses_get_window_orientation: wid %d out of range. Not a main window.",
wid);
return CENTER; return CENTER;
} }
@@ -461,7 +468,7 @@ curses_get_window_orientation(winid wid)
/* Output a line of text to specified NetHack window with given coordinates /* Output a line of text to specified NetHack window with given coordinates
and text attributes */ and text attributes */
void void
curses_puts(winid wid, int attr, const char *text) curses_puts(winid wid, int attr, const char *text)
@@ -490,10 +497,12 @@ curses_puts(winid wid, int attr, const char *text)
if (curses_is_menu(wid) || curses_is_text(wid)) { if (curses_is_menu(wid) || curses_is_text(wid)) {
if (!curses_menu_exists(wid)) { if (!curses_menu_exists(wid)) {
impossible("curses_puts: Attempted write to nonexistant window %d!", wid); impossible(
"curses_puts: Attempted write to nonexistant window %d!",
wid);
return; return;
} }
identifier = malloc(sizeof (anything)); identifier = (anything *) alloc((unsigned) sizeof (anything));
identifier->a_void = NULL; identifier->a_void = NULL;
curses_add_nhmenu_item(wid, NO_GLYPH, identifier, 0, 0, attr, text, curses_add_nhmenu_item(wid, NO_GLYPH, identifier, 0, 0, attr, text,
FALSE); FALSE);