PatR [Fri, 5 Feb 2021 09:04:48 +0000 (01:04 -0800)]
curses: honor menu_next_page/&c option settings
tty and X11 honor the menu_xxx options. Qt currently doesn't
support menu manipulation by keyboard. curses does support that
but was only handling the default menu keys.
PatR [Thu, 4 Feb 2021 09:35:58 +0000 (01:35 -0800)]
some options tidying
Somehow several arrays of compound option values ended up in
between defining menu_cmd_t and using menu_cmd_t. Reorder them.
Also, add a terminator to the list of menu commands so that it
could potentially be used manipulated from other source files
that don't have access to the array size.
nhmall [Wed, 3 Feb 2021 20:31:57 +0000 (15:31 -0500)]
unused-but-set-variable warning in qt_main.cpp
../win/Qt/qt_main.cpp: In member function ‘virtual void nethack_qt_::NetHackQtMainWindow::closeEvent(QCloseEvent*)’:
../win/Qt/qt_main.cpp:1377:9: warning: variable ‘ok’ set but not used [-Wunused-but-set-variable]
1377 | int ok = 0;
| ^~
nhmall [Wed, 3 Feb 2021 18:18:43 +0000 (13:18 -0500)]
clear a number of Qt build warnings on linux related to compiler flags
option ‘-Wimplicit’ is valid for C/ObjC but not for C++
option ‘-Wimplicit-function-declaration’ is valid for C/ObjC but not for C++
option ‘-Wimplicit-int’ is valid for C/ObjC but not for C++
option ‘-Wmissing-prototypes’ is valid for C/ObjC but not for C++
option ‘-Wmissing-parameter-type’ is valid for C/ObjC but not for C++
option ‘-Wold-style-definition’ is valid for C/ObjC but not for C++
option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
nhmall [Wed, 3 Feb 2021 17:56:55 +0000 (12:56 -0500)]
variable set but not used warning in qt_yndlg.cpp
../win/Qt/qt_yndlg.cpp: In member function ‘char nethack_qt_::NetHackQtYnDialog::Exec()’:
../win/Qt/qt_yndlg.cpp:80:9: warning: variable ‘ch_per_line’ set but not used [-Wunused-but-set-variable]
80 | int ch_per_line=6;
| ^~~~~~~~~~~
nhmall [Wed, 3 Feb 2021 15:55:07 +0000 (10:55 -0500)]
Qt c++ function name shadow warnings
We have a struct called mkroom and a function called mkroom()
so c++ complains about the mkroom() function hiding the
initializer for the struct.
Similarly, we have a struct called attack and a function
called attack().
There may be a more elegant way of eliminating those two
warnings, but renaming mkroom() to do_mkroom() and
attack() to do_attack() was straightforward enough.
nhmall [Wed, 3 Feb 2021 00:03:12 +0000 (19:03 -0500)]
enable -Wformat-nonliteral for linux and equivalent for windows compilers
Whitelist all the verified existing triggers:
makedefs.c: In function ‘name_file’
attrib.c: one compiler balks at a ? b : c for fmtstring
cmd.c: In function ‘extcmd_via_menu’
cmd.c: In function ‘wiz_levltyp_legend’
do.c: In function ‘goto_level’
do_name.c: In function ‘coord_desc’
dungeon.c: In function ‘overview_stats’
eat.c: one compiler balks at a ? b : c for fmtstring
end.c: one compiler balks at a ? b : c for fmtstring
engrave.c: In function ‘engr_stats’
hack:c one compiler balks at a ? b : c for fmtstring
hacklib.c: one compiler balks at a ? b : c for fmtstring
insight.c: one compiler balks at a ? b : c for fmtstring
invent.c: In function ‘let_to_name’
light.c: In function ‘light_stats’
mhitm.c: In function ‘missmm’
options.c: In function ‘handler_symset’
options.c: In function ‘basic_menu_colors’
options.c: In function ‘optfn_o_autopickup_exceptions’
options.c: In function ‘optfn_o_menu_colors’
options.c: In function ‘optfn_o_message_types’
options.c: In function ‘optfn_o_status_cond’
options.c: In function ‘optfn_o_status_hilites’
options.c: In function ‘doset’
options.c: In function ‘doset_add_menu’
options.c: In function ‘show_menu_controls’
options.c: In function ‘handle_add_list_remove’
pager.c: In function ‘do_supplemental_info’
pager.c: In function ‘dohelp’
region.c: In function ‘region_stats’
rumors.c: sscanf usage
sounds.c: In function ‘domonnoise’
spell.c: In function ‘dospellmenu’
timeout.c: In function ‘timer_stats’
topten.c: In function ‘outentry’, fscanf, sscanf, fprintf usage
windows.c: In function ‘genl_status_update’
zap.c: one compiler balks at a ? b : c for fmtstring
win/curses/cursstat.c: In function ‘curses_status_update’
win/tty/wintty.c: In function ‘tty_status_update’
win/win32/mswproc.c: In function ‘mswin_status_update’
nhmall [Tue, 2 Feb 2021 01:02:12 +0000 (20:02 -0500)]
resolve a warning in sounds.c
sounds.c: In function ‘add_sound_mapping’:
sounds.c:1381:33: warning: ‘sprintf’ may write a terminating nul past the end of the destination [-Wformat-overflow=]
1381 | Sprintf(filespec, "%s/%s", sounddir, filename);
| ^
In file included from ../include/config.h:631,
from ../include/hack.h:10,
from sounds.c:5:
../include/global.h:274:24: note: ‘sprintf’ output 2 or more bytes (assuming 257) into a destination of size 256
274 | #define Sprintf (void) sprintf
sounds.c:1381:9: note: in expansion of macro ‘Sprintf’
1381 | Sprintf(filespec, "%s/%s", sounddir, filename);
| ^~~~~~~
nhmall [Mon, 1 Feb 2021 21:36:17 +0000 (16:36 -0500)]
clear some more format-overflow warnings
clear some -Wformat-overflow warnings being experienced with
i586-pc-msdosdjgpp-gcc (GCC) 10.2.0 cross-compiler
--
Warnings log:
botl.c: In function 'status_hilite_menu_add':
botl.c:3661:38: warning: ' or ' directive writing 4 bytes into a region of size between 1 and 80 [-Wformat-overflow=]
3661 | Sprintf(obuf, "%s or %s",
| ^~~~
In file included from ../include/config.h:631,
from ../include/hack.h:10,
from botl.c:6:
../include/global.h:274:24: note: 'sprintf' output between 5 and 163 bytes into a destination of size 80
274 | #define Sprintf (void) sprintf
botl.c:3661:21: note: in expansion of macro 'Sprintf'
3661 | Sprintf(obuf, "%s or %s",
| ^~~~~~~
do_name.c: In function 'getpos_menu':
do_name.c:594:37: warning: 'sprintf' may write a terminating nul past the end of the destination [-Wformat-overflow=]
594 | Sprintf(fullbuf, "%s%s%s", firstmatch,
| ^
In file included from ../include/config.h:631,
from ../include/hack.h:10,
from do_name.c:6:
../include/global.h:274:24: note: 'sprintf' output 1 or more bytes (assuming 257) into a destination of size 256
274 | #define Sprintf (void) sprintf
do_name.c:594:13: note: in expansion of macro 'Sprintf'
594 | Sprintf(fullbuf, "%s%s%s", firstmatch,
| ^~~~~~~
dungeon.c: In function 'print_dungeon':
dungeon.c:2172:27: warning: '%s' directive writing up to 1407 bytes into a region of size 256 [-Wformat-overflow=]
2172 | Sprintf(buf, "%s: %s %d", dptr->dname, descr, dptr->depth_start);
| ^~
In file included from ../include/config.h:631,
from ../include/hack.h:10,
from dungeon.c:6:
../include/global.h:274:24: note: 'sprintf' output between 10 and 1427 bytes into a destination of size 256
274 | #define Sprintf (void) sprintf
dungeon.c:2172:13: note: in expansion of macro 'Sprintf'
2172 | Sprintf(buf, "%s: %s %d", dptr->dname, descr, dptr->depth_start);
| ^~~~~~~
dungeon.c:2169:27: warning: '%s' directive writing up to 1407 bytes into a region of size 256 [-Wformat-overflow=]
2169 | Sprintf(buf, "%s: %s %d to %d", dptr->dname, makeplural(descr),
| ^~
dungeon.c:2169:26: note: directive argument in the range [-2147483647, 2147483646]
2169 | Sprintf(buf, "%s: %s %d to %d", dptr->dname, makeplural(descr),
| ^~~~~~~~~~~~~~~~~
In file included from ../include/config.h:631,
from ../include/hack.h:10,
from dungeon.c:6:
../include/global.h:274:24: note: 'sprintf' output 10 or more bytes (assuming 1427) into a destination of size 256
274 | #define Sprintf (void) sprintf
dungeon.c:2169:13: note: in expansion of macro 'Sprintf'
2169 | Sprintf(buf, "%s: %s %d to %d", dptr->dname, makeplural(descr),
| ^~~~~~~
dungeon.c: In function 'print_mapseen':
dungeon.c:3185:33: warning: '%s' directive writing up to 255 bytes into a region of size 249 [-Wformat-overflow=]
3185 | Sprintf(outbuf, " (play %s to open or close drawbridge)", tmp);
| ^~ ~~~
In file included from ../include/config.h:631,
from ../include/hack.h:10,
from dungeon.c:6:
../include/global.h:274:24: note: 'sprintf' output between 37 and 292 bytes into a destination of size 256
274 | #define Sprintf (void) sprintf
dungeon.c:3185:9: note: in expansion of macro 'Sprintf'
3185 | Sprintf(outbuf, " (play %s to open or close drawbridge)", tmp);
| ^~~~~~~
dungeon.c:3350:35: warning: '%s' directive writing up to 255 bytes into a region of size 240 [-Wformat-overflow=]
3350 | Sprintf(buf, "%sThe castle%s.", PREFIX, tunesuffix(mptr, tmpbuf));
| ^~
In file included from ../include/config.h:631,
from ../include/hack.h:10,
from dungeon.c:6:
../include/global.h:274:24: note: 'sprintf' output between 18 and 273 bytes into a destination of size 256
274 | #define Sprintf (void) sprintf
dungeon.c:3350:9: note: in expansion of macro 'Sprintf'
3350 | Sprintf(buf, "%sThe castle%s.", PREFIX, tunesuffix(mptr, tmpbuf));
| ^~~~~~~
explode.c:541:69: warning: '%s' directive writing up to 255 bytes into a region of size 236 [-Wformat-overflow=]
541 | Sprintf(g.killer.name, "caught %sself in %s own %s", uhim(),
| ^~
In file included from ../include/config.h:631,
from ../include/hack.h:10,
from explode.c:5:
../include/global.h:274:24: note: 'sprintf' output 21 or more bytes (assuming 276) into a destination of size 256
274 | #define Sprintf (void) sprintf
explode.c:541:21: note: in expansion of macro 'Sprintf'
541 | Sprintf(g.killer.name, "caught %sself in %s own %s", uhim(),
| ^~~~~~~
hacklib.c: In function 'yyyymmddhhmmss':
hacklib.c:1034:28: warning: '%02d' directive writing between 2 and 11 bytes into a region of size between 4 and 11 [-Wformat-overflow=]
1034 | Sprintf(datestr, "%04ld%02d%02d%02d%02d%02d", datenum, lt->tm_mon + 1,
| ^~~~
hacklib.c:1034:22: note: directive argument in the range [-2147483647, 2147483647]
1034 | Sprintf(datestr, "%04ld%02d%02d%02d%02d%02d", datenum, lt->tm_mon + 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../include/config.h:631,
from ../include/hack.h:10,
from hacklib.c:7:
../include/global.h:274:24: note: 'sprintf' output between 15 and 67 bytes into a destination of size 15
274 | #define Sprintf (void) sprintf
hacklib.c:1034:5: note: in expansion of macro 'Sprintf'
1034 | Sprintf(datestr, "%04ld%02d%02d%02d%02d%02d", datenum, lt->tm_mon + 1,
| ^~~~~~~
nhmall [Mon, 1 Feb 2021 18:37:04 +0000 (13:37 -0500)]
more warnings.h - macOS issue
It turns out that macOS barked when a POP was issued without
a prior PUSH, so since the DISABLE_WARNING_CONDEXPR_IS_CONSTANT
expanded to an empty macro on that platform.
Include a corresponding
RESTORE_WARNING_CONDEXPR_IS_CONSTANT macro for use with that
particular warning.
nhmall [Mon, 1 Feb 2021 17:54:19 +0000 (12:54 -0500)]
suppress a particular warning for an individual function; useful for non-gcc
Microsoft and other non-GNU compilers don't recognize gcc tricks
like /*NOTREACHED*/ to suppress individual warnings. clang recognizes most
of them because it tries to be gcc-compatible. Because of that, a lot of
potentially useful warnings have had to be completely suppressed in the
past in all source files when using the non-gcc compatible compilers.
Now that the code is C99, take advantage of a way to suppress warnings for
individual functions, a big step up from suppressing the warnings
altogether.
Unfortunately, it does require a bit of ugliness caused by the
insertion of some macros in a few spots, but I'm not aware of
a cleaner alternative that still allows warnings to be enabled
in general, while suppressing a warning for known white-listed
instances.
Prior to the warning-tiggering function, place whichever one of
the following is needed to suppress the warning being encountered:
PatR [Sun, 31 Jan 2021 21:05:32 +0000 (13:05 -0800)]
outdated vs Unix 'make depend'
After the most recent round of moving old stuff to 'outdated',
src/windows.c contained two references to non-existent files.
That broke 'make depend'. Updating it to turn those two into
comments seems risky because someone might add an include for
some new interface later in the file. So comment them out in
the source instead. Also, redo previous 'make depend' update
from about three weeks ago to do the same thing.
PatR [Sun, 31 Jan 2021 01:19:17 +0000 (17:19 -0800)]
fix #K3257 - lichens' sticky attack holds hero
in the air. can_reach_floor() was changed relatively recently
to return False if hero was held by a monster. It wasn't
necessarily because the monster was lifting him or her off the
floor though. Restricted movement could produce same effect.
Change the new behavior to only happen when holder has used a
hug attack, so that being held by a fungus or mimic doesn't
prevent access to the floor.
This may need to be revisited because the idea that the hero's
arms have been pinned by a hugging monster contradicts the
ability to attack that monster. However, it matches the long-
standing inability to attack any other adjacent monster in
that circumstance.
copperwater [Sun, 24 Jan 2021 21:39:33 +0000 (16:39 -0500)]
Unify code for extracting an object from a monster's inventory
The code for doing this (basically an obj_extract_self() call plus
handling if the object was worn or wielded) was duplicated all over, and
inconsistent - for instance, though all of them updated the monster's
misc_worn_check to indicate it was no longer wearing something in
whatever slot, only one call also set the bit that flags the monster to
consider putting on other gear afterwards.
Under a new function, extract_from_minvent, all this extra handling is
checked in one function, which can simply replace the obj_extract_self
call.
A few callers (such as stealing) have some common code *after* the
object is extracted and some other things happen such as message
printing, such as calling mselftouch if the object was worn
gloves. extract_from_minvent does not handle these cases.
PatR [Fri, 29 Jan 2021 18:48:35 +0000 (10:48 -0800)]
extcmdlist[] formatting
Reformat the list of commands, making all of them take two lines
(except for a couple that need more) even if they fit on one.
Put "#wizmgender" into alphabetical order. I don't think we need
it anymore, but if we keep the functionality then it should be
demoted from a command to a wizard mode boolean option.
Also wrap a handful of lines wider than the formatting threshold.
PatR [Fri, 29 Jan 2021 01:10:18 +0000 (17:10 -0800)]
fix class discovery for fully discovered class
This was caused by a post-3.6 change I made when adding sorting
capability to '`' (and to '\' but that wasn't affected). Cited
case was lack of "water" when all potions had been discovered.
Some other classes (but not all) were vulnerable too.