Commit Graph

9508 Commits

Author SHA1 Message Date
PatR
9326f80ecc lava_effects() bit
lava_effects() item destrunction had the logic for handling Book of
the Dead wrong.  (However, that didn't matter since the obj_resists()
check earlier would prevent it from being burned up.  Fix it anyway.)
2024-02-09 15:52:17 -08:00
PatR
381851348b fix #K4103 - crash after confused #loot of throne
If gold is moved into throne's coffer chest (or added to exchequer
monster's minvent) while quivered by the hero, it wasn't being unworn
to remove it from quiver slot.  That could lead to a crash.  Example
was segfault during 'f' command.

freeinv() expects caller to unwear item being removed from inventory;
reverse_loot() wasn't doing so.
2024-02-09 15:48:47 -08:00
PatR
bffa88b04e regions vs long worm tails
If any part of a long worm is within a posion gas cloud region,
include it just once no matter how many segments are inside.  The
tail will take harm from poison gas, but only once rather than for
repeated for every segment inside the region.

Unlike with detection, show long worm tail if hero is adjacent to
it in a gas cloud region and would see that tail segment if the
region wasn't inhibiting visibility.
2024-02-08 23:44:22 -08:00
PatR
ad8bcc6b3f comment typo of the day
I have no idea how this got in.  It's not just a typo; what's beyond
thinko?
2024-02-08 12:32:43 -08:00
PatR
fd5526db7c fix for #H9430 and github issue #1207 - gas clouds
Reported yesterday as issue #1207 by elunna and over four years ago
in #H9430:  monsters in gas clouds that should be shown by Warning
aren't.  And in some discussion of #H9430 back then:  monsters
adjacent to the hero while in gas clouds aren't shown on the map,
but combat and other interaction describes them as if they were.
There have been changes since then--to prevent seeing things on the
far side of gas clouds as if there were no clouds in the way--but
the basic problems with warning and adjacency weren't addressed.

This is a band-aid (tm) that probably makes things livable.  Don't
allow gas region display to override monsters that are sensed via
warning or when the hero is next to them.  That part doesn't work
correctly if the hero isn't blind and is inside the cloud while the
monster is adjacent but outside.  I think it will take more than a
band-aid to deal with that sensibly.

Closes #1207
2024-02-08 07:04:15 -08:00
PatR
5212e4b3db fix github issue #1204 - reflected poison gas
Reported by elunna:  a poison gas breath attack that was reflected
by the target still left that target enveloped in a poison gas cloud.

This makes the gas trail not extend to the target if the attack hits
and is reflected.  But if the attack misses then the cloud does reach
the target, which seems weird to me.  However, being in the cloud is
a separate event that isn't deterred by reflection.

Closes #1204
2024-02-07 11:58:12 -08:00
Pasi Kallinen
6b9f411a32 Accessibility: mon_movement
Adds a new boolean option, mon_movement. When hero notices monster
movement, give a message. Use with spot_monsters and accessiblemsg.
2024-02-07 19:50:38 +02:00
nhmall
1f255dcd03 comment bit 2024-02-06 15:03:59 -05:00
nhmall
a62ded6d28 ini_inv_mkobj_filter() bit
The try count of 1000 is never going to be reached.

The obj result, if it were ever to be reached, would have
been unfiltered and potentially incorrect.

There is no harm in having the result, in that theoretical edge
case, not be one of the obj values that was intended to be
filtered out.

No practical change results from this, and pancake was used
because it is innocuous.
2024-02-06 14:33:16 -05:00
nhmall
f6577e1989 update for --dumpenums
Include a value added back on January 11, 2024
2024-02-06 14:19:16 -05:00
PatR
dfdb6f0ab6 couple of comments in steal()
Teleporting due to loss of protection against water or lava isn't
the only way a visible thief might produce "It stole <item>" prior
to the fixup the comment explains.

The late comment about uball and uchain becoming Null was there to
explain why they weren't referenced when inserting the phrase
| (was_punished && !Punished) ? " removed your chain and" : "",
into "<Mon> stole a heavy iron ball."  That isn't there anymore so
get rid of the comment.
2024-02-06 10:46:01 -08:00
nhmall
3a9e53a629 issue #1205 - crash using the curses interface
curses_yn_function() was returning a value that wasn't in the
subset of legal return values. This fixes that.

The unexpected return value of 32 (or space) then brought to
light an indexing error in the core that's been there a while,
apparently since at least 3.2.0, and that caused a null pointer
dereference in a strlen() call, which is what actually caused
the crash in issue #1205. This fixes that too.

Close #1205
2024-02-06 13:12:04 -05:00
Pasi Kallinen
8c815d3bfa Init petattr in core, not in curses
My recent change to petattr caused a crash in curses when no
petattr was used in config file - because curses was setting
petattr to curses-specific value.  Init the setting in core
instead.
2024-02-06 08:50:16 +02:00
PatR
3466575fa1 handedness fix 2024-02-05 13:06:22 -08:00
PatR
163fb7613f fix theft of uball
Yesterday's commit to add a "<Mon> takes off <item>" during theft
of a worn item used uchain instead of uball when the item was uball.
That works as intended when uball is just carried, but if it is also
wielded, alt-wielded, or quivered then the pointers for those weapon
slots weren't updated (because uchain doesn't have the corresponding
owornmask bits set when removal performs unpunish()).  Check for that
and call remove_worn_item() again if necessary.

Also, the subsequent "<Mon|She> stole <item>" message was inserting
"removed the chain and" before "stole" when item is uball, but that
isn't needed anymore since the preface message "<Mon> takes off the
iron chain (attached to you)" will have just been given.
2024-02-05 12:57:13 -08:00
PatR
32e5c1df5c fix message sequencing when worn item is stolen
When a nymph or monkey successfully steals a worn item from hero,
first the item is unworn, side-effects of that take place (most
noticeably descending when losing levitation or flight) including
feedback about such side-effects, finally "<Mon> steals <item>" and
transfer from invent to thief's minvent.  If the side-effects were
fatal (such as drowning or burning up in lava), the player wouldn't
see any explanation for why that happened.

When a thief removes a worn item, give a message to that effect:
"<Mon> takes off your <item>."  That will usually be immediately
followed by "She stole <item>."  When the thief isn't a nymph or if
any messages were delivered after the "takes off" one, the monster
will be described by name:  "<Mon> stole <item>."
2024-02-05 01:14:36 -08:00
nhkeni
6b189fb0e1 Merge branch 'NetHack-3.7' of https://rodney.nethack.org:20040/git/NHsource into NetHack-3.7 2024-02-04 22:07:58 -05:00
nhkeni
aa8aa24d3b git glue memory leaks
- fix stack imbalances
- call panic() instead of nhl_error() if L==0 to prevent immediate crash
- drop unused argument prep in get_nh_lua_variables
- change nhl_pcall_handle to clean up stack after calling impossible()
- don't force full garbage collection runs
- don't collect garbage to do memory usage checking
- remove unnecessary stack resets
2024-02-04 22:07:05 -05:00
PatR
cae20175c3 fix "It stole <item>" if hero teleports to safety
Having an item that allowed being in/on water/lava be stolen could
result in the hero teleporting.  If the thief wasn't visible from
hero's new location, the message given was "It stole <whatever>."

Save the thief's name/description before removing the item and
potentially dropping hero into trouble and triggering teleport, then
use that in the eventual message.
2024-02-04 17:20:21 -08:00
PatR
061c2ab1b1 fix #K4098 - lava burns up item being stolen
Three months ago to prevent an "object lost" panic situation when
stealing an item that let hero survive water (several candidates)
would result in drowning, remove_worn_item() was changed to flag the
item being removed as in_use and emergency_disrobe() was changed to
avoid dropping in_use items while drowning.  That seemed to work ok.
But for lava instead of water, in_use is a flag to destroy the item
(set in advance, before issuing messages that can give the player a
chance to trigger a hangup save).  So instead of keeping the item
around for theft to finish, it was deallocating it.  steal() would
format the freed object and then access some of its fields, leading
to havoc.

This adds a hack to allow one item already flagged as in_use to be
treated differently by lava_effects() from the ones it flags for
destruction.  This also seems to work ok, but we may need to start
putting freed items on a deferred deallocation list similar to how
dead monsters are kept around for the rest of the current move.

The fix/hack has revealed two more bugs that this doesn't address.
An item being stolen is removed without any message, then if that
removal doesn't kill the hero a theft message is given.  The message
sequencing is wrong.  Flying hero who loses amulet of flying just
gets affected by lava; player is only told why after life saving.

The other issue is that life-saving from lava can teleport the hero
to where the thief can no longer be seen, yielding "It steals <item>"
even though "It" was visible when the theft started.
2024-02-04 15:40:00 -08:00
nhmall
e201184dd3 follow-up to 70b8bc04e for internal recover 2024-02-04 00:15:33 -05:00
Pasi Kallinen
0d7fc06eb9 Do garbage collection on luacore
Another lua state that is not freed until end of game,
so clean up the stack and do GC regularly.
2024-02-03 12:55:10 +02:00
Pasi Kallinen
e7a7526ea9 Minor code formatting 2024-02-03 10:56:16 +02:00
PatR
2d886dfcd8 fix #K4095 - race-specific food weight
Lembas wafers give more than normal nutrition for elves and less than
normal for orcs.  Cram rations give more that nomral for dwarves.  The
way that was implemented affected the weight of those items, at least
after they were partly eaten.  Polymorphing to or from any of the
affected races resulted in inconsistent partly eaten food.

Change how the nutritional bonus or penalty is applied so that there
isn't any affect on item weight.

I haven't incremented EDITLEVEL, so any wafers/rations with incorrect
weight in existing save files will continue to have that wrong weight.
I suppose that it matters more for bones files but even they should be
ok living with this instead of being forced to be thrown away.
2024-02-02 15:32:49 -08:00
Pasi Kallinen
fc0b61be60 Fix another wall_angle problem
Secret doors also need the correct wall_angle.
2024-02-02 18:41:45 +02:00
PatR
899cca50ef alternate fix for merge_choice() with Null invent
merge_choice() doesn't need the address of its list argument, just to
return Null if that list is Null.  Could have been solved by having
its callers check for Null invent and skip the call if necessary but
this is simpler.

Finishes reverting commit 378648bd9c.
2024-02-01 14:38:28 -08:00
PatR
16f4bdb5a6 Revert "fix crash on NULL gi.invent"
This reverts commit 378648bd9c.

The problem was triggered by marking the 'objlist' argument in
merge_choice() prototype with __attribute__((nonnull)) when it
shouldn't have been, then a followup which relied on that.  The
'objlist' argument might be Null.  Instead of passing its address to
force it to be non-Null, remove the attribute.
2024-02-01 14:25:23 -08:00
Pasi Kallinen
2a5a7160c9 Fix object weight when part of stack burns up on floor 2024-02-01 20:58:22 +02:00
nhmall
378648bd9c fix crash on NULL gi.invent 2024-01-31 12:51:33 -05:00
Pasi Kallinen
95e42bf692 Split out random trap type picking 2024-01-29 20:10:07 +02:00
nhmall
594eead50d pick_familiar_pm follow-up 2024-01-29 12:09:14 -05:00
Pasi Kallinen
97678379dc Split picking familiar permonst type 2024-01-29 19:00:25 +02:00
nhmall
0dfe92ac61 more italic support
There might be some follow-ups to this.
2024-01-29 08:40:05 -05:00
PatR
57c8ae4b9a add NONNULLARG6
Incorporate some inconsequential bits from the testing I've been doing.
2024-01-28 01:13:08 -08:00
Pasi Kallinen
fd8b2b58d1 petattr: Change accepted parameters, add support for tty 2024-01-28 10:05:42 +02:00
Pasi Kallinen
c497c14fda Split discovered sort and output lines 2024-01-27 19:47:42 +02:00
PatR
107c17efc4 yet another comment typo 2024-01-26 14:52:31 -08:00
PatR
9993fa97ec vision vs gas cloud dissipation
Reported directly to dev-team:  vapor cloud dissipation didn't always
update vision properly.

Region removal affecting visibility needs to make two passes, the
first unblocking all no longer blocked spots, then the second deciding
whether spots are visible.

Attempting to do that in one pass was doing
| unblock <x1,y1>
| if cansee <x1,y1> whatever
| unblock <x2,y2>
| if cansee <x2,y2> whatever
and the cansee <x1,y1> test wasn't accurate if <x2,y2> blocked it and
hadn't been unblocked yet.

Testing with steam didn't seem to trigger the problem but with poison
vapor trail from green dragon breath did.  The order of evaporation
mattered too; sometimes the single pass unblocking plus vision-testing
worked ok by coincidence.
2024-01-26 13:40:34 -08:00
PatR
524ae27c99 fake trap deaths
Eliminate the 'goto' for human corpse added a day or two ago.

If a dead gnome is generated with a candle, light it if/when the spot
is dark.  (Testing never managed to verify that this works as intended.)

mkcorpstat() never returns Null.
2024-01-26 12:52:52 -08:00
PatR
1bfde1eb6a itermonarr comments
Fix several typos/thinkos about 'itermonsiz' and remove an obsolete
remark about 'monarr'.
2024-01-26 11:57:01 -08:00
Pasi Kallinen
39fb072a92 Simplify rhack and parse
AFAICT, we only used the first char of the "command_line" string.
Just turn it into int to hold the key the main input loop parse() got.

Shouldn't have any functional difference.
2024-01-26 15:19:24 +02:00
PatR
17414c500a more monster iteration
Re-use the array allocated for iterating over all monsters during
monster movement much of the time.  It was being allocated from
scratch for each round of monster movement, then freed after they
moved, then repeated the next round.
2024-01-25 23:59:32 -08:00
PatR
9cd1a571ae more weight tweaks
Update some potential weight issues.  Eggs won't hatch when in
containers so they weren't affected but add some bulletproofing.
Corpse revival from inside containers was already ok too, so
effectively there's no change except for making container_weight() be
global instead of local to mkobj.c.
2024-01-25 23:09:12 -08:00
PatR
ec4691a859 fewer human corpses
When a low-level trap is created with a dead pseudo-adventurer,
usually make a player monster when the human case gets picked.

They have default level and no inventory.  They should probably be
given montraits that force low level but this doesn't do that.
2024-01-25 14:12:05 -08:00
nhmall
fa672fa1ba some utf8map corrections
Correct a color value and remove an unnecessary variable
2024-01-25 16:45:58 -05:00
PatR
4512e85e58 fix hero Strength
The recent acurr() changes introduced a bug that caused Str less
than 25 to be limited to 18/07.  25 was treated correctly as a
special case but 18/01 through 18/100 and 19 through 24 were not.
The cap of 25 imposed on the other characteristics is the same as
encoded Str 18/07.
2024-01-25 13:17:23 -08:00
PatR
500cbb0b11 comment typo 2024-01-25 12:20:00 -08:00
PatR
1c08982d56 Strlen_()
Restore its ability to reject a string longer than will fit within
size_t that was lost by moving away from strnlen().  Determine the
length inline rather than using strlen().

Move it from hacklib.c to alloc.c so that utility programs have easy
access, and remove the copy of it from dlb_main.c.

Fix a logic bug in str_start_is().  If a string was considered to
be too long, it exited the loop when n was 0 but also performed
post-decrement.  So after the loop, n would be -1 and the 'if (n==0)'
test would fail.  panic() would occur if the initial string matched
and happened to be LARGEST_INT-1 characters long.
2024-01-25 12:16:39 -08:00
Pasi Kallinen
47fa2eb000 Split kicking non-door terrain out of dokick 2024-01-25 21:43:55 +02:00
PatR
4be4f55ccf some reformatting for utf8map.c
and a few omitted 'const's for some constant pointers to constant
characters.

utf8map.c is missing date, branch, and revision tags on its first line.
2024-01-25 11:22:01 -08:00