Commit Graph

604 Commits

Author SHA1 Message Date
RainRat
2787bfdcbd Merge branch 'NetHack:NetHack-3.7' into NetHack-3.7 2024-04-10 23:26:14 -07:00
nhmall
46370fc124 another follow-up: move values that can't be indexes
Move the values that are not legal mons indexes out of the default
handling case in make_corpse().
2024-04-10 11:34:41 -04:00
nhmall
125208d30b follow-up bit to explit mon entries in make_corpse() 2024-04-10 11:29:31 -04:00
nhmall
a85cd7d5c8 let compiler catch missing additions during development
Take advantage of the ability of some compilers to warn if
not all values are covered in a switch statement, to draw
attention to the need to update make_corpse() when new
monsters are added to NetHack.

This adds explicit entries for the current "default" handling
in make_corpse().

It might be a good idea to review the explicit entries to see
if any of them represent others that are not being handled,
but should be.

To test this, I temporarily reverted 85c86444, and I did receive the
following warning:

mon.c:545:13: warning: enumeration value 'PM_GOLD_DRAGON' not handled in switch [-Wswitch]
  545 |     switch (mndx) {
      |             ^~~~
1 warning generated.
2024-04-10 11:07:40 -04:00
RainRat
7656804ae9 fix typos 2024-04-10 00:46:21 -07:00
Pasi Kallinen
85c8644469 Gold dragon should drop scales 2024-04-09 08:40:56 +03:00
PatR
f16a5f49ed mfrozen sanity check
Add another monster sanity check case:  if a monster has the mfrozen
counter set to non-zero, make sure that mcanmove is zero.
2024-04-06 18:59:45 -07:00
Pasi Kallinen
f0fdd3c371 Make hero polyed into fog cloud emit clouds
Also prevent cloud creation giving a message, if it was a single
cloud on hero and deals no damage.
2024-04-04 12:17:44 +03:00
Pasi Kallinen
defb5d5f80 Pets considered any noise made by hero as whistling
In 3.6.2 parts of the wakeup code were merged together, and this
caused pets consider any noise made by the hero - such as hitting
iron bars or digging - as whistling for them to come to the hero.

Change it to only consider actual whistling and ringing a bell.
2024-04-03 12:46:15 +03:00
nhkeni
9c0ed8ae63 NOSTATICFN for src/* 2024-03-14 17:41:51 -04:00
PatR
1922dd96eb theme room vampire fix
From a reddit thread:  a 'mausoleum' theme room picked a vampire for
its occupant and applied the wait-for-you strategy to it.  Hero's ESP
or monster detection showed a meditating vampire bat.  Change monster
creation by the special level loader (which also handles theme rooms)
to force such a creature into its normal vampire form.

That revealed an older bug which wouldn't have been exercized prior
to theme rooms:  a meditating vampire could and would shape change
without ceasing meditation.  Make it not shape change rather come out
of its trance.
2024-03-11 17:40:01 -07:00
RainRat
a3658f85ac fix typos 2024-02-28 20:15:56 -08:00
nhmall
0a985459f0 make style consistent for function ptr arguments 2024-02-19 17:21:04 -05:00
nhmall
688ac6ffbe remove register from variable declarations 2024-02-19 16:30:07 -05:00
PatR
107c17efc4 yet another comment typo 2024-01-26 14:52:31 -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
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
nhmall
8aadfd794c comment updates
The comments referred to the function pointer variable before those
changed names, so this assumes that they still should.
2024-01-24 18:51:12 -05:00
PatR
78252de3bc fix memory leak in iter_mons_safe()
While hunting for a memory leak in object allocation--which I haven't
found yet--I discovered one in monster movement.  iter_mons_safe()
allocates an array of (monst *) pointers for the monsters on the
current level, loops over that array to call a function for each
one, then frees the array.  But if the game ends while that called
function is running, execution never returns to iter_mons_safe() so
it wasn't able to free the memory.

Since that can happen at most once per game, it wasn't a signifcant
leak.  This fixes it anyway.

There was a second issue:  make sure that iter_mons_safe() doesn't
call alloc(0) to make the temporary array for zero monsters when
there aren't any on the level.  That might not be able to happen for
monster movement but the routine is written to be more general than
just movement.  alloc(0) could confuse the MONITOR_HEAP code.  In
C89/C90 I think malloc(0) is allowed to return NULL (don't recall
for sure; maybe that was just known pre-standard behavior for some
implementations).  Null return would trigger a panic even without
MONITOR_HEAP.  Don't know about C99 and later.
2024-01-23 23:04:06 -08:00
Pasi Kallinen
829f9f65f7 Split out harmless-to-monster trap
Also make the code much easier to understand, and
more-or-less match hero trap triggering.
2024-01-23 19:01:34 +02:00
Pasi Kallinen
57747535af Add m_next2u, analogous to m_next2m and next2u 2024-01-19 21:53:25 +02:00
nhmall
25a8c258e6 replace x >= LOW_PM with ismnum(x) shorthand macro 2024-01-11 14:01:10 -05:00
Michael Meyer
f930a12fba Make erinyes scale with alignment abuse
Consistent with their mythological role of punishing those who had
violated societal taboos -- oathbreakers, hosts who attacked their
guests, etc -- erinyes scale with the cumulative amount of alignment
abuse the hero has committed over the course of the game.  This is
tracked separately from the alignment record, and cannot be cleared by
the hero improving her favor with her god via "good deeds" as the normal
alignment record can.  Erinyes will gain abilities, levels, and attacks
as the hero's alignment abuse worsens.  They will also aggravate
monsters when near the hero.
2024-01-10 22:57:10 -08:00
PatR
83bdf71932 pull request #1175 - obj->corpsenm fixes
Pull request by mkuoppal:  some objects which use the corpsenm field
to access the mons[] array can have a corpsenm value of NON_PM (-1)
and weren't avoiding array access in those cases.

In addition to a fixes entry for it, this makes some revisions to the
commited code, handling a few of the cases differently.

Closes #1175
2024-01-06 15:13:31 -08:00
Mika Kuoppala
4f15e134fc src/mon: Avoid addressing with invalid corpsenm in mstoning
corpsenm can be -1 (for EGGs and TINs) so touch_petrifies
using this as index would point to bad entry.

Fix this by making mstoning as helper function and bailing
out early if corpsenm <= LOW_PM (while keeping MEDUSA as is)
2024-01-06 12:06:54 -08:00
PatR
21068b05c5 fix github issue #1192 - engulfers vs iron bars
Issue reported by Umbire:  an engulfing monster capable of passing
through iron bars (vortices and air elemental) could do so while
carrying the hero.

Prevent an engulfer from doing that unless the hero happens to be
polymorphed into a subset of the types of monsters that can move to
iron bar locations.

Fixes #1192
2024-01-05 16:15:30 -08:00
nhmall
4e19221e55 variable 'display' causes shadow variable warnings in X11 build
display.botl      -> disp.botl
display.botlx     -> disp.botlx
display.time_botl -> disp.time_botl
2024-01-05 05:58:51 -05:00
nhmall
49a5d043c0 consistent use of TRUE vs 1 with botl and botlx 2024-01-04 23:48:38 -05:00
nhmall
22e52ee905 bundle the display-related hints, that tell bot() and others
that an update is required, into a struct. Remove it from
context since there is no reason to save those.
2024-01-04 23:16:27 -05:00
Pasi Kallinen
dc8d9d6cd0 Accessibility: Add location info to messages
Adds a new boolean option, accessiblemsg.  If on, some game messages
are prefixed with direction or location information, for example:

   (west): The newt bites!
   (northwest): You find a hidden door.

I added the info to the most common messages, but several are
still missing it.
2024-01-02 18:59:25 +02:00
PatR
cd91d0630b github issue #1180 - humans and murder
Issue reported by Umbire:  reviving a human corpse into a human
monster and then killing it entails murder penalty even when it is
hostile.

This is probably a non-issue.  Human monsters tend to not leave
human corpses, they leave shopkeeper corpses or sergeant corpses
and so forth.  Most human corpses created in normal play have
montraits attached and revive as a zombie, mummy, or vampire rather
than as a human.

This doesn't attempt to be clever, it just treats PM_HUMAN like
role monsters, not subject to 'murder'.

Closes #1180
2023-12-30 17:10:39 -08:00
nhmall
fbf8e0d5bc static analyzer warnings for mon.c
src/mon.c(2370): warning: Dereferencing NULL pointer '((mtmp2))->mextra->epri'.
src/mon.c(2375): warning: Dereferencing NULL pointer '((mtmp2))->mextra->eshk'.
src/mon.c(2380): warning: Dereferencing NULL pointer '((mtmp2))->mextra->emin'.
src/mon.c(2385): warning: Dereferencing NULL pointer '((mtmp2))->mextra->edog'.
src/mon.c(4419): warning: Dereferencing NULL pointer 'ga.animal_list'.
2023-12-24 00:36:21 -05:00
nhmall
c3ce08b794 NO_NONNULLS -> NO_NNARGS
I find:
    extern char *an(const char *) NONNULL NO_NNARGS;

slightly better than this:
    extern char *an(const char *) NONNULL NO_NONNULLS;
2023-12-20 22:26:16 -05:00
nhmall
07ef4583ce functions passed a chain explicitly NO_NONNULLS
Some functions are passed an obj or monst chain,
and  the callers typically don't check them
against 0, so mark them explicitly as NO_NONNULLS

(NO_NONNULLS expands to nothing, but it flags that
some null arg analysis has been done)
2023-12-20 18:48:50 -05:00
PatR
a7db78f7d6 fix #K4060 - "you walk quietly" while riding
Donning elven boots while riding and not already stealthy, you'd get
the message "you walk quietly" when not walking at all.  Instead of
just changing the message, make riding a non-flying steed block
stealth.  Riding a flying steed (or one you take aloft with an amulet
of flying) does not.  It would have been quite a bit simpler to have
made riding anything block stealth, but the hard part is done.
2023-12-10 22:09:26 -08:00
PatR
c41cb1a7fa source reformatting
Fixup some of the inconsistently formatted code that has been
introduced recently or been building up for a while.  Done manually.
I wasn't systematic except for looking for lines ending in '&' or '|'
(which wouldn't find such things if they're followed by a comment)
so there might be lots more.  I changed a bunch of C++-style //...
comments to old style C /*...*/ so that they'll match the rest of
the core's code rather than because they shouldn't be used.
2023-12-08 00:30:10 -08:00
Pasi Kallinen
d2ae6fd5d2 Split out wizmode monpolycontrol part 2023-12-08 08:32:07 +02:00
nhmall
12ca2be5b4 more fixes via monsym() 2023-12-07 09:55:37 -05:00
nhmall
ee3ebcc10d fix bug in mon.c reported by paxed
Also adds a shorthand macro
    monsym(&mons[n])
for getting the default symbol, used in the bugfix.
2023-12-06 22:18:11 -05:00
Alex Smith
39a7dc1c52 Most monsters no longer deathdrop comestibles other than their corpse
Playtesting has shown that there is too much permafood in the game
at present: in the late-game the only food-related problem is how
much to carry in order to avoid burdening yourself. In the early
game, food could previously have been a problem prior to
Minetown/Sokoban (thus the recent commit to add a guaranteed ration
in the upper dungeons), but past that point, there is easily enough
food generated on the ground. Additionally, the recent commits to
make healing sources more available in the early game reduce the
amount of time that needs to be spent waiting to heal, thus
further reducing food requirements.

The main purposes of food as a mechanic are to given an incentive
to press onwards and to discourage grinding. However, if monsters
are deathdropping non-corpse permafood, then beyond the very
early game, grinding actually generates more food than it uses up,
so the nutrition mechanic doesn't do its job properly.

Playtesting (including a full ascension!) has shown that there is
still plenty of food available even without deathdrops available
(my test game had 8 spare non-deathdrop food rations upon reaching
the Castle, at which point nutrition is no longer an issue due to
the Castle food stores and the huge numbers of C- and K-rations
dropped by the soldiers). I will address the potential problems
this causes for vegetarian Monks in a future commit.
2023-12-02 08:18:01 +00:00
Pasi Kallinen
a30a205c45 Fix sanity error with migrating monster 2023-12-01 22:15:10 +02:00
nhmall
d064ac2cda more cast style consistency 2023-11-13 20:31:02 -05:00
Michael Meyer
a69ff06e85 Make mstate flag checks more mutually consistent
Various places checking for whether a monster was on the map based on
mstate flags were inconsistent about which ones they checked (and then
place_monster() was additionally inconsistent with all of them about
which bits were cleared when placing a monster onto the map).  I think
some places were also more convoluted than is now necessary because they
date back to mstate being an alias for mspare1, which it shared with
migflags before those became two separate dedicated fields (MSTATE_MASK
also dates back to this and is no longer used, so I removed it).

I tried to go through all the MON_foo mstate bits, understand when/why
they are set, and make the various functions I noticed more consistent
(with each other, and with my understanding of how the bits work) about
how they are treated.  I don't know for a fact that I understood
everything right -- some diagnostic bits that aren't used for much of
anything, like MON_OBLITERATE, had me mystified until I read the 5ee78c5
commit message -- but this patch hasn't caused any new problems (sanity
check or otherwise) with the fuzzer in my testing so far.  All the same,
it could probably use review by someone who has a good sense of what the
mstate bits mean.
2023-11-08 10:41:40 -08:00
Michael Meyer
98d2b0ecb3 Follow up on disturbing buried zombies
Change 852f8e4 by requiring a minimum impact before a buried zombie
nearby will be disturbed: light, but still excluding things like
scrolls, if it's a violent impact (dropped while levitating, thrown, or
kicked), and fairly heavy if the hero is just placing the item on the
ground normally.

Moving the call out of flooreffects meant it no longer applied to
pushing boulders around, so have moverock disturb nearby zombies.  I
additionally had wake_nearby do the same thing.

Finally, I renamed check_buried_zombies (which doesn't really reflect
what it does) to disturb_buried_zombies.
2023-11-05 21:51:45 -08:00
nhmall
6cbefc7c2d Revert "granular verbose message suppression mechanics"
This reverts commit be76727265.
2023-10-29 20:39:07 -04:00
Pasi Kallinen
638c487c59 Split deadbook undead pacify effect into separate function
Also make the monster chain iterator functions more robust,
in case the called function changes the next monster pointer.
2023-10-28 19:01:46 +03:00
Pasi Kallinen
72016b1f17 Don't iterate over off-map monsters 2023-10-16 11:28:01 +03:00
Pasi Kallinen
9b4eaafe8c Fog clouds maintain any gas clouds 2023-10-02 13:05:15 +03:00
Pasi Kallinen
cf0eb8dfa0 Steam vortices leave steam clouds behind
Code via xnethack by copperwater <aosdict@gmail.com>
2023-10-01 20:30:54 +03:00
PatR
c868feb383 impossible "ceiling hider hiding without ceiling"
Reported by a hardfought user, a ceiling_hider monster hid on the
Astral level, triggering a sanity check warning that gets repeated
each move until the hider comes out of hiding.  Normally sanity_check
can only be set in wizard mode, but hardfought must force it on for
to-be-3.7.

I was able to reproduce it before this fix and unable to do so
afterward, but there is a random factor involved hence no guarantees.
I think that lack of ceiling for Astral is recent, but this could
have happened on other levels which lack a ceiling.  I didn't try to
figure out whether it might happen with 3.6.x, just put the fixes
entry in the "exposed by git" (found in code not yet released, that
is) section.
2023-09-21 14:17:01 -07:00