Commit Graph
100 Commits
Author SHA1 Message Date
nhmall 8bbe9282aa add soundeffects hooks to core
Insert the calls to trigger a number of potential soundeffects
into the core.

If no additional soundlib support is integrated into the
build, then the Soundeffect macro (sndprocs.h) expands to nothing:

[#define Soundeffect(seid, vol)
]

If, however, at least one additional soundlib support is integrated
into the build, then the Soundeffect macro gets defined as this
in sndprocs.h:

[#define Soundeffect(seid, vol) \
    do {                                                              \
        if (!Deaf && soundprocs.sound_soundeffect                     \
            && ((soundprocs.sndcap & SNDCAP_SOUNDEFFECTS) != 0))      \
            (*soundprocs.sound_soundeffect)(emptystr, (seid), (vol)); \
    } while(0)
]

That macro definition checks for the hero not being Deaf; it checks
to ensure that the active soundlib interface has a non-null
sound_soundeffect() function pointer; and it checks to ensure
that the active soundlib interface has declared that it supports
soundeffects by setting the SNDCAP_SOUNDEFFECTS bit in its sndcap
entry. That just means that the interface routines are prepared to
accept and deal with the calls from the core, whether or not it
actually produces the desired soundeffect.
2023-01-20 14:20:08 -05:00
nhmall 6c111aaed5 guard call 2023-01-20 05:19:06 -05:00
nhmall 76b569cae0 update visual studio dirs.props with new directory 2023-01-19 20:09:39 -05:00
nhmall 485211b72c mingw32 bit 2023-01-19 20:03:45 -05:00
nhmall 54a9b72e35 another update to visual studio project files 2023-01-19 19:48:55 -05:00
nhmall 897d58655d update visual studio project files 2023-01-19 19:44:25 -05:00
nhmall 3c7aad898f follow-up for windows build based on CI results 2023-01-19 19:26:23 -05:00
nhmall 3294d760a2 remove obsolete file sys/windows/ntsound.c 2023-01-19 19:13:55 -05:00
nhmall ea4a81901d add an interface for sound libraries
Groundwork for a more versatile interface for using
sound libraries. A lot of sound libraries work across
multiple platforms.

The current NetHack sound stuff is quite limited.

Binaries can have a variety of window ports linked into
them, and it makes sense to have something similar for
sound.

This tries to set things up in a more soundlib-centric way,
rather than inserting things in a platform-centric way.

It establishes a new top-level directory sound (akin to win
for the window interface routines, or "window-port") where
sound-related additions and sndprocs and support files can be
added and used across platforms.

The default interface is nosound and the 'nosound' interface
is in src/sounds.c

The interface for 'windsound', which contains the same minimal
USER_SOUNDS support using built-in routines that has been in the
windows port for a long time is added to
sound/windsound/windsound.c.

For now, the sound interface support for 'qtsound' has been added
to the existing Qt files win/Qt/qt_bind.h and win/Qt/qt_bind.cpp,
and a note has been placed in sound/qtsound/README.md to avoid
confusion.

New header file added: include/sndprocs.h.
2023-01-19 18:51:42 -05:00
nhmall 5c4ae701b3 visual studio package settings 2023-01-17 21:07:45 -05:00
nhmall b0a5c0ee0d quiet a new warning
src/eat.c(74,46): warning C4132: 'zero_victual': const object should be initialized
2023-01-17 19:59:24 -05:00
nhmall c5cc631b13 comment typo: vicutal -> victual 2023-01-17 19:44:05 -05:00
nhmall 9b01ab2fd5 some tilebmp.c code cleanup
Remove some conditional code that isn't needed these days.

Use C99 fixed width integer types for all platforms, instead
of using it for some and Microsoft types for others.
2023-01-16 13:58:58 -05:00
nhmall b82a19ec02 suppress a new warning 2023-01-15 15:39:22 -05:00
nhmall 11705aa108 free newbmp memory
Even though the program is exiting on the next line, free the
memory that was allocated. That should keep any monitoring tools
content.
2023-01-12 19:24:52 -05:00
nhmall 5b27e25d6d avoid a warning on x ? :
Surround the code to the left of the '?' in the DESTROY_ARM(o) macro
with () to quiet a warning on each use of the macro.
2023-01-12 16:31:35 -05:00
nhmall ac87656855 remove a static analyzer warning from botl.c
One static analyzer warned that there was a lower bound range check
ahead of the array index, but no upper bound check.
2023-01-12 16:28:39 -05:00
nhmall ba5356603a yn()
A number of C compiler suites have a math.h library that includes a yn()
function name that conflicts with NetHack's yn() macro:
"The y0(), y1(), and yn() functions are Bessel functions of the second kind,
for orders 0, 1, and n, respectively. The argument x must be positive. The
argument n should be greater than or equal to zero. If n is less than zero,
there will be a negative exponent in the result."

At one point, isaac64.h included math.h, although that has since been removed.

Some libraries used in NetHack (Qt for one) do include math.h and that required
build work-arounds to avoid the conflict.

Rename the NetHack macro from yn() to y_n() and avoid the math.h conflict
altogether, eliminating the need for that particular work-around.
2023-01-12 16:04:40 -05:00
nhmall 6e136c6f7d more ATTNORETURN
A recent commit to alloc.c by Keni drew attention to the fact that
there are extern prototypes scattered around in various .c files.
Those can make use of ATTRNORETURN (non-gcc compilers and C23) the
same way the prototypes in extern.h can, and they were overlooked
when ATTRNORETURN was first added.
2023-01-12 15:38:15 -05:00
nhmall 1b4161c168 add some tile credit where it is due
Since tile files can now contain comments, incorporate the comments
that accompanied some contributions that were adopted back when
male and female tile differentiation became possible.

If the original contributing artist wants to alter their name or handle
that was used in any of the credits, or wants to change any comment text,
please send your corrections to devteam@nethack.org.
Or, better yet, do a pull request with your desired alterations.

Alternatively, if they are fine as they are, a note to devteam@nethack.org
acknowledging that would be welcome, but certainly not required.

Thanks again for contributing the tiles.
2023-01-12 13:10:33 -05:00
nhmall 40ebfab8e4 tab to spaces 2023-01-12 09:52:14 -05:00
nhmall 99a9f8600e remove some outdated code, tidy up 2023-01-12 09:42:02 -05:00
nhmall e2457754a6 fix warning
fix warning introduced in 1755d27bf8

win/share/tiletext.c(208) : warning C4701: potentially uninitialized local
variable 'i' used
2023-01-12 09:24:56 -05:00
nhmall 45780b5d37 do exit 2023-01-12 09:21:53 -05:00
nhmall a22b56174f fix actual problem of #955 by counting the tiles 2023-01-12 08:51:59 -05:00
nhmall 33c13d6fff static analyzer bit display.c
A static analyzer pointed out that the 'if' was checking
for null pointer, but the 'else' was not, yet they were
both then dereferencing the same variable.
2023-01-02 16:06:11 -05:00
nhmall 8755b3bb53 Guidebook update 2023-01-01 20:23:15 -05:00
nhmall ff814326aa update for tilemap.c generated tile.c code 2023-01-01 20:05:59 -05:00
nhmall 095e4ffe31 add some curses support for coloring of map frame 2023-01-01 20:05:03 -05:00
nhmall 32a030c8c6 introduce X11 support for coloring map frame 2023-01-01 20:04:27 -05:00
nhmall 0a03ca1e99 introduce Qt support for color of map frame 2023-01-01 20:03:30 -05:00
nhmall 2fc0d25d45 introduce support for coloring the frame behind a map location
Also includes support by paxed for polearm targeting using the
frame color.

Also renames USE_TILES to TILES_IN_GLYPHMAP which is a more
accurate description.

Not all window interfaces have full support for the color framing
of the background square yet.

MS-DOS needs further work (to bring it to both VESA and VGA, with
and without tiles.

Windows GUI is missing support.

X11 and Qt have been started, but may require further refinement.
2023-01-01 19:55:02 -05:00
nhmall 1972c8447f update year in copyright 2023-01-01 17:31:34 -05:00
nhmall 57dc8891d6 Guidebook datestamp 2022-12-27 21:03:41 -05:00
nhmall a4c9073a7c Guidebook datestamp; updated Guidebook.txt 2022-12-25 10:12:47 -05:00
nhmall ca716c831b make some corrections to Guidebook.tex 2022-12-25 10:09:43 -05:00
nhmall bfe668c7ef memory not freed
Reported directly by feedback form.

Changes from a recent pull request resulted in more array entries
than MAX_GLYPH, so the for loop in free_glyphid_cache() wasn't going far
enough, leaving some dupstr() strings unfreed.
2022-12-23 16:38:53 -05:00
nhmall 995fae39b5 spurious warning with visual studio 2017
Don't force on a particular warning in the nmake Makefile if
compiling using the older visual studio 2017.

Resolves #950
2022-12-15 08:39:30 -05:00
nhmall 9dbb21cfcb update tested versions of Visual Studio 2022-12-14 2022-12-14 14:33:36 -05:00
nhmall 2ee061e02d cast away a new warning
role.c: In function 'plnamesuffix':
role.c:1615:19: warning: operand of '?:' changes signedness from 'int' to 'unsigned int'
due to unsignedness of other operand [-Wsign-compare]
1615 |                 ? (int) (eptr - gp.plname)
                         ^~~~~~~~~~~~~~~~~~~~~~~~

Since Strlen() (actually hacklib's Strlen_ function) returns 'unsigned' for the
second operand of the '?:', the compiler was having to change the signedness
of the first operand '(int) (eptr - gp.plname)' to 'unsigned' and issuing the
warning.

Cast the result of Strlen() to int to make both operands of the '?:' the same
('signed').
2022-12-13 19:17:00 -05:00
nhmall bc13b52d32 windconf.h mingw bit 2022-12-12 15:20:22 -05:00
nhmall 71c26361ff follow-up: make the ifdef logic a bit clearer 2022-12-12 14:37:40 -05:00
nhmall 9e91064659 makedefs temp files issue with mingw
The unlink call wasn't operating the same on a makedefs built
on mingw, and dat/mdXXXX files were being left behind post-build.

Provide an alternative way of doing the temporary files if
MD_USE_TMPFILE_S is defined during the compile of makedefs.c
2022-12-12 12:53:51 -05:00
nhmall 092068495b fixes update 2022-12-11 21:55:15 -05:00
nhmall 5ac96e9318 odd Windows lighting in lit rooms (issue #929)
bkglyph variable gets initialized to GLYPH_UNEXPLORED so ends
up being returned by get_bk_glyph() if something more interesting
wasn't chosen in the switch statement.

The Windows win32 interface will then use the tile mapped to
GLYPH_UNEXPLORED as a background. The tile is 16x16 all black
pixels. That looked very odd.

Treat GLYPH_UNEXPLORED as an out-of-range value.

Closes #929
2022-12-11 21:29:42 -05:00
nhmall 9e2effe710 Merge branch 'unicode-performance' of https://github.com/chasonr/NetHack into NetHack-3.7 2022-12-10 17:15:31 -05:00
nhmall 4c32ca571a doc update 2022-12-08 10:46:36 -05:00
nhmall 873d08b7bc fix Makefile rule when building pdcurses library
Also, use Bill Gray's pdcursesmod for now.
2022-12-07 21:23:14 -05:00
nhmall 3ac4e55f1f submodule update for pdcurses 2022-12-07 17:22:10 -05:00
nhmall d18ce24320 more continuation alignment after g to g? (.h) 2022-12-07 11:31:11 -05:00
nhmall 8120b74051 realign macro continuation after g to g? expansion 2022-12-07 11:24:17 -05:00
nhmall f61a862a47 paste error in Makefile.mingw32 2022-12-06 11:00:29 -05:00
nhmall 215808abd1 clear up a few gcc warnings 2022-12-05 23:19:38 -05:00
nhmall afef4bc781 issue with mingw resolved; resume mingw build in CI 2022-12-05 19:03:11 -05:00
nhmall b88ff70435 disable mingw build for now 2022-12-05 15:11:26 -05:00
nhmall 693e708228 yet another follow-up after CI report 2022-12-05 14:12:36 -05:00
nhmall 6d19d8ff1c another mingw follow-up after CI report 2022-12-05 14:07:33 -05:00
nhmall 883e4cbadd another mingw Makefile follow-up 2022-12-05 14:00:22 -05:00
nhmall 64f060bfa9 mingw Makefile updates 2022-12-05 13:54:09 -05:00
nhmall d4968e752e fix pair of prototype differences between date.c and mdlib.c 2022-12-05 13:39:46 -05:00
nhmall b86109e9fa Merge branch 'windows-makefile' into NetHack-3.7 2022-12-05 13:27:25 -05:00
nhmall 485797ee8c rework windows nmake file
Keep object files separate between gui and tty builds as they
are not the same binary on windows.

The stubs.c file will no longer be necessary.
2022-12-05 13:21:19 -05:00
nhmall 225af4ed4b CI ms-dos build: 1 warning was logged as 2 due to set -x 2022-12-02 00:23:46 -05:00
nhmall df0c65ce41 more fetch-cross-compiler.sh tweaks 2022-12-02 00:20:41 -05:00
nhmall cc231e47c0 exit on fetch-cross-compile failure, not proceed 2022-12-01 23:58:14 -05:00
nhmall 233e4a41af exit return code 2022-12-01 21:46:19 -05:00
nhmall a1cd77e39c in fetch-cross-compiler.sh, stop if required piece failed to download 2022-12-01 20:36:10 -05:00
nhmall 4ede5f1cd4 Use-after-free with engulfer in xkilled #938
If you were on a level teleporter, the spoteffects() call after
the hero gets expelled could end up going to a new level and
freeing all the monst chains from the level you were originally
engulfed on.

    #0 0xba0507 in free
    #1 0x87feda in dealloc_monst src/mon.c:2369
    #2 0x880a02 in dmonsfree src/mon.c:2194
    #3 0x9a7aa2 in savelev_core src/save.c:507
    #4 0x9a7a21 in savelev src/save.c:466
    #5 0x71eb9d in goto_level src/do.c:1483
    #6 0x71833f in deferred_goto src/do.c:1903
    #7 0xa2533f in level_tele src/teleport.c:1117
    #8 0xa2567b in level_tele_trap src/teleport.c:1198
    #9 0xa5c007 in trapeffect_level_telep src/trap.c:1861
    #10 0xa5f856 in trapeffect_selector src/trap.c:2497
    #11 0xa47497 in dotrap src/trap.c:2586
    #12 0x7d669b in spoteffects src/hack.c:2859
    #13 0x89d495 in xkilled src/mon.c:3187

The latter parts of xkilled() after the spoteffects() call would
then attempt to dereference the free'd monst pointer.

Save a copy of the monst struct prior to spoteffects() if you were
expelled, then point at the reference copy afterwards.

Resolves #938
2022-12-01 03:48:11 -05:00
nhmall cf1a46afa6 Merge branch 'cursed-gold-detection' of https://github.com/vultur-cadens/NetHack into NetHack-3.7 2022-11-30 23:18:09 -05:00
nhmall b4f97ff18c typo in README 2022-11-30 10:21:41 -05:00
nhmall 6b99a50821 fix a couple of ms-dos shadow declaration warnings 2022-11-29 23:43:42 -05:00
nhmall 02a48aa8cf split g into multiple structures
The consolidation of global variables from scattered source
files into decl.c and declared in decl.h was begun in 3.7.0.
Their placement in common files was done for centralized
initialization and potential re-initialization during a
"play again" scenario.

It wasn't really necessary for all of them to be housed in a
single huge structure to meet the "play again" requirement,
and the single huge structure has been a little unwieldy when
it comes to maintenance.

Following this commit, instead of one single extremely large structure
named 'g' to house all of the relocated global variables, they
are distributed into several ga through gz.

To make things easy for the developer, each variable is placed
into the struct corresponding to the starting letter of the variable.
That way, no lookup is required in order to know which struct houses
a particular variable, it is a simple match to the starting letter
for all the centralized global variables.

A global variable named 'amulets', would be found in ga.
    ga.amulets
     ^ ^
A global varable named 'move', would be found in gm.
    gm.moves
     ^ ^
A global variable named 'val_for_n_or_more' would be found in gv.
    gv.val_for_n_or_more
     ^ ^
A global variable named 'youmonst' would be found in gy.
    gy.youmonst
     ^ ^
2022-11-29 21:53:21 -05:00
nhmall 864d3c7638 fix a syntax error in Makefile.src 2022-11-26 17:03:53 -05:00
nhmall 4b04b1e6ac expand support for noreturn declarations
Although gcc specifies support for declaring a function as
noreturn after the function name and parameters, other compilers
do so via an attribute at the start of the declaration. Add some
macro support for the attribute-at-the-beginning method:
  o MS Visual Studio compiler
  o Upcoming C23 standard (untested at this point)
2022-11-24 00:51:42 -05:00
nhmall ddf1dfde29 quiet another warning that recently appeared
../win/curses/cursinit.c:102:9: warning: variable 'min_message_height' set but not used [-Wunused-but-set-variable]
    int min_message_height = 1;
        ^
1 warning generated.
2022-11-24 00:49:51 -05:00
nhmall 6ab7cafb25 quiet a warning that has appeared recently
botl.c:1303:25: warning: variable 'notpresent' set but not used [-Wunused-but-set-variable]
    int i, updated = 0, notpresent = 0;
                        ^
1 warning generated.
2022-11-23 23:34:47 -05:00
nhmall 3398b34cc7 another follow-up, don't cast hardcoded u.ux, u.uy 2022-11-23 19:10:28 -05:00
nhmall 9efa5d5b44 follow-up bit (in unused ms-dos code) 2022-11-23 18:57:14 -05:00
nhmall 937355038d some coordxy and other conversion warnings
When dist2() got changed to use coordxy parameters, a macro that uses
it in its definition was overlooked and it had (int) casts in it.
That caused a warning about possible data loss when the int
then got converted to coordxy for the dist2() call.

Give online2() coordxy parameters instead of int, like its bretheren.

Avoid a couple of implicit conversion warnings where ints were being assigned
to smaller uchar or ints being assigned to smaller short.

A couple of signed vs unsigned warnings on some rumor processing.

Avoid some signed vs unsigned warnings in mdlib/makedefs where a signed int
param eventually got used in an external call that took size_t.
Eliminate all of it by just having the outer NetHack routine also take
a size_t.

Lastly, insert some default C99 alternative time-related code
in mdlib/makedefs since asctime() and ctime() are being flagged as
deprecated in the upcoming C23 standard and will now start to trigger
warnings for anyone using a C23-compliant compiler.
2022-11-23 17:49:55 -05:00
nhmall 8badbc06d4 update tested versions of Visual Studio 2022-11-14 2022-11-14 12:57:21 -05:00
nhmall dcb1250ed6 move Makefile variable assignment 2022-11-14 00:22:32 -05:00
nhmall 0666a1c5da fix path to djgpp c++ compiler in ms-dos cross-compile 2022-11-14 00:00:20 -05:00
nhmall 583d124735 some follow-up for warnings experienced on macOS 2022-11-13 22:56:05 -05:00
nhmall 3f93d54b66 some Makefile and hints tinkering
1. remove all window interface bits from compiler.370, and have
   the preceding include files set some variables to control
   the behavior of compiler.370 when it comes to c++.
2. some more common Makefile lines into sys/unix/hints/include/multiw-3.370.
3. make it so you can pass cppregex=1 on the Make command line to build with
   sys/share/cppregex.cpp instead of posixregex.c
4. fix sys/share/cppregex.cpp so that it will build with clang compiler
   (required an additional header include). I don't know if it would have
   worked with g++ without that change. The include can be placed into an #ifdef
   block if there's an issue with the change on other compilers.
5. Anything that needs to compile using c++ (Qt, sys/share/cppregex.cpp) can
   just ensure that CPLUSPLUS_NEEDED Makefile variable is set above the lines
   in compiler.370 to ensure that things get set up for c++. It no longer
   checks specifically for Qt. That is what sys/unix/hints/include/multiw-2.370
   does now.
2022-11-13 22:25:07 -05:00
nhmall 21203c950e multiw-3.370
Add a 3rd multi-window include file that comes after compiler.370.

Relocate a small section of Makefile lines common to both macOS.370
and linux.370 to multiw-3.370.

Also relocate a section near the tail of compiler.370 that really
has nothing to do with compilers or compiler flags, but was
related to Qt which is one of the supported multi-window interfaces.
2022-11-13 12:17:27 -05:00
nhmall 9ef7135ccd typo 2022-11-10 12:22:13 -05:00
nhmall 6864e6cf22 add a note 2022-11-10 11:57:00 -05:00
nhmall 27e311b733 remove code on Windows referencing WIN32_GRAPHICS
As far as I know, there's no such thing as WIN32_GRAPHICS in the
current source tree. The Windows graphical port uses the preprocessor
macro MSWIN_GRAPHICS.
2022-11-10 11:47:31 -05:00
nhmall 88a0153a6e avoid use of variables near and far
Some recent testing with a multi-platform compiler encountered difficulty
with the use of a variable 'near' (and presumably 'far', but we don't have
any of those in the source tree) due to reserved word extensions.

Avoid using that as a variable name.
2022-11-10 11:18:49 -05:00
nhmall 9e92fefdd8 keep propertynames static in timeout.c 2022-11-06 10:02:27 -05:00
nhmall 38ff4029aa follow-up bit to fixes3-7-0.txt 2022-11-05 19:40:23 -04:00
nhmall 6b804c0e84 warning resolution
makedefs.c:100:6: warning: unused variable 'Dont_Edit_Code' [-Wunused-variable]
    *Dont_Edit_Code =
     ^
1 warning generated.
2022-11-05 19:36:46 -04:00
nhmall 993a82858b Merge branch 'old-software-compatibility' of https://github.com/chasonr/NetHack into NetHack-3.7 2022-11-05 19:30:20 -04:00
nhmall 76833d6f5e add fixes3-7-0.txt entry for pr923 2022-11-05 19:28:28 -04:00
nhmall e0f4ad405b Merge branch 'pr923' into NetHack-3.7 2022-11-05 19:26:50 -04:00
nhmall 779d0b2f20 Merge branch 'unicode-X11-2' of https://github.com/chasonr/NetHack into pr923 2022-11-05 19:23:18 -04:00
nhmall 185322421a relocate mstrength() and supporting function again
Also, purge the code for makedefs -m
2022-11-05 18:40:57 -04:00
nhmall 242c05ccf3 Revert "ranged_attk() - there can be only one"
This reverts commit b399e3f2f5.
2022-11-05 15:26:29 -04:00
nhmall b399e3f2f5 ranged_attk() - there can be only one
Relocate the newer code for the function to mdlib.c
where makedefs can still use it.
2022-11-05 13:07:10 -04:00
nhmall eeedff9478 prefix static version of ranged_attk() in mdlib.c 2022-11-05 12:38:02 -04:00