Commit Graph

3740 Commits

Author SHA1 Message Date
nhmall
21d35e768c bump EDITLEVEL for previous two commits DEC19-2024 2024-12-19 17:54:55 -05:00
nhmall
111ef1e1a5 consume a bit in obj.h for future resolution of a TODO in bones.c
Since EDITLEVEL is being incremented for the previous patch anyway,
add the "name_from" bit to the obj struct now, as groundwork for
the code change mentioned in a TODO comment in bones.c:

            /* strip user-supplied names */
            /* Statue and some corpse names are left intact,
               presumably in case they came from score file.
               [TODO: this ought to be done differently--names
               which came from such a source or came from any
               stoned or killed monster should be flagged in
               some manner; then we could just check the flag
               here and keep "real" names (dead pets, &c) while
               discarding player notes attached to statues.] */
            if (has_oname(otmp)
                && !(otmp->oartifact || otmp->otyp == STATUE
                     || otmp->otyp == SPE_NOVEL
                     || (otmp->otyp == CORPSE
                         && otmp->corpsenm >= SPECIAL_PM))) {
                free_oname(otmp);
            }

Also, the bitfield per-byte groupings identified in the struct
weren't accurately reflected, so rearrange the Bitfields,
and correct the per-byte groupings.

This invalidates existing save files and bones.
2024-12-19 17:54:14 -05:00
nhmall
f7853be3dc fix GitHub issue 1303 related to engravings
GitHub issue reported by ars3niy:
https://github.com/NetHack/NetHack/issues/1303

@ars3niy commented on Oct 27:
Stepping on a square with a dust or "graffiti" engraving while blind
produces no message because presumably you can't read them by swiping
the floor with your hands, however the engraving glyph still shows up on
the map afterwards. While this helps zen players, it looks like a bug.

@ville-v commented 3 days ago:
Searching while blind also reveals the engravings. Here is a save file
demonstrating the issue.
[...]

This adds an erevealed bit to engravings, to accompany the the eread
bit that is already there.

eread:      refers to the text of the engraving
erevealed:  refers to the engraving map symbol

Hopefully, this resolves issue 1303 without creating additional bugs.

This invalidates existing save files and bones.

Fixes #1303
2024-12-19 17:53:43 -05:00
Pasi Kallinen
87694e1a95 Hero remembers trapped boxes
After finding a trap on a chest or a large box, remember it
as trapped: "You see here a trapped large box."
Randomly generated chests and boxes can be obviously trapped.
Allow defining obviously trapped containers via lua.

Invalidates saves and bones.
2024-12-19 13:11:25 +02:00
nhmall
2965ce4bc5 msdos build correction
ENHANCED_SYMBOLS is defined by default in config.h.
The msdos build tried to #undef ENHANCED_SYMBOLS
in tilemap.c, but doing it in there created a mismatch
between the data struct definition for glyph_map in wintype.h
and the initializers generated in tilemap.c

Move the msdos build catch for ENHANCED_SYMBOLS to
one single place in config1.h so that the code and data agree.
2024-12-15 09:53:50 -05:00
Pasi Kallinen
fd23463941 Sparkle shield effect and accessibility
When sparkle is turned off, there are some places where
a monster resisting the effect did not give any message.

This fixes some of those.
2024-12-14 14:34:22 +02:00
PatR
b2b9b685c5 fix issue #1305 - failed #untrap from doorway
Issue reported by loggersviii:  attempting #untrap from an adjacent
doorway can move the hero diagonally out of the doorway.

A followup comment by elunna pointed out that a monster's attack that
results in knockback can produce similar result.

Fixes #1305
2024-12-13 22:48:32 -08:00
Alex Smith
3491535548 More bugfixes for the recent artifact gifting changes 2024-12-12 07:35:50 +00:00
Alex Smith
d87cadaf73 Artifact and #offer rebalance, part 1: sacrifice gifts
In 3.6, artifact gifts are often either a) entirely useless or
b) gamebreaking, neither of which is really ideal from a balance
perspective.

This commit aims to make artifact gifts more useful in the early
game by greatly increasing the chance for situational artifacts to
generate positively enchanted.  However, the most powerful
artifacts will now only be gifted if you offer a high-value corpse,
meaning that they are only likely to be accessible later in the
game.  The selection of which artifact to gift has become more
complicated in order to a) increase the chance that it fits the
character and b) reduce cheese strategies (e.g. it is no longer
possible for elves to force the gifting of Stormbringer as the
first sacrifice gift).
2024-12-12 03:14:47 +00:00
nhmall
1f8b75b8c6 different ls content values, so bump EDITLEVEL 2024-12-09 16:21:31 -05:00
nhmall
02259dd1d0 light source troubleshooting
I don't think this solves the recent light source reports,
but it changes a couple of things in an attempt to get more
information.

1. Having gy.youmonst.m_id field always be zero makes it tough
to distinguish it from uninitialized memory, or a random memory
value. This changes the m_id for the hero's gy.youmonst.m_id
to always hold the identifier 1, instead of 0.

2. write_ls was taking the stashed pointer in the light source,
and using it to immediately extract the m_id field and search
for that m_id. This changes the approach slightly, to actually
try and locate the stashed pointer itself in one of the monster
chains. Only if the monster pointer is located, do we dereference
it to obtain the m_id field.

3. For the interim, mark the saved ls with another set bit when
there has been a failure to locate the monst. At this time,
no code is acting on that bit, but it can be seen in a debug
session.

Hopefully, the next report will provide enough information to
understand the scenario a little better.
2024-12-09 15:52:29 -05:00
Pasi Kallinen
57abae29e8 Don't switch away from polearm if monster in range
Using 'f', if hero is wielding a polearm, and a monster is in range,
don't switch away even if we do have ammo in quiver and a launcher
in the inventory.
2024-12-08 22:19:36 +02:00
Pasi Kallinen
863d455e1d Tourists gain experience by using camera flash on monsters
This counts as seeing the monster up close, so the tourist
doesn't need to get next to the monster
2024-12-07 11:24:30 +02:00
Pasi Kallinen
89c4c3a722 Tourists gain experience by seeing new types of creatures up close
Experience equivalent to killing a monster is gained when starting a turn
adjacent to and being able to see the monster.

Breaks saves.

Idea and parts of code via dNetHack
2024-12-06 21:30:23 +02:00
Pasi Kallinen
e23e6ef235 Blessed scroll of destroy armor asks which armor to destroy
via xNetHack with some slight modifications.
2024-12-06 11:09:27 +02:00
nhmall
fec6320e68 rename sys/windows/Makefile.mingw32 to GNUmakefile
GNU make looks first for a file called GNUmakefile, ahead of
looking for Makefile and then makefile.

Renaming sys/windows/Makefile.mingw32 to sys/windows/GNUmakefile
allows:

o src/GNUmakefile (for use by GNU make) and src/Makefile (for use
  Microsoft nmake) to both reside in the src folder during build.

o src/GNUmakefile will be used by GNU make, without having to
  explicitly specify "-f GNUmakefile" on the GNU make command line.

o src/Makefile will be used by Microsoft nmake, without having to
  explicitly specify "-f Makefile" on the Microsoft nmake command line.

For the gcc build, the movemement of sys/windows/GNUmakefile needs
to be copied to src/GNUmakefile as part of the build process (see
sys/windows/build-msys2.txt).

For the Microsoft Visual Studio command line build with nmake,
sys/windows/Makefile.nmake needs to be copied to src/Makefile as
part of the build process (see sys/windows/build-nmake.txt).

They are both copied to the src folder from their respective
repository source file names when the nhsetup.bat file is used.
2024-12-02 19:04:08 -05:00
PatR
1301234039 mimic feedback tuning
When a mimic in door form is hit by a wand of locking or wand of
opening or corresponding spell, bring it out of concealment like
was recently done for being zapped while in chest form.  And give
some feedback rather than just changing the mimic's form to 'm'.

Give more detailed feedback when bumping into a mimic while moving.
2024-12-02 11:37:04 -08:00
nhmall
9f33d1cf7a Merge branch 'newsym_worm' of https://github.com/entrez/NetHack into NetHack-3.7 2024-11-30 20:14:40 -05:00
nhmall
b89e792873 Some Windows gcc fixes 2024-11-30 19:06:05 -05:00
Michael Meyer
92d931f190 Refresh worm segments when (un)taming
Because newsym() would be called only on the head position of the worm,
if hilite_pet was on, the segments and head of a long worm would have
mismatched highlighting in the immediate aftermath of taming or
untaming.
2024-11-30 17:30:52 -05:00
nhmall
bc88266081 NetHack's regex function prototypes into nhregex.h
There was an issue with Windows mingw build because the function
prototypes were not available. Place them into a distinct
header file nhregex.h and include it from extern.h, and
available for cppregex.cpp to include without the rest of
extern.h (which can give some problems with c++).
2024-11-30 17:08:54 -05:00
nhmall
f8d9b288b9 Merge branch 'NetHack-3.7' of https://github.com/guillaumebrunerie/NetHack into NetHack-3.7 2024-11-30 15:54:21 -05:00
nhmall
0792e5fe9e expand implicit fallthrough detection to non-gcc compilers
gcc has recognized various "magic comments" for white-listing
occurrences of implicit fallthrough in switch statements for
a long time:

    The range and shape of "falls through" comments accepted are
    contingent upon the level of the warning. (The default level is =3.)

    -Wimplicit-fallthrough=0 disables the warning altogether.
    -Wimplicit-fallthrough=1 treats any kind of comment as a "falls through" comment.
    -Wimplicit-fallthrough=2 essentially accepts any comment that contains something
     that matches (case insensitively) "falls?[ \t-]*thr(ough|u)" regular expression.
    -Wimplicit-fallthrough=3 case sensitively matches a wide range of regular
     expressions, listed in the GCC manual. E.g., all of these are accepted:
        /* Falls through. */
        /* fall-thru */
        /* Else falls through. */
        /* FALLTHRU */
        /* ... falls through ... */
       etc.
    -Wimplicit-fallthrough=4 also, case sensitively matches a range of regular
     expressions but is much more strict than level =3.
    -Wimplicit-fallthrough=5 doesn't recognize any comments.

Plenty of other compilers did not recognize the gcc comment convention,
and up until now the compiler warning for detecting unintended
fallthrough had to be suppressed on other compilers. That's because the code
in NetHack has been relying on the gcc approach, and only the gcc approach.

The C23 standard introduces an attribute [[fallthrough]] for the
functionality, when implicit fallthrough warnings have been enabled.

Several popular compilers already support that, or a very similar attribute
style approach, today, even ahead of their C23 support:

       C compiler                       whitelist approach
       ---------------------------   -------------------------------------
       C23 conforming compilers         [[fallthrough]]

       clang versions supporting
       standards prior to
       C23                              __attribute__((__fallthrough__))

       Microsoft Visual Studio
       since VS 2022 17.4.
       The warning C5262 controls
       whether the implict
       fallthrough is detected and
       warned about with
       /std:clatest.                    [[fallthrough]]

This adds support to NetHack for the attribute approach by inserting a
macro FALLTHROUGH to the existing cases that require white-listing, so
other compilers can analyze things too.

The definition of the FALLTHROUGH macro is controlled in include/tradstdc.h.

The gcc comment approach has also been left in place at this time.
2024-11-30 14:16:27 -05:00
Guillaume Brunerie
52876c4798 WASM fixes 2024-11-30 17:07:10 +01:00
PatR
d32ab55b84 new property: BLND_RES
Add enlightenment feedback for Sunsword's blocking of becoming blind
from light flashes.  It uses an extra property so that wizard mode
can report the reason.

EDITLEVEL is being incremented, so existing save and bones files are
invalidated.
2024-11-26 20:57:11 -08:00
nhmall
15e70035d0 Remove unnecessary macro that wasn't ideally named
Also add a comment that states the intent.
2024-11-26 23:27:29 -05:00
Anhijkt
d93704a154 change CHDIR definition conditions 2024-11-23 19:04:12 +02:00
nhmall
13db1aed0d replace stray tabs that have crept in 2024-11-14 11:54:39 -05:00
nhmall
5c28b9e987 fix another memory leak
In sys_early_init(), the values for sysopt.gdbpath and
sysopt.greppath were being assigned by calling dupstr()
without ensuring that a value previously assigned by
dupstr() were free()'d.

Also, the sysopt struct definition is changed to sysopt_s,
not because there's anything wrong with the original
    struct sysopt sysopt;
but because I couldn't convince the debugger to use the
correct thing when trying to track down the leak.
2024-11-13 09:07:10 -05:00
nhmall
e83e04dbb3 fix some memory leaks 2024-11-10 22:24:45 -05:00
nhmall
9a7dcf16a3 rm.h comment update 2024-11-10 17:49:54 -05:00
nhmall
c87a373b11 more follow-up related to #1320 2024-11-10 10:06:07 -05:00
nhmall
5cc529efc8 follow-up related to #1320
This is additional groundwork related to
https://github.com/NetHack/NetHack/issues/1320

This additional groundwork just puts some safeguards
in place to make it rather tough to end up with an
instant death from handling a cockatrice corpse in
your inventory without appropriate protection.

At this point, still no actual petrification will occur.
2024-11-09 23:49:10 -05:00
nhmall
9c554895b1 adjust wish for cockatrice corpse
Wishing is powerful, so if you cannot safely handle a cockatrice
corpse, then have a wish for one result in the corpse materializing
on the floor rather than in your inventory.

Resolves #1320
2024-11-09 14:06:43 -05:00
nhmall
36d8998edb try not including trees when check_pos() returns it's 3rd argument.
Related to #1309
https://github.com/NetHack/NetHack/issues/1309

K2 commented: "This might help - k21971/EvilHack@afed641"

A comment in there states:
"Fix: sections of wall being visible when they shouldn't yet.
This has been a long-standing bug for as long as I can remember, and qt
appears to have figured it out. What was happening: the player would all
of the sudden see a section of wall in an area that they hadn't explored
yet. It was discovered that this was only occurring if that section of
wall had any type of tree up against it."

The fix there attempts to leave trees out of the check_pos non-zero return,
so give that a shot.

I didn't attempt to reproduce the situation myself,
and therefore cannot confirm that this does resolve it.

Feedback on effectiveness or side-effects are welcomed. If someone is
able to confirm that this resolves the issue without creating new
issues, we can close it, otherwise this can be reverted.
2024-11-09 11:40:09 -05:00
nhmall
1dbba0f63b rename IS_ROCK() macro to IS_OBSTRUCTED()
It has included trees since they were added, so give it a
more fitting name.
2024-11-09 11:12:42 -05:00
nhmall
f1743d0e5c more rm.h comment updates 2024-11-09 10:58:58 -05:00
nhmall
a74badd271 rm.h comment updates 2024-11-09 10:53:48 -05:00
nhmall
9a42d70901 ranged attack in repertoire might not be used
Commit 22884522, ported (from Sporkhack, Evilhack), added the ability
for monsters to maintain awareness of player resistances that they
observed.

Since they will refrain from using a ranged attack that they deem
futile, take the specific monster's seen_resistance field into consideration
when choosing code paths based on the availability of ranged attacks.

Resolves #1307
2024-11-03 09:03:04 -05:00
Alex Smith
4c49239940 Update a comment in config.h to allow for gnome-terminal updates
gnome-terminal was recently fixed to work correctly with
TTY_TILES_ESCCODES (and other similar private-use terminal code
sequences), and thus this isn't an incompatible combination any
more.
2024-10-25 01:34:48 +01:00
Mika Kuoppala
25061dbce4 Remove magic members from instance globals.
We ought to trust compiler and we have other
tools to check oob access.
2024-10-23 23:41:24 +03:00
Pasi Kallinen
945ccff1ff Allow changing command autocompletions via #optionsfull 2024-10-19 14:46:11 +03:00
Pasi Kallinen
696af89299 Change MSGHANDLER from compile-time to sysconf 2024-10-19 10:47:53 +03:00
Pasi Kallinen
f12635ccd9 Prevent monster generation in the sokoban trap hallway
Makes Sokoban far less tedious when you don't have to worry about
monsters randomly popping up in the trap hallway while you're pushing
the boulder.

Adds a new exclusion zone for monster generation, and the goodpos
routine avoids the zones when GP_AVOID_MONPOS is used.
2024-10-18 13:30:51 +03:00
nhmall
67cfdf6843 get rid of a static analyzer warning
src/pager.c(696): warning: Reading invalid data from 'def_warnsyms'
2024-10-12 14:56:36 -04:00
nhmall
57fc8f10a6 replace fuzzer state magic numbers 2024-10-12 10:14:44 -04:00
PatR
11a4fe42de 'selectsaved' again - update EDITLEVEL again
The role, race, gender, and alignment string values are 3 letters
preceded by a dash.  I was looking at "name-race-role-gend-algn"
and mistakenly treated them as 4 letters preceded by a dash.

Fixing that changes PL_NSIZ_PLUS and there is one item of that size
written into save files, so the fix invalidates existing save files.
2024-10-11 22:35:38 -07:00
PatR
1f36b98b8f 'selectsaved' extension
Instead of a menu listing
 a - hero1
 b - hero2
 n - New game
 q - Quit
show
 a - hero1-role1-race1-gend1-algn1
 b - hero2-role2-race2-gend2-algn2
 n - New game
 q - Quit
or
 a - - hero1-role1-race1-gend1-algn1
 b - X hero2-role2-race2-gend2-algn2
 c - D wizard-role3-race3-gend3-algn3
 n - New game
 q - Quit
when any game in the list wasn't saved during normal play.  (Those
are sorted by character name; the playmode is just coincidence.)

The dash for 'normal' doesn't look great but -/X/D are codes used in
entries written to paniclog.  The whole playmode prefix doesn't look
particularly good but I suspect that most players relying on restore
via menu won't see it.

It should work when the character name has dashes in it but that
hasn't been properly tested.

The gender and alignment suffices reflect their value at the time of
save rather than at the start of the game.  That might be considered
a bug but it was easiest.

Increments EDITLEVEL; existing save and bones files are invalidated.
2024-10-10 23:14:25 -07:00
nhmall
fb70aadbb5 improve copy_bytes() maintenance
Remove the copy_bytes() function from files.c and util/recover.c
and place a single copy into hacklib.
2024-10-05 15:55:20 -04:00
PatR
525c6744ee some changes tried while working on issue #1289
display.h -- bring an unused macro up to date
detect.c  -- always call newsym() when searching or secret door
  detection finds a trap rather than just when not blind
glyphs.c  -- some formatting
pager.c   -- lookat() behaves very strangely when single-stepping
  in the debugger (gdb); this didn't help
2024-09-28 23:50:27 -07:00