Commit Graph

9609 Commits

Author SHA1 Message Date
nhmall
118a82c9a0 staticfn bit in sounds.c 2024-03-16 20:45:25 -04:00
nhmall
a9fd04013a remove some obsolete code from options.c 2024-03-16 15:23:47 -04:00
nhmall
295d6e257c used, unused variables
some variables marked as unused, are now actually used
some unused variables are eliminated or commented out
2024-03-16 12:53:58 -04:00
Pasi Kallinen
9d97835686 Minor wishing alias improvement
Previously when wishing for "ring of protection from shape shifters",
you got a random ring instead of the protection from shape changers,
because the string matching alias was "protection from shape shifters"
without the object class.  Now, we'll check if the wish matched any
object class, but not existing object or alias, and try matching
the aliases again, but only those of the already matching obj class.

Add an alias for the ring of increase accuracy: "ring of accuracy",
and tests for it.
2024-03-16 16:59:58 +02:00
nhkeni
54c3dd35ac Merge branch 'keni-staticfn' into NetHack-3.7 2024-03-16 09:38:21 -04:00
nhkeni
fabbb491e8 Avoid a complaint from GCC's analyzer. Patch from Pat. 2024-03-15 20:46:10 -04:00
nhmall
3b75501937 get rid of a couple of warnings if -Wassign-enum is used
symbols.c:429:7: warning: integer constant not in range of enumerated type 'enum symparse_range' [-Wassign-enum]
  429 |     { 0, 0, (const char *) 0 } /* fence post */
      |       ^
windows.c:1765:32: warning: integer constant not in range of enumerated type 'enum from_core_requests' [-Wassign-enum]
 1765 |                              { 0, 0, { NO_COLOR, ATR_NONE }}};
      |                                ^
2024-03-15 16:24:49 -04:00
nhmall
79648c6ce2 some variables not referenced in another translation unit made static
Also adds some cross-refence comments for some variables that are
referenced in another translation unit.
2024-03-15 16:00:14 -04:00
nhkeni
96a74ccfbf Silence a compiler warning in cross-compile 2024-03-15 14:05:14 -04:00
nhkeni
9c0ed8ae63 NOSTATICFN for src/* 2024-03-14 17:41:51 -04:00
nhmall
d80352a983 warning fix read.c
read.c:148:13: warning: suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma? [-Wstring-concatenation]
  147 |         "Ms. Palm's House of Negotiable Affection--A Very Reputable"
      |
      |                                                                     ,
  148 |             " House Of Disrepute",
      |             ^
read.c:147:9: note: place parentheses around the string literal to silence warning
  147 |         "Ms. Palm's House of Negotiable Affection--A Very Reputable"
      |         ^
1 warning generated.
2024-03-13 19:09:26 -04:00
PatR
9ee55d87eb fix pull request #1223 - wand of striking by monst
Pull request by elunna with assistance by entrez tried to fix up
wand of striking discovery when the wand is zapped by a monster.

The fix didn't match the intended behavior (which may or may not be
the desired behavior...), so this skips the code in the pull request.
[I can't post comments on github anymore since I declined to switch
to their 2-factor authentication.  But I can still read submissions
without logging in.]

This also tries to fix a couple of inconsistencies between zapping
by the hero versus by a monster.  If the zap "boinged" :-) due to
target's magic resistance, zap by hero didn't discover the wand but
zap by monster did.  Conversely, a zap by the hero that reached a
target and missed did discover it but one by a monster did not.

Now a zap of not-yet-discovered wand of striking by the hero which
hits, whether or not the hit gets resisted, will become discovered
provided that the spot where target is hit can be seen (the target
itself need not be), and one which misses or which can't be seen
hitting something will no longer be.

Supersedes #1223
Closes #1223
2024-03-13 13:28:05 -07:00
PatR
ff82541b74 comment typo fix... 2024-03-13 13:04:05 -07:00
PatR
2006ec6ca3 read.c bits
Add a comment to seffects_remove_curse().  Also shorten a handful of
wide lines.
2024-03-13 12:41:41 -07:00
PatR
68312f7feb magic trap uncursing vs scroll of remove curse
Reported directly to devteam:  if a magic trap gave its uncurse
effect, scroll of remove curse could become discovered.

Turns out that it would happen if hero was wielding a stack of
unholy water potions.  It didn't matter whether they were known
as water or known to be cursed or whether hero was carrying any
scrolls of remove curse.
2024-03-13 12:39:50 -07:00
nhkeni
d523041b60 zap.c as a demo for NOSTATICFN 2024-03-13 11:40:50 -04:00
nhmall
dcc6890cee hacklib comment bit 2024-03-12 16:54:49 -04:00
nhmall
14c139746d yet more disabled code removal 2024-03-12 16:39:23 -04:00
nhmall
a11898bef5 some code cleanup following recent code relocations 2024-03-12 16:13:33 -04:00
PatR
6ca54852ee perm_invent initialization fix
Using
|OPTIONS=windowtype:Foo
|OPTIONS=perm_invent
or
|NETHACKOPTIONS='perm_invent,windowtype:Foo'
would enable perm_invent if interface "Foo" supported it, but using
|OPTIONS=perm_invent
|OPTIONS=windowtype:Foo
or
|NETHACKOPTIONS='windowtype:Foo,perm_invent'
or combined
|OPTIONS=perm_invent
|NETHACKOPTIONS='windowtype:Foo'
would only enable perm_invent if both "Foo" and the default interface
supported it.

Using '--windowtyp:Foo' on the command line didn't have this issue
because command line interface selection replaces the default one
before configuration file and environment options are processed.
2024-03-12 11:19:35 -07:00
PatR
1922dd96eb theme room vampire fix
From a reddit thread:  a 'mausoleum' theme room picked a vampire for
its occupant and applied the wait-for-you strategy to it.  Hero's ESP
or monster detection showed a meditating vampire bat.  Change monster
creation by the special level loader (which also handles theme rooms)
to force such a creature into its normal vampire form.

That revealed an older bug which wouldn't have been exercized prior
to theme rooms:  a meditating vampire could and would shape change
without ceasing meditation.  Make it not shape change rather come out
of its trance.
2024-03-11 17:40:01 -07:00
nhmall
33ea32dbe3 warning fix in end.c 2024-03-11 11:41:26 -04:00
nhkeni
2980c55f5c report.c: silence some compiler warnings for clang + nhmd4 2024-03-10 19:51:55 -04:00
nhkeni
7ad921ebe7 Merge branch 'keni-pending2' into NetHack-3.7 2024-03-10 10:36:24 -04:00
PatR
3e2999d3e6 refine walking on ice might slip in random dirctn
If moving on ice causes the hero to hurtle an extra step in a random
direction, don't allow that to be backward to where hero started.

Also, if hero is in grid bug form, only allow hurtling forward.
It was allowing slips in a diagonal direction, which seems wrong
for grid bug, and even when it slipped in an orthogonal direction,
buffered screen updating made the combined step+hurtle appear to be
a single diagonal step.

I'm not a fan of this seemingly simple change.  The hurtle/second
step comes after the "you slip on the ice" vs "you slip off the ice"
messaging and might put the hero in a location which contradicts it.
2024-03-09 16:05:11 -08:00
nhkeni
79867d78c8 Two new features primarily in Makefile.src:
NOSTATICCORE - an option for Linux to get a better backtrace
updatedepend - an easier alternative to "make depend"

- .gitignore: ignore new temporary .*.c files
- hints/linux.370: add NOSTATICCORE and instructions
- Makefile.src:
-- If NOSTATICCORE defined, run core .c files through awk to
   remove static attribute from functions.
-- add updatedepend target and related bits
2024-03-09 15:16:24 -05:00
PatR
42d5d6a453 reformat lots of the CRASHREPORT code
Replace tabs, split 'if (condtion) do_something' across two lines,
insert lots of spaces in things like 'if(condition){'.  I changed
a lot of C++ style comments to traditional C style, but left quite
a few of those as-is.

This also rewrites the code that pull request #1216 purports to fix.
I still can't make sense of the original and the patched edition.

Supersedes #1216
Closes #1216
2024-03-09 14:25:38 -05:00
nhmall
6d22361fca separate function for acid potion damage pr#1195
Also includes a couple of trailing whitespace removals.
2024-03-09 09:25:43 -05:00
nhmall
2bda94e982 Merge branch 'pot-acid-damage' of https://github.com/argrath/NetHack into NetHack-3.7 2024-03-09 09:23:20 -05:00
PatR
4af03d8ef8 fix garbled comment
The prolog comment for hurtle() ends with
 * dx and dy should be the direction of the hurtle, not of the original
 * kick or throw and be only.
The clause "and be only" is incomplete and was added sometime between
3.3.0 and 3.4.0.

I suspect it was meant to say "and be only -1 or 0 or +1" but the code
enforces that with sgn(dx) and sgn(dy) so if that's the case, it isn't
necessary.  Whether that guess is right or wrong, remove the clause
since as it stands now, it makes no sense.
2024-03-08 23:34:12 -08:00
PatR
cb50fbb2ce fix for breaking unreachable statue
Reported almost 9 years ago:  if an adjacent statue was in a pit,
you could use a pick-axe to break it even though if you managed to
move to the pit location without falling in, you wouldn't be able
to reach objects there including the statue.

Allow a pick to reach if hero is in a conjoined pit, or if it is a
mattock rather than an ordinary pick-axe.  Otherwise you'll get the
"you swing at thin air" result.  Similarly when hero is in a pit and
and adjacent statue or boulder is on the floor:  mattock will work
but pick-axe now yields "you can't reach".
2024-03-08 13:08:28 -08:00
PatR
76826744d7 fix analyzer complaint about get_mkroom_name()
Force the result to be non-Null.
2024-03-08 10:08:11 -08:00
nhmall
d52f05fc0e comment correction 2024-03-08 09:42:03 -05:00
nhkeni
2d864961bf Close /dev/null in child process to keep analyzer happy. 2024-03-08 09:24:36 -05:00
nhmall
dbda2967cc attempt to fix MS-DOS cross-compile 2024-03-07 15:50:05 -05:00
nhmall
23e39ee5f5 DUMPLOG_MSG_COUNT depends on DUMPLOG_CORE for its definition 2024-03-07 15:35:12 -05:00
nhmall
056fcf7173 more CI build fixes 2024-03-07 12:42:19 -05:00
Pasi Kallinen
8cd8759e04 Walking on ice can make you slide in a random direction 2024-03-07 19:29:09 +02:00
nhmall
aacfbecf5c more CI build fixes 2024-03-07 11:44:35 -05:00
nhmall
9720ea323c attempt to fix CI minimal build 2024-03-07 11:24:32 -05:00
nhmall
50811037f3 split some code into separate files
new .h files: hacklib.h selvar.h stairs.h

new .c files: calendar.c, getpos.c, report.c, selvar.c, stairs.c,
              strutil.c, wizcmds.c

cleanup of hacklib.c and mdlib.c

hacklib contains functions that do not have to link with the core

relocate wiz commands from cmd.c to wizcmds.c

relocate CRASHREPORT stuff to report.c

relocate getpos stuff from do_name.c to getpos.c

remove temporary struct definition from extern.h

cross-compile PRE-section split into cross-pre1.370 and cross-pre2.370

Windows sys/windows/Makefile.nmake and sys/windows/Makefile.mingw32 and
visual studio project file updates

Unix sys/unix/Makefile.src, sys/unix/Makefile.utl

populate selvar.c and selvar.h

build on MS-DOS (not cross-compile) Makefile updates
for sys/msdos/Makefile.GCC (untested)

vms updates for above (untested)
2024-03-07 11:01:04 -05:00
PatR
c22900fb63 reformat lots of the CRASHREPORT code
Replace tabs, split 'if (condtion) do_something' across two lines,
insert lots of spaces in things like 'if(condition){'.  I changed
a lot of C++ style comments to traditional C style, but left quite
a few of those as-is.

This also rewrites the code that pull request #1216 purports to fix.
I still can't make sense of the original and the patched edition.

Supersedes #1216
Closes #1216
2024-03-04 16:13:03 -08:00
nhmall
ed5ef46109 fix name in new file header line 2024-03-04 08:37:30 -05:00
nhmall
6619d10d90 ENHANCED_SYMBOLS: store all CLR_ colors specially
The 0x1000000 bit (NH_BASIC_COLOR bit) was used to mark
CLR_BLACK when storing it in u->ucolor. Now, all of the basic CLR_*
colors are stored that way.

The NH_BASIC_COLOR bit indicates that the value in u->ucolor is
not an rgb value, rather it is one of the 0-15 basic NetHack colors.
The window-ports need to strip the NH_BASIC_COLOR bit off before using
it for color changes.
2024-03-03 18:31:11 -05:00
nhmall
dbea5d8684 shorten options.c a little by moving some color stuff out of it
creates new coloratt.c file

Also, this attempts to fulfill a wish-list item by paxed, to
allow naming colors in symbols file by name as an alternative
to using r-g-b values.  The basic color names as well as html
color names are supported.
2024-03-03 14:11:17 -05:00
Patric Mueller
fb353fff6c Add NULL pointer guards for the crash reports variables
Calling sprintf with NULL string for a %s format identifier seems to be
undefined behavior.  I got some semi persistent crashes while calling
the extend options menu with mO.
2024-03-03 16:14:15 +01:00
PatR
5e79f8c425 fix #K4113 - OPTIONS=symset:blank in RC file
Any plain text symbol set specified in .nethackrc or NETHACKOPTIONS
didn't get loaded but did set the symset name.

Faulty 'if' logic excluded loading of symbol sets that used the
default handling type of H_UNK.
2024-03-02 05:50:44 -08:00
Pasi Kallinen
140fb7215d Message location for monster going thru trap door 2024-03-02 10:00:38 +02:00
Pasi Kallinen
8588873858 Item destruction and recharging fix
Recharge only handles items carried by hero.
I don't think it really matters that we just skip it, but leave
a FIXME in the code if anyone has enough energy to improve this later.
Fallout from the unified item destruction.
2024-03-02 09:29:55 +02:00
nhkeni
ad667216ee Prevent conflicting types for name "body" 2024-03-01 16:19:30 -05:00