Commit Graph

2384 Commits

Author SHA1 Message Date
PatR
b264e17cf2 fix use-after-free bug in curses shutdown
A year ago a use-free-bug was reported for curses.  I don't use ASAN
so haven't reproduced it, but I think this should fix it.

If the RIP window is deleted after the map window has gone away, the
code from commit 5e572d3d5f (post 3.6.7)
would execute and access the internals of the deleted map window.
2026-04-11 01:02:42 -07:00
nhmall
3acb327115 resolve a warning on one platform 2026-04-10 10:53:53 -04:00
nhmall
3b7c0e8a19 follow-up: more Windows startup 2026-04-09 14:14:49 -04:00
nhmall
335cd65d5a some further Windows startup tweaking 2026-04-09 14:04:28 -04:00
nhmall
8716d92280 objects.txt tile numbering
Closes #1496 reported by @horlogeislux
2026-04-06 12:38:25 -04:00
nhmall
6234e96b57 Change Windows startup - take 2
remove the safeproc pseudo-windowport routines from
almost a decade ago.

A very early pass is made through the config file,
seeking out just the interface-related OPTIONS=windowport
and OPTIONS=soundlib and ignoring all other options in the
config file during that early pass, so the windowport
can be activated without the NetHack core initialization
in place that some of the other rcfile OPTIONS require.

Bundles the existing rcfile processing code into rcfile().

New functions to control which rcfile options will be
disregarded in the early config file pass, and which will be
processed:

    set_all_options_disregarded();
    set_all_options_heeded();
    disregard_this_option(opt_xx);
    heed_this_option(opt_xx);

Windows calls rcfile_interface_options(), which is
a bundling of a series of function calls to achieve
the desired result.

    void
    rcfile_interface_options(void)
    {
        allopt_array_init();
        set_all_options_disregarded();
        heed_this_option(opt_windowtype);
        heed_this_option(opt_soundlib);
        rcfile();
        set_all_options_heeded();
        disregard_this_option(opt_windowtype);
        disregard_this_option(opt_soundlib);
    }
2026-04-05 13:11:14 -04:00
nhmall
db1f230772 Revert "Change Windows startup"
This reverts commit acb85b18cf.

Some optlist issues arose on some platforms, but not all.
I need to investigate the cause of those.
2026-04-05 12:07:57 -04:00
nhmall
acb85b18cf Change Windows startup
remove the safeproc pseudo-windowport routines from
almost a decade ago.

A very early pass is made through the config file,
seeking out just the interface-related OPTIONS=windowport
and OPTIONS=soundlib and ignoring all other options in the
config file during that early pass, so the windowport
can be activated without the NetHack core initialization
in place that some of the other rcfile OPTIONS require.

Bundles the existing rcfile processing code into rcfile().

New functions to control which rcfile options will be
disregarded in the early config file pass, and which will be
processed:

    set_all_options_disregarded();
    set_all_options_heeded();
    disregard_this_option(opt_xx);
    heed_this_option(opt_xx);

Windows calls rcfile_interface_options(), which is
a bundling of a series of function calls to achieve
the desired result.

    void
    rcfile_interface_options(void)
    {
        allopt_array_init();
        set_all_options_disregarded();
        heed_this_option(opt_windowtype);
        heed_this_option(opt_soundlib);
        rcfile();
        set_all_options_heeded();
        disregard_this_option(opt_windowtype);
        disregard_this_option(opt_soundlib);
    }
2026-04-05 11:37:20 -04:00
Alex Smith
07fc4904c6 Add a new wand, the wand of stasis
A wand of stasis prevents teleportation (even in some cases where
it would normally not be prevented, e.g. the hero teleporting a
monster, or covetous monsters teleporting). This is intended to
provide an alternative tactic against covetous monsters (and their
AI has been adjusted to handle being under a stasis effect), but
might also be useful in other situations. It does not prevent
teleportation of objects, only the hero / monsters, and does not
at present prevent level teleportation (although I'm not sure about
this and it might well change in the future).

This breaks save compatibility, but is being pushed together with
other save-breaking changes to avoid the need for multiple bumps to
EDITLEVEL.
2026-03-19 01:16:30 +00:00
Alex Smith
5d3a1e684b Add shields of shock resistance and of drain resistance
These both appear as "wooden shield" when unidentified; so does the
small shield.
2026-03-18 23:27:54 +00:00
PatR
d6bff63025 X11 comment thinko
Fix a phrasing mistake that was introduced when unmatched apostrophies
were removed from the sample NetHack.ad file.
2026-03-08 03:17:42 -07:00
Pasi Kallinen
0dac2b5fa0 TTY: add support for the palette config option
For now, terminal colors are not reset back when exiting NetHack.
Depends on CHANGE_COLOR compile-time option.
2025-12-30 19:26:07 +02:00
nhmall
b3db46fd71 clear up some warnings in win/win32/NetHackW.c 2025-11-23 09:40:39 -05:00
nhmall
d5658018ac alternative to display_inventory for window-port
Several window ports that support perm_invent were
using a call back to the core display_inventory()
function.

While calling from the window port back to core functions
is arguably not ideal in the first place, it was recently
brought to light that code NetHack-3.7 code changes to
display_inventory() actually caused it to stop repopulating
the perm_invent window as intended under certain circumstances.

For now, provide an alternative function, repopulate_perminvent(),
that hopefullshould still work the way it did previously.

There will likely be some additional changes after this to
further improve things, at some point.

For now though, this
Resolves #1454
2025-11-08 14:26:07 -05:00
nhmall
60e2598d81 SYMBOLS=S_ghost:
Resolves #1448
2025-10-05 22:10:34 -04:00
nhmall
a3b60ba36f build bit for CROSS_TO_WASM=1
../win/shim/winshim.c:194:23: error: unused parameter 'wri' [-Werror,-Wunused-parameter]
  194 |     win_request_info *wri) {
      |                       ^
1 error generated.
2025-10-03 10:00:48 -04:00
nhmall
d5d40b322c fix broken Windows GUI ascii mode text color
Issue identified in
https://github.com/NetHack/NetHack/issues/1359

Resolves #1359
2025-09-05 16:38:56 -04:00
nhmall
6c3e70ad77 remove stray tabs from *.c files and config.h 2025-08-19 08:35:39 -04:00
nhmall
070730d845 Qt6 wasn't exiting as expected after saving the game
Reported by email to devteam on Feb 1, 2025.
2025-08-17 01:33:24 -04:00
nhmall
b876381b72 add support for [[maybe_unused]] if available 2025-08-07 21:47:40 -04:00
nhmall
93803de413 work around an X11 build issue under C23 2025-08-07 21:41:25 -04:00
nhmall
dcef128290 control-v on curses using pdcursesmod 2025-07-13 23:46:50 -04:00
Pasi Kallinen
e240efa10b Restoring a game can return to the wishing prompt
In TTY or curses, if the terminal goes away while you're in the wishing
prompt, return to the prompt when the game is restored.

Breaks saves.
2025-07-12 18:21:12 +03:00
nhmall
fed5be6943 another follow-up bit for X11 2025-06-30 09:21:17 -04:00
nhmall
1ece615eb2 fixes3-7-0.txt catch-up; also replace some magic hex numbers 2025-06-30 09:04:41 -04:00
nhmall
a93397e286 follow-up bit
This may not be required, but it won't hurt.
2025-06-29 20:43:28 -04:00
nhmall
459a339a95 X11: strip extra bits off color when used as index 2025-06-29 13:31:02 -04:00
PatR
02885dfccf X11 xrdb complaints
Three instances of "'s" were triggering warnings due to unmatched
apostrophe in the X11 application defaults file.  Reword the affected
comments.
2025-06-21 22:16:35 -07:00
nhmall
50e5715ca5 fix X11 warning with gcc-15
../win/X11/winX.c: In function ‘init_standard_windows’:
../win/X11/winX.c:2769:46: warning: passing argument 2 of ‘XtAppSetErrorHandler’ makes ‘__attribute__((noreturn))’ qualified function pointer from unqualified [-Wdiscarded-qualifiers]
 2769 |     (void) XtAppSetErrorHandler(app_context, X11_error_handler);
      |                                              ^~~~~~~~~~~~~~~~~
In file included from ../win/X11/winX.c:27:
/usr/include/X11/Intrinsic.h:1771:5: note: expected ‘__attribute__((noreturn)) void (*)(char *)’ but argument is of type ‘void (*)(char *)’
 1771 |     XtErrorHandler      /* handler */ _X_NORETURN
      |     ^
2025-05-30 21:17:07 -04:00
nhmall
8ac31b24f6 libnh build
The macOS.370 has not yet been tested, but it is patterned after
the linux.370 changes.
2025-05-12 08:45:26 -04:00
PatR
a587ccaa26 merge new use_menu_glyphs option with menu_objsyms
The two options are very similar but probably mutually exclusive
except when using look-here and look-into-container (both via ':')
with the default setting for 'sortloot', or with inventory when
'sortpack' has been toggled off.

This removes 'use_menu_glyphs' and changes 'menu_objsyms' from a
boolean to a compound taking six possible values:
| 0: no object symbols in menus,
| 1: append object class symbol to object header lines (same as old
|menu_objsyms boolean),
| 2: include object symbol in menu entry lines for objects (same as
|recently added use_menu_glyphs),
| 3: both 1 and 2,
| 4: display as #2 but only if the menu lacks class header lines,
| 5: if header lines are present, display as #1; if headers are not
|present, then display as #4 (which will implicitly be #2).
Default is #4.

Effectively replaces the options portion of pull request #1406 and
retains the functionality, but not as default for normal menus.

Guidebook.tex is only partially updated.  Someone else will need to
finish that.
2025-04-28 18:12:02 -07:00
PatR
ba4f90eefb PR #1406 = use_menu_glyphs for curses and tty
Pull request from NullCGT:  add 'use_menu_glyphs' option to be able
show the object class symbol in menus of objects.
tty:
|a ? scroll of identify  (instead of 'a - scroll of identify'),
curses:
| a) ? scroll of identify  (instead of ' a) scroll of identify').

This commit fixes a bit of formatting in wintty.c.

Closes #1406
2025-04-26 12:50:48 -07:00
Kestrel
9e1e032ea8 use_menu_glyphs 2025-04-26 12:50:18 -07:00
PatR
e21a5c6ac3 curses band-aid
heaputil reported an attempt to free a null pointer at line 1314 of
cursdial.c (in menu_display_page()).

curses_break_str() can return Null but its callers aren't prepared
for that.  Make it return an empty string that can be passed to
free() instead.
2025-04-20 14:19:40 -07:00
nhmall
932f598689 follow-up bit 2025-04-13 12:23:09 -04:00
nhmall
a70db6dafb WIN_MAP==WIN_ERR on a code path to tty_wait_synch 2025-04-13 12:14:38 -04:00
disperse
c271f878f9 Fixed tile numbering in objects.txt 2025-04-09 19:46:05 +03:00
disperse
b5768d676c Added tile for silver mace
Copied the mace tile and added more blue and white and softened the
shadows on the head of the mace.
2025-04-09 19:46:05 +03:00
PatR
858bf3b30d analysis lint for tilemap.c 2025-01-23 20:15:40 -08:00
PatR
6ac0be46f6 last analyzer bit for win/curses/cursmesg.c
I got confused and thought that this one (actually pair) was more
complicated than it actually is.  have_mixed_leadin is used in an
ordinary way, but resetting it to false happens in spots where it
can't be used again.  The analyzer complains that the assignments
don't do anything useful.
2025-01-23 17:30:27 -08:00
nhmall
349f3871be preproc fix 2025-01-23 19:37:19 -05:00
PatR
150b331189 analyzer lint for win/curses/*.c
There is still an issue in cursmesg.c.

The last diff band (curses_putch) isn't related to static analysis.
2025-01-23 13:52:19 -08:00
PatR
29f7580fc1 analyzer lint for sys/unix/*.c sys/share/*.c win/tty/*.c
Actually only ioctl.c for sys/share.  And with all of these, only
for the conditionals used by MacOS.
2025-01-23 12:01:46 -08:00
PatR
ba8076b142 static ananlyzer issue for alloc.c
Verifying that strlen(string) isn't too long, then allocating and
copying strlen(string)+1 draws a complaint about strcpy() overflowing
its output buffer.

Not an issue for regular play, but could matter for config file and
sysconf manipulation.
2025-01-18 18:04:09 -08:00
nhmall
d2aff9a9b2 remove some xchar vestiges 2025-01-14 12:13:39 -05:00
nhmall
1b8bc6fc29 finished CI testing; put things back 2025-01-13 13:12:40 -05:00
nhmall
fd919c1560 Revert "Revert "Revert "eliminate a couple of build warnings (noticed with clang)"""
This reverts commit 6dad19a4f6.
2025-01-13 12:13:06 -05:00
nhmall
6dad19a4f6 Revert "Revert "eliminate a couple of build warnings (noticed with clang)""
This reverts commit 1a8395002f.
2025-01-13 11:48:46 -05:00
nhmall
1a8395002f Revert "eliminate a couple of build warnings (noticed with clang)"
This reverts commit 7e8a04b35a.
2025-01-13 11:47:57 -05:00
nhmall
7e8a04b35a eliminate a couple of build warnings (noticed with clang)
2025-01-12T19:08:53.4759829Z ../win/curses/cursinvt.c:191:5: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
2025-01-12T19:08:53.4760198Z   191 |     case KEY_RIGHT:
2025-01-12T19:08:53.4767986Z       |     ^
2025-01-12T19:08:53.4967354Z ../win/curses/cursinvt.c:191:5: note: insert '__attribute__((fallthrough));' to silence this warning
2025-01-12T19:08:53.4967860Z   191 |     case KEY_RIGHT:
2025-01-12T19:08:53.4968026Z       |     ^
2025-01-12T19:08:53.4968219Z       |     __attribute__((fallthrough));
2025-01-12T19:08:53.4968404Z ../win/curses/cursinvt.c:191:5: note: insert 'break;' to avoid fall-through
2025-01-12T19:08:53.4968583Z   191 |     case KEY_RIGHT:
2025-01-12T19:08:53.4968709Z       |     ^
2025-01-12T19:08:53.4968820Z       |     break;
2025-01-12T19:08:53.5099063Z 1 warning generated.

2025-01-12T19:08:53.8002074Z ../win/X11/winX.c:995:5: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
2025-01-12T19:08:53.8008155Z   995 |     case NHW_TEXT:
2025-01-12T19:08:53.8008513Z       |     ^
2025-01-12T19:08:53.8032511Z ../win/X11/winX.c:995:5: note: insert '__attribute__((fallthrough));' to silence this warning
2025-01-12T19:08:53.8032899Z   995 |     case NHW_TEXT:
2025-01-12T19:08:53.8033057Z       |     ^
2025-01-12T19:08:53.8033219Z       |     __attribute__((fallthrough));
2025-01-12T19:08:53.8033395Z ../win/X11/winX.c:995:5: note: insert 'break;' to avoid fall-through
2025-01-12T19:08:53.8033644Z   995 |     case NHW_TEXT:
2025-01-12T19:08:53.8033783Z       |     ^
2025-01-12T19:08:53.8033912Z       |     break;
2025-01-12T19:08:53.8800783Z 1 warning generated.
2025-01-13 09:36:48 -05:00