Commit Graph

14713 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
Pasi Kallinen
b1fd7344e3 Poly into fire elemental, eat flammable items 2023-01-20 18:56:01 +02:00
Pasi Kallinen
b998a368c7 Random sink effect: noxious gas cloud 2023-01-20 17:39:04 +02:00
Pasi Kallinen
93d7d79fca Fix mouse menu movement
When using mouse to move to a location next to the hero,
the test_move result was reversed, causing the click to fall
in to the travel case instead of normal movement.
2023-01-20 14:37:01 +02:00
Pasi Kallinen
af1bd84766 Add hell_tweaks to Orcus' level 2023-01-20 14:08:34 +02: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
nhw_cron
411f56dbbe This is cron-daily v1-May-8-2022. 000files updated: Files 2023-01-19 19:28:02 -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
Pasi Kallinen
6e49372d8f Mindless monsters are not scared of music 2023-01-19 22:18:52 +02:00
Pasi Kallinen
242a7ba796 Boomerang hitting a sink is noisy 2023-01-19 19:59:19 +02:00
Pasi Kallinen
e260aa5877 Digging is noisy 2023-01-19 19:55:47 +02:00
Pasi Kallinen
1113373892 Fix vibrating square
The Gehennom changes broke the vibrating square, allowing hero to go
down into the Sanctum via stairs without performing the invocation.

Fix this by making the hellfill lua check for invocation level, and
placing down the vibrating square trap, instead of stairs.
2023-01-19 12:15:46 +02:00
PatR
8952ea9bb5 add Japanese item names to discoveries list
When playing as a Samurai, add things like "osaku" to the discoveries
list even though they don't have separate descriptions to be used
when not yet discovered.  Non-magic ones are pre-discovered and
players can now use the '\' command to figure out what things like
"tanko" mean without resorting to '/?'.

"wooden harp" has been getting changed to "koto (harp)"; make that be
| koto [wooden harp] (koto)
"magic harp" has been staying as "magic harp (harp)"; add it to the
list of Japanese item names.  Since it's magic it isn't pre-discovered.
Once discovered it becomes
| magic koto [magic harp] (koto)

Those two needed special case handling, none of the other items did
aside from forcing them to be discoverable when lacking descriptions.
The discoveries list now has things like
| wakizashi [short sword]
| naginata [glaive] (single-edged polearm)
| gunyoki [food ration]
if--and only if--the hero is a Samurai.
2023-01-18 22:00:57 -08:00
Pasi Kallinen
bb8656c190 Move familiar level message into function 2023-01-18 23:33:21 +02:00
PatR
f61cfe7e48 pacify static analyzer - vision.c
Include some assertions to convince the analyzer that some pointers
can't be Null.  They're Null if 'vis_func' is non-Null but only used
when that function pointer is Null and they have values.

If there's a macro that's defined when the analyzer is running and
undefined when not--or vice versa--it could be used to control NDEBUG
and avoid the assertion code when not analyzing.  That's a bit like
using fake code to pacify 'lint'; however, since the assertions should
never fail, suppressing them isn't really switching to fake code.

I reordered a couple of macros so that the set of them matches the
comment which precedes them and refers to "the last three".  It is
referring to the three within the block comment rather than the macro
defintions but putting those in the same order removes any ambiguity.
2023-01-18 11:57:49 -08:00
PatR
4571a49b3f static analyzer vs symbols.c
This will probably shut up the static analyzer's exceedingly verbose
complaint for symbols.c.
2023-01-18 11:29:40 -08:00
Pasi Kallinen
2511637169 Make plane of fire hot 2023-01-18 10:50:32 +02: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
PatR
2ca7916fdf maybe pacify static analyzer - eat.c
The complaint is that victual.canchoke might be used without having
been initialized.  I'm fairly sure that that isn't correct but get
dizzy trying to trace through the eating code.

This might improve the situation, or maybe not.
2023-01-17 16:31:59 -08:00
PatR
a9dc8dcd1a pacify static analyzer - dog.c
This is similar to the earlier potential fix that I didn't like,
but I think think one is better.

The analyzer claimed that 'fptr' might be Null inside the switch
case for
|struct permonst *fptr = NULL;
|if (obj->otyp == CORPSE || ...) fptr = &mons[obj->corpsenm];
|switch (obj->otyp) { case CORPSE: ... /* dereference 'fptr' */ }
even though it will always have a non-Null value for otyp==CORPSE.

Make the assignment of 'fptr' unconditional.  mons[NUMMONS] is
valid and won't match any actual monster.  In this case it will
only be used when initializing fptr, never when fptr gets used.
2023-01-17 10:42:00 -08:00
Pasi Kallinen
bb8c144809 Level temperature
Allow setting a per-level "temperature": hot, cold, or temperate
via special level flags. Currently it only affects some messages
in Gehennom, but it could be expanded to ice melting, water freezing,
or monster generation, for example.

Invalidates saves and bones.
2023-01-17 20:11:45 +02:00
PatR
9df4a38d65 static analyzer - shk.c
Add a couple of redundant tests for 'shkp = shop_keeper()' yielding
Null to pacify the static analyzer.

Make the paired calls to shkp = shop_keeper() and inhishop(shkp) look
more consistent.  Barring typos, the behavior hasn't been changed.
2023-01-16 17:15:26 -08: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
Pasi Kallinen
bd267c0c61 Add a cold, watery gehennom filler maze 2023-01-16 19:17:19 +02:00
Pasi Kallinen
b5fe7415cf fixes entry 2023-01-16 10:45:23 +02:00
Pasi Kallinen
3ee54d1c4e Fix deleting worn object
When going down stairs while punished, if you had quivered a mirror
and the mirror was dropped because you fell down the stairs, it would
not have been unequiped.
2023-01-16 09:41:43 +02:00
nhmall
b82a19ec02 suppress a new warning 2023-01-15 15:39:22 -05:00
PatR
68d8b5376a generic object fix
When hallucinating, random object selection for objects was including
the new generic objects.  It was already excluding 'strange object'
by using 'rn2(NUM_OBJECTS - 1) + 1' to skip objects[0]; changing that
to be 'rn2(NUM_OBJECTS - MAXOCLASSES) + MAXOCLASSES' will skip the
first 18 objects, 'strange object' plus the 17 generic objects.

(I'm trying to convince myself that there's no off-by-1 or off-by-N
error and think I've succeeded.)
2023-01-15 11:04:35 -08:00
PatR
2e1f52e882 strange object vs generic objects
Try to fix a fuzzer issue.  I wasn't able to reproduce it so am not
sure whether this actually fixes it.  A mimic seemed to be mimicking
object #1 (generic ILLOBJ_CLASS object which shouldn't occur) rather
than #0 (strange object).  Strange object always has dknown==1 and
generic objects should always have dknown==0 but farlook of mystery
object #1 had its dknown flag set.

An earlier fix to force non-Null oc_name when formatting objects in
order to pacify the static analyzer might have been the reason that
the problem couldn't be reproduced.

This includes a few miscellaneous changes made while unsuccessfully
hunting for the problem.
2023-01-15 01:45:14 -08:00
Pasi Kallinen
6abb12aee0 Lua: Persistent variables
Add a way for the lua scripts to set and retrieve variables
that are persistent - saved and restored with the game.

Invalidates saves.
2023-01-15 10:34:45 +02:00
PatR
18cc99150a couple more analyzer complains - nhlua.c
I don't know whether there is potentially a real problem with either
of these.  The two trivial changes should shut the static analyzer.
2023-01-14 15:55:55 -08:00
PatR
bdaa51a689 another static analyzer bit - cast_protection()
The code tested u.uswallow and then accessed u.ustuck.  Under normal
circumstances that works fine but it could be a problem if the two
fields got out of synch.  This ought to fix the analyzer complaint
and avoid any trouble with mondata access.
2023-01-13 23:55:37 -08:00
PatR
97a90de172 another static analyzer bit - Japanese_item_name()
The analyzer complained that the second call to Japanese_item_name()
might return Null after the first one didn't.
|    if (Role_if(PM_SAMURAI) && Japanese_item_name(otyp))
|        actualnm = Japanese_item_name(otyp);
even though the code involved is self-contained and deterministic.
Then later in obj_typename() 'actualnm' gets passed to strcat() or
strcpy() where Null isn't acceptable.

Could probably fix that by caching and reusing the first return value:
|    if (Role_if(PM_SAMURAI) && (jname = Japanese_item_name(otyp)) != 0)
|        actualnm = jname;
but I went a different route, revising that routine to take a second
argument:
|    if (Role_if(PM_SAMURAI))
|        actualnm = Japanese_item_name(otyp, actualnm);
It now passes back 'actualnm' instead of Null when no substitution
takes place.

The recent introduction of generic objects without names meant that
'actualnm' could actually be Null, but generic objects only occur
for map glyphs and only when dknown is 0, so the actual-name field
shouldn't ever be get used for them.  Give actualnm a fallback value
just in case.

Wishing is a place that loops over all of objects[] so have it skip
the generic objects.  They're all flagged no-wish so weren't being
chosen, but explicitly skipping them makes the intention clear.
2023-01-13 23:41:23 -08:00
PatR
ed884c0579 pacify analyzer's complaint - restore_waterlevel()
Redo the restore_waterlevel() code a bit to eliminate a static
analyzer complaint.  The previous code would not have done the right
thing if 'gb.bbubbles' was already non-Null, but that should not be
possible.  I didn't backtrack to make sure that it was always Null
at the time restore_waterlevel() gets called.

Also, some of the code was misformatted.
2023-01-13 22:23:30 -08: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
PatR
0649f5860a remove extra potion enums
Generic object handling ended up not using FIRST_POTION, LAST_POTION,
and NUM_POTIONS so don't bother setting those up.
2023-01-12 14:54:05 -08: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
Pasi Kallinen
eacb68666e Deadly afflictions and resistances for safe_wait
Amend the safe_wait so it still waits if you have a deadly property,
even if you have a resistance to it.

External resistances do not protect against already existing
deadly properties, for example becoming deadly ill is not cured
even if you wear a green dragon scale mail.
2023-01-12 23:19:28 +02: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