I recently changed a comment in objclass.h and that should have
triggered a full or nearly full rebuild but only resulted in a
couple of files being recompiled. Instead of trying to figure out
why, I just ran Makefile.src through 'make depend' to force it to
be up to date.
A side-effect is that version.c won't be unnecessarily recompiled
every time nethack gets relinked. The reason for that (date.h
being regenerated with new data) is handled by date.c now.
Pasi Kallinen [Sun, 12 Sep 2021 16:44:35 +0000 (19:44 +0300)]
Reveal the monster your strike moved
When you hit a small hidden monster (by eg. force-fighting)
that got moved by the strike, the monster stayed hidden, possibly
causing a sanity checking error.
Save files from before the 'disambiguate WHACK' patch were not
necessarily compatible with ones after it, leading to potential
restore problems.
Comments in objclass.h (from before the patch) suggested that
inappropriate assumptions were being made about field layout.
This deliberately introduces new incompatibility and increments
EDITLEVEL to caused earlier save and bones files to be thrown
away.
when fleeing hero who was wearing gold dragon scales/mail and not
wielding any weapon.
When a gremlin was made to flee "artifact light", code originally
intended for Sunsword attempted to format 'uwep' as an artifact. For
gold scales/mail instead of that, it gave a sane but inappropriate
value if wielding something or segfaulted if not wielding anything.
when an unseen monster picks up an item that the hero knows some
things about. That's intentional, but vision is turned off while
engulfed so throwing or dropping something while swallowed always
treated it as being handled by an unseen monster.
If hero is swallowed or held by a monster or poly'd and holding a
monster, behave as it the monster can 'seen' by touch when items are
added to its inventory.
triggered by Grayswandir's hallucination resistance. If the game
is saved while hero is hallucinating but having that be suppressed
by wielding Grayswandir, is riding, and the steed is on an object,
then during restore the hero's location will be updated because
of the presence of the object but the attempt to display the hero
there is made before u.usteed has been restored and fails.
Currently weapons are set up as piercing, slashing, or whacking, using
their object's oc_dir field, with the intention that certain weapons
can classify as both. However, since oc_dir is only 2 bits and WHACK is
0, there's no way to unambiguously express some of these combinations.
Certain weapons such as the lucern hammer are defined as combination
piercing/blunt weapons, but the game just sees it as a piercing weapon.
This commit adds a third bit to oc_dir and promotes the WHACK constant
to its own bit. Nothing should be affected by this (wand directions and
the like should remain working as usual) other than the
blunt-and-something-else weapons being defined properly.
Michael Meyer [Fri, 3 Sep 2021 20:55:37 +0000 (16:55 -0400)]
Fix: 'Suddenly you cannot see it'
Updates to m_dowear_type(worn.c) in 5a09a01a13 inadvertently reversed
the effect of an xor near the end of the function, causing it to go from
testing whether a monster's status as 'seen' or 'unseen' changed over
the course of the function to testing whether it remained the same.
As a result, whenever an unseen, invisible monster donned a piece of
armor anywhere on the map, the message 'suddenly you cannot see it'
would be printed. Fix the xor so that it goes back to testing whether
visibility changed since the start of the function.
Pasi Kallinen [Fri, 3 Sep 2021 10:27:36 +0000 (13:27 +0300)]
Fix eel hiding in dry land
When an eel was hiding in a pool and a rolling boulder trap
launched a boulder on top of the pool, and the boulder then
filled the pool, the eel ended up hiding on the dry land.
As a stopgap measure, kill off any monster that is in the
pool location when the boulder hits the pool. This should
probably be expanded to handle flying monsters differently.
Michael Meyer [Tue, 3 Aug 2021 21:05:22 +0000 (17:05 -0400)]
Amplify booze effect if drinking on empty stomach
Drinking booze on an empty stomach will amplify its effects
(i.e. increase the duration of the resulting confusion); stuffing
yourself before drinking will have the opposite effect.
Michael Meyer [Fri, 20 Aug 2021 23:20:00 +0000 (19:20 -0400)]
Count all poly'ing tins as potential sliming cures
Popeye, used to check whether eating a particular tin is a potential
lifesaving action, considered tins of chameleon meat a cure for sliming
(since you can polymorph into a fiery monster), but didn't credit the
same possible curative power to other tins which can polymorph the hero.
Use the polyfodder macro (used elsewhere to check whether eating
something will polymorph a monster/pet) to determine whether a tin will
polymorph the hero.
copperwater [Sun, 22 Aug 2021 13:53:24 +0000 (09:53 -0400)]
Remove g.monstermoves
It's redundant with g.moves, so there is no more need for it.
Way, way back, it looks like g.moves and g.monstermoves can and did
desync, where g.moves would track the amount of moves the player had
gotten (and would therefore increase faster if the player were hasted)
and g.monstermoves would track the amount of monster move cycles, aka
turns. But this has not been the case for a long time, and they both
increment together in the same location in allmain.c. There are no
longer any cases where they will not be the same value.
This is a save-breaking change because it changes struct
instance_globals, but I have not updated the editlevel in this commit.
copperwater [Mon, 23 Aug 2021 00:01:14 +0000 (20:01 -0400)]
Remove requirement of object probs adding to 1000
When discussing the recent commit that removed makedefs -o from the
build process, nhmall pointed out that a sanity check ensuring all
objects within one class add up to 1000 probability had been removed as
well. This requirement was a perennial thorn in the side for anyone
doing anything that touches object probabilities, because allocating
probability to something meant deciding what to take it away from,
without a good way to evenly distribute that across all the other
members of the object class.
I had gotten around this in xNetHack by removing the sanity check and
making mkobj() total up the probability within an object class and then
using that instead of 1000. This commit takes a similar approach, but
instead of inefficiently recalculating the sum every time mkobj() is
called, it instead computes it at the start of the game or when
restoring the save file and stores it in a global variable.
This fixes a slight bias problem with rings - they are all supposed to
be of equal probability, but there are 28 of them and 1000 is not evenly
divisible by that, so the old formula made the later rings slightly more
likely. Now instead of a 35/1000 or 36/1000 chance, they are all
uniformly 1/28. (Internally they have a oc_prob of 1 now, not 0).
Gems are also weird, because their oc_prob values change every level.
This ought to have still worked without a change, because the arcane
formula for assigning the probabilities would still end up with them
adding to 1000. But I added in code to reset the total gem probability
anyway; this may help make the formula less arcane in the future.
There is still a sanity check against object classes having a nonzero
number of objects but zero total probability, in which case an
impossible will be thrown and every member of the class will be given
equal probability. I also downgraded the "probtype error" panic in
mkobj() to an impossible because it has a reasonable failure case -
return the first item in that class.
PatR [Thu, 26 Aug 2021 22:32:52 +0000 (15:32 -0700)]
Guidebook tweaks for ^E, section 5 header
Describe #wizdetect as revealing hidden things rather than searching
for hidden things since the latter is described more than once as
possibly needing multiple tries.
For plain text output, the "Rooms and corridors" section header was
harder than necessary to notice because it seemed to run together
with the list of commands preceding it.
|
| u #untrap
|
| 5. Rooms and corridors
|
Inserting an extra blank line in between them is helpful. That isn't
needed for Postscript/PDF output because the text of the section
title is rendered with bold font, but I didn't attempt to make the
extra line be conditional. The 'roff directive is added as a comment
to the TeX source without knowing whether an extra blank line would
be useful there (doubtful).
Pasi Kallinen [Thu, 26 Aug 2021 15:46:22 +0000 (18:46 +0300)]
Fix ball bypass sanity complaint
Be punished, get swallowed, drop the ball inside the monster
via the 'D' drop, kill the swallower - this issued a sanity
check complaint about the ball bypass flag.
In this case, the ball was "floating", not on any object chain,
when dropped inside the monster, so clear_bypasses didn't
clear the flag.
Pasi Kallinen [Thu, 26 Aug 2021 11:11:57 +0000 (14:11 +0300)]
Clear bypasses at beginning of main loop
Object bypass flag is used to check if an object was already
handled in an iteration loop, in cases where the linked list order
may change during iteration. The flags should never stay set
past a turn, if any were used.
Reset the bypass flags at the beginning of the main loop, without
checking g.context.move -flag; that flag gets reset if hero lifesaved.
PatR [Wed, 25 Aug 2021 21:14:23 +0000 (14:14 -0700)]
elapsed time handling
The code has been assuming that time_t is some number of seconds.
That's valid for traditional Unix systems and for Posix compliant
systems but is not something guaranteed by the C standard. (We ran
into a long time ago when trying out an alternate way to calculate
phase of moon. That code made a similar assumption and broke one
of the ports.)
'ubirthday' also warrants being re-done but I've run out of energy.
PatR [Tue, 24 Aug 2021 15:20:18 +0000 (08:20 -0700)]
some restore.c reformatting
Some reformatting I did while investigating the mimic-as-strange-object
vs protection-from-shape-changers situation. Not part of the fix for
that and no change in behavior.
PatR [Tue, 24 Aug 2021 15:09:30 +0000 (08:09 -0700)]
fix #K3422 - mimic remains as 'strange object'
even when protection from shape changers is in effect. I'm not sure
why mimicking other things doesn't trigger the same sanity check
warning. This fix works for the strange object case and I assume
that it doesn't break the more general case.
When investigating, I noticed that save and restore (even leaving
the level and then returning) causes cancelled shape changers to be
uncancelled. Treat being cancelled similarly to having to having
protection from shape changers in effect: shape changer is forced
to revert to its innate form and not allowed to change shape.
Pasi Kallinen [Sun, 22 Aug 2021 15:44:17 +0000 (18:44 +0300)]
Prevent impossible trying to find a door position
When random dungeon level generation looks for room walls
to place doors at (for joining corridors or creating niches),
it complained about impossible, if the shaped theme room
doesn't have a valid place for a door.
Make the position routine return FALSE and let the
caller deal with it...
Observed this with the small circular themeroom which had
all 4 valid positions already joined with corridors, and
the niche function tried to add a niche to the room.
copperwater [Wed, 18 Aug 2021 03:32:18 +0000 (23:32 -0400)]
Fix: gold dragon scale mail remained lit in bones
This is caused by the bones-pile-making routine using artifact_light()
as a test for whether it needs to call end_burn. Gold dragon scale mail
uses artifact_light(), but only returns true when its owornmask is set.
But owornmask was getting zeroed right before artifact_light() is
called. Fix is to move it right after instead.
Tested that Sunsword is not affected by this (created bones while
wearing gold dragon scales and wielding Sunsword in a dark area; when
returning to them, no light was emitted from the gravesite) because it
always returns true in artifact_light() irrespective of owornmask.
PatR [Sat, 21 Aug 2021 12:36:06 +0000 (05:36 -0700)]
sanity checking: obfree() vs obj->in_use
Drinking a potion sets the in_use flag so that it can be deleted
if found in a hangup save file. That flag wasn't being cleared if
a shop-owned item is used up and goes onto the shop bill instead of
being discarded. The recently revised object sanity checking was
complaining (turn after turn after turn until player paid for the
potion) that there was an object with its in_use bit set.
Restore only purges in_use objects in invent and didn't mess up
billing by getting rid such objects since they're on another list.
nhmall [Tue, 17 Aug 2021 18:43:29 +0000 (14:43 -0400)]
compile NetHack-3.7 without makedefs-generated .h files
This evolves and hopefully eases the game-build requirements by
removing game-compile dependencies on any header files generated
by the makedefs utility, including:
date.h dependency and its inclusion is removed and comparable functionality
is produced at runtime via new file src/date.c.
pm.h dependency and its inclusion is removed and comparable functionality is
produced by moving the monster definitions from monst.c into new header
file called monsters.h and altering them slightly. The former pm.h header
file #define PM_ values are now replaced with appropriate emitted enum
entries during the compiler preprocessing.
onames.h dependency and its inclusion is removed and comparable functionality
is produced by moving the object definitions from objects.c into new header
file called objects.h and altering them slightly. The former onames.h header
file #define values are now replaced with appropriate emitted enum entries
during the compiler preprocessing.
artilist.h has been slightly altered, and the former onames.h artifact-related
header file #define ART_ values are now replaced with appropriate emitted enum
entries during the compiler preprocessing.
makedefs can still produce date.h (makedefs -v), pm.h (makedefs -p), and
onames.h (makedefs -o) for reference purposes. They won't be used during
the compiler.
The other uses for makedefs remain. They are used to prepare external
file content that the game utilizes, not prerequisite code for the
compile:
makedefs -d (database)
makedefs -r (rumors)
makedefs -h (oracles)
makedefs -s (epitaphs, engravings, bogusmons)
date.c
Pull the code for date/time stamping from mdlib.c into date.c.
Set date.o to be dependent on source files, header files, and .o files
so that date.o is rebuilt from date.c when any of those changes, thus
ensuring an accurate date/time stamp. It also includes git sha
functionality formerly done by makedefs writing #define directives
into include/date.h. For unix it passes the git info on
the compile line for date.c (via sys/unix/hints/linux.2020, macOS.2020)
nethack --dumpenums (optional, but on by default)
Allow developer to obtain some internal enum values from NetHack
without having to resort to an external utility such as
makedefs.
Uncomment #define NODUMPENUMS in config.h to disable this.
The updates to sys/windows/Makefile.gcc have not been tested yet.
PatR [Fri, 20 Aug 2021 22:11:24 +0000 (15:11 -0700)]
potionbreathe's obj->in_use
potionbreathe() uses obj->in_use as a flag to inhibit wielded unholy
water from being dropped in case that gets broken against a monster
and triggers the hero to change from human were-critter to beast were-
critter. Reset that to zero if caller hasn't already set it to 1.
PatR [Fri, 20 Aug 2021 22:06:05 +0000 (15:06 -0700)]
ohitmon: obfree vs delobj
Make missiles that aren't launched by the hero and that hit a monster
use the routine that protects the Amulet and invocation items against
being deleted. I don't think there are any cases where this matters
because those items don't break when they hit something, but be more
cautious.
PatR [Thu, 19 Aug 2021 21:55:22 +0000 (14:55 -0700)]
delobj() rejection
If the Amulet or an invocation item refuses to be deleted, make sure
the retained object doesn't get left with its in_use bit set. I'm not
sure whether there are any cases where this matters.
PatR [Thu, 19 Aug 2021 20:08:22 +0000 (13:08 -0700)]
sanity check false positive for obj->nomerge
The luckstone in the Mines and the amulet of reflection or bag of
holding in Sokoban have their 'nomerge' bit set until they make
it into the hero's inventory. So don't complain about them when
sanity_check is enabled.
PatR [Thu, 19 Aug 2021 00:40:09 +0000 (17:40 -0700)]
when spellbook being read becomes cursed
Revisit a 3.6.1 fix. When the hero is occupied reading a spellbook
and something causes it to become cursed without interrupting (post-
Wizard harassment's malignant aura), always stop reading instead of
just when the book's bknown flag is already set.
PatR [Thu, 19 Aug 2021 00:17:14 +0000 (17:17 -0700)]
extended object sanity checking
When sanity checking is enabled, check objects for bits used as
temporary flags that should always be cleared by the time that a
sanity check pass gets made: o.in_use, o.bypass, and o.nomerge.
Also, fix glob checking. It was unintentionally placed within
the braces of ``if (obj->owornmask) { ... }'' so didn't actually
check globs except for the unlikely case when wielded in one of
the uwep/uswapwep/uquiver slots.
nhmall [Sat, 14 Aug 2021 19:36:54 +0000 (15:36 -0400)]
fix some VS warnings that recently appeared
..\src\explode.c(884): warning C4028: formal parameter 1 different from declaration
That one stems from commit 6b60618e0e.
Adjust the prototype in include/extern.h to match the function definition in
src/explode.c
Also, a recent update to the Microsoft Visual Studio 2019 causes the
compiler to complain while compiling a vendor c++ header (string) if
warning C4774 is enabled.
We force that warning to be enabled during the Makefile build, even though
it is not enabled by default.
Only do so in the Makefile.msc for c source files, and not for c++
(sys/share/cppregex.cpp).
See below for an example of the compiler complaint.
cppregex.cpp
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\string(530):
warning C4774: '_scprintf' : format string expected in argument 1 is
not a string literal
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\string(530):
note: e.g. instead of printf(name); use printf("%s", name); because
format specifiers in 'name' may pose a security issue
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\string(530):
note: consider using constexpr specifier for named string literals
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\string(583):
note: see reference to function template instantiation 'std::string
std::_Floating_to_string<float>(const char *,_Ty)' being compiled
with
[
_Ty=float
]
Pasi Kallinen [Sat, 14 Aug 2021 18:03:13 +0000 (21:03 +0300)]
Qt: Fix Qt5 deprecation warnings
Mostly the warnings were about QString::sprintf and QFontMetrics::width.
sprintf replacement is asprintf, which annoyingly behaves differently
from sprintf - it seems to append to the string.
Pasi Kallinen [Sat, 14 Aug 2021 10:33:04 +0000 (13:33 +0300)]
Fix eels hiding when a pool boiled off
Sanity check caught an eel hiding on floor; this was caused by
an exploding flaming sphere boiling off the pool the eel was
hiding in. The freezing water case was already handled, so
add the same, rather lackluster handling, to the fire case.
Michael Meyer [Wed, 11 Aug 2021 00:21:11 +0000 (20:21 -0400)]
Fix up msgs when dropping obj on trapdoor
Messages for dropping an object on a trapdoor or hole seemed to
imply they still operate by the rules of a pit (that any object on the
same square as the trap is automatically inaccessible). Since this is
no longer true for trapdoors and holes as of 1b7c372f, it seems
misleading to say an item "tumbles into the hole" even when it doesn't
fall through and stays on the current level.
Even for an item which really did fall through to the level below, these
messages were redundant since they were immediately followed by
near-identical messages from down_gate(dokick.c).
Limit the "tumbles into the pit" messages to pits only, and rely on the
standard down_gate message for items which fall through a trap door
or hole.
Michael Meyer [Wed, 11 Aug 2021 00:14:27 +0000 (20:14 -0400)]
Permit blind feeling for objects on trapdoor
Items on a trap door or on the edge of a hole are accessible (they can
be picked up, kicked, etc), but these locations were considered
inaccessible for purposes of feeling the ground for objects while blind.
nhmall [Sun, 8 Aug 2021 16:29:46 +0000 (12:29 -0400)]
header files sym.h and defsym.h
There were multiple symbol-related lists that had to be kept
in sync in various places.
Consolidate some of that into a single new file
defsym.h
with a set of morphing macros that can be custom-called from
the various places that use the sym info without maintaining
multiple occurrences. Most maintenance can be done there.
Rename monsym.h to sym.h since it looks after some
symbols not related to monsters now too.
The defsym.h header file is included in multiple places to
produce different code depending on its use and the controlling
macro definitions in place prior to including it.
Its purpose is to have a definitive source for
pchar, objclass and mon symbol maintenance.
The controlling macros used to morph the resulting code are
used in these places:
- in include/sym.h for enums of some S_ symbol values
(define PCHAR_ENUM, MONSYMS_ENUM prior to #include defsym.h)
- in include/objclass.h for enums of some S_ symbol values
(define OBJCLASS_ENUM prior to #include defsym.h)
- in src/symbols.c for parsing S_ entries in config files
(define PCHAR_PARSE, MONSYMS_PARSE, OBJCLASS_PARSE prior
to #include defsym.h)
- in src/drawing.c for initializing some data structures/arrays
(define PCHAR_DRAWING, MONSYMS_DRAWING, OBJCLASS_DRAWING prior
to #include defsym.h)
- in win/share/tilemap.c for processing a tile file
(define PCHAR_TILES prior to #include defsym.h).
PatR [Sat, 7 Aug 2021 00:59:53 +0000 (17:59 -0700)]
fix github issue #564 - unicorn vs displaced hero
Unicorns attempted to avoid being in direct line with the hero's
actual location even when displacement causes unicorn to think hero
was at some other spot. Change to avoid lining up with presumed
location even if that leaves the monster lined up with the hero.
While in mon.c, reorder the static function declarations near the
beginning of the file to match their order within it.
PatR [Thu, 5 Aug 2021 20:46:20 +0000 (13:46 -0700)]
description of stair destination for level 1 up
Having the opposite side of the stairs up from level 1 be unknown is
weird because the hero conceptually just came down those stairs at
the start of the game. But it's tricky because remote destination
varies depending on whether the Amulet is being carried. This gives
an accurate description of where the stairs lead (if you step on
them with the 'mention_decor' option On, or use the ':' command when
already on them).
|"There is a staircase up out of the dungeon here."
or
|"There is a branch staircase up to the Elemental Planes here."
It gives away a little information when carrying the Amulet, but not
much and anyone who gets that far deserves a break.