From 02b21865fd288626db6984d963078afd0ec34716 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 8 Mar 2019 11:48:31 -0800 Subject: [PATCH 1/7] more UCHAR_P When setting up an alternate definition for UCHAR_P to accommodate DEC C's non-ANSI mode(s), leave the default definition to tradstdc.h. DEC C's VAXC mode will end up expecting 'unsigned char' rather than either 'int' or 'unsigned int'. Not applicable for Unix but this makes similar change there as is being made for VMS. --- include/unixconf.h | 4 +--- include/vmsconf.h | 7 ++++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/unixconf.h b/include/unixconf.h index 63dbddcae..b7c5cabe0 100644 --- a/include/unixconf.h +++ b/include/unixconf.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 unixconf.h $NHDT-Date: 1552007506 2019/03/08 01:11:46 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.40 $ */ +/* NetHack 3.6 unixconf.h $NHDT-Date: 1552074505 2019/03/08 19:48:25 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.41 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Pasi Kallinen, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -274,8 +274,6 @@ /* Digital Unix/HP Tru64 -- see vmsconf.h for explanation */ #if defined(__DECC) && (!defined(__STDC__) || !__STDC__) #define UCHAR_P unsigned int -#else -#define UCHAR_P int #endif /* diff --git a/include/vmsconf.h b/include/vmsconf.h index da77be35a..bebe6b468 100644 --- a/include/vmsconf.h +++ b/include/vmsconf.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 vmsconf.h $NHDT-Date: 1552007507 2019/03/08 01:11:47 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.28 $ */ +/* NetHack 3.6 vmsconf.h $NHDT-Date: 1552074506 2019/03/08 19:48:26 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.29 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */ /* NetHack may be freely redistributed. See license for details. */ @@ -192,6 +192,8 @@ PANICTRACE_GDB=2 #at conclusion of panic, show a call traceback and then #endif #endif +/* tradstdc.h has't set this up yet, but config1.h might have */ +#ifndef UNWIDENED_PROTOTYPES /* ANSI C uses "value preserving rules", where 'unsigned char' and 'unsigned short' promote to 'int' if signed int is big enough to hold all possible values, rather than traditional "sign preserving rules" @@ -203,8 +205,7 @@ PANICTRACE_GDB=2 #at conclusion of panic, show a call traceback and then default 'relaxed' mode, __STDC__ is 1 and uchar widens to 'int'.) */ #if defined(__DECC) && (!defined(__STDC__) || !__STDC__) #define UCHAR_P unsigned int -#else -#define UCHAR_P int +#endif #endif #ifdef __DECC From 683226c3c52b159ebbfeb3769c7ac3287f2cc3f7 Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 10 Mar 2019 14:53:31 -0700 Subject: [PATCH 2/7] curses vs extended commands Extend the earlier support for Delete/Rubout in getline() to the text entry for extended commands. In other words, treat and as synonyms in both places. Some reformatting too, but only in a couple of the files. --- doc/fixes36.2 | 3 ++- win/curses/cursdial.c | 56 ++++++++++++++++++++++--------------------- win/curses/cursmain.c | 27 +++++++++++---------- 3 files changed, 45 insertions(+), 41 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index a95220e7a..480df2705 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.270 $ $NHDT-Date: 1551920371 2019/03/07 00:59:31 $ +$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.271 $ $NHDT-Date: 1552254771 2019/03/10 21:52:51 $ 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, @@ -477,6 +477,7 @@ curses: if the interface code ran out of memory, it would crash rather than curses: when getting multi-character responses from player, support as well as to remove last character entered; also, return to core if ESC is typed when there is no input entered +curses: extend preceding support to typing of extended command names vms: add compile of isaac64.c to Makefile.src and vmsbuild.com diff --git a/win/curses/cursdial.c b/win/curses/cursdial.c index 52083ffc1..c8ee59808 100644 --- a/win/curses/cursdial.c +++ b/win/curses/cursdial.c @@ -76,7 +76,8 @@ static int menu_max_height(void); static nhmenu *nhmenus = NULL; /* NetHack menu array */ -/* Get a line of text from the player, such as asking for a character name or a wish */ +/* Get a line of text from the player, such as asking for a character name + or a wish */ void curses_line_input_dialog(const char *prompt, char *answer, int buffer) @@ -333,7 +334,7 @@ curses_ext_cmd() if (iflags.extmenu) { return extcmd_via_menu(); } - + startx = 0; starty = 0; if (iflags.wc_popup_dialog) { /* Prompt in popup window */ @@ -341,9 +342,9 @@ curses_ext_cmd() extwin2 = curses_create_window(25, 1, UP); wrefresh(extwin2); /* create window inside window to prevent overwriting of border */ - getbegyx(extwin2,y0,x0); - getmaxyx(extwin2,h,w); - extwin = newwin(1, w-2, y0+1, x0+1); + getbegyx(extwin2, y0, x0); + getmaxyx(extwin2, h, w); + extwin = newwin(1, w - 2, y0 + 1, x0 + 1); if (w - 4 < maxlen) maxlen = w - 4; } else { curses_get_window_xy(MESSAGE_WIN, &winx, &winy); @@ -355,8 +356,9 @@ curses_ext_cmd() } winy += messageh - 1; - extwin = newwin(1, messagew-2, winy, winx); - if (messagew - 4 < maxlen) maxlen = messagew - 4; + extwin = newwin(1, messagew - 2, winy, winx); + if (messagew - 4 < maxlen) + maxlen = messagew - 4; pline("#"); } @@ -390,7 +392,7 @@ curses_ext_cmd() break; } - if ((letter == '\r') || (letter == '\n')) { + if (letter == '\r' || letter == '\n') { if (ret == -1) { for (count = 0; extcmdlist[count].ef_txt; count++) { if (!strcasecmp(cur_choice, extcmdlist[count].ef_txt)) { @@ -402,7 +404,9 @@ curses_ext_cmd() break; } - if ((letter == '\b') || (letter == KEY_BACKSPACE)) { + if (letter == '\177') /* DEL/Rubout */ + letter = '\b'; + if (letter == '\b' || letter == KEY_BACKSPACE) { if (prompt_width == 0) { ret = -1; break; @@ -749,10 +753,9 @@ menu_get_accel(boolean first) ret = next_letter; - if (((next_letter < 'z') && (next_letter >= 'a')) || ((next_letter < 'Z') - && (next_letter >= - 'A')) || - ((next_letter < '9') && (next_letter >= '0'))) { + if ((next_letter < 'z' && next_letter >= 'a') + || (next_letter < 'Z' && next_letter >= 'A') + || (next_letter < '9' && next_letter >= '0')) { next_letter++; } else if (next_letter == 'z') { next_letter = 'A'; @@ -789,8 +792,8 @@ menu_is_multipage(nhmenu *menu, int width, int height) menu_item_ptr->num_lines = num_lines; curline += num_lines; menu_item_ptr = menu_item_ptr->next_item; - if ((curline > height) || ((curline > height - 2) && - (height == menu_max_height()))) { + if (curline > height + || (curline > height - 2 && height == menu_max_height())) { break; } } @@ -895,7 +898,7 @@ menu_win_size(nhmenu *menu) menu_item_ptr = menu_item_ptr->next_item; } - /* If the widest entry is smaller than maxwidth, reduce maxwidth accordingly */ + /* If widest entry is smaller than maxwidth, reduce maxwidth accordingly */ if (maxentrywidth < maxwidth) { maxwidth = maxentrywidth; } @@ -922,7 +925,7 @@ menu_win_size(nhmenu *menu) if (lastline < maxheight) { maxheight = lastline; } - } else { /* If multipage, make sure we have enough width for page footer */ + } else { /* If multipage, make sure we have enough width for page footer */ if (width < 20) { width = 20; @@ -1218,8 +1221,8 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how) menu_item_ptr = menu->entries; while (menu_item_ptr != NULL) { - if ((menu_item_ptr->identifier.a_void != NULL) && - (strstri(menu_item_ptr->str, search_key))) { + if (menu_item_ptr->identifier.a_void != NULL + && strstri(menu_item_ptr->str, search_key)) { if (how == PICK_ONE) { menu_clear_selections(menu); menu_select_deselect(win, menu_item_ptr, SELECT); @@ -1247,12 +1250,11 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how) menu_item_ptr = menu->entries; while (menu_item_ptr != NULL) { if (menu_item_ptr->identifier.a_void != NULL) { - if (((curletter == menu_item_ptr->accelerator) && - ((curpage == menu_item_ptr->page_num) || - (!menu->reuse_accels))) || ((menu_item_ptr->group_accel) - && (curletter == - menu_item_ptr-> - group_accel))) { + if ((curletter == menu_item_ptr->accelerator + && (curpage == menu_item_ptr->page_num + || !menu->reuse_accels)) + || (menu_item_ptr->group_accel + && curletter == menu_item_ptr->group_accel)) { if (curpage != menu_item_ptr->page_num) { curpage = menu_item_ptr->page_num; menu_display_page(menu, win, curpage); @@ -1266,7 +1268,7 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how) num_selected = 1; dismiss = TRUE; break; - } else if ((how == PICK_ANY) && (curletter == count_letter)) { + } else if (how == PICK_ANY && curletter == count_letter) { menu_select_deselect(win, menu_item_ptr, SELECT); menu_item_ptr->count = count; count = 0; @@ -1280,7 +1282,7 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how) } } - if ((how == PICK_ANY) && (num_selected != -1)) { + if (how == PICK_ANY && num_selected != -1) { num_selected = 0; menu_item_ptr = menu->entries; diff --git a/win/curses/cursmain.c b/win/curses/cursmain.c index e792c9376..0a56427f3 100644 --- a/win/curses/cursmain.c +++ b/win/curses/cursmain.c @@ -84,9 +84,9 @@ struct window_procs curses_procs = { /* * Global variables for curses interface */ - + int term_rows, term_cols; /* size of underlying terminal */ -int orig_cursor; /* Preserve initial cursor state */ +int orig_cursor; /* Preserve initial cursor state */ WINDOW *base_term; /* underlying terminal window */ boolean counting; /* Count window is active */ WINDOW *mapwin, *statuswin, *messagewin; /* Main windows */ @@ -96,7 +96,7 @@ WINDOW *mapwin, *statuswin, *messagewin; /* Main windows */ the inventory window. */ static int inv_update = 0; -/* +/* init_nhwindows(int* argcp, char** argv) -- Initialize the windows used by NetHack. This can also create the standard windows listed at the top, but does @@ -264,7 +264,7 @@ curses_resume_nhwindows() curses_refresh_nethack_windows(); } -/* Create a window of type "type" which can be +/* Create a window of type "type" which can be NHW_MESSAGE (top line) NHW_STATUS (bottom lines) NHW_MAP (main dungeon) @@ -307,6 +307,7 @@ void curses_display_nhwindow(winid wid, BOOLEAN_P block) { menu_item *selected = NULL; + if (curses_is_menu(wid) || curses_is_text(wid)) { curses_end_menu(wid, ""); curses_select_menu(wid, PICK_NONE, &selected); @@ -314,9 +315,9 @@ curses_display_nhwindow(winid wid, BOOLEAN_P block) } /* don't overwrite the splash screen first time through */ - if (!iflags.window_inited && wid == MAP_WIN) + if (!iflags.window_inited && wid == MAP_WIN) { iflags.window_inited = TRUE; - else { + } else { /* actually display the window */ wnoutrefresh(curses_get_nhwin(wid)); /* flush pending writes from other windows too */ @@ -332,7 +333,7 @@ curses_display_nhwindow(winid wid, BOOLEAN_P block) } -/* Destroy will dismiss the window if the window has not +/* Destroy will dismiss the window if the window has not * already been dismissed. */ void @@ -586,7 +587,7 @@ print_glyph(window, x, y, glyph, bkglyph) port wants (symbol, font, color, attributes, ...there's a 1-1 map between glyphs and distinct things on the map). bkglyph is to render the background behind the glyph. - It's not used here. + It's not used here. */ void curses_print_glyph(winid wid, XCHAR_P x, XCHAR_P y, int glyph, @@ -679,8 +680,8 @@ int nh_poskey(int *x, int *y, int *mod) a position in the MAP window is returned in x, y and mod. mod may be one of - CLICK_1 -- mouse click type 1 - CLICK_2 -- mouse click type 2 + CLICK_1 -- mouse click type 1 + CLICK_2 -- mouse click type 2 The different click types can map to whatever the hardware supports. If no mouse is supported, this @@ -841,14 +842,14 @@ preference_update(preference) port of that change. If your window-port is capable of dynamically adjusting to the change then it should do so. Your window-port will only be notified of a particular - change if it indicated that it wants to be by setting the + change if it indicated that it wants to be by setting the corresponding bit in the wincap mask. */ void curses_preference_update(const char *pref) { - if ((strcmp(pref, "align_status") == 0) || - (strcmp(pref, "align_message") == 0)) { + if (!strcmp(pref, "align_status") + || !strcmp(pref, "align_message")) { curses_create_main_windows(); curses_last_messages(); doredraw(); From 53777fa03a1c5865d1f7b706fe98a1c4b30fa54e Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 10 Mar 2019 16:06:29 -0700 Subject: [PATCH 3/7] win/curses comment Twice I've gone through the curses code to deal with CHAR_P, BOOLEAN_P, and so forth. Both times I eventually changed my mind. This time I'm just adding an explanatory comment instead. --- win/curses/cursdial.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/win/curses/cursdial.c b/win/curses/cursdial.c index c8ee59808..966f15109 100644 --- a/win/curses/cursdial.c +++ b/win/curses/cursdial.c @@ -17,6 +17,36 @@ #define strncasecmp strncmpi #endif +/* + * Note: + * + * Prototypes need to use the widened/unwidened type macros (CHAR_P, &c) + * in order to match fields of the window_procs struct (see winprocs.h). + * But for a standard-conforming compiler, we'll end up with the widened + * types necessary to match the mixed prototype/old-style function + * definition environment as used by nethack's core. Prototype +int func(CHAR_P); + * becomes +int func(int); + * after expansion, which matches the definition +int func(arg) char arg; { ... } + * according to the rules of the C standard. But the use of new-style + * definitions +int func(char arg) { ... } + * by the curses interface turns that into a conflict. No widening takes + * place so it ought to be 'int func(char);' instead. Unfortunately that + * would be incompatible for functions assigned to window_procs. + * + * So, the code here (also cursmain.c and cursinvt.c) is mis-using the + * widening macros for variable types +int func(CHAR_P arg) { ... } + * (no doubt modelling it after the C++ code in win/Qt where the option + * to switch the applicable definitions to old-style isn't available). + * Other alternatives aren't significantly better so just live with it. + * [Redoing the windowing interface to avoid narrow arguments would be + * better since that would fix Qt's usage too.] + */ + /* Dialog windows for curses interface */ From 44639ab1e8c8d4aff3d5d32b0fd36fe1ed5f2410 Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 11 Mar 2019 18:11:21 -0700 Subject: [PATCH 4/7] long #version feedback Hide a bug in the X11 interface by manually wrapping 'short' version line (the first line of #version output) when runtime ID or git hash and/or branch is present. Otherwise the very wide 'short' line causes a horizontal scrollbar to be present at the bottom of the popup window, but the window size doesn't take that into account so ends up being one line too short. Worse, there's no vertical scrollbar to bring the last line into view. Even if somebody figures out how to fix that properly, the really wide line above a couple of paragraphs which have been carefully wrapped for a much narrower width looked strange. Also, move the 'short' version's period to the end of the text. old: basic version info. (extra info) new: basic version info (extra info). --- src/version.c | 53 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/src/version.c b/src/version.c index 94f1f3024..1ed62b7d3 100644 --- a/src/version.c +++ b/src/version.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 version.c $NHDT-Date: 1546137502 2018/12/30 02:38:22 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.51 $ */ +/* NetHack 3.6 version.c $NHDT-Date: 1552353060 2019/03/12 01:11:00 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.52 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -17,10 +17,10 @@ #endif #if defined(NETHACK_GIT_SHA) -const char * NetHack_git_sha = NETHACK_GIT_SHA; +const char *NetHack_git_sha = NETHACK_GIT_SHA; #endif #if defined(NETHACK_GIT_BRANCH) -const char * NetHack_git_branch = NETHACK_GIT_BRANCH; +const char *NetHack_git_branch = NETHACK_GIT_BRANCH; #endif STATIC_DCL void FDECL(insert_rtoption, (char *)); @@ -38,24 +38,21 @@ char * getversionstring(buf) char *buf; { - boolean details = FALSE; - Strcpy(buf, VERSION_ID); -#if defined(RUNTIME_PORT_ID) || \ - defined(NETHACK_GIT_SHA) || defined(NETHACK_GIT_BRANCH) - details = TRUE; -#endif - if (details) { -#if defined(RUNTIME_PORT_ID) || defined(NETHACK_GIT_SHA) || defined(NETHACK_GIT_BRANCH) +#if defined(RUNTIME_PORT_ID) \ + || defined(NETHACK_GIT_SHA) || defined(NETHACK_GIT_BRANCH) + { int c = 0; -#endif #if defined(RUNTIME_PORT_ID) - char tmpbuf[BUFSZ]; - char *tmp = (char *)0; + char tmpbuf[BUFSZ], *tmp; #endif + char *p = eos(buf); + boolean dotoff = (p > buf && p[-1] == '.'); - Sprintf(eos(buf), " ("); + if (dotoff) + --p; + Strcpy(p, " ("); #if defined(RUNTIME_PORT_ID) tmp = get_port_id(tmpbuf); if (tmp) @@ -72,8 +69,15 @@ char *buf; c++ ? "," : "", NetHack_git_branch); #endif #endif - Sprintf(eos(buf), ")"); + if (c) + Strcat(buf, ")"); + else /* if nothing has been added, strip " (" back off */ + *p = '\0'; + if (dotoff) + Strcat(buf, "."); } +#endif /* RUNTIME_PORT_ID || NETHACK_GIT_SHA || NETHACK_GIT_BRANCH */ + return buf; } @@ -92,12 +96,25 @@ int doextversion() { dlb *f; - char buf[BUFSZ]; + char buf[BUFSZ], *p = 0; winid win = create_nhwindow(NHW_TEXT); /* instead of using ``display_file(OPTIONS_USED,TRUE)'' we handle the file manually so we can include dynamic version info */ - putstr(win, 0, getversionstring(buf)); + + (void) getversionstring(buf); + /* if extra text (git info) is present, put it on separate line */ + if (strlen(buf) >= COLNO) + p = rindex(buf, '('); + if (p && p > buf && p[-1] == ' ') + p[-1] = '\0'; + else + p = 0; + putstr(win, 0, buf); + if (p) { + *--p = ' '; + putstr(win, 0, p); + } f = dlb_fopen(OPTIONS_USED, "r"); if (!f) { From 8e7fe38daec1ad5231f3c3d3bc82b7f827782d80 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 12 Mar 2019 13:31:00 -0700 Subject: [PATCH 5/7] avoid crash for X11 tombstone If nethack is built to use graphical tombstone but file rip.xpm is missing from the playground, there would be a crash if the rip output was shown. My first attempt to fix it prevented the crash but didn't display any tombstone, just the last couple of lines of output which follow the tombstone. This keeps that in case of some other Xpm failure, but checks for rip.xpm via stdio and reverts to genl_outrip for text tombstone if it can't be opened. --- doc/fixes36.2 | 4 +++- win/X11/winX.c | 12 +++++++++++- win/X11/wintext.c | 28 ++++++++++++++++------------ 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index 480df2705..f293fec72 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.271 $ $NHDT-Date: 1552254771 2019/03/10 21:52:51 $ +$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.272 $ $NHDT-Date: 1552422652 2019/03/12 20:30:52 $ 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, @@ -566,6 +566,8 @@ X11: text popups on OSX wouldn't accept keyboard input unless the 'autofocus' resource was enabled; most noticeable when trying to dismiss 'things that are here' while walking over object piles X11: default to using XPM format tile file and rip screen +X11: when showing graphical tombstone, would crash if file rip.xpm is missing; + revert to text tombstone instead General New Features diff --git a/win/X11/winX.c b/win/X11/winX.c index 654e997e4..958625a0d 100644 --- a/win/X11/winX.c +++ b/win/X11/winX.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 winX.c $NHDT-Date: 1546081304 2018/12/29 11:01:44 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.71 $ */ +/* NetHack 3.6 winX.c $NHDT-Date: 1552422652 2019/03/12 20:30:52 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.72 $ */ /* Copyright (c) Dean Luick, 1992 */ /* NetHack may be freely redistributed. See license for details. */ @@ -1355,10 +1355,20 @@ int how; time_t when; { struct xwindow *wp; + FILE *rip_fp; check_winid(window); wp = &window_list[window]; + /* make sure the graphic_tombstone is available; it's not easy to + revert to ordinary text tombstone once we're past this point... */ + rip_fp = fopen(appResources.tombstone, "r"); /* "rip.xpm" */ + if (!rip_fp) { + genl_outrip(window, how, when); + return; + } + (void) fclose(rip_fp); + if (wp->type == NHW_TEXT) { wp->text_information->is_rip = TRUE; } else { diff --git a/win/X11/wintext.c b/win/X11/wintext.c index 122ef8e02..61615447c 100644 --- a/win/X11/wintext.c +++ b/win/X11/wintext.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 wintext.c $NHDT-Date: 1546081305 2018/12/29 11:01:45 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.17 $ */ +/* NetHack 3.6 wintext.c $NHDT-Date: 1552422654 2019/03/12 20:30:54 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.18 $ */ /* Copyright (c) Dean Luick, 1992 */ /* NetHack may be freely redistributed. See license for details. */ @@ -181,8 +181,7 @@ boolean blocking; * _some_ lines. Finally, use the number of lines in the text if * there are fewer than the max. */ - nlines = - (XtScreen(wp->w)->height - text_info->extra_height) / font_height; + nlines = (XtScreen(wp->w)->height - text_info->extra_height) / font_height; nlines -= 4; if (nlines > text_info->text.num_lines) @@ -204,13 +203,16 @@ boolean blocking; #ifdef GRAPHIC_TOMBSTONE if (text_info->is_rip) { Widget rip = create_ripout_widget(XtParent(wp->w)); - XtSetArg(args[num_args], nhStr(XtNfromVert), rip); - num_args++; + + if (rip) { + XtSetArg(args[num_args], nhStr(XtNfromVert), rip); + num_args++; + } else + text_info->is_rip = FALSE; } #endif - if (width - > (Dimension) XtScreen(wp->w)->width) { /* too wide for screen */ + if (width > (Dimension) XtScreen(wp->w)->width) { /* too wide for screen */ /* Back off some amount - we really need to back off the scrollbar */ /* width plus some extra. */ width = XtScreen(wp->w)->width - 20; @@ -420,8 +422,7 @@ boolean concat; if (str) { (void) memcpy((tb->text + tb->text_last), str, length + 1); if (length) { - /* Remove all newlines. Otherwise we have a confused line count. - */ + /* Remove all newlines. Otherwise we have a confused line count. */ copy = (tb->text + tb->text_last); while ((copy = index(copy, '\n')) != (char *) 0) *copy = ' '; @@ -577,6 +578,7 @@ XtPointer widget_data; /* expose event from Window widget */ int len = strlen(rip_line[i]); XFontStruct *font = WindowFontStruct(w); int width = XTextWidth(font, rip_line[i], len); + XDrawString(dpy, XtWindow(w), gc, x - width / 2, y, rip_line[i], len); x += appResources.tombtext_dx; y += appResources.tombtext_dy; @@ -603,14 +605,16 @@ create_ripout_widget(Widget parent) attributes.valuemask = XpmCloseness; attributes.closeness = 65535; /* Try anything */ - errorcode = - XpmReadFileToImage(XtDisplay(parent), appResources.tombstone, - &rip_image, 0, &attributes); + errorcode = XpmReadFileToImage(XtDisplay(parent), + appResources.tombstone, + &rip_image, 0, &attributes); if (errorcode != XpmSuccess) { char buf[BUFSZ]; + Sprintf(buf, "Failed to load %s: %s", appResources.tombstone, XpmGetErrorString(errorcode)); X11_raw_print(buf); + return (Widget) 0; } rip_width = rip_image->width; rip_height = rip_image->height; From e0bf7a01cc3bb7d2152dcdc247fd8456d199ea60 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 12 Mar 2019 14:11:26 -0700 Subject: [PATCH 6/7] nethack.sh: test -e vs test -f Change the test for whether fonts.dir exists (added to the script in 3.6.0, for automatically setting up possible use of the NH10 font under X11) from 'test -e file' to 'test -f file' since the latter seems to be more universally available. When present, fonts.dir is plain text, so a test for "exists and is a regular file" rather than one for general existance is appropriate. --- doc/fixes36.2 | 4 +++- sys/unix/nethack.sh | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index f293fec72..fe465e3e9 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.272 $ $NHDT-Date: 1552422652 2019/03/12 20:30:52 $ +$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.273 $ $NHDT-Date: 1552425075 2019/03/12 21:11:15 $ 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, @@ -517,6 +517,8 @@ unix: Makefile.src and Makefile.utl inadvertently relied on a 'gnu make' specifically requested; use 'make QUIETCC=1 ' to get the 3.6.1 behavior back unix: add curses window port +unix: in nethack.sh, use 'test -f' instead of 'test -e' when checking for + fonts.dir while running under X11 vms: data file processing and playground setup were missing post-3.4.3 files engrave, epitaph, and bogusmon made from corresponding *.txt windows: Added ntassert() mechanism for Windows based port use diff --git a/sys/unix/nethack.sh b/sys/unix/nethack.sh index 7ca74865d..2c2b62cdf 100755 --- a/sys/unix/nethack.sh +++ b/sys/unix/nethack.sh @@ -1,5 +1,5 @@ #!/bin/sh -# NetHack 3.6 nethack.sh $NHDT-Date: 1524689450 2018/04/25 20:50:50 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.19 $ +# NetHack 3.6 nethack.sh $NHDT-Date: 1552425075 2019/03/12 21:11:15 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.20 $ # Copyright (c) 2015 by Kenneth Lorber, Kensington, Maryland # NetHack may be freely redistributed. See license for details. @@ -17,7 +17,7 @@ esac export XUSERFILESEARCHPATH # Get font dir added, but only once (and only if there's an xset to be found). -test -n "$DISPLAY" -a -e $HACKDIR/fonts.dir && xset p >/dev/null 2>&1 && ( +test -n "$DISPLAY" -a -f $HACKDIR/fonts.dir && xset p >/dev/null 2>&1 && ( xset fp- $HACKDIR >/dev/null 2>&1; xset fp+ $HACKDIR ) From 93201e9e242c38a84cd292c49681ca853173361f Mon Sep 17 00:00:00 2001 From: nhmall Date: Tue, 12 Mar 2019 21:14:43 -0400 Subject: [PATCH 7/7] first attempt at mingw w64 build for Windows --- include/ntconf.h | 2 ++ sys/winnt/Makefile.gcc | 38 ++++++++++++++++++-------------------- sys/winnt/win10.c | 2 ++ sys/winnt/windmain.c | 2 +- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/include/ntconf.h b/include/ntconf.h index 094c50c73..05edf9071 100644 --- a/include/ntconf.h +++ b/include/ntconf.h @@ -98,6 +98,8 @@ extern void FDECL(interject, (int)); #ifdef strcasecmp #undef strcasecmp #endif +extern void FDECL(nethack_exit, (int)); +extern void NDECL(getlock); #endif #ifdef _MSC_VER diff --git a/sys/winnt/Makefile.gcc b/sys/winnt/Makefile.gcc index 4450e1f75..9813b22a2 100644 --- a/sys/winnt/Makefile.gcc +++ b/sys/winnt/Makefile.gcc @@ -4,13 +4,12 @@ # #============================================================================== # -# Win32 Compilers Tested: -# === TDM-GCC Compiler Suite for Windows === -# --- GCC 4.6 & 4.7 Series --- -# *** Standard MinGW 32-bit Edition *** +# Win32 Compilers Tested with this Makefile.gcc: +# mingw-w64 +# from: +# https://sourceforge.net/p/mingw-w64/wiki2/GeneralUsageInstructions/ +# Toolchain for Windows 32-bit target # -# If you don't have this compiler, you can get it at: -# http://tdm-gcc.tdragon.net/ # #============================================================================== # This is used for building two versions of NetHack: @@ -92,7 +91,7 @@ TARGET_CPU=x86 # your machine. # ADD_CURSES=Y -PDCURSES_TOP=..\..\pdcurses +PDCURSES_TOP=../../pdcurses #4b Qt # @@ -180,6 +179,7 @@ OBJ = o RANDOM = $(OBJ)/random.o #RANDOM = +BCRYPT=-lbcrypt WINPFLAG = -DTILES -DMSWIN_GRAPHICS -DWIN32CON -D_WIN32_IE=0x0400 -D_WIN32_WINNT=0x0501 ifeq "$(WANT_WIN_QT4)" "Y" @@ -288,7 +288,7 @@ VOBJ06 = $(O)dothrow.o $(O)drawing.o $(O)dungeon.o $(O)eat.o VOBJ07 = $(O)end.o $(O)engrave.o $(O)exper.o $(O)explode.o VOBJ08 = $(O)extralev.o $(O)files.o $(O)fountain.o $(O)hack.o VOBJ09 = $(O)hacklib.o $(O)invent.o $(O)light.o $(O)lock.o -VOBJ10 = $(O)mail.o $(O)makemon.o $(O)mapglyph.o +VOBJ10 = $(O)mail.o $(O)makemon.o $(O)mapglyph.o $(O)isaac64.o VOBJ11 = $(O)mcastu.o $(O)mhitm.o $(O)mhitu.o $(O)minion.o VOBJ12 = $(O)mklev.o $(O)mkmap.o $(O)mkmaze.o $(O)mkobj.o VOBJ13 = $(O)mkroom.o $(O)mon.o $(O)mondata.o $(O)monmove.o @@ -321,8 +321,8 @@ else CURSESOBJ= endif -SOBJ = $(O)winnt.o $(O)pcsys.o $(O)pcunix.o \ - $(SOUND) $(O)pcmain.o $(O)nhlan.o +SOBJ = $(O)windmain.o $(O)winnt.o $(O)win10.o \ + $(O)safeproc.o $(O)nhlan.o $(SOUND) OBJS = $(VOBJ01) $(VOBJ02) $(VOBJ03) $(VOBJ04) $(VOBJ05) \ $(VOBJ06) $(VOBJ07) $(VOBJ08) $(VOBJ09) $(VOBJ10) \ @@ -475,10 +475,10 @@ endif #========================================== #========================================== -cc = gcc +cc = i686-w64-mingw32-gcc.exe cxx = g++ rc = windres -link = gcc +link = i686-w64-mingw32-gcc.exe ifeq "$(WANT_WIN_QT4)" "Y" link = g++ endif @@ -497,7 +497,7 @@ CFLAGSBASE = -c $(cflags) $(WINPINC) $(cdebug) $(CURSESDEF) #LFLAGSBASEC = $(linkdebug) #LFLAGSBASEG = $(linkdebug) -mwindows -conlibs = -lgdi32 -lwinmm +conlibs = -lgdi32 -lwinmm $(BCRYPT) guilibs = -lcomctl32 -lwinmm ifeq "$(WANT_WIN_QT4)" "Y" # Might be either Qt 4 or Qt 5 @@ -541,7 +541,7 @@ LFLAGSU = $(LFLAGSBASEC) # - Game build #========================================== -CFLAGS = $(CFLAGSBASE) $(WINPFLAG) $(DLBFLG) +CFLAGS = $(CFLAGSBASE) $(WINPFLAG) $(DLBFLG) -DSAFEPROCS lflags = $(LFLAGSBASEC) $(linkdebuf) CXXFLAGS = $(CFLAGS) @@ -750,10 +750,8 @@ endif $(subst /,\,if exist $(DAT)/symbols copy $(DAT)/symbols $(GAMEDIR)) $(subst /,\,if exist $(DOC)/guidebook.txt copy $(DOC)/guidebook.txt $(GAMEDIR)/Guidebook.txt) $(subst /,\,if exist $(DOC)/nethack.txt copy $(DOC)/nethack.txt $(GAMEDIR)/NetHack.txt) - $(U)makedefs -c - $(subst /,\,if not exist $(GAMEDIR)/defaults.nh copy fixed_defaults.nh $(GAMEDIR)/defaults.nh) $(subst /,\,if not exist $(GAMEDIR)/defaults.nh copy $(MSWSYS)/defaults.nh $(GAMEDIR)/defaults.nh) - $(subst /,\,-if not exist $(GAMEDIR)/record. goto>$(GAMEDIR)/record.) + $(subst /,\,-if not exist $(GAMEDIR)/record. echo.>$(GAMEDIR)/record.) # # $(subst /,\,echo install done > $@) @@ -1544,9 +1542,9 @@ $(O)topl.o: ../win/tty/topl.c $(HACK_H) $(INCL)/tcap.h $(O)wintty.o: ../win/tty/wintty.c $(HACK_H) $(INCL)/dlb.h \ $(INCL)/date.h $(INCL)/patchlevel.h $(INCL)/tcap.h $(cc) $(CFLAGS) -o$@ ../win/tty/wintty.c -$(O)Window.o: ../win/X11/Window.c $(INCL)/xwindowp.h $(INCL)/xwindow.h \ - $(CONFIG_H) - $(cc) $(CFLAGS) -o$@ ../win/X11/Window.c +#$(O)Window.o: ../win/X11/Window.c $(INCL)/xwindowp.h $(INCL)/xwindow.h \ +# $(CONFIG_H) +# $(cc) $(CFLAGS) -o$@ ../win/X11/Window.c $(O)dialogs.o: ../win/X11/dialogs.c $(CONFIG_H) $(cc) $(CFLAGS) -o$@ ../win/X11/dialogs.c $(O)winX.o: ../win/X11/winX.c $(HACK_H) $(INCL)/winX.h $(INCL)/dlb.h \ diff --git a/sys/winnt/win10.c b/sys/winnt/win10.c index 48f5bb98a..c6d667080 100644 --- a/sys/winnt/win10.c +++ b/sys/winnt/win10.c @@ -2,6 +2,7 @@ /* Copyright (C) 2018 by Bart House */ /* NetHack may be freely redistributed. See license for details. */ +#ifdef _MSC_VER #include "win10.h" #include #include @@ -79,3 +80,4 @@ void win10_monitor_info(HWND hWnd, MonitorInfo * monitorInfo) monitorInfo->left = info.rcMonitor.left; monitorInfo->top = info.rcMonitor.top; } +#endif /* _MSC_VER */ diff --git a/sys/winnt/windmain.c b/sys/winnt/windmain.c index 45e36174f..24fd33746 100644 --- a/sys/winnt/windmain.c +++ b/sys/winnt/windmain.c @@ -45,7 +45,7 @@ void NDECL(windows_nhbell); int FDECL(windows_nh_poskey, (int *, int *, int *)); void FDECL(windows_raw_print, (const char *)); char FDECL(windows_yn_function, (const char *, const char *, CHAR_P)); -void FDECL(windows_getlin, (const char *, char *)); +static void FDECL(windows_getlin, (const char *, char *)); extern int NDECL(windows_console_custom_nhgetch); void NDECL(safe_routines);