Commit Graph

17639 Commits

Author SHA1 Message Date
PatR
b44a547153 fix resistance breakage
The Mitre of Holiness commit broke resistance handling.  This seems
to work correctly.
2025-02-03 23:20:07 -08:00
PatR
a311f4b467 fix issue #1362 - carrying Mitre of Holiness
Issue reported by elunna:  the definition of the Mitre of Holiness
specifies that carrying it should confer fire resistance but that
didn't work.

The Mitre's definition (added in 3.1.0) has always included that,
but such a capability had never been implemented.  Wearing it didn't
confer fire resistance either--its definition doesn't bother to
specify a 'defend' attribute since the 'carry' one should cover that.

This adds carrying capability for damage types fire, cold, sleep,
disintegration, electrity, poison, acid, and petrification.  Fire is
still specified by the Mitre; none of the others are currently used.

Fixes #1362
2025-02-03 11:42:36 -08:00
nhmall
785f78c39b avoid "You fall down a deep shaft!" if flying down
Fixes #1371
2025-02-03 00:53:06 -05:00
nhmall
d65d0062a9 follow-up: evolve placeholder content to match variant
suggestion by paxed

Increments EDITLEVEL again.
2025-02-02 12:53:58 -05:00
nhmall
d331029b03 more clobber-detection 2025-02-02 09:08:48 -05:00
nhmall
bda3437eab bump EDITLEVEL 2025-02-02 09:00:21 -05:00
nhmall
d785f7a649 add two unused fields for hardfought save compatability
There are two hardfought code additions that render save and bones files incompatible
with the upstream NetHack-3.7, and that makes testing with hardfought
save and bones files more challenging than it needs to be, when
investigating and troubleshooting bug reports.

Add some unused fields to advance towards achieving save file parity with
hardfought, which is a significant source of play-testing for NetHack-3.7.

1) the elbereth field addition to u_conduct

This adds an unused placeholder field named 'hf_reserved1', at the appropriate
place in u_conduct to achieve struct field parity with the one in use on
hardfought.

2) hardfought adds a field to struct monst:
    char former_rank[25]; /* for bones' ghost rank in their former life */

Instead of adding that to every monst, this adds a new mextra struct
named 'former', which currently contains the equivalent 25-character
field called 'rank' which can hold the content that was in the
former_rank[25] field. That way, the field will only be added when it
is needed.

A pull request https://github.com/k21971/NetHack37/pull/2 has been
done on hardfought to do it the same way (untested there as of yet).

Even though NetHack-3.7 does not utilize that information presently,
this will be a further step toward allowing hardfought-generated save
and bones files to be used for troubleshooting, without modification,
on a similar architecture running stock NetHack-3.7 code.

That savefile parity won't be achieved until the after the
hardfought pull-request mentioned above (or equivalent) is merged.

As this change will not be compatible with existing save and bones
files, it will be accompanied with an EDITLEVEL increment.
2025-02-02 09:00:05 -05:00
nhmall
d74624abbd add mexta field to simplify detection of overwrite
Because this invalidates existing save and bones files,
an increment of EDITLEVEL will accompany this.
2025-02-02 08:30:48 -05:00
nhmall
6431f4727c comment instructions in mextra.h updated 2025-02-01 14:09:58 -05:00
Pasi Kallinen
3ffbfc724c Fix another impossible no_charge object
Tame earth elemental picked up a no_charge object from a shop and moved
it out of the shop, causing "no_charge obj not inside tended shop"
impossible.  Non-tame monsters picking up no_charge items cleared that
bit, so make the same happen for pets.
2025-01-28 21:26:10 +02:00
nhmall
7ff7679a76 remove a redundant check for NULL
mksobj is declared to have a NONNULL return:
extern struct obj *mksobj(int, boolean, boolean) NONNULL;

Remove an unnecessary if block.
2025-01-27 10:12:10 -05:00
PatR
b6eda14368 obj->tknown comments 2025-01-27 00:37:35 -08:00
nhmall
f75e4a13b7 more follow-up for mk_artifact() 2025-01-26 21:38:37 -05:00
nhmall
ee0d955050 follow-up: make definition match proto staticfn 2025-01-26 12:25:27 -05:00
nhmall
3cca4f2707 avoid mk_artifact()-related memory leaks
Reported directly to devteam after being discovered in nerfhack.
2025-01-26 11:57:01 -05:00
nhmall
ed44da351e more follow-up, less hiding of illegal values
Catch it prior to the rn2() call instead. We need to
be aware of the issue.
2025-01-24 18:26:56 -05:00
nhmall
dc938b7acf don't hide the zero value of apport
It was pointed out that it might not be a good idea to hide the illegal value of apport.
2025-01-24 18:24:26 -05:00
PatR
3c824cd866 fix incorrect lint fix
>  if (strlen(simpleoname) > BUFSZ - sizeof "the ")
>    simpleoname[sizeof "the "] = '\0';

The second line should have been
|    simpleoname[strlen(simpleoname) - sizeof "the "] = '\0';
but fixing that isn't adequate.  The BUFSZ limit is not valid when
dealing with object names since xname() leaves room for a prefix so
doesn't return the start of a BUFSZ-sized buffer.

Strangely enough, the complaint that caused me to add those two lines
isn't being triggered any more.  Some other change at the same time,
perhaps splitting
  Strcpy(simpleoname, obufp = the(simpleoname));
into
  obufp = the(simpleoname);
  Strcpy(simpleoname, obufp);
pacified the analyzer.  However, it didn't resolve the valid complaint
that inserting "the " might result in overflow.

I've added a comment about simpleonames(), ansimpleoname(), and
thesimpleoname() about the possible overflow, but I don't think that
such overflow can actually happen when user-applied object name is
being suppressed.
2025-01-24 14:50:53 -08:00
nhmall
02102de396 attempt to resolve issue #1368
Resolve #1368
2025-01-24 17:06:17 -05:00
Pasi Kallinen
c9abc92dd7 Fix lua.adoc 2025-01-24 19:04:17 +02:00
nhkeni
9313e819de nhgitset.pl: leftover tid 2025-01-24 10:57:40 -05: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
bac7cd7365 analyzer lint for v*.c 2025-01-22 16:58:04 -08:00
PatR
ffc43610f0 analysis lint for u*.c
One actual bug:  mhitm_ad_ench() could pass Null to drain_item()
which was not prepared to deal with that.
2025-01-22 16:34:05 -08:00
PatR
f86bb9b7b6 analysis lint for s*.c
shk.c was dealt with previously.
2025-01-22 13:29:44 -08:00
PatR
5cd20d5389 finding data.base entry for stairs
When testing the analyzer lint fixes for pager.c, I noticed that //
wasn't finding the data.base entry for stairs when examining the up
stairs on level 1.  It is labelled "branch stairs up" which doesn't
match "stair*".
2025-01-22 13:16:42 -08:00
PatR
9a88efb20b analysis lint for r*.c 2025-01-22 12:39:35 -08:00
PatR
c1d9ba9ce7 analyzer lint for p*.c 2025-01-22 12:15:39 -08:00
PatR
3109e706e9 static analysis for o*.c
This construct triggered several complaints about passing Null to
  Strcpy(simpleoname, obufp = the(simpleoname));
Changing that to
  obufp = the(simpleoname);
  Strcpy(simpleoname, obufp);
prevents it, but the original complaint is bogus and the "fix"
doesn't do anything to deal with Null arguments.

A couple of other changes introduce different code in order to get
different behavior.  I updated from llvm-16 to llvm-19 but didn't
eliminate any of the spurious complaints.
2025-01-21 22:42:23 -08:00
PatR
dc5c098cb5 analyzer lint for n*.c 2025-01-21 19:39:35 -08:00
PatR
2c1f2c1cb1 clear "next" from "next boulder" sooner
Clear "next" boulder so that when pushing a pile of boulders, only
the first message for each of the 2nd, 3rd, &c will be formatted as
"next boulder".  If any of them trigger additional messages, those
messages will use normal "boulder".
2025-01-21 14:55:05 -08:00
nhmall
61f969e88b follow-up for put_saddle_on_mon()
Commit 1acc2727 helped ensure that the which_armor(mtmp, W_SADDLE)
test at the top of put_saddle_on_mon() wouldn't lead to an obj
leak.

This commit covers off the adjacent can_saddle() test in
put_saddle_on_mon(), because if that failed, it could also lead
to a memory leak of the saddle obj passed by the caller.

- have put_saddle_on_mon() create and use its own saddle obj
  if a NULL saddle obj is passed, instead of having to do that
  in the caller.
- where an existing saddle obj needs to be passed from the caller,
  ensure that the caller has done its own can_saddle(mon) check prior
  to calling put_saddle_on_mon(), so that the can_saddle() test
  in put_saddle_on_mon() won't fail.
- lastly, add an impossible() to put_saddle_on_mon() to catch
  a failure when a saddle obj is passed from the caller and either
  test has failed, just in case. That should not happen with any of
  the existing cases now, but it will provide some bullet-proofing
  for new code, new callers.
2025-01-20 14:37:46 -05:00
PatR
1acc272718 fix memory leak for knight's starting pony
makemon() has a 1% chance to bestow a worn saddle when creating any
rideable monster.  If that chance kicked in on a knight's starting
pony, an extra saddle would end up being created but not worn nor
in inventory nor on floor so not be freed when the game ended.

That 1% chance also overrode saddle suppression for pauper knights.
There wouldn't be any extra saddle but their pony could start with
one, against intent.

Have makedog() (which is only used for starting pet) tell makemon()
to suppress inventory when creating the initial pet.
2025-01-20 10:24:12 -08:00
Pasi Kallinen
991a1dbe43 Fix exploding landmine and boulders next to lava
Same issue as with breaking a wand of digging in commit 7ce0751a
2025-01-20 19:26:12 +02:00
Pasi Kallinen
0c18792916 Fix vision when vault guard clears corridor 2025-01-20 19:24:09 +02:00
PatR
8fe02c2a7c analyzer "lint" for muse.c fix
Overzealous change yesterday.  For use_defensive(), the unicorn
horn case already has guards for Null item and the added one
issues bogus panic() when a unicorn or ki-rin uses its own horn.
2025-01-20 08:39:33 -08:00
PatR
df06fc36f2 analyzer lint for m[o-u]*.c
The changes to muse.c are more extensive that most.  The many new
panic calls could be simplified by assigning a dummy object for the
trap cases.
2025-01-20 00:58:06 -08:00
PatR
f2c4396641 analyzer lint for m[a-k]*.c 2025-01-19 23:31:26 -08:00
PatR
41f6582690 analyzer lint for hack.c 2025-01-19 23:06:38 -08:00
PatR
6368bf2e73 analyzer lint for i*.c 2025-01-19 22:53:03 -08:00
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