Commit Graph

630 Commits

Author SHA1 Message Date
Pasi Kallinen
2db7e20116 Fix invisible gold symbol in status lines 2017-09-16 23:49:28 +03:00
Pasi Kallinen
52ed881b2c Remove overview for wizmode regenerated map
The wizmakemap command throws away the current level, so don't keep
the overview data for it around.
2017-09-15 14:45:51 +03:00
PatR
2b8c2eac23 fix #HH5887 - Dark One / Eye message bug
Some roles' quest message when returning the nemesis lair refer to
sensing the presence/aura/whatever of the quest artifact, but it might
not be there anymore.  In reported case, the nemesis had picked it up
and later fled up the stairs to another level.  Other situations are
possible; it's feasible for the hero to already have it.  So provide
an alternate message, and some extra code to decide whether to use it.

Other anomalous messages, such as looking down on the dead body of a
nemesis who didn't leave a corpse, can still occur.
2017-09-11 15:59:50 -07:00
Pasi Kallinen
9c118b5b6b Secure config errors
If user can make NETHACKOPTIONS point to a file, that user could then
get the file contents via the extended config file error reporting.
Add CONFIG_ERROR_SECURE compile-time option to make that case output
only the first error, no line number or error context.
2017-09-10 21:05:51 +03:00
Pasi Kallinen
f8211f69f2 Improve config file error reporting
Show the original line from the config file, followed by the line number and
a specific error message. Also show all errors from the config file before
waiting for key press.
2017-09-09 13:04:08 +03:00
Pasi Kallinen
189809a55c Rename terminate to nh_terminate so VS2015 can compile 2017-08-19 14:10:29 +03:00
PatR
5e54397609 fix #H5853 - carrots don't cure blind pets
Report was for a blinded horse which ate a carrot but remained blind.
This fixes that, and also lets blinded carnivorous pets eat carrots.
Gelatinous cubes now handle carrots too, but since they lack eyses
there won't be any noticeable effect for them.
2017-08-14 16:30:23 -07:00
Pasi Kallinen
b6d1ee3320 Using a cursed tin whistle in a vault summons the guard
...since guards respond to shrill whistles.
Based on a patch by Leon Arnott.
2017-08-04 22:41:26 +03:00
PatR
3b675c5b49 USE_OLDARGS update (2 of 2)
Files modified:
include/extern.h
src/pline.c, priest.c, potion.c, mkobj.c

A bunch of calls to pline() in pline.c started triggering warnings
either as-is or possibly after the changes to tradstdc.h.  Fixing
them in place would include intrusive VA_PASSx() like in lev_main.c.
Moving them to other files is much simpler (and they didn't
particularly belong in pline.c in the first place, although I didn't
actually find any better place for them....).

The probing/stethoscope feedback went to priest.c, where there's a
comment stating that it should move to wherever englightenment ends
up once that is moved out of its completely inappropriate current
home in cmd.c.  (Holdover from when ^X was wizard-mode only but even
the other wizard mode commands don't really belong with the command
processing code.)
2017-08-02 18:56:54 -07:00
Pasi Kallinen
b13bae91dc Add way to cycle through valid locations for polearm or jump target 2017-07-31 19:10:26 +03:00
Pasi Kallinen
439028dcae Add whatis_filter option to filter eligible map locations for travel
Compound option whatis_filter, filters the eligible map locations
when getting a cursor location for targeting. Accepts 'n' (none),
'v' (map locations in view), or 'a' (map locations in the same area,
eg. room or corridor).
2017-07-31 16:58:23 +03:00
PatR
ca84c8e0ff named-fruit manipulation
Add some new routines for dealing with fruit.  I had hoped they would
let the existing fruit handling be simplified quite a bit, but the
improvement wasn't great.  However, they're also groundwork for fixing
an old bug.
2017-07-03 18:57:50 -07:00
Pasi Kallinen
8180310630 Make #wizmakemap handle unpaid items and punishment 2017-06-28 00:40:00 +03:00
PatR
e32c09c5bf BUCX filtering
The different menustyle settings have been offering different degrees
of support for BUCX filtering:
  Full       : multi-drop, container-in, container-out
  Trad, Combo: multi-drop
  Partial    : none (to be expected; it explicitly jumps past class
    filtering, where BUCX gets handled, to a menu of all objects)

This adds pickup, container-in, container-out, multi-unwear/unwield,
and object-ID for Trad and Combo, and multi-unwear/unwield for Full.
(Full behaves like Partial for pickup--not sure why--and for object-ID,
bypassing filters to go straight to a menu of all applicable items.)

There are probably several new bugs--this stuff is very convoluted....
2017-06-23 18:44:35 -07:00
Pasi Kallinen
60443a4ee7 Add sanity checking for long worms 2017-06-16 18:27:25 +03:00
PatR
743d3a1eb5 yet another pass at 'A' bugs
I think this finally quashes the "cursed without otmp" issue.
Various ways of destroying wielded weapon used setnotworn() rather
than unwield(), so the previous change to have unwield() clear the
pending W_WEP bit from takeoff.mask wasn't sufficient to prevent
'A' moving on from another item (blindfold--it's the only thing
processed before primary weapon) to weapon which wasn't there any
more.  Also, if weapon was already set in takeoff.what to be
processed on the next move, clearing W_WEP from takeoff.mask wasn't
sufficient either.

Move the previous unwield() 'fix' to setworn() and setnotworn() and
extend it to include cancel_don() if the item being replaced or
removed is in progress or scheduled for next.  (Most of the time,
remove_worn_item() has already done that before setworn() or
setnotworn() is called.)
2017-06-08 15:05:24 -07:00
PatR
964fd0fdbd dynamic format strings vulnerable to user input
This adds new utility routine strNsubst(), a more versatile version
of the existing strsubst(), that can replace the Nth occurrence of
a substring rather than just the first, and replaces all occurrences
if N is 0.

When working on vampire shape-shifting messages a few days ago I
noticed that a constructed pline/sprintf format was vulnerable to
the player giving the vampire a name with '%' in it and included
a fix for that.  This fixes two other instances of the same
vulnerability:  a monster with reflection triggering a floating
eye's gaze and the hero using a silver weapon against a silver-
hating monster.

I didn't do a lot of experimenting with the failure, just assigned
the name "foo%s" to the floating eye or the weapon.  The resulting
feedback for the relevant messages was garbled due to parameters
being substituted in the wrong place.  When that caused there to be
too few arguments to satisfy the format, the final message included
"null" for the missing one rather than triggering a crash while
trying to format something arbitrary from the stack.

I don't think these bugs provided sufficient user control to be
vulnerable to stack manipulation that does something naughty.

I found the dynamic format strings by searching for "%%".  There
may be others scattered around the code which don't have that as
an indicator....
2017-06-07 11:39:24 -07:00
PatR
3512297f59 fix #H5547 - named vampire shapeshifting message
Report was about "Pet vampire" but the relevant aspect was that the
vampire had been assigned a name, not that it was tame:
You observe a Hilda where a Hilda was.

Investigating this has uncovered two other bugs, one potentially
serious.  m_monnam() overrides hallucination but seems to be getting
used to some situations where hallucination should be honored (several
instances).  Dynamically constructed format strings are including
monster or object names in the format (rather than the usual use as
arguments), so player assigned names containing percent signs could
cause havoc (a few instances).  This fixes some of the former and one
of the latter, but doesn't deal with various other cases revealed by
grep.
2017-06-03 16:05:23 -07:00
PatR
ead698fd02 dumplog of map
When writing the known portion of the current level's map into
dumplog, discard any blank rows at the top (there will already be
one blank line separating it from the text that precedes) and keep
at most one blank row at the bottom (sometimes there won't be any).
2017-05-20 22:55:08 -07:00
PatR
f6b32bf03c fix #H5245 - levitation boots message sequencing
Report was for
  You finish taking off your boots.
  You float gently to the altar.  [destination was a red herring]
  [take some action to run through moveloop() for next turn]
  Your movements are slowed slightly because of your load.

Having float_down() do the next encumbrance check instead of
waiting for moveloop() to do so was straightforward.  However,
while testing I noticed the reverse situation (not due to the fix
for the above) when putting on levitation boots
  Your movements are now unencumbered.
  You finish your dressing maneuver.
  You start to float in the air!

Having float_up() do the encumbrance check isn't adequate to fix
this, because it takes multiple turns to put on boots but the
properties they confer are enabled immediately, so moveloop() runs
while hero is already levitating even though the game hasn't told
the player about it yet.  Fix is a hack to defer the effect of
levitation on encumbrance until the boots are fully worn, which
might lead to strangeness somewhere.  It's also boot-specific so
will need to be updated if some other multi-turn armor that confers
levitation ever gets added.
2017-05-06 14:47:28 -07:00
PatR
8fc7bc548c setmangry fixes
Some discussion in the newsgroup about nearby peaceful monsters becoming
hostile if they observed the hero attacking a peaceful monster made me
look at the code and I spotted a couple of problems.  An auto array was
being initialized in an inner block--some pre-ANSI compilers couldn't
handle that.  Worse, it was inside a loop and may or may not have
resulted in unnecessary setup each iteration.  Make it static.  Oddly,
the array had the same name as a function but `gcc -Wshadow' either
didn't notice or didn't care.

A more significant problem was that mon->mpeaceful was being set to 0
without checking whether mon->mtame was set, potentially resulting in
humanoid pets being both tame and hostile at the same time.  This change
prevents that but doesn't do anything interesting about pets who observe
attacks against peacefuls.  (I also wonder why chaotic peacefuls now get
upset by seeing other peacefuls be attacked; it seems out of character.)

There was also a check for non-humanoid peacefuls seeing another of the
same species be attacked, but it was checking for an exact match without
regard for littler or bigger incarnations of the same species.  I've
added the latter.

This also reformats a couple of block comments.
2017-04-20 17:06:28 -07:00
PatR
6ba906b234 maybe fix #H5264 - screen clears on prompting
I couldn't reproduce the reported problem of the "In what direction?"
being issued after the screen was cleared, but bypassing pline() in
favor of putstr(WIN_MESSAGE) for tty prompts did also bypass
  if (vision_full_recalc) vision_recalc(0);
  if (u.ux) flush_screen(1);
done in pline().  Inadvertent loss of the latter could conceivably be
responsible for the problem.  If so, the escape code used by cl_end()
may be broken for somebody's termcap or terminfo setup since clearing
to the end of the line in the message window shouldn't erase the rest
of the screen.

Regardless, the prompting change also bypassed the ability to show
the prompt with raw_printf() if the display wasn't fully intialized
yet, so some change to the revised prompting was necessary anyway.

Switching back from putstr(WIN_MESSAGE) to pline() resulted in
duplicated entries in DUMPLOG message history, one with bare prompt
followed by another with response appended, so more tweaking was
needed.  The result is use of new custompline() instead of normal
pline().  custompline() accepts some message handling flags to give
more control over pline()'s behavior.  It's a more general variation
of Norep() but its caller needs to specify an extra argument.
2017-03-30 14:14:38 -07:00
PatR
82620d16f5 tty prompting fix and DUMPLOG of prompts+answers
Update DUMPLOG's message history to include player responses to
most queries.  For tty, both getlin() and yn_function().  For other
interfaces, only yn_function() is covered.  (It's intercepted by a
core routine that can take care of the logging; getlin() isn't.)
Also includes saved messages from previous session(s), for the
interfaces which support that (tty), to fill out the logging when
a game ends shortly after a save/restore cycle.

The tty interface was using pline() to display prompt strings.
Having 'MSGTYPE=hide "#"' or 'MSGTYPE=hide "yn"' in .nethackrc
would suppress many prompt strings (in the two examples mentioned,
entering extended commands or the vast majority of yes/no questions,
respectively) and generally lead to substantial confusion even if
done intentionally, so switch to putstr(WIN_MESSAGE) instead.
2017-03-20 19:11:48 -07:00
PatR
278b6d52eb dumplog message history groundwork
Separate the message logging out of pline so that other things (for
instance, one-line summary for quest block messages) can be logged.
The code that utilizes this isn't ready for prime time yet.

For FREE_ALL_MEMORY, release DUMPLOG message history when saving.
(Actually, this frees it unconditionally rather just doing so for
FREE_ALL_MEMORY.)  It was being freed when logged at end of game,
but not during save.  If dumplog message history and interface
message history get integrated, the existing message history
save/restore handling should become applicable instead.
2017-03-10 16:41:49 -08:00
PatR
fd2cfba544 dumplog lint and formatting 2017-02-25 18:27:21 -08:00
Pasi Kallinen
7d8b4d4f97 Add end-of-game dumplogs
This is based on the "new" dumplog patch for 3.6.0, by Maxime Bacoux.

Define DUMPLOG to enable. By default only enabled for the TTY linux.
2017-02-19 15:33:27 +02:00
PatR
2655910a0f fix #H4597 - sitting on level teleport trap
During #sit:  "You sit down.  You step on a level teleporter."
Switch to alternate phrasing for #sit.

Webs and polymorph traps had similar issues.
2016-12-08 17:22:59 -08:00
PatR
66a0c98954 fix some recent lint 2016-12-08 16:01:09 -08:00
Pasi Kallinen
b8d8556eff Fix some issues found with fuzz testing
Mostly to do with relocating monsters when the level is already full,
and unsticking a monster if it gets relocated.
2016-12-07 17:53:08 +02:00
Alex Smith
ee5b488514 Differentiate between monster anger from attacks and from other causes
setmangry() and wakeup() were being used for multiple purposes. Add an
extra parameter to track which. This fixes several minor bugs (e.g.
whether monsters with no eyes were angered by (useless) gaze attacks
against them previously depended on the state of a UI option, and
the Minetown guards would be annoyed if you used a cursed scroll of
tame monster on a shopkeeper). It's also a prerequisite for the
Elbereth changes I'm working on.
2016-10-17 18:19:22 +01:00
Pasi Kallinen
abb4f0fab2 Allow toggling menu for any travel target list 2016-10-13 20:16:21 +03:00
PatR
e81c58aa1d keybinding lint and formatting 2016-10-07 13:14:54 -07:00
Pasi Kallinen
efd7526194 Accessibility: Pick travel/cursor targets from a menu
Adds two new configurable keys to the cursor targeting: 'A' (getpos.menu)
and 'a' (getpos.menu.cansee). First one shows a menu of all interesting
glyphs on the map, second one shows only those in sight.

Travel command also now obeys the "request menu" -prefix, showing
the menu with interesting targets in sight, and then traveling there.

Idea via the NetHack accessibility research by Alexei Pepers.
2016-10-06 13:10:13 +03:00
Pasi Kallinen
53cd30c54c Show menu control keys in help menu 2016-10-06 08:53:38 +03:00
Pasi Kallinen
680c8a542c Add key rebinding
This is a modified version of Jason Dorje Short's key rebinding
patch, and allows also binding special keys, such as the ones
used in getloc and getpos.

One of the ways to play NetHack on nethack.alt.org is via a HTML
terminal in browser. Unfortunately this means several ctrl-key
combinations cannot be entered, because the browser intercepts
those. Similar thing applies to some international keyboard layouts
on Windows. With this patch, the user can just rebind the command
to a key that works best for them.

I've tested this on Linux TTY, X11, and Windows TTY and GUI.
2016-10-05 20:04:56 +03:00
Pasi Kallinen
f82205c232 For travel target location, report if no known travel path
Yet another accessibility feature.  When asked for a location
to travel, and autodescribe is on, the location description
has "(no travel path)" appended, if there is no known path
to that location.
2016-08-31 22:08:15 +03:00
PatR
a16000d80a fix #H4482 - "a some <foo> corpses"
farlook was changed (end of December) to use doname instead of xname
to yield more info for items which had already been seen up close,
but it gave away info about ones which hadn't.  So doname was changed
(end of April) to use "some" instead of precise quantity (when the
quantity is greater than 1) for the latter, but that doesn't work
well with corpse_xname() when the hero is blind, yielding "a some
<foo> corpses".  While testing the first fix attempt, I noticed that
pickup gave "you can only lift some of the some <foo> corpses".

This fix is far from perfect.  farlook can still say "some <item>s"
but lookhere and pickup always say "N <item>s".  Picking up a stack
while blind will show "N <item>s" in inventory display, but dropping
it while still blind will revert to "some <item>s" for farlook.
2016-08-13 11:17:32 -07:00
PatR
a72d19b905 fix #H4475 - shop message about disenchanted item
drain_item() always assumed player was responsible, so called
costly_alteration() to adjust shop price of disenchanted item.
If it was unpaid and the effect was caused by a disenchanter
attack rather than by the hero, the feedback was nonsensical.

This also lets a disenchanter hit worn rings, amulet, or blindfold
if no armor gets targetted.  Amulets, blindfolds, and most rings
have no charge to be drained, but several types of rings do.
2016-08-10 02:04:09 -07:00
Pasi Kallinen
3502cfcc5a Hallucinatory liquids for water, lava, and acid 2016-06-07 20:57:50 +03:00
PatR
e3c15574ac lint cleanup 2016-06-05 14:52:01 -07:00
Pasi Kallinen
5009a67264 Allow pets to use ranged attacks
This is the Pet ranged attack -patch by Darshan Shaligram,
with the spellcaster parts removed to keep it simpler.

Pets will now throw, spit and breathe at other monsters.
2016-06-04 01:06:07 +03:00
Pasi Kallinen
984785b13c Give a hint that containers are looted instead of opened 2016-06-02 18:11:41 +03:00
PatR
894d6c6859 detection revamp
Change most instances of detection to offer the player a chance to
move the cursor around on the map so that the getpos() autodescribe
feature can explain things that might go away as soon as the
current detection completes.  The few instances that don't offer
such a chance are the ones where everything which has been revealed
will still be there once the action finishes (such as regular magic
mapping and blessed/persistent monster detection).

There were quite a lot of inconsistencies in things like handling
for detection while swallowed or underwater.  I didn't keep track
of them to distinguish between 3.6.0, current dev code, or my patch
in progess.  They should be much more consistent now but without a
comprehensive fixes36.1 entry.

Blessed clairvoyance (divination spells at skilled or expert) now
shows monsters as well as terrain.  I first had it like that for
any clairvoyance, but having getpos/autodescribe kick in every 15
or 30 turns once you have the amulet--or pay the appropriate amount
to a temple preist--was nearly unplayable.  When it only follows an
explicit spell cast it is not intrusive.
2016-06-02 01:08:34 -07:00
PatR
71113a6971 detecting chest and door traps
When confused gold detection finds a door trap or a chest trap, it
puts a bear trap glyph/tile on the map at that location.  (They
disappear once they're within sight.)  Those should be given their
own glyphs so that they can have their own tiles, but this doesn't
do that.  What it does do is describe such fake bear traps as
"trapped door" or "trapped chest" when examined with far-look.
The '^' command--if used while blind so that '^' hasn't disappeared
yet--needs to catch up: it says "I can't see a trap there" when the
adjacent '^' is a fake bear trap.
2016-05-31 00:08:17 -07:00
PatR
0c70b1bd06 reset travel cache when changing levels
When travel fails to reach its destination, it remembers the target
spot to use as default next time.  But that spot is only meaningful
on the current level.  Discard last travel destination when moving
to a different level.

Also, discard unlocking context when changing level unless the
context is for a container being brought along (after having been
picked up since you can't unlock a carried box).  Previously, a
door pointer on the new level could happen to match the last one
being unlocked on the old level.

Discard trap setting context when changing level even if the trap
object is brought along.

Somehow the code for applying a touchstone got inserted in between
two sections of code for applying a trap (ages ago; probably since
touchstone was first introduced however many versions back), so
clean that up.
2016-05-28 19:54:19 -07:00
Pasi Kallinen
3b38c75517 Free mailbox at exit 2016-05-23 17:18:24 +03:00
Pasi Kallinen
0db1e1ca38 Unify pet and monster digging item checks 2016-05-19 18:46:29 +03:00
PatR
759544dd33 long worm #stats
When #stats shows memory use for monsters, include long worm tails.
2016-05-01 00:34:36 -07:00
PatR
2fe9170ee4 implement #H4305 - Quivering wielded weapon
This ended up being more elaborate than I anticipated.  'Q' will
now accept the wielded weapon as a choice of item to quiver.  If
that item is a stack of more than one, it will offer to split N-1
into the quiver and leave 1 wielded.  If the offer is declined, or
if there is already just 1, it will require confirmation to move the
item from the weapon slot to the quiver slot.  The alternate weapon
is handled similarly, with different phrasing when in twoweapon
combat mode.

Just to be crystal clear:  a single object cannot be in more than
one weapon, alt-weapon, or quiver slot at the same time.  'Q's old
behavior of rejecting the wielded weapon was to avoid accidentally
becoming empty-handed, not anything to do with multiple worn/wield
slots.

'Q' will also accept a count when picking an inventory item, then
put 'count'-many into the quiver, leaving N-count in original stack.
Except when the chosen item is already in the quiver; it that case,
it undoes the stack split and leaves things as they were.  (That
restriction may not have been necessary but I'm not planning to
revisit it....)
2016-04-29 15:10:56 -07:00
PatR
713d8cc492 piousness lint 2016-04-23 11:57:14 -07:00