From 77d4b4c955a9256129b601f0af70033821c3c502 Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Fri, 22 Jan 2021 14:14:12 -0500 Subject: [PATCH 1/2] Allow custom increment amounts in #wizintrinsic Let users of #wizintrinsic set a specific amount by which they want to increment each particular timeout, by entering a count/typing in numerals before selecting the item in the list. I think doing it this way should be pretty intuitive to players who are familiar with the 'enter count -> make selection' flow of normal inventory menus in NetHack, and is simpler than using a separate prompt, as was mentioned as a possibility in a comment. When an intrinsic is selected without entering a count, the increment will continue to default to the previous value of 30; this value is set via the DEFAULT_TIMEOUT_INCR macro. I also deleted a redundant declaration of wiz_intrinsic; the duplicate seems to have been added by mistake in ff6139c6c5. --- src/cmd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cmd.c b/src/cmd.c index bfc9ece1c..f4233aa6a 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -130,7 +130,6 @@ static int NDECL(dotravel); static int NDECL(doterrain); static int NDECL(wiz_wish); static int NDECL(wiz_identify); -static int NDECL(wiz_intrinsic); static int NDECL(wiz_map); static int NDECL(wiz_makemap); static int NDECL(wiz_genesis); @@ -1548,6 +1547,8 @@ wiz_smell(VOID_ARGS) return 0; } +#define DEFAULT_TIMEOUT_INCR 30 + /* #wizinstrinsic command to set some intrinsics for testing */ static int wiz_intrinsic(VOID_ARGS) @@ -1600,11 +1601,12 @@ wiz_intrinsic(VOID_ARGS) n = select_menu(win, PICK_ANY, &pick_list); destroy_nhwindow(win); - amt = 30; /* TODO: prompt for duration */ for (j = 0; j < n; ++j) { i = pick_list[j].item.a_int - 1; /* -1: reverse +1 above */ p = propertynames[i].prop_num; oldtimeout = u.uprops[p].intrinsic & TIMEOUT; + amt = (pick_list[j].count == -1L) ? DEFAULT_TIMEOUT_INCR + : (int) pick_list[j].count; newtimeout = oldtimeout + (long) amt; switch (p) { case SICK: From 18a4a41b157f720b34522667c27637e43f215a08 Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 22 Jan 2021 16:05:30 -0500 Subject: [PATCH 2/2] compiler settings alignment between macOS.2020 and linux.2020 get the warning flags on linux and macOS into better alignment move the compiler flags into hints/include/compiler.2020 so that maintenance changes can be made there and take effect for both linux and macOS this will likely trigger some initial new code warnings to be investigated on either or both platforms --- sys/unix/hints/include/compiler.2020 | 76 ++++++++++++++++++++++++++++ sys/unix/hints/include/multiw-1.2020 | 16 +----- sys/unix/hints/linux.2020 | 35 +++---------- sys/unix/hints/macOS.2020 | 40 +++------------ 4 files changed, 90 insertions(+), 77 deletions(-) create mode 100755 sys/unix/hints/include/compiler.2020 diff --git a/sys/unix/hints/include/compiler.2020 b/sys/unix/hints/include/compiler.2020 new file mode 100755 index 000000000..52b028ca2 --- /dev/null +++ b/sys/unix/hints/include/compiler.2020 @@ -0,0 +1,76 @@ +#------------------------------------------------------------------------------ +# NetHack 3.7 compiler.2020 $NHDT-Date: 1597332785 2020/08/13 15:33:05 $ $NHDT-Branch: NetHack-3.7 $ + +# compiler flags: CCFLAGS is used to construct a value for CFLAGS with +# various -I, -D, and -W settings appended below; +# these are the settings of most interest for an end-user build +# (clang doesn't support '-Og', gcc needs 4.x or later) +CCFLAGS = -g +#CCFLAGS = -g -Og +#CCFLAGS = -O2 +# Note: this is not the usual 'CFLAGS' which is used in default +# rules for compiling C code; specifying a value for that on the +# 'make' command line should be avoided. + +CCISCLANG := $(shell echo `$(CC) --version` | grep clang) +ifeq "$(CCISCLANG)" "" +CXX=g++ -std=gnu++11 +else +CXX=clang++ -std=gnu++11 +endif +# if you want to override the compiler detection just carried out +# uncomment one of the following pairs as desired. +#CC= gcc +#CXX= g++ -std-gnu++11 +# +#CC= clang +#CXX=clang++ -std=gnu++11 + +CFLAGS=$(CCFLAGS) -I../include -DNOTPARMDECL + +ifndef WANT_WIN_QT +ifndef WANT_LIBNH +# these are normally used when compiling nethack's core +# but -ansi forces -std=c90 for C or -std=c++98 for C++; +# win/Qt/qt_*.cpp compiled with C++98 semantics trigger +#In file included from .../qt5/include/QtCore/qglobal.h:105: +#.../qt5/include/QtCore/qcompilerdetection.h:561:6: +# error Qt requires a C++11 compiler and yours does not seem to be that. +# so we suppress -ansi when the build includes Qt +#CFLAGS+=-ansi -Wno-long-long +#CFLAGS+=-std=c99 +# +#LIBNH's winshim requires C99 for the way it is currently coded +endif +endif + +CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers -Wimplicit \ + -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings +CFLAGS+=-pedantic +CFLAGS+=-DGCC_WARN +CFLAGS+=-Wimplicit-function-declaration +CFLAGS+=-Wimplicit-int +CFLAGS+=-Wmissing-declarations +CFLAGS+=-Wmissing-prototypes +ifeq "$(CCISCLANG)" "" +#gcc-specific here +CFLAGS+=-Wmissing-parameter-type +# get the version of gcc +GCCGTEQ9 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 9) +ifeq "$(GCCGTEQ9)" "1" +# flags present in gcc version greater than or equal to 9 can go here +#CFLAGS+=-Wno-format-overflow +endif #gcc version greater than or equal to 9 +else # clang +# clang-specific here +endif # clang +# As of LLVM build 2336.1.00, this gives dozens of spurious messages, so +# leave it out by default. +#CFLAGS+=-Wunreachable-code +# +# Can't use these; NetHack uses old-style-definitions +#CFLAGS+=-Wold-style-definition +#CFLAGS+=-Wstrict-prototypes + +#end of compiler.2020 +#------------------------------------------------------------------------------ diff --git a/sys/unix/hints/include/multiw-1.2020 b/sys/unix/hints/include/multiw-1.2020 index 3fb550882..a7d934e4a 100644 --- a/sys/unix/hints/include/multiw-1.2020 +++ b/sys/unix/hints/include/multiw-1.2020 @@ -1,3 +1,4 @@ + #------------------------------------------------------------------------------ # NetHack 3.7 multiw-1.2020 $NHDT-Date: 1597332785 2020/08/13 15:33:05 $ $NHDT-Branch: NetHack-3.7 $ @@ -18,20 +19,5 @@ #WANT_DEFAULT=Qt #WANT_DEFAULT=X11 -# 3. compiler detection or optional override -CCISCLANG := $(shell echo `$(CC) --version` | grep clang) -ifeq "$(CCISCLANG)" "" -CXX=g++ -std=gnu++11 -else -CXX=clang++ -std=gnu++11 -endif -# if you want to override the compiler detection just carried out -# uncomment one of the following pairs as desired. -#CC= gcc -#CXX= g++ -std-gnu++11 -# -#CC= clang -#CXX=clang++ -std=gnu++11 - #end of multiw-1.2020 #------------------------------------------------------------------------------ diff --git a/sys/unix/hints/linux.2020 b/sys/unix/hints/linux.2020 index a9aeef494..b79d495e8 100755 --- a/sys/unix/hints/linux.2020 +++ b/sys/unix/hints/linux.2020 @@ -16,21 +16,11 @@ # linux.2020 hints file provides a single-user build for Linux (such # as Ubuntu focal). -# compiler flags: CCFLAGS is used to construct a value for CFLAGS with -# various -I, -D, and -W settings appended below; -# these are the settings of most interest for an end-user build -# (clang doesn't support '-Og', gcc needs 4.x or later) -CCFLAGS = -g -#CCFLAGS = -g -Og -#CCFLAGS = -O2 -# Note: this is not the usual 'CFLAGS' which is used in default -# rules for compiling C code; specifying a value for that on the -# 'make' command line should be avoided. - -# note: '#-INCLUDE' is not just a comment; multiw-1 contains sections 1 to 3 +# note: '#-INCLUDE' is not just a comment +# multiw-1.2020 contains sections 1 to 2 #-INCLUDE multiw-1.2020 -# 4. If you set WANT_WIN_QT, you need to +# 3. If you set WANT_WIN_QT, you need to # A) set QTDIR either here or in the environment to point to the Qt5 # Library installation root. # B) set XPMLIB to point to the Xpm library @@ -46,7 +36,7 @@ ifndef LIBXPM LIBXPM= -L/opt/X11/lib -lXpm endif -#5. Other +#4. Other GAMEUID = $(USER) GAMEGRP = games @@ -57,21 +47,10 @@ GAMEGRP = games #-INCLUDE multiw-2.2020 -CFLAGS=$(CCFLAGS) -I../include -DNOTPARMDECL +# compiler.2020 contains compiler detection and adjustments common +# to both linux and macOS -ifeq "$(CCISCLANG)" "" -# get the version of gcc -GCCGTEQ9 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 9) -ifeq "$(GCCGTEQ9)" "1" -CFLAGS+=-Wno-format-overflow -endif #gcc version greater than or equal to 9 -endif #not clang -# As of LLVM build 2336.1.00, this gives dozens of spurious messages, so -# leave it out by default. -#CFLAGS+=-Wunreachable-code -#CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers -Wimplicit \ -# -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -#CFLAGS+=-DGCC_WARN +#-INCLUDE compiler.2020 # NetHack sources control CFLAGS+=-DDLB diff --git a/sys/unix/hints/macOS.2020 b/sys/unix/hints/macOS.2020 index 283f1a779..a743049b5 100755 --- a/sys/unix/hints/macOS.2020 +++ b/sys/unix/hints/macOS.2020 @@ -16,21 +16,10 @@ # macOS X hints file # -# compiler flags: CCFLAGS is used to construct a value for CFLAGS with -# various -I, -D, and -W settings appended below; -# these are the settings of most interest for an end-user build -# (clang doesn't support '-Og', gcc needs 4.x or later) -CCFLAGS = -g -#CCFLAGS = -g -Og -#CCFLAGS = -O2 -# Note: this is not the usual 'CFLAGS' which is used in default -# rules for compiling C code; specifying a value for that on the -# 'make' command line should be avoided. - -# note: '#-INCLUDE' is not just a comment; multiw-1 contains sections 1 to 3 +# note: '#-INCLUDE' is not just a comment; multiw-1 contains sections 1 to 2 #-INCLUDE multiw-1.2020 -# 4. If you set WANT_WIN_QT, you need to +# 3. If you set WANT_WIN_QT, you need to # A) set QTDIR either here or in the environment to point to the Qt5 # library installation root. (Qt2, Qt3, Qt4 will not work) # B) set XPMLIB to point to the Xpm library @@ -50,7 +39,7 @@ ifndef LIBXPM LIBXPM= -L/opt/X11/lib -lXpm endif -# 5. Other +# 4. Other #----------------------------------------------------------------------------- # You shouldn't need to change anything below here (in the hints file; if @@ -59,27 +48,10 @@ endif #-INCLUDE multiw-2.2020 -CFLAGS=$(CCFLAGS) -I../include -DNOTPARMDECL +# compiler.2020 contains compiler detection and adjustments common +# to both linux and macOS -ifndef WANT_WIN_QT -ifndef WANT_LIBNH -# these are normally used when compiling nethack's core -CFLAGS+=-ansi -pedantic -Wno-long-long -# but -ansi forces -std=c90 for C or -std=c++98 for C++; -# win/Qt/qt_*.cpp compiled with C++98 semantics trigger -#In file included from .../qt5/include/QtCore/qglobal.h:105: -#.../qt5/include/QtCore/qcompilerdetection.h:561:6: -# error Qt requires a C++11 compiler and yours does not seem to be that. -# so we suppress -ansi when the build includes Qt -#LIBNH's winshim requires C99 for the way it is currently coded -endif -endif -# As of LLVM build 2336.1.00, this gives dozens of spurious messages, so -# leave it out by default. -#CFLAGS+=-Wunreachable-code -CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers -Wimplicit \ - -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -CFLAGS+=-DGCC_WARN +#-INCLUDE compiler.2020 # NetHack sources control CFLAGS+=-DDLB