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.
PatR [Thu, 5 Aug 2021 19:32:30 +0000 (12:32 -0700)]
fix engraving with miscellaneous items
Reported directly to devteam: when selecting an item to engrave
with, "getobj refactor"'s stylus_ok() classified none-of-the-above
objects as not viable instead of allowing arbitrary things to
engrave in the dust or give specific can't-use-that messages like
for food. Make the suggested fix: change default result when
checking an inventory item for applicability from GETOBJ_EXCLUDE
to GETOBJ_DOWNPLAY.
Engrave feedback rather than getobj selection: splash of venom
isn't necessarily wizard mode-only so don't reject attempting to
engrave with it as using an illegal object. And remove the extra
question mark from its "poison pen" message.
PatR [Wed, 4 Aug 2021 20:26:56 +0000 (13:26 -0700)]
wizard mode light source bug
In wizard mode if you're already polymorphed and you choose your
role's form when polymorphing again, polyself() calls rehumanize()
to restore your original shape. rehumanize() turns off any light
the hero is emitting from polymorph form. After it returned,
polyself() then tried to do the same thing based on a cached value.
If the previous form had been emitting light, that resulted in an
impossible() warning "del_light_source: not found type=1, id=N".
Couldn't happen in normal play because a request to polymorph into
any role monster is usually rejected; it's only honored in wizard
mode for current role. Noticed when testing something while in
gold dragon form but this bug predates addition of that monster.
Clear the cached value when rehumanize() returns to polyself().
PatR [Tue, 3 Aug 2021 00:44:03 +0000 (17:44 -0700)]
diagonal movement glitch
|..X..
|.X}X.
|..X..
When testing the odd Samuari moats, I discovered that you could
easily walk diagonally between any two of the solid stone pillars
and fall into the water but you would always drown because it's a
no-teleport level and the crawl routine wouldn't let you back out
via that same diagonal.
The crawl routine is also being used by travel for the last step--a
post 3.6 change--so there was an unnecessary restriction on diagonal
movement there too.
PatR [Tue, 3 Aug 2021 00:40:28 +0000 (17:40 -0700)]
Samurai "moat"
Samurai home level has two isolated moat spots, each within a set
of four solid stone pillars (depicted here as 'X' instead of blank).
|..X..
|.X}X.
|..X..
Having them be described as "moat" looked pretty silly. Keep them
moat but special case their description to be "water". It would be
simpler to change them to be pools, but that would make a slight
change in behavior (pools can be boiled away to become pits, moats
can't; probably should have made the simpler change anyway...).
New routine known_branch_stairs() was performing two different things
and was unnecessarly complicated because of that. Split off newer
routine stairs_description() to handle one of those.
Noticed while testing the stair labeling, knowing the teleport away
spell (and without innate teleport ability--not sure whether that's
a factor), using ^T always attempted to cast the spell, even if you
used m^T to explicitly request wizard mode telport on demand. Since
my samurai had no chance to cast such a high level spell, I couldn't
use ^T any more.
With a different character, I ended up with 15(2) energy after a ^T
attempt failed. I've put in a fix for this but after the other one
I don't think it matters.
First cut at displaying branch stairs/ladder up/down as ordinary
stairs/ladder up/down if the destination hasn't been visited yet.
Stepping on stairs with 'mention_decor' enabled, or using ':' when
already on them, will report regular stairs' destination level.
Probably not very useful since it's just N+1 for downstairs or N-1
for upstairs when currently on level N.
It's based on whether the destination level has been visited, not
on whether the stairs have been traversed, so reaching a level via
trap or level teleporation can make the level's stairs known when
their destination really shouldn't be discovered yet.
For the hero, a worn alchemy smock confers both poison resistance
and acid resistance. For monsters, it was only conferring poison
resistance. Change ut to add acid resistance too.
Pasi Kallinen [Wed, 28 Jul 2021 16:11:30 +0000 (19:11 +0300)]
Start of movement tests
Adds the following lua functions:
- nh.pushkey("x")
Pushes a key into the command queue. Support is spotty,
currently only the keys handled in rhack.
- nh.doturn()
Runs one turn of main loop, or if optional boolean param
is true, until g.multi == 0
- nh.monster_generation(false)
Disable monster generation, and kill off all monsters.
Adds a testmove.lua script to test hero movement. Currently
covers only hjklyubn and HJKLYUBN.
Michael Meyer [Thu, 22 Jul 2021 00:07:28 +0000 (20:07 -0400)]
Fix: crash when appending to long engraving
If an engraving was appended to repeatedly, it could eventually exceed
BUFSZ and cause a crash. Add some checks to prevent this from happening
and inform the player when she runs out of space to engrave on a
particular square.
From 8 or so years ago, hitting a disenchanter without wielding a
weapon and without wearing gloves while wearing a possitively
'charged' ring should reduce the ring's enchantment. This doesn't
fix that, it just adds a brief comment about it.
fix #H2797 - avoid "vision clears" if hero can't see
From 8 years ago, sitting on a throne and getting the confers-see-
invisible result gave "your vision becomes clear" message even when
hero was blind (who stays blind at the time). Give an alternate
message if hero is blind, with another alternate when the blindless
is due to being poly'd into something without eyes.
From the newsgroup 6.5 years ago,
| Subject: Re: Reviving drowned pets impossible
if you displaced your pet into water and it drowned, it would never
leave a corpse. That seems to be moot these days because a pet or
peaceful monster which would drown will refuse to swap places, but
change corpse handling anyway.
From a 7 or 8 year old bug report from a beta tester. A pyrolisk's
gaze against a mimic didn't unhide that mimic. Somewhere along the
line that has been fixed, but some apparently redundant code inside
'if (visible)' should be done even when not visible.
Put the flag that parse() uses to tell readchar() that the next
keystroke is a command into the program_state structure instead of
having it be a static variable in cmd.c. Conceivably an interface
could make use of it, and even if none do, it is program state....
Pasi Kallinen [Tue, 27 Jul 2021 14:11:02 +0000 (17:11 +0300)]
Add colored branch stairs
Different color for stairs that go to another dungeon branch.
Adds four new glyphs, S_br{up,dn}{stair,ladder}, which use the
same character as normal stairs/ladders, but yellow color.
In tiles, the up/down arrow is yellow-green instead of while-blue.
This feature has been around a lot and is in several different
variants, but this is implemented from scratch so tiles work too.
Setting the 'altmeta' option affects how ESC is handled. Normally it
is for terminals/emulators which transmit two character sequence ESC c
when the user types Meta+c, but it can also be used to construct meta
characters 'manually' by typing ESC c. Unfortunately setting this
option has a side-effect of requiring a second character after ESC
before our readchar() will return, so it is only honored when parse()
wants the next command, not for general input.
When readchar() was recently split into two parts, the use of static
variable 'alt_esc' by parse() and readchar() was removed. That
resulted in requiring the user to type a second character whenever
ESC was typed, instead of just when it was transmitted or typed as
the prefix of a command that uses a meta-character keystroke.
Instead of just putting 'alt_esc' back, do things differently by
adding static 'getting_cmd' flag instead.