Merge branch 'NetHack-3.6.2'

This commit is contained in:
nhmall
2019-03-25 07:26:43 -04:00
14 changed files with 168 additions and 106 deletions
+15 -10
View File
@@ -498,16 +498,21 @@ curses_create_nhmenu(winid wid)
while (menu_item_ptr->next_item != NULL) {
tmp_menu_item = menu_item_ptr->next_item;
free((genericptr_t) menu_item_ptr->str);
free(menu_item_ptr);
free((genericptr_t) menu_item_ptr);
menu_item_ptr = tmp_menu_item;
}
free((genericptr_t) menu_item_ptr->str);
free(menu_item_ptr); /* Last entry */
free((genericptr_t) menu_item_ptr); /* Last entry */
new_menu->entries = NULL;
}
if (new_menu->prompt != NULL) { /* Reusing existing menu */
free((genericptr_t) new_menu->prompt);
new_menu->prompt = NULL;
}
new_menu->num_pages = 0;
new_menu->height = 0;
new_menu->width = 0;
new_menu->reuse_accels = FALSE;
return;
}
@@ -708,7 +713,7 @@ curses_menu_exists(winid wid)
/* Delete the menu associated with the given NetHack winid from memory */
void
curses_del_menu(winid wid)
curses_del_menu(winid wid, boolean del_wid_too)
{
nhmenu_item *tmp_menu_item;
nhmenu_item *menu_item_ptr;
@@ -735,21 +740,21 @@ curses_del_menu(winid wid)
}
/* Now unlink the menu from the list and free it as well */
if (current_menu->prev_menu != NULL) {
tmpmenu = current_menu->prev_menu;
if ((tmpmenu = current_menu->prev_menu) != NULL) {
tmpmenu->next_menu = current_menu->next_menu;
} else {
nhmenus = current_menu->next_menu; /* New head mode or NULL */
}
if (current_menu->next_menu != NULL) {
tmpmenu = current_menu->next_menu;
if ((tmpmenu = current_menu->next_menu) != NULL) {
tmpmenu->prev_menu = current_menu->prev_menu;
}
free((genericptr_t) current_menu->prompt);
free(current_menu);
if (current_menu->prompt)
free((genericptr_t) current_menu->prompt);
free((genericptr_t) current_menu);
curses_del_wid(wid);
if (del_wid_too)
curses_del_wid(wid);
}
+3 -5
View File
@@ -13,14 +13,12 @@ int curses_character_input_dialog(const char *prompt, const char *choices,
CHAR_P def);
int curses_ext_cmd(void);
void curses_create_nhmenu(winid wid);
void curses_add_nhmenu_item(winid wid, int glyph, const ANY_P * identifier,
void curses_add_nhmenu_item(winid wid, int glyph, const ANY_P *identifier,
CHAR_P accelerator, CHAR_P group_accel, int attr,
const char *str, BOOLEAN_P presel);
void curses_finalize_nhmenu(winid wid, const char *prompt);
int curses_display_nhmenu(winid wid, int how, MENU_ITEM_P ** _selected);
int curses_display_nhmenu(winid wid, int how, MENU_ITEM_P **_selected);
boolean curses_menu_exists(winid wid);
void curses_del_menu(winid wid);
void curses_del_menu(winid, boolean);
#endif /* CURSDIAL_H */
+7 -1
View File
@@ -107,7 +107,7 @@ set_window_position(int *winx, int *winy, int *winw, int *winh,
}
}
/* Create the "main" nonvolitile windows used by nethack */
/* Create the "main" nonvolatile windows used by nethack */
void
curses_create_main_windows()
{
@@ -827,6 +827,12 @@ curses_init_options()
iflags.wc2_petattr = A_REVERSE;
}
/* curses doesn't support 's' (single message at a time; successive
^P's go back to earlier messages) and 'c' (combination; single
on first and second of consecutive ^P's, full on third) */
if (iflags.prevmsg_window != 'f')
iflags.prevmsg_window = 'r';
#ifdef NCURSES_MOUSE_VERSION
if (iflags.wc_mouse_support) {
mousemask(BUTTON1_CLICKED, NULL);
+21
View File
@@ -241,6 +241,12 @@ curses_get_nh_event()
void
curses_exit_nhwindows(const char *str)
{
curses_destroy_nhwindow(INV_WIN);
curses_destroy_nhwindow(MAP_WIN);
curses_destroy_nhwindow(STATUS_WIN);
curses_destroy_nhwindow(MESSAGE_WIN);
curs_destroy_all_wins();
curses_cleanup();
curs_set(orig_cursor);
endwin();
@@ -340,6 +346,21 @@ curses_display_nhwindow(winid wid, BOOLEAN_P block)
void
curses_destroy_nhwindow(winid wid)
{
switch (wid) {
case MESSAGE_WIN:
curses_teardown_messages(); /* discard ^P message history data */
break;
case STATUS_WIN:
curses_status_finish(); /* discard cached status data */
break;
case INV_WIN:
iflags.perm_invent = 0; /* avoid unexpected update_inventory() */
break;
case MAP_WIN:
break;
default:
break;
}
curses_del_nhwin(wid);
}
+25 -23
View File
@@ -148,9 +148,9 @@ curses_message_win_puts(const char *message, boolean recursed)
int
curses_block(boolean noscroll)
/* noscroll - blocking because of msgtype = stop/alert */
/* else blocking because window is full, so need to scroll after */
curses_block(boolean noscroll) /* noscroll - blocking because of msgtype
* = stop/alert else blocking because
* window is full, so need to scroll after */
{
int height, width, ret = 0;
WINDOW *win = curses_get_nhwin(MESSAGE_WIN);
@@ -165,7 +165,7 @@ curses_block(boolean noscroll)
* just any key, as we want to prevent YASD from
* riding direction keys. */
while ((ret = wgetch(win)) != 0 && !index(resp, (char) ret))
continue;
continue;
if (height == 1) {
curses_clear_unhighlight_message_window();
} else {
@@ -233,13 +233,10 @@ curses_last_messages()
nhprev_mesg *mesg;
int i;
if (border) {
mx = 1;
my = 1;
} else {
mx = 0;
my = 0;
}
if (border)
mx = my = 1;
else
mx = my = 0;
for (i = (num_messages - 1); i > 0; i--) {
mesg = get_msg_line(TRUE, i);
@@ -287,28 +284,34 @@ curses_teardown_messages(void)
void
curses_prev_mesg()
{
int count;
int count, fifo_count;
winid wid;
long turn = 0;
anything Id;
nhprev_mesg *mesg;
menu_item *selected = NULL;
boolean do_lifo = (iflags.prevmsg_window != 'f');
wid = curses_get_wid(NHW_MENU);
curses_create_nhmenu(wid);
Id = cg.zeroany;
for (count = 0; count < num_messages; count++) {
mesg = get_msg_line(TRUE, count);
if ((turn != mesg->turn) && (count != 0)) {
for (count = 0, fifo_count = num_messages - 1; count < num_messages;
++count, --fifo_count) {
mesg = get_msg_line(TRUE, do_lifo ? count : fifo_count);
if (turn != mesg->turn && count != 0) {
curses_add_menu(wid, NO_GLYPH, &Id, 0, 0, A_NORMAL, "---", FALSE);
}
curses_add_menu(wid, NO_GLYPH, &Id, 0, 0, A_NORMAL, mesg->str, FALSE);
turn = mesg->turn;
}
if (!count)
curses_add_menu(wid, NO_GLYPH, &Id, 0, 0, A_NORMAL,
"[No past messages available.]", FALSE);
curses_end_menu(wid, "");
curses_select_menu(wid, PICK_NONE, &selected);
curses_del_wid(wid);
}
@@ -655,20 +658,19 @@ get_msg_line(boolean reverse, int mindex)
if (reverse) {
current_mesg = last_mesg;
for (count = 0; count < mindex; count++) {
if (current_mesg == NULL) {
return NULL;
}
if (!current_mesg)
break;
current_mesg = current_mesg->prev_mesg;
}
return current_mesg;
} else {
current_mesg = first_mesg;
for (count = 0; count < mindex; count++) {
if (current_mesg == NULL) {
return NULL;
}
if (!current_mesg)
break;
current_mesg = current_mesg->next_mesg;
}
return current_mesg;
}
return current_mesg;
}
/*cursmesg.c*/
+7 -5
View File
@@ -177,9 +177,9 @@ curses_bail(const char *mesg)
winid
curses_get_wid(int type)
{
winid ret;
static winid menu_wid = 20; /* Always even */
static winid text_wid = 21; /* Always odd */
winid ret;
switch (type) {
case NHW_MESSAGE:
@@ -586,11 +586,9 @@ curses_view_file(const char *filename, boolean must_exist)
menu_item *selected = NULL;
dlb *fp = dlb_fopen(filename, "r");
if ((fp == NULL) && (must_exist)) {
pline("Cannot open %s for reading!", filename);
}
if (fp == NULL) {
if (must_exist)
pline("Cannot open \"%s\" for reading!", filename);
return;
}
@@ -605,6 +603,7 @@ curses_view_file(const char *filename, boolean must_exist)
dlb_fclose(fp);
curses_end_menu(wid, "");
curses_select_menu(wid, PICK_NONE, &selected);
curses_del_wid(wid);
}
@@ -675,6 +674,9 @@ curses_convert_attr(int attr)
case ATR_BOLD:
curses_attr = A_BOLD;
break;
case ATR_DIM:
curses_attr = A_DIM;
break;
case ATR_BLINK:
curses_attr = A_BLINK;
break;
+3 -1
View File
@@ -66,6 +66,7 @@ curses_status_init()
/* let genl_status_init do most of the initialization */
genl_status_init();
return;
}
void
@@ -78,8 +79,9 @@ curses_status_finish()
if (status_vals_long[i])
free(status_vals_long[i]), status_vals_long[i] = (char *) 0;
}
genl_status_finish();
#endif /* STATUS_HILITES */
genl_status_finish();
return;
}
+20 -20
View File
@@ -147,7 +147,7 @@ curses_create_window(int width, int height, orient orientation)
/* Erase and delete curses window, and refresh standard windows */
void
curses_destroy_win(WINDOW * win)
curses_destroy_win(WINDOW *win)
{
werase(win);
wrefresh(win);
@@ -303,8 +303,11 @@ void
curses_del_nhwin(winid wid)
{
if (curses_is_menu(wid) || curses_is_text(wid)) {
curses_del_menu(wid);
curses_del_menu(wid, TRUE);
return;
} else if (wid == INV_WIN) {
curses_del_menu(wid, TRUE);
/* don't return yet */
}
if (!is_main_window(wid)) {
@@ -312,9 +315,6 @@ curses_del_nhwin(winid wid)
wid);
return;
}
if (wid == MESSAGE_WIN) {
curses_teardown_messages();
}
nhwins[wid].curwin = NULL;
nhwins[wid].nhwin = -1;
}
@@ -326,31 +326,35 @@ void
curses_del_wid(winid wid)
{
nethack_wid *tmpwid;
nethack_wid *widptr = nhwids;
nethack_wid *widptr;
if (curses_is_menu(wid) || curses_is_text(wid)) {
curses_del_menu(wid);
curses_del_menu(wid, FALSE);
}
while (widptr != NULL) {
for (widptr = nhwids; widptr; widptr = widptr->next_wid) {
if (widptr->nhwid == wid) {
if (widptr->prev_wid != NULL) {
tmpwid = widptr->prev_wid;
if ((tmpwid = widptr->prev_wid) != NULL) {
tmpwid->next_wid = widptr->next_wid;
} else {
nhwids = widptr->next_wid; /* New head mode, or NULL */
}
if (widptr->next_wid != NULL) {
tmpwid = widptr->next_wid;
if ((tmpwid = widptr->next_wid) != NULL) {
tmpwid->prev_wid = widptr->prev_wid;
}
free(widptr);
break;
}
widptr = widptr->next_wid;
}
}
/* called by destroy_nhwindows() prior to exit */
void
curs_destroy_all_wins()
{
while (nhwids)
curses_del_wid(nhwids->nhwid);
}
/* Print a single character in the given window at the given coordinates */
@@ -439,15 +443,11 @@ curses_window_has_border(winid wid)
boolean
curses_window_exists(winid wid)
{
nethack_wid *widptr = nhwids;
nethack_wid *widptr;
while (widptr != NULL) {
if (widptr->nhwid == wid) {
for (widptr = nhwids; widptr; widptr = widptr->next_wid)
if (widptr->nhwid == wid)
return TRUE;
}
widptr = widptr->next_wid;
}
return FALSE;
}
+1
View File
@@ -20,6 +20,7 @@ void curses_add_wid(winid wid);
void curses_refresh_nhwin(winid wid);
void curses_del_nhwin(winid wid);
void curses_del_wid(winid wid);
void curs_destroy_all_wins(void);
void curses_putch(winid wid, int x, int y, int ch, int color, int attrs);
void curses_get_window_xy(winid wid, int *x, int *y);
boolean curses_window_has_border(winid wid);