diff --git a/doc/fixes36.2 b/doc/fixes36.2 index a95220e7a..fe465e3e9 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.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, @@ -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 @@ -516,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 @@ -565,6 +568,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/include/ntconf.h b/include/ntconf.h index afbc8feed..2abaf80a2 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/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 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) { 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 ) 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 b29c106e8..2c6f7353b 100644 --- a/sys/winnt/windmain.c +++ b/sys/winnt/windmain.c @@ -44,7 +44,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); diff --git a/win/X11/winX.c b/win/X11/winX.c index 99412cd15..ffc9558e0 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 c52b956d8..e6b02758a 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; diff --git a/win/curses/cursdial.c b/win/curses/cursdial.c index 3c0bcbad1..12d6eb52f 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 */ @@ -76,7 +106,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 +364,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 +372,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 +386,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 +422,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 +434,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 +783,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 +822,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 +928,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 +955,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 +1251,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 +1280,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 +1298,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 +1312,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 90674fbf3..f321a2ebb 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();