Commit Graph

16977 Commits

Author SHA1 Message Date
Pasi Kallinen
30d2eeea41 Accessibility: more monster message locations, pt 2 2024-06-13 19:41:41 +03:00
Pasi Kallinen
6c1a883f90 Accessibility: more monster message locations 2024-06-13 19:27:34 +03:00
Pasi Kallinen
a72b95e4bc Accessibility: more message locations
Add a new pline_mon() which sets the message location
to the monster location.

Add locations to several trap messages.
2024-06-13 19:04:33 +03:00
nhmall
a86b9e6899 update tested versions of Visual Studio 2024-06-13 2024-06-13 09:05:01 -04:00
PatR
73f46845ca refine wizard mode throne #sit 2024-06-12 12:35:08 -07:00
PatR
9896a81d6c wizard mode control of throne sitting outcome
When debugging, allow player to choose which outcome for #sit on a
throne (just 1 to 13; no menu; player has to check source to figure
out what the values mean).  Also when the chance to use up the throne
afterward comes up, prompt whether to honor it (similar to drying up
a fountain).

Added to ease testing for github issue #1250 but I still haven't been
able to produce anything odd with ^A after #sit whether or not it was
preceded by a counted action that got interrupted before the count
expired.
2024-06-11 14:15:33 -07:00
PatR
b9baaeb139 comment thinko 2024-06-10 12:09:19 -07:00
nhmall
d04c0f00ed follow-up bit (from leading tab replacements) 2024-06-10 11:02:52 -04:00
nhmall
588b3ae92f replace some leading tabs that had crept in 2024-06-10 10:57:59 -04:00
PatR
bc897ac69c fixes entry type fix, plus expansion 2024-06-09 14:30:40 -07:00
PatR
05cbbc7181 fix PR #1254 - avoid signed integer overflow
Pull request from mkuoppal:  avoid integer overflow when user types
digits and they're combined into a number by successively multiplying
intermediate value by 10 and adding new digit.  Needed to avoid
triggering undefined behavior if the value overflows the largest
signed integer (actually long int).

This is a much more general fix than the code in the pull request,
which imposed an arbitrary limit for one aspect of tty input.

I'm not convinced that integer.h was the right place to add the new
AppendLongDigit() macro.  I may not have caught all the places where
it is needed.  files.c accumulates a value from digits but uses
unsigned int, so overflow won't trigger undefined behavior (although
it presumably ends up with a different value than what was intended).
options.c and coloratt.c accumulate smaller integers and have a limit
on the number of digits they'll use, so can't overflow.

Fixes #1254
2024-06-09 14:17:14 -07:00
PatR
50e9b7f404 out of date 'struct gi' bit 2024-06-09 11:17:54 -07:00
Mika Kuoppala
20f8af224b hints/linux.370: Add support for ubsan (undefined behaviour sanitizer) for gcc
This will add an option to compile and link nethack executable
with ubsan and catch undefined behaviour errors on runtime.
2024-06-09 09:34:57 -04:00
PatR
6718a8af1f fire_damage() vs containers
Containers can't become fireproofed so the line of code in
fire_damage() which tested for that led to confusion.

Also, add missing handling for statues as containers.
2024-06-08 15:22:08 -07:00
PatR
304f18ae16 gdb vs 'gi'
I was trying to examine gi.invent (via
  print ((struct instance_globals_i *)&gi).invent
don't ask...) and gdb gave me very confusing rejections that don't
occur with other g<letter>.variables.  It turned out that gdb was
treating 'gi' as a type rather than as a variable reference.

I suspect it was because Qt was included so linking used C++ mode,
and C++ handles struct names differently from C.  Anyway, renaming
'struct gi' to 'struct glyphinfo' made the mystery problem go away.
2024-06-08 15:04:28 -07:00
PatR
d7008f8fe5 fix #K4189 - dorecover() bug
Restoring was hiding unhidden mimics and if that chose an object
other than boulder of gold pieces, it called mkobj() before an
array used by that routine was initialized.  The result was warning
"rnd(0) attempted" when NH_DEVEL_STATUS wasn't set to 'released' or
divide by 0 crash if it was set to that.

Restore should not be catching up for lost time when unpacking a
save file into individual level files, and if it hadn't done that
it wouldn't hide mimics who aren't currently hidden.

In addition to avoiding that, this also moves the initialization of
the offending mkobj array sooner.

[3.6 didn't use that array so wasn't susceptible to this.  It is
hiding unhidden mimics during what should be a strictly bookkeeping
operation though.]
2024-06-08 13:34:12 -07:00
PatR
d02028fe66 more issue #1253 - shape change vs Eleberth
I happened to restore a save file left over from testing yesterday's
attempt to fix github issue #1253 and had a werejackal change from
human to beast while next to my hero on "Elbereth", then attack me.

This should be sufficient to prevent that.  I'm not sure why the
previous fix attempt seemed to be adequate when testing it.  The new
fix relies on the previous one.
2024-06-05 22:58:44 -07:00
PatR
cfb053157a fix github issue #1253 - shape change vs Elbereth
Issue reported by chadministratorwastaken:  were-creature that was
ignoring Elbereth while in human form would make one more attack
after changing into creature form.

Have new_were() make an onscary() check when changing to beast form
while next to the hero.  Do likewise for polymorphing creature.

Fixes #1253
2024-06-04 23:59:39 -07:00
PatR
8652262105 DEBUGFILES
Fetching a value of DEBUGFILES from the environment to enable
debugpline() messages was intended to operate in wizard mode only
but that wasn't enforced.
2024-06-04 14:53:17 -07:00
PatR
cf2a97dea4 tty invisible cursor
Make the cursor visible when performing a shell escape or pushing
nethack into the background.
2024-06-04 14:45:00 -07:00
nhmall
16ac21297a update tested versions of Visual Studio 2024-05-04 2024-06-04 07:45:23 -04:00
nhmall
8b0ea3f204 remove inappropriate PDCURSES use of stdin,stdout
Use of stdout and stdin was inappropriate for general curses.
Windows GUI links with PDCURSES wingui code.
2024-06-04 06:46:25 -04:00
PatR
6f8ed4c589 tty_curs() again
Honor the objection to an earlier change to tty_curs(), despite the
fact that it seems delusional.  Four integer comparisons per cursor
positioning call affect the throughput of cmov(), but only if the
program is built without DEBUG defined?
2024-06-03 23:23:14 -07:00
PatR
ad0153a328 tty_curs() debugpline()
More analyzer induced hackery.  If tty_curs() discovers that the x,y
passed to it are no good, don't use them, even if that results in
the next output being in the wrong place.

The old issue of behaving differently when built with DEBUG defined
versus when it is not defined is fixed in a different way.
2024-06-03 14:20:21 -07:00
PatR
2ab477459f DEBUGFILES setup
Check getenv("DEBUGFILES") unconditionally during startup rather
than waiting until it's needed.

Might prevent the static analyzer from getting so aggravated.
Most likely not though, but should make debugpline() less fragile
if it gets called during a panic or a signal.
2024-06-03 14:16:49 -07:00
PatR
61d3cce4b8 fix static analyzer complaint in remove_room()
Since croom and maxroom both point to elements in the rooms[] array,
the complaint that the memcpy() in

| if (croom != maxroom)
|  memcpy(croom, maxroom, sizeof (struct room));

might have overlapping source and destination is bogus.  The fix is
trivial but not vetted by the analyzer.
2024-06-03 09:28:38 -07:00
Pasi Kallinen
4e29c9b282 Fix eating non-pyrolisk egg effect 2024-06-03 17:40:50 +03:00
Pasi Kallinen
2bec685bae Pyrolisk eggs explode when broken 2024-06-02 10:50:58 +03:00
PatR
d8aa4c0b1f still more brides of Dracula
Another tweak to PR #1240.  Vampires start out vampshifted to
bat/fog/wolf form.  Marking them as 'waiting' forces them back to
vampire form.  Testing that revealed one of the brides as a vampire
lord rather than a vampire lady.  That could probably be construed
as being politically correct but doesn't match the source material.

The reversion from vampshifted to vampire entailed a 10% chance of
toggling gender, comparable to hero self-polymorph.  Don't do that
for vampires.  From the player's perspective they change randomly but
from their own perspective, the change is controlled.
2024-06-01 02:08:06 -07:00
PatR
30f5f0055d more Brides of Dracula
Extend PR #1240 by giving the three brides names.

It looks a bit odd when they're in bat/fog/wolf form rather than in
base vampire lady form but I think that we can live with that.
2024-05-31 11:06:22 -07:00
Kestrel Gregorich-Trevor
d956ab502d pull request #1240 - Brides of Dracula
In the original Bram Stoker novel, Dracula has three brides,
colloquially referred to as the [Brides of Dracula]
(https://en.wikipedia.org/wiki/Brides_of_Dracula).  I thought it would
be a nice touch for NetHack to quietly reflect this by ensuring three
of the vampires of his court are vampire ladies.  While this
technically increases the difficulty of Vlad's Tower, the vampires in
Vlad's court are not necessary to fight, and the experience level of
a hero at this point in the game is likely to cause them to spawn as
vampire lords or ladies in any case.

No established names exist for these characters, so I have left them
unnamed.

[Cherry picked rather than merged into order to reformat the commit's
log message.  PatR]

Closes #1240
2024-05-31 10:38:05 -07:00
PatR
2caa26a24a pull request #1228 - mon_escapes()
Pull request from argrath:  split monster escaping from the dungeon
via the stairs on level 1 into a separate function.

Closes #1228
2024-05-31 10:29:44 -07:00
SHIRAKATA Kentaro
ce9abbc52d split monster escaping the dungeon into separate function 2024-05-31 10:27:31 -07:00
PatR
914744665b pull request #1168 - nothing_special()
Pull request from argrath:  replace 'goto nothing_special' with calls
to new routine nothing_special().

Needed some conflict resolution from 'git rebase' after sitting for
such long time.

Closes #1168
2024-05-31 10:16:54 -07:00
SHIRAKATA Kentaro
c68f870819 split 'nothing_special' of arti_invoke() into separate function 2024-05-31 10:15:25 -07:00
PatR
34d6c3cf7c github PR #1185 - refactor give_u_to_m_resistances
Pull request from entrez:  redo the code that confers intrinsics
acquired by dying hero to the monster it becomes in bones.

Closes #1185
2024-05-31 09:52:50 -07:00
Michael Meyer
4ac8241917 Use a macro for all foo_RES to MR_foo conversions
This makes it easier to understand what is happening in each of those
places, and also much easier to find the places that conversion between
hero and monster resistances happens (since you can now just grep for
"res_to_mr").  I think I got all the instances where the macro should be
used but I'm not 100% sure since there wasn't a single unique term to
search for to find them all.

I replaced the modifications to give_u_to_m_resistances made in the
previous commit, so that it now uses the same macro as other
conversions, since otherwise it would be much harder to find the
complete list of places where conversions between hero and monster
properties happen.
2024-05-31 09:23:20 -07:00
Michael Meyer
a71866d7d9 Refactor (very slightly) give_u_to_m_resistances
I think that using two arrays in tandem like give_u_to_m_resistances
originally did is frequently considered a bad idea, because one can
easily be added to or subtracted from without modifying the other --
that could obviously cause problems.  Combining the arrays like this
avoids that potential problem.
2024-05-31 09:23:20 -07:00
Pasi Kallinen
2ba42cf78c Fix accessing freed landmine trap
Landmine blew up, scatter exploded a potion of oil, which melted
the ice on which the landmine was, resulting in the landmine trap
being deleted.  The code then tried to access it to make a pit.
2024-05-31 10:28:44 +03:00
Pasi Kallinen
0490f7736c Fix couple cases of boulders over pits
When a zombie claws itself out of the ground.
When a polymorph is zapped on a pile of objects over a pit,
and one of them turns into a boulder.
2024-05-31 07:46:55 +03:00
Pasi Kallinen
5b94745658 Fix only flying monsters able to evade some traps 2024-05-30 17:51:56 +03:00
PatR
5641e2560f fix issue #1248 - drowning on Plane of Water
Issue reported by Umbire:  if hero dies by drowning on the Plane
of Water, cause of death was reported as "drowning in a limitless
water".

Reported for livelogging but applied to tombstone and logfile too.
Omit the article "a" in this situation.

For 3.6.7, it would have started as "drowning in a water" and been
updated on the fly to be "drowning in deep water".  3.7 changed
terrain type WATER to be "wall of water", where "a" is expected,
and also added "limitless water" for Plane of Water, but it was
neglecting to include a similar fixup for the latter.  The "deep
water" fixup is still present but doesn't get triggered anymore.

Fixes #1248
2024-05-29 14:24:10 -07:00
Pasi Kallinen
61e54c2a87 Fix monster hp being above max hp
If the monster took damage from a fire trap, got killed, and then
lifesaved, the trap effect then reduced the map hp below the hp.
2024-05-28 20:58:03 +03:00
Pasi Kallinen
2ebbd13f79 Fix boulder over a hole or a pit dug by a monster
When a monster digs down and creates a pit or a hole,
drop the boulder at the location into it.
2024-05-28 19:10:36 +03:00
Pasi Kallinen
800b3b4b4b Fix swallower being in the same location as hero
A monster swallowed hero, hero teleported the monster away, but the level
was full of monsters, so the swallower ended up not moving anywhere,
so it was in the same location as hero, but hero wasn't swallowed by it.
Move the monster into limbo instead.
2024-05-28 18:12:55 +03:00
Pasi Kallinen
5fe872bf98 Pet titan killed itself with a boulder
A pet titan dropped a boulder over a pool, and the code killed
the titan, because the code was considering the titan to be in
the water.

If a flyer or a floater is over the pool, don't kill them off
if a boulder is dropped in there.  Also make the pet movement
code handle the case where the pet might've died while dropping
items.
2024-05-28 17:57:16 +03:00
PatR
6b750cb551 hit points sanity checks 2024-05-25 17:48:17 -07:00
PatR
537fd6dd74 fix gremlin cloning fix
The revised code returned an uninitialized variable if the new test
failed.

The cloneu() case was ok but this changes it to keep parallel to the
clone_mon() case.
2024-05-25 13:49:12 -07:00
Pasi Kallinen
9df851d5da Fix split monster with 0 max hp
A gremlin first hit a fire trap, reducing its max hp to 1, and
then it plunged into water, making the split gremlin have 0 max hp.
2024-05-25 18:32:37 +03:00
PatR
4217eee07b wizard mode #migratemons fixes
Noticed while doing rudimentary testing of the mnearto() fix for
mimics.  #migratemons wouldn't add monsters to migrating_mons if
getlin() was compiled with EDIT_GETLIN defined unless you manually
deleted the invisible default value that wiz_migrate_mons() was
passing.  It took a while to puzzle that one out.

The command list has conditional description of what #migratemons
does and it was using the wrong spelling of the macro used to
control that.  So '# ?' described the behavior of #migratemons as
it operates without DEBUG_MIGRATING_MONS enabled even when that is
enabled, adding to the getlin() confusion.
2024-05-24 16:23:15 -07:00