Commit Graph

17595 Commits

Author SHA1 Message Date
nhmall
3a64b404e3 Remove an unused macro that conflicts with pdcursesmod
In file included from ../include/config.h:723:0,
                 from ../include/hack.h:10,
                 from files.c:8:
../include/global.h:519:24: error: expected ')' before '<=' token
 #define unctrl(c) ((c) <= C('z') ? (0x60 | (c)) : (c))
                        ^
../lib/pdcursesmod/curses.h:1686:16: note: in expansion of macro 'unctrl'
 PDCEX  char   *unctrl(chtype);
                ^~~~~~
2025-01-19 22:36:38 -05:00
nhmall
8de3aa564f update tested versions of Visual Studio 2025-01-19 2025-01-19 22:02:43 -05:00
nhmall
9da836fb4a more follow-up: Qt build fix 2025-01-19 21:55:36 -05:00
nhmall
d992155f1f follow-up for tradstdc.h
remove a duplicate comment
2025-01-19 21:20:52 -05:00
nhmall
3221665f5a updates to tradstdc.h
Define a macro NH_C to provide a shorter & simpler way to test for
which C standard the build is being carried out under (c99 or c23).

 NH_C > 202300L     Being compiled under C23 or greater
 NH_C > 199900L     Being compiled under C99 or greater
 NH_C > 198900L     Being compiled under C89 or greater,
                    or C std could not be determined.

While NetHack only requires c99, we've been taking advantage
of some c23 features (attributes), if they are available,
to allow the use of ATTRNORETURN/NORETURN and FALLTHROUGH on
compilers other than gcc.

Also add some comment documentation to tradstdc.h about NetHack's
use of c99.

The sys/unix/Makefile.top change overcomes a warning in the
Makefile-generated nhlua.h. That warning arises under some compilers
that rely on attribute [[noreturn]] ahead of a declaration
(NetHack macro ATTRNORETURN), rather than the trailing gcc
__attribute((noreturn)) (NetHack macro NORETURN). The sed command
is modified to include ATTRNORETURN at the start of the declaration
in addition to the NORETURN at the end of the declaration, in the
generated file. That's the same combination that's used for the
declaration of other functions that don't return.
2025-01-19 20:51:46 -05:00
PatR
e317436e8d static analyzer lint for glyphs.c 2025-01-19 12:40:28 -08:00
PatR
e0f6c6987b analyzer lint for files.c
Not sure about 'do_historical' since it isn't used--or implicitly
is always used--without the field-by-field save and restore as an
alternative.
2025-01-19 12:16:16 -08:00
PatR
1907dd9cd8 analyzer lint for e*.c 2025-01-19 11:59:48 -08:00
PatR
ec855a93c2 static analyzer lint for w*.c 2025-01-19 11:52:44 -08:00
PatR
047ae6f68e analyzer lint for zap.c 2025-01-19 11:42:02 -08:00
PatR
49a2851882 static analyzer fix for dungeon.c
I'm not really sure about this one.  insert_branch(branch,) is
specified as not accepting a Null pointer and doesn't have any
defense against it, but the know level setup seems to allow a null
pointer through.  I'm not sure whether this is the right fix.
2025-01-19 11:24:40 -08:00
PatR
d8d4f18a00 analyzer lint for do_wear.c, dothrow.c 2025-01-19 11:23:05 -08:00
Pasi Kallinen
663ab8aa89 Fix wall spines outside map bounds 2025-01-19 21:16:27 +02:00
Pasi Kallinen
7ce0751a6c Fix breaking wand of digging and boulders next to lava
If one or more boulders were next to lava and hero broke a wand of digging
next to that location, the boulder(s) stayed over the lava causing a sanity
checking error.
2025-01-19 19:34:58 +02:00
PatR
9e2d862ba9 static analyzer fix for dog.c
The missing break meant that executation fell through to the default
case and reset xlocale and ylocale to 0.  The comment states that
this is for the fuzzer; I have no idea whether this fix matters to it.
2025-01-18 20:04:26 -08:00
PatR
c97bb2c0a4 static analyzer lint for dig.c, do.c 2025-01-18 19:58:30 -08:00
PatR
e8d9331f14 static analyzer lint for coloratt.c 2025-01-18 19:36:06 -08:00
PatR
3418c871b1 static analyzer lint for cmd.c 2025-01-18 18:35:21 -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
PatR
6a457056a3 analyzer lint and stale comment for apply.c 2025-01-18 16:36:51 -08:00
Pasi Kallinen
7f36a5db3c Fix vision when guard moves a monster 2025-01-18 19:30:10 +02:00
PatR
34dc5d7acf static analyzer changes for trap.c
Picked arbitrarily; there weren't any unresolved analyzer complaints
for trap.c.  I wonder why the onefile analysis isn't complaining here.

'in_sight' may have been relevant before the trapeffect_xyz() code
was split apart, but it isn't useful for trapeffect_hole() despite
the comment about it.

release_holding_trap() is fairly convoluted and the complaints being
addressed here were relevant.
2025-01-17 21:26:32 -08:00
PatR
e48824223f fix static analyzer complaints for shk.c
This cleans up analyzer feedback in shk.c, based on the set of
warnings specified by hints/MacOS.370 and the lower level hints it
applies, rather than anything specified during periodic 'onefile'
processing.

shk.c is the only file I've analyzed, to try again to figure out
how to suppress the old complaint that has been causing a special
case in Genonefile.  It isn't triggering during my testing but that
might be due to something in use by onefile but not by normal hints.
I'm running ccc-analyzer from llvm-16; I don't know whether that
matches Genonefile.
2025-01-17 13:20:59 -08:00
nhmall
fc7fdd7f08 get rid of a compiler gripe 2025-01-17 14:26:03 -05:00
Pasi Kallinen
6df83cb677 Fix pet data being reset when charm monster was cast
Casting charm monster with pets nearby could reset the edog struct.
If the pet ate a mimic corpse and was pretending to be something else
when that edog reset happened, the sanity checking would issue an impossible.
The error happened because meating was reset, but the pet appearance was not,
but the edog struct reset is the part being wrong.  Lets not do that.

To reproduce, turn on sanity checking, create a tame dog, give it a mimic corpse
to eat, #wizcast charm monster next to it.
2025-01-17 17:07:07 +02:00
PatR
c0a1ed9c41 another stab at stumble_onto_mimic
The unreliable sanity check is removed.
2025-01-16 12:51:40 -08:00
PatR
b4f912e3c4 add a couple cf comments 2025-01-15 15:44:09 -08:00
nhmall
d2aff9a9b2 remove some xchar vestiges 2025-01-14 12:13:39 -05:00
nhmall
b2f4b687c1 yet another coordxy bit 2025-01-14 11:33:30 -05:00
nhmall
a513b41748 more coordxy consistency, mklev.c 2025-01-14 11:17:41 -05:00
nhmall
2354fef2d6 be more consistent with coordxy in mkmap.c
Also closes #1365
2025-01-14 10:32:36 -05:00
PatR
f32e32d447 still more PR #1364
Earlier commit left out an intended line, resulting in the sanity
check being bogus because the incomplete test wasn't impossible.
2025-01-13 16:55:58 -08:00
nhmall
1b8bc6fc29 finished CI testing; put things back 2025-01-13 13:12:40 -05:00
nhmall
ea647f3adb test custom warning filter in CI 2025-01-13 12:52:32 -05:00
nhmall
3c224fc49d update azure-pipelines.yml 2025-01-13 12:31:57 -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
92340296ad azure-pipelines warning filter take 2 2025-01-13 12:01:16 -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
0a401253ce test CI warnings 2025-01-13 11:47:00 -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
PatR
34159d42e5 more PR #1364 2025-01-13 05:48:20 -08:00
nhmall
1bb0f89b82 Merge branch 'check_version' of https://github.com/argrath/NetHack into NetHack-3.7 2025-01-13 08:24:15 -05:00
nhmall
62fe9e83c6 Merge branch 'xytod' of https://github.com/argrath/NetHack into NetHack-3.7 2025-01-13 08:23:52 -05:00
nhmall
8ee014f5d1 update credits 2025-01-12 23:57:56 -05:00
SHIRAKATA Kentaro
36443c965b second argument of check_version() can take NULL
There is a code path starting at restore.c line 830.

    (void) validate(nhfp, (char *) 0, FALSE);
2025-01-13 13:57:40 +09:00
nhmall
e08a9671dc another follow-up: another bit is needed
breaks savefiles and bones.
2025-01-12 14:08:15 -05:00
nhmall
25558e1e01 follow-up
Check the correct bits before returning.
2025-01-12 13:58:13 -05:00
nhmall
bee21e3447 fix K4318
Reported by paxed. A potion of oil, that was already in the midst of exploding,
got picked up through spot_effects(), which led to it merging with
another potion of oil and the freeing of the original obj.

The original obj pointer was still held by breakobj(), and breakobj()
proceeded to delete the obj (again).

Function nesting:

 1    spelleffects()
 2     -> weffects()
 3      -> bhit()
 4       -> bhitpile()
 5        -> bhito(obj ...)
 6         -> hero_breaks(obj ...)
 7          -> breakobj(obj ...)
 8           -> explode_oil(obj ...)
 9            -> splatter_burning_oil()
10             -> explode()
11              -> zap_over_floor()
12               -> melt_ice()
13                -> spot_effects()
14                 -> pickup()
15                  -> pickup_object(obj ...)
16                   -> pick_obj(obj ...)
17                    -> addinv(obj ...)
18                     -> addinv_core0(obj ...)
19                      -> merged(obj ...)
20                       -> obfree(obj ...)
21                        -> dealloc_obj(obj ...)

 8           -> delobj(obj ...)
 9            -> delobj_core(obj ...)
10             -> obfree(obj ...)
11              -> dealloc_obj(obj ...)
12               -> impossible("obj already deleted)

This marks the exploding potion with LOST_EXPLODING, so that it won't
get picked up, or merged with another object during the long
sequence of functions, and that should take care of 15-21 above.
2025-01-12 13:50:25 -05:00
Alex Smith
a8be021913 Change monster regeneration over time to use healmon(), too
I missed this one.
2025-01-12 18:28:59 +00:00