Commit Graph

1627 Commits

Author SHA1 Message Date
nhmall
e83e04dbb3 fix some memory leaks 2024-11-10 22:24:45 -05:00
nhmall
5cc529efc8 follow-up related to #1320
This is additional groundwork related to
https://github.com/NetHack/NetHack/issues/1320

This additional groundwork just puts some safeguards
in place to make it rather tough to end up with an
instant death from handling a cockatrice corpse in
your inventory without appropriate protection.

At this point, still no actual petrification will occur.
2024-11-09 23:49:10 -05:00
nhmall
9c554895b1 adjust wish for cockatrice corpse
Wishing is powerful, so if you cannot safely handle a cockatrice
corpse, then have a wish for one result in the corpse materializing
on the floor rather than in your inventory.

Resolves #1320
2024-11-09 14:06:43 -05:00
nhmall
9a42d70901 ranged attack in repertoire might not be used
Commit 22884522, ported (from Sporkhack, Evilhack), added the ability
for monsters to maintain awareness of player resistances that they
observed.

Since they will refrain from using a ranged attack that they deem
futile, take the specific monster's seen_resistance field into consideration
when choosing code paths based on the availability of ranged attacks.

Resolves #1307
2024-11-03 09:03:04 -05:00
Pasi Kallinen
945ccff1ff Allow changing command autocompletions via #optionsfull 2024-10-19 14:46:11 +03:00
Pasi Kallinen
f12635ccd9 Prevent monster generation in the sokoban trap hallway
Makes Sokoban far less tedious when you don't have to worry about
monsters randomly popping up in the trap hallway while you're pushing
the boulder.

Adds a new exclusion zone for monster generation, and the goodpos
routine avoids the zones when GP_AVOID_MONPOS is used.
2024-10-18 13:30:51 +03:00
PatR
1f36b98b8f 'selectsaved' extension
Instead of a menu listing
 a - hero1
 b - hero2
 n - New game
 q - Quit
show
 a - hero1-role1-race1-gend1-algn1
 b - hero2-role2-race2-gend2-algn2
 n - New game
 q - Quit
or
 a - - hero1-role1-race1-gend1-algn1
 b - X hero2-role2-race2-gend2-algn2
 c - D wizard-role3-race3-gend3-algn3
 n - New game
 q - Quit
when any game in the list wasn't saved during normal play.  (Those
are sorted by character name; the playmode is just coincidence.)

The dash for 'normal' doesn't look great but -/X/D are codes used in
entries written to paniclog.  The whole playmode prefix doesn't look
particularly good but I suspect that most players relying on restore
via menu won't see it.

It should work when the character name has dashes in it but that
hasn't been properly tested.

The gender and alignment suffices reflect their value at the time of
save rather than at the start of the game.  That might be considered
a bug but it was easiest.

Increments EDITLEVEL; existing save and bones files are invalidated.
2024-10-10 23:14:25 -07:00
PatR
e9a25a0a1c sanity_check: current hero health better than max
Changes to setuhpmax() a couple of days ago to deal with sanity_check
for "current hero health as monster better than maximum" ended up
triggering sanity_check about "current hero health better than maximum"
when gaining experience level(s) while polymorphed.
2024-09-26 23:00:42 -07:00
PatR
a3f176c9dc probably fix #K4269 - sanity failure for u.mh \
being greater than u.mhmax

I think this will fix the situation where current HP as a monster
was greater than maximum HP as a monster, triggering a sanity_check
failure.  No promises though.

[poisoned() needs some missing Upolyd handling.]
2024-09-24 13:59:28 -07:00
PatR
5bb4adace0 'tips' fix and enhancement
When 'tips' are enabled, the farlook tip displays some text at the
start of getpos().  But it clobbered the initial prompt, leaving
the screen in an ambiguous state (seemingly a normal map display,
but it is actually waiting for player to move the cursor) after
removing the tip's popup window.

Reissue the prompt.  farlook's short but misleading prompt of
"Pick an object" is changed to "Pick a monster, object or location".
I would normally include a comma before "or" but omitting it makes
the longer text seem slightly less cluttered.

The other tips are all one-line, delivered via pline().  Prefix
all of their messages with "Tip:" (which the farlook one already
uses) as a hint for using OPTIONS=!tips to shut them off.
2024-09-14 12:53:48 -07:00
nhmall
cbb32ac64a glyph_to_cmap() becomes function instead of macro
Also adds swallow and explosion glyphs to glyph_to_cmap()

References:
https://github.com/NetHack/NetHack/pull/1022 by argrath
https://github.com/NetHack/NetHack/pull/1277 by ars3niy

Closes #1277
Closes #1022
2024-09-14 10:12:09 -04:00
klorpa
02c4147893 Typos 2024-08-31 15:28:42 -05:00
PatR
fd57c9ca83 wizard mode #timeout command vs gas regions
Show visible regions among the other timed events.  Turn number is
relative rather than absolute.  Location is the internal bounding box
which tends to cover more area than just the gas cloud spots.

When multiple regions are present (common on Plane of Fire), they're
listed in arbitrary order.  It would be better to order them by
timeout or by location or both, but the extra effort to do that seems
unjustified.
2024-08-13 13:28:24 -07:00
PatR
0eb8896301 paranoid_confirm:Trap vs vapor+gas cloud regions
Extend paranoid_confirm:trap to also ask for confirmation when
attempting to enter a gas cloud region (scroll of stinking cloud,
breath from green dragons or iron golems, steam clouds from boiling
water, vapor left by fog cloud movement, no doubt several others).

Like with traps, can be overridden for a given move by using the
'm' prefix.  Unlike traps, doesn't try to guess whether moving into
a region will be harmless.

Doesn't affect movement into cloud terrain (Plane of Air).

Update the Guidebook to describe the revised behavior of
paranoid_confirm:trap and to mention how #terrain deals with regions.

'any_visible_region()' got mixed in with this but isn't used yet.
Affects extern.h and region.c.
2024-08-11 14:59:57 -07:00
PatR
2d68ee8f9f fix #K4210 - vampshifter fog clouds
Messaging for vampires changing into fog clouds was inconsistent
in 3.6.x but already fixed in to-be-3.7.

However, maintaining an extra set of shape change messages (one
in newcham(), the other in vamp_shift() which turns out to only be
used when a vampshifter turns into a fog cloud in order to pass
under a closed door) was a nuisance.  Redo vamp_shift() to use
newcham() feedback.  Update that feedback to be accessibility-aware
and also to use "Your <mon>" instead of "The <mon>" when appropriate.

While in there, remove a couple of trailing spaces and eliminate
use of one dynamically constructed format string that necessitated
warning manipulation.
2024-07-27 14:49:17 -07:00
nhmall
d5785f287e GitHub issue #1254
> If there's a trap on a no-dig level, the floor beneath it will always be "too hard to dig into", making it impossible to remove the trap.
>
> As you can still dig pits in these levels (just not holes), the floor under the trap itself resisting to become a pit seems inconsistent.
>
> Steps to reproduce:
>
> Go to no-dig level like Mine's End
> Make a trap
> Dig a pit next to it -> works
> Dig on the trap -> does not work

Return more information about the dig_check() results to caller (was
just a boolean).

Move the messaging that was in dig_check() into a separate
digcheck_fail_message() function that uses the expanded return
information.

Resolves #1254

.
2024-07-23 01:06:24 -04:00
Pasi Kallinen
d4ac146c5f Pets avoid a possible boulder pushing location in Sokoban 2024-07-06 23:12:19 +03:00
PatR
a33f1edd24 YMonnam(monst)
Replace several upstart(y_monnam(mon)) with new YMonnam(mon) to
produce "Your little dog" and such.

Also change one or two Monnam(mon) to YMonnam(mon) and one pline(...)
to pline_mon(mon, ...).
2024-07-04 14:27:28 -07:00
PatR
14d0e48e73 less verbose sanity checking
If the 'sanity_check' option triggers a warning, don't show the
"Program in disorder!  (Save and restore might fix this.)" and
"Report these messages to <devteam>." messages and also don't run
the crash report submission.

Doesn't affect the fuzzer because it escalates impossible() to
panic() before reaching those extra messages.
2024-07-01 00:44:42 -07:00
PatR
2674a9904d github issue #1249 - menu pay of contained items
Issue reported by ars3niy:  unpaid containers containing one or
more other unpaid items appear on the menu for 'p' along with
separate menu entries for those other items.  Buying the container
buys the contents too, then if any of the contents were also picked
in the menu, an attempt will be made to pay for them separately.
Since they are no longer on the bill by that point, that triggers
an impossible warning.

This fixes that by paying for the container but not its contents.
(Temporarily, until more extensive changes get implemented.)  Then
those contents will still be on the bill.  It they've been chosen
in the 'p' menu, paying for them will work as expected.

This also fixes the pay menu for the case where the bill contains
any instances of a partly used up portion of some stack and also
the unpaid intact portion of the same stack.  With itemized billing,
you are allowed to buy the used up portion separately, then maybe
drop the unpaid portion.  (If you try to pay for the intact portion,
the shk won't accept the payment and will tell you to pay for the
used up portion first.)  With the recently added menu for billing,
they were lumped together as a single item and you had to pay for
their whole stack.

And it fixes a much older bug dealing with the cheapest item on
the shop bill.  If you don't have enough to pay for that, the rest
of buying gets skipped.  But stacks that had used up and intact
portions were lumping those together instead of separately checking
the two portions for possibly being the cheapest, so it was possible
to have enough gold to pay for one portion but be told that you
couldn't affort to pay for anything.  If it was the intact portion,
you wouldn't be able to buy it anyway, but if the cheapest item was
used up portion, being told you didn't have enough gold was wrong.

This commit does not fix the longstanding bug that itemized billing
reveals the contents of containers which haven't been opened.  It
was intended to do so but I've run out of steam.

(There is groundwork for that, where buying a container would
include payment for its unpaid contents without revealing what those
are, and they couldn't be purchased separately unless they get taken
out of the container.  Uncommenting '#define CONTAINED_BUYING' will
enable it, with updated pay menu handling but without being able to
pay for non-empty containers.)

Fixes #1249
2024-06-27 14:13:39 -07:00
Pasi Kallinen
89ea47f702 Monsters can track hero through fixed teleport traps
Also make fixed teleport traps always trigger when entered.
2024-06-15 18:44:30 +03:00
PatR
24e06171db fix issue #1256 - no_of_wizards incorrect \
if Wizard escapes the dungeon

Reported by vultur-cadens:  a fix to prevent quest feedback when quest
nemesis is removed from the game during bones creation introduced a
regression for an earlier fix that kept context.no_of_wizards up to
date if the Wizard of Yendor escapes the dungeon without dying.

Change 'wizdead()' to 'wizdeadorgone()' and call it from m_detach()
for mongone() as well as for mondead().

Fixes #1256
2024-06-13 12:18:17 -07: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
Pasi Kallinen
1a58ed8de9 Rework object deletion
Make object deletion work similarly to monster deletion:
it's marked for deletion (by setting the where-field to OBJ_DELETED
and moved to specific deleted-objects chain), but they're actually
freed at the beginning of turn.

This may need some more tweaking, especially in places that iterate
over object chains, but fuzzing did not find any obvious problems.

Fix a case of accessing freed memory: a monster breathed at hero,
destroying some items.  The code stored the next item in the chain
(a cloak), but a ring of levitation was destroyed, causing hero to
plop down into lava, destroying the cloak.  The item destruction
code then tried to access the destroyed cloak object.
Make the code check the object where-field - which will be different
if the object was marked for deletion.  Also removed an extra loop
going through the whole object chain looking for the items to
destroy.
2024-05-06 17:57:47 +03:00
Michael Meyer
b662134eba Fix: bill_dummy_obj billed excessively for stacks
Add a way to request that unpaid_cost() produce the cost for a single
item, which is necessary for the price adjustment made in
bill_dummy_object.  Another option would be to simply divide by quan in
bill_dummy_object, but this might be more future-proof in case
unpaid_cost ever involves more than simple multiplication by quan
(e.g. the use of alternate units vs the base price, as are used for
globs).

Fixes #1236
2024-04-27 18:42:50 -07:00
Pasi Kallinen
94dd316e80 Make saveoptions save changed autocompletions 2024-04-25 10:13:08 +03:00
PatR
9d71c8e1f4 Sunsword #invoke, directed at self
Give a resistance animation if you #invoke Sunsword while it's
wielded and direct its blinding ray at yourself.  Flashing a camera
at a monster who is wielding it will also produce the animation.
2024-04-19 10:50:46 -07:00
PatR
29b4c47bdf fix #K4142 - camera flash vs mimic
When a camera flash hit a mimic which was posing as something, the
feedback mentioned the mimic but didn't bring it out of hiding.

Change to make light pass over a mimic impersonating an object but
unhide one impersonating furniture.  Ones impersonating some other
monster are woken up but wakeup doesn't force it back to mimic shape.

Trying to get the messages right brought on more code changes than
antipated.  I changed one of the arguments to mhidden_description()
so had to change its callers; fortunately there aren't very many.
2024-04-16 23:34:26 -07:00
Pasi Kallinen
3086f16386 Shopkeepers bill you for using their bear trap or land mine 2024-04-13 15:10:15 +03:00
Pasi Kallinen
a57d0e6f4f Curses: add support for the palette config option
Depends on CHANGE_COLOR compile-time option.

Also allow multiple palette-definitions in the config file.
2024-04-13 12:01:43 +03:00
nhmall
15db874f71 CHANGE_COLOR palette option adjustments
It was too early to call the windowport change_color() routine
while processing the config file. The windowport was not yet
fully operational.

Now the palette option processing will just place the rgb
value into the appropriate ga.altpalette[CLR_MAX] entry.

init_sound_disp_gamewindows(void) [allmain.c] calls
change_palette() [coloratt.c] and it will call the windowport
change_color() function for each ga.altpalette[] entry that
has been set.

Notes:
The rgb values stored in ga.altpalette[] have the NH_ALTPALETTE bit set
so that the rgb value of 0 can be stored and be distinguishable from
a "not set" entry.

The NH_ALTPALETTE bit is cleared from the rgb value in change_palette()
prior to calling the windowport change_color() function.

The syntax for palette is colorname/r-g-b.
For example: palette:black/12-12-12

colorname must be one of the NH_BASIC_COLOR names or a suitable
alias for one of those 16 entries.

Some of the windowport CHANGE_COLOR functions had the wrong parameters,
perhaps due to bitrot. Those have been corrected to match the prototype.
2024-04-12 21:57:27 -04:00
PatR
7da370d74a experimental hitpointbar change
For tty, make hitpointbar blink if current HP falls to the critical
HP threshold.  Doesn't require status highlighting.  Not changed:
when status highlighting is active, use the HP color but force the
attribute to be inverse (plus blink if the criterium is met) rather
than whatever the HP highlight specifies.

For curses, do the same thing.  It used to honor HP attribute for
hitpointbar, now it behaves the same as tty:  always inverse, maybe
combined with blink.  The new code assumes that inverse and color
can be turned off without turning off active blink in the process.

I had intended to make hitpointbar be a full-fledged status field
(which happens to be rendered on top of title) so that it could be
highlighted differently from hit points (mainly so that one could
highlight up and down changes while the other showed percentages).
This is less versatile than that but much simpler.
2024-04-11 11:06:29 -07:00
Pasi Kallinen
f1c77aa2fd Pets avoid a location hero just kicked
If hero kicks a location, pets and peacefuls will avoid moving
into that location for that turn.
2024-04-11 18:05:18 +03:00
Pasi Kallinen
62b78ba037 Hero movement affects water bubble direction 2024-04-10 21:57:05 +03:00
Pasi Kallinen
969c87c0a1 Unblind telepathy range and carried artifacts 2024-04-05 09:44:52 +03: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
e2d3368b0e Make hero polyed into hezrou also stink 2024-04-04 11:22:20 +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
Pasi Kallinen
c71e8ec8d4 Sunsword can be invoked to create a blinding ray 2024-03-31 19:43:33 +03:00
PatR
e4ffda7386 blanking novels
Simplify converting novels into blank spellbooks via water damage.
Since that can occur, update cancellation to do it too.
2024-03-28 23:44:34 -07:00
nhmall
80fb1b5f54 provide way for developer to verify custom colors and symbols in effect
' #wizcustom
2024-03-25 20:42:48 -04:00
nhmall
e3409fd4af reinstate 256 color 2024-03-24 23:47:24 -04:00
nhmall
29495f77f7 runtime toggle of ENHANCED_SYMBOLS customsymbols 2024-03-24 19:39:36 -04:00
nhmall
0b35079acc add customcolors option
customcolors (default) and !customcolors toggle whether the
custom colors get applied to the glyphmap.
2024-03-24 16:55:23 -04:00
nhmall
d15ab932e7 more code moves
move an ENHANCED_SYMBOLS function from glyphs.c to utf8map.c
2024-03-24 15:36:19 -04:00
Pasi Kallinen
f131942dd2 Another tamedog message
Give a different message when a peaceful creature was tamed.
Allow suppressing this and the previous message, when the caller
handles messaging.
2024-03-24 10:48:29 +02:00
nhmall
ba00dc9066 sever extracolors from utf8map and ENHANCED_SYMBOLS
move the custom color data into its own field in the glyphmap
and disassociate it from the unicode/utf8 stuff.

move the glyphcache stuff during options processing and parsing
into new file glyphs.c and out of utf8map.c, and make it
general, and not part of ENHANCED_SYMBOLS.

Do the groundwork for allowing glyph color customizations to
work when any symset is loaded and not restrict it only to
the enhanced1 H_UTF8 symsets.

The customizations in effect are still affiliated with a particular
symset.

Also closes #1224, but the PR itself references a data structure
made obsolete by this commit. The curses comment from the PR was
added into the code.

The PR also made several suggestions, but only the first
one has been included in this commit (and no longer based on
the handler), that being:
"allow defining colors if other symbol handling modes are used
(possibly limited to the standard 16 colors)."

FredrIQ also wrote the following suggestions in PR#1224:

Something I was also contemplating, unrelated to implementation of this
support in curses, would be the ability for the following:

allow defining colors if other symbol handling modes are used (possibly limited to the standard 16 colors)
allow defining attributes (for example: glyph:G_pet_female_kitten:U+0066/red/underline)
allow specifying glyphs as wildcards for defining global color/attribute changes

Something I also want to see are keywords for "don't change the current defined data". If this
were to be added, you could for example do this:
OPTIONS=glyph:G_*_fox:U+0064/blue
OPTIONS=glyph:G_statue_*:basechar/gray/underline
for "make all foxes use a blue color, make all statues gray with underline" without needing
to specify the relevant character for every statue. This ("basechar", "basefg", etc)
should perhaps also be added for MENUCOLORS and statushilites, so that you can, for
example, underline all items being worn without needing to specify a bunch of
near-duplicate rules for combining BUC colors + underline worn items
as per #1064
2024-03-23 15:36:22 -04:00
PatR
ef17c7ac2b unix check_panic_save
Inspired by self-recover, sort of.  Enabled for unix by default; can
be disabled by commenting out '#define CHECK_PANIC_SAVE' in unixconf.h.

When starting the game, if there is no save file to restore and no
lock/level files to recover, check whether a panic save file exists.
If there is one, tell the player that it's there and that it might be
viable, then ask whether to start a new game.

It doesn't convert the panic save into a reconverable one (rename by
nethack, then continue trying to restore) or tell the player how to
make it viable (rename to remove ".e" by game admin), just whether it
is present.  If player opts to start a new game, the panic save is
left alone and will trigger the "there's a panic save file" situation
again once the new game finishes and player starts another.
2024-03-23 10:11:35 -07:00
PatR
9ba0cf2ff0 fix memory leaks for #quit while in tutorial
The new change to reset discoveries and monster-stats when exiting
the tutorial used dynamic data which wouldn't be freed if player
used #quit and declined to resume the regular game.

It turns out that such a leak was already present for start-of-game
inventory that gets stashed away during the tutorial.

In both cases, it could happen at most once per game so wasn't a big
deal as far as memory leaks go.
2024-03-21 15:28:13 -07:00
PatR
2e9d0753c8 enhance the windowcolors option
When processing
|OPTIONS=windowcolors:window-type foreground-color/background-color
parse the color values and use their names rather than the player's
raw options text.  Affects the feedback from 'm O' and is essential
for the next feature.

Accept either "gray" or "grey" where colortable[] always uses "gray"
(half a dozen or so instances), and accept dash or underscore where
colortable[] always uses dash (many instances).

Also, complain about 'window-type' if it isn't recognized as one of
menu, message, status, or text.  [For curses, the complaint gets
written to stdout and is then immediately erased as it goes into full
screen mode.  That's a general problem, not specific to this option.]
2024-03-18 13:24:21 -07:00