Commit Graph

17795 Commits

Author SHA1 Message Date
nhmall
a3e12550ea savefile changes - part 1
This is the first of several savefile-related changes to
follow later. This one is groundwork for those later changes.

Remove internal compression schemes (RLECOMP and ZEROCOMP)
and discard the savefile_info struct that was primarily used to
convey which internal compression schemes had been in use.

Relocate some struct definitions into appropriate header files
for use by code to come in later changes.

Remove the two struct size-related fields from version_info and
from the nmakedefs_s. Instead, include a series of bytes near the
beginning of the savefile, representing the size of each
struct or base data type that impacts the historical savefile
content. Those are referred to as the "critical bytes".
(Related note: the "you" struct required two bytes, low and high,
due to its size).

Compare those critical bytes in a savefile against the NetHack
build that is reading the savefile. This allows mismatch detection
early in the savefile-reading process, and a clean exit, rather than
proceeding to read nonsensical values from the file. Include some
feedback on what the first mismatch was when encountering
one.

For arrays stored in the savefile, use loop-logic in the core
to write/read the array elements one at a time, rather than in
a single blob. This will be required for changes to follow later.
(impacts artiexist[], artidisco[], svd.dungeons[], svl.level_info[],
svl.level.locations[][], msrooms[] field of mapseen, svb.bases[],
svb.disco[] objects[], svm.mvitals[], svs.spl_book[], svd.doors[],
go.oracle_loc[], utrack[], wgrowtime[])

This also adds data model to the long version information.

This invalidates existing save and bones files due to the changes in
the information at the start of the file.
2025-04-15 15:35:17 -04:00
Pasi Kallinen
af3e601ff7 Remove melting ice timer when breaking digging wand 2025-04-15 14:45:51 +03:00
Pasi Kallinen
d6dd5c743c Reinstate some of the mind flayer amnesia
When I reworked amnesia to not forget levels or objects, I removed
the forgetting from the mind flayer attacks.  I intended to add
something to replace it, but forgot ...
2025-04-13 20:16:00 +03:00
nhmall
932f598689 follow-up bit 2025-04-13 12:23:09 -04:00
nhmall
a70db6dafb WIN_MAP==WIN_ERR on a code path to tty_wait_synch 2025-04-13 12:14:38 -04:00
Pasi Kallinen
a185c270bb Expose trap once-field to lua 2025-04-13 17:32:14 +03:00
nhmall
eeb96c4151 update tested versions of Visual Studio 2025-04-13 2025-04-13 10:22:59 -04:00
Pasi Kallinen
85de51a69a Add invocation effect to Fire and Frost Brand
Casts fireball or cone of cold at expert level
2025-04-13 13:13:54 +03:00
Pasi Kallinen
652f8576c0 Cursed magic whistle can teleport you to your pet 2025-04-13 12:48:21 +03:00
PatR
e26a496088 fix issue #1309 - secret doors in Garden rooms
Issue reported by elunna:  when a room gets converted into a theme
room with fill type Garden, its walls are changed to trees but any
secret doors in those walls are still displayed as regular walls.

This adds a new D_ARBOREAL flag for secret doors, used to force them
to be displayed as a tree instead of a wall.

Fixes #1309
2025-04-12 17:21:40 -07:00
PatR
8f344a30b5 github PR #1399 - add "Murphy" to ghost names
Pull request from greg-kennedy:  add "Murphy" to the list of random
ghost names.

Closes #1399
2025-04-12 12:33:10 -07:00
PatR
efee4553b6 github PR #1394 - "Mine's End" epitaph
Pull request from chappg:  add "I have reached Mine's End" to the set
of epitaphs.

Blame the explantory comment on me.

Closes #1394
2025-04-12 12:19:50 -07:00
Greg Chappell
9821caf984 Add "I have reached Mine's End" epitaph 2025-04-12 12:10:11 -07:00
PatR
a05cca16ef fixes entry for PR #1408, typos in tribute names
Pull request from rbsec:  a couple of character names had misspellings.

Closes #1408
2025-04-12 10:43:32 -07:00
rbsec
6a74f46c25 Fix a couple of incorrect names in the Terry Pratchett tributes 2025-04-12 10:36:37 -07:00
PatR
ab8ab7b344 more THEMERM and THEMERMFILL
Give a little more information if environment variable THEMERM or
THEMERMFILL has an invalid value.
2025-04-12 10:22:52 -07:00
Pasi Kallinen
8f7258dc35 Buff Grimtooth with poison
Grimtooth is now permanently poisoned, protects the wielder from
poison, and can be invoked to throw poison.

Permapoison code comes from xNetHack by copperwater <aosdict@gmail.com>.
2025-04-12 19:24:36 +03:00
PatR
48d1b8617e themerms.lua formatting
Do some reformatting of dat/themerms.lua.  I didn't try to reproduce
the changes that were in the reverted commit, and didn't slow through
to the end.
2025-04-11 17:07:55 -07:00
PatR
1fd27044b7 github PR #1384 - THEMERM and ThEMERMFILL
Pull request from copperwater:  reorganize the theme rooms data so
that a room or a fill can be chosen by name, and when in wizard mode,
consult environment variables THEMERM and THEMERMFILL during level
creation to provide control over which theme rooms/room fills to
generate.

I reverted a commit that did a bunch of reformatting to themerms.lua
because to caused substantial merge conflicts.  I will redo at least
part of it.

Closes #1384
2025-04-11 16:29:08 -07:00
copperwater
3427c43df2 Guard against no themed rooms or fills being eligible to generate
The themed room code previously assumed that on any given level, at
least one room or fill would resolve as OK to generate there. However,
that's not a great assumption to make, and if it happened to be broken,
the first themed room or fill would arbitrarily be executed, even though
it wasn't eligible. Fix that by setting the initial pick to nil, and
raising an impossible if it's still nil after trying to choose a random
room.
2025-04-11 16:27:34 -07:00
copperwater
47e6edc663 Enable generating specific themed rooms for debugging
A common pain point I encounter when working on themed rooms is making
specific rooms generate. The only ways to do this were mass commenting
out the rooms not being tested, or hacking in different room frequency
values (even more annoying when testing a fill, not a room, or testing
pure-function rooms/fills that have no frequency).

This change solves that problem by allowing a wizard-mode user to define
THEMERM or THEMERMFILL environment variables to make specific rooms or
fills generate.

The first part of this change is converting all themed rooms and fills
that were plain functions into tables, and converting their comment
names into actual names in those tables. The names are not intended to
be shown during gameplay, but instead serve as values that THEMERM or
THEMERMFILL can be matched to to generate those rooms. It's no longer
possible to have a function themeroom; this will raise an impossible.
As far as I'm concerned, this is a good change because it allows some
code simplification of themerooms_generate and makes it easier to add
difficulty or eligibility parameters to rooms.

The second part of this change is adding a new nh.debug_themerm function
to make the environment variable values accessible to themerms.lua. I
looked for an existing way to do this but didn't see one (nh.variable
is the closest but appears to be for variables that get saved).

The final part is inserting behavior into the actual themeroom
generation code that changes how they generate when either a room or a
fill is set. I don't think it's safe to generate every single room with
the requested type or fill - that might lead to cases where the stairs
or a magic portal cannot generate. So it creates ordinary rooms half of
the time, which still results in plenty of themed rooms on levels.

Another thing to note is that any themed room using filler_region will
still only pick a fill 30% of the time. If one specifies both a fill and
a room that uses filler_region, many of those rooms will appear without
a themed fill.
2025-04-11 16:27:34 -07:00
PatR
5a910f3df7 Revert "whitespace cleanup for themerms.lua"
This reverts commit eee5a1698b.
Easier to commit PR #1384.
2025-04-11 15:19:06 -07:00
Pasi Kallinen
7138af00ba Praying on an altar with pet statue on it can revive the pet 2025-04-10 23:38:44 +03:00
Pasi Kallinen
197e6af78c Increment EDITLEVEL for silver maces 2025-04-09 21:26:22 +03:00
Pasi Kallinen
fa229439d4 Fixes entry for silver mace
Fixes #1405
2025-04-09 21:05:59 +03:00
disperse
c271f878f9 Fixed tile numbering in objects.txt 2025-04-09 19:46:05 +03:00
disperse
b5768d676c Added tile for silver mace
Copied the mace tile and added more blue and white and softened the
shadows on the head of the mace.
2025-04-09 19:46:05 +03:00
disperse
67d58202ad Silver maces
Added the silver mace to be the base weapon type of Demonbane.  It is appropriate that an artifact weapon designed to slay Demons would be made of (or plated with) silver.  This helps to offset the damage reduction when Demonbane was changed from a longsword to a mace and makes it more specialized against silver-haters.
Set the probability to 2, equal to that of a silver spear.
Increased the weight of the silver mace by 120% -- equal to the weight increase from a normal spear to a silver spear. (Assuming the weapon is silver plated rather than made entirely out of silver.)
Increased the base cost to 60, a similar increase as spear to silver spear, to be an even number between silver spear and silver saber.
Monsters will prefer silver maces over regular maces.
Otherwise, identical in function to a normal mace.
2025-04-09 19:46:05 +03:00
Pasi Kallinen
2065d2d392 Avoid premapping outside Sokoban map to prevent showing stone glyphs
If user has changed the stone glyph to something other than a space
(or uses a tileset), Sokoban levels showed the unreachable stone outside
the map area.  Prevent marking those areas as seen, so the stone
glyphs aren't shown.
2025-04-09 18:41:00 +03:00
PatR
3aecc90b2d commit 46b98bab5b951c16f3c6766f23acb22c3046608c
Author: PatR <rankin@nethack.org>
Date:   Mon Apr 7 13:58:28 2025 -0700

    fix issue #1404 - re-tamed feral pet starves

    Issue reported by k21971:  changes in 'struct edog' initialization
    resulted in re-taming of a feral former pet producing a tame monst
    that immediately dies of starvation.

    I didn't look at the earlier behavior, just forced hunger to be
    initialized separately from other edog fields.

    Fixes #1404
2025-04-07 14:11:58 -07:00
PatR
afc34c9873 mon throw-and-return cleanup
Fix up a few comments in the monster throwing code.  And change a
couple 'if (!Blind)' checks to use 'if (canseemon(magr))' instead
of that the player won't be told about a returning aklys hitting an
invisible monster ("it") on the arm.
2025-04-05 09:50:38 -07:00
PatR
500af49dd3 fix issue #1407 - mon throw-and-return crash
Issue reported by k21971:  a gnome throwing a wielded aklys at the
hero was killed when failing to catch its return.  Bookkeeping for
dead monsters got messed up, then a crash occurred.

This fixes things.  Instead of a comment stating that the thrower
might be dead, kill it off.
2025-04-05 09:44:02 -07:00
PatR
4afb9254e1 fuzzer vs yn_function()
This has been sitting around for a long time.  It prevents at least
one fuzzer exit.

Before adding this, I did trigger one yn_function() 'impossible'
while doing ordinary testing but wasn't able to reproduce that, so
am still not sure what is going on.
2025-04-03 20:07:31 -07:00
PatR
0ecd573152 escape_from_sticky_mon()
Reorganized a 'switch' statement in order to eliminate a 'goto'.
There should be no changed in behavior.
2025-04-03 15:26:05 -07:00
PatR
eee5a1698b whitespace cleanup for themerms.lua
I hope this doesn't break anything.  There seemed to be one or two
misplaced 'end' statements, but after some massaging I'm not sure
about this anymore.

There were lots of wide lines; those are easy.  The Water-surrounded
vault had very inconsistent indentation so was harder to untangle.
2025-03-30 14:43:09 -07:00
copperwater
b32ce258e3 Fix: buffer overflow in gamelog with an extremely long wish string
This was discovered when a game of xNetHack crashed with stack smashing
detected during dumplog creation after an ascension. I traced the
problem to a wish with a very long string the player had made much
earlier in the game ("greased very blessed holy rustproof unlit historic
thoroughly +5 very cloak of protection named it would be a shame if
something happened to me wearing this cloak"), which is further recorded
in an even longer form in the chronicle as 'wished for "X", got "Y"'.
That string does get truncated, but since the gamelog strings are
dynamically allocated, they can be longer than BUFSZ.

When show_gamelog was subsequently called, it didn't use any bounds
checking, which allowed its stack-allocated buffer to overflow. Changing
the offending sprintf to snprintf and limiting it to the buffer size
appears to fix this issue. It will truncate the string at BUFSZ-1
characters and therefore will be expressed in the dumplog as an
incomplete string, but 1) that was happening anyway because the gamelog
string already doesn't capture the entire "wished for X, got Y" message
on such a wish, and 2) this should only ever happen for very long
wishes.
2025-03-29 07:21:04 -04:00
nhmall
da197df75e comment typo 2025-03-22 12:17:12 -04:00
PatR
1df8fd8b3b cutting down closed doors
Most things that can be dug or chopped can only have that done by one
of the two types of digging/chopping tools:  pick-axe or axe.  Since
closed door can be broken open via either type, mention the type of
implement in the final "you break through the door" message by adding
"with your <uwep>."
2025-03-20 16:09:15 -07:00
nhmall
9e2a0f977e fixes entry update 2025-03-20 14:39:04 -04:00
nhmall
3ed63f9be4 more Xcode cleanup 2025-03-19 21:20:39 -04:00
nhmall
f30780e42e clean up absolute paths 2025-03-19 21:16:46 -04:00
PatR
d7f107eaf9 still more 'nethack --dumpweights'
After updating the --dumpweights code in hack.c to insert "pair of"
for gloves and boots and "set of" for dragon scales, I've switched
it to use simple_typename() instead.

Turns out that that routine also lacked handling for 'pair|set of'.
And it was generating "coin of gold piece".  Fix those.

Roughly half of the gems are "<gem>" and the others "<gem> stone",
so the --dumpweights output is different by more than just pair/set.
2025-03-19 17:30:56 -07:00
nhmall
b55162a605 more file name change follow-up for weight.h 2025-03-19 19:46:11 -04:00
nhmall
872a9778ed Xcode project update 2025-03-19 19:26:27 -04:00
nhw_cron
5cc94c74c8 This is cron-daily v1-Apr-1-2024. 000files updated: Files 2025-03-19 17:57:02 -04:00
PatR
b237337806 streamline domove_core()
Split handling for paranoid_confirm:Trap out of domove_core() into
a separate routine.  There should be no change in behavior.
2025-03-19 14:33:13 -07:00
nhmall
e70b92e200 paste error in Makefile.nmake 2025-03-19 17:31:19 -04:00
nhmall
1f99638bbf ren nhconst.h -> weight.h
The speed related values were not used, except for NORMAL_SPEED,
which has been moved back to permonst.h
2025-03-19 17:14:07 -04:00
nhw_cron
601d03b71d This is cron-daily v1-Apr-1-2024. 000files updated: Files 2025-03-19 14:33:00 -04:00
nhmall
526571b1f7 another follow-up for magic number replacement 2025-03-19 14:12:03 -04:00