Commit Graph

9592 Commits

Author SHA1 Message Date
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
nhmall
c6124585db Onefile bit 2024-03-01 09:30:21 -05:00
Pasi Kallinen
121cf75d39 Minor changes to mention_map
Disable it during screen redraw.
Always use the message coordinates with it, even if accessiblemsg is off.
2024-02-29 18:29:43 +02:00
nhkeni
acf60063d5 Add missing prototypes for static functions to avoid warnings. 2024-02-29 10:49:53 -05:00
RainRat
a3658f85ac fix typos 2024-02-28 20:15:56 -08:00
nhmall
b53a43027f generic obj addition broke obj entity count use
yet another EDITLEVEL bump
2024-02-28 16:24:40 -05:00
nhmall
3edd3e5869 catch invalid id on restore
Another EDITLEVEL bump.
2024-02-28 16:15:30 -05:00
PatR
41a5565403 new 'showvers' option
Add options 'showvers' (boolean) and 'versinfo' (numeric mask) to
show nethack's version on the status lines during play.  It won't be
particularly interesting to ordinary players but should be useful
when making screenshots or video to be streamed, or for someone who
switches between git branches or between nethack and variants.

I worked on this several months back but it was combined with
unfinished changes to 'hitpointbar'.  I've separated it out so that
it can be put into use.  When enabled, one or more components of
"<name> <branch> <version>" will be shown right justified after
status conditions.  At present the default is "<branch>" if that is
available and overall status isn't 'released', or "<version>" if
'released' or if branch isn't available.  That might need some
refinement.

It works as intended for tty and curses, although some abbreviation
mechanism would be useful if/when the program resorts to abbreviating
status conditions to make things narrow enough to fit.

For X11, it works ok for fancy_status:True (the default, controlled
via NetHack.ad settings) but is messed up for tty-style status.  The
text is positioned correctly but there are gaps in it, making it
appear garbled, similar to what I saw when I tried and failed to
implement statuslines:3 for X11.  [It might be due to having empty
condition widgets be 1 pixel wide instead of being totally removed
but I don't think the situation is that simple.]

For Qt, if the text needs to be truncated in order to fit, the center
portion of the string will be shown, discarding parts from the left
and right.  That ought to discard from left and retain rightmost
portion instead.

For win32|mswin|Win GUI, no attempt to support it has been included.
Things should be ok when 'showvers' is left as False (the default)
but I don't know what will happen if that gets toggled to True.  At a
minimum, the version info won't be right justified.  The information,
or at least some of it, is displayed in the game window's title bar
so there isn't any pressing need to add it to status, but toggling
the option will need to behave sensibly if it doesn't already.
2024-02-28 11:47:16 -08:00
Pasi Kallinen
25fa293c81 Accessibility: lookaround command, mention_map option
Adds a new extended command #lookaround, which will describe
the map around the hero they can see or remember.

Adds a new boolean option mention_map, which will give a message
when an interesting map location in sight changes.
2024-02-28 20:53:52 +02:00
PatR
1532a052c0 spellbook of blank paper named Making Money
Reported directly to devteam, polymorphing a spellbook could produce
a blank spellbook with a Discworld novel's title attached.
2024-02-27 11:27:02 -08:00
nhmall
334535e7b0 Fix makemon() trying to generate a monster on top of another monster
When makemon was called with all-zero arguments (e.g. for random
monster generation over time), ptr==NULL means "a random monster".
This was being forwarded to mon==NULL in makemon_rnd_goodpos, and
then mtmp==NULL in goodpos, which means "an object, not a monster".
Because objects can be generated under monsters, this meant that an
attempt to create a random monster could end up choosing a location
that already had a monster, which would then cause the monster
generation to fail.

This mostly wasn't noticeable in normal play: it effectively
reduced the monster generation rate depending on how many locations
outside LOS happened to contain a monster. Normally that's a very
small proportion, so the bug had no obvious effects: but when there
are very few locations outside LOS (i.e. the player can see almost
every location on the level), the bug effectively caused monster
generation to stop once those locations became occupied by
non-moving (e.g. hiding) monsters, something that became observable
in games where the player decided to dig out and light almost an
entire level.

This commit fixes the problem by adding a new flag to goodpos that
requests that it not choose a position that already has a monster.

This bug was diagnosed, and this fix committed, by ais523; but
nhmall wrote almost all of the code implementing the fix.
2024-02-27 19:04:35 +00:00
PatR
1d26f80ccf more nhmd4.c formatting
Insert a space between cast operator and target.

For 'x | y' expression spanning multiple lines, split with bitwise OR
operator at the beginning of second line instead at the end of first.

I changed a macro that was expanding to 'expr_1; expr_2' into
'(expr_1, expr_2)'.  Both expressions modify arg 'a' which would be
a no-no within a single expression, but the comma operator provides a
sequence point that guarantees that the first expression will be fully
evaluated with side-effects--assignment to 'a'--completed before the
second one starts, making both assignments be well defined.
2024-02-26 11:46:03 -08:00
PatR
5acb82640d update a getpos() comment
Not a typo this time; the highlight-valid-position callback interface
was simplified.
2024-02-25 12:36:19 -08:00
PatR
53f16f9e8c reformat nhmd4.{c,h} 2024-02-24 13:49:51 -08:00
Pasi Kallinen
dd37c5326a Accessibility: showdamage option
Add a new boolean option showdamage, if on, outputs a message
like "[HP -2, 14 left]" - several variants have something similar,
but I chose the message based on how eSpeak said it, while keeping
it short.
2024-02-24 17:38:46 +02:00
PatR
9927e264b5 hacklib.c NONNULL functions
A bunch of routines return a pointer which is never Null but weren't
telling the compiler that such was the case.  A couple (strsubst(),
stripchars()) were accepting Null output argument and then returning
Null, but callers had no reason to use them that way, so they've been
changed.  (upstart() could have been changed similarly; I've already
forgotten why I left it as-is.)
2024-02-23 20:02:01 -08:00
nhkeni
5f64dd3f1b Make initoptions() call initoptions_init() if that hasn't already happened. 2024-02-23 20:14:03 -05:00
nhkeni
eadebf0132 Use local md4 implementation instead of libcrypto for linux.
NB: "make depend" needs to be rerun
2024-02-23 17:08:49 -05:00