Commit Graph

326 Commits

Author SHA1 Message Date
PatR
a8550fc0e7 ball&chain sanity checking
Add a bc sanity check.  It seems to work ok--in other words, not
trigger--under normal punishment.  I don't have any test cases to
exercise its warnings.

This dragged in a couple of minor bc changes that were pending.  I
should have cleared those out before tackling the sanity checking.
2019-05-05 13:33:30 -07:00
nhmall
dcf4da2150 preserve dknown field between fakeobj instances
Preserve temporary fake object's previous dknown value by storing it
as a flag value within the m_ap_type field of the posing monster, and
recalling it when it is needed.

This is intended to help eliminate observable differences in price display
between real objects and mimics posing as objects.

98% of this is just switching the code to utilize macro M_AP_TYPE(mon)
everywhere to ensure that the flag bits are stripped off when needed.
2019-04-22 14:17:18 -04:00
PatR
190c90e95e tty ^P message recall
Extend 'putstr(WIN_MESSAGE, attribute, string)'s attribute so that
'custompline(SUPPRESS_HISTORY, ...)' can work with ^P's message
history like DUMPLOG history, in order to keep autodescribe feedback
and intermediate prompts for multi-digit count ('Count: 12', 'Count:
123') prompts out of recall history.  The old autodescribe behavior
could easily push all real messages out of the recall buffer when
moving the cursor around for getpos, and the count behavior looked
silly for a four or five digit gold count if you set the msg_window
option to 'full' or 'combination' and viewed them all at once.

Other interfaces may want to follow suit, but this doesn't force them
to make any changes.  I added a hook for "urgent messages" that might
be rendered in bold or red or some such and/or override the use of
ESC at --More-- from suppressing further messages, but there aren't
any custompline(URGENT_MESSAGE, ...) calls (potentially "You die...",
for instance) to exercise it.  Other people have implemented similar
feature it different ways and I'm not sure whether this one is really
the way to go since the core needs to categorize each message that it
deems to be urgent.  MSG_TYPE:stop may be sufficent, although MSG_TYPE
matching can entail a lot of regexp execution overhead at run-time.
2019-02-04 16:46:04 -08:00
PatR
8bf16b940e stale lock picking context
Lock context wasn't being cleared if it was for a container and that
container got destroyed.  Case discovered was forcelock() ->
breakchestlock() -> delobj() (sometimes the container is destroyed
rather than just breaking its lock) followed by #wizmakemap (replace
current level) and maybe_reset_pick() trying to check whether
xlock.box was being carried.  But being interrupted, destroying the
container or dropping it down a hole to ship it to another level, then
attempting to resume picking the lock would also find a stale pointer.
2019-01-31 15:50:12 -08:00
nhmall
55fdfb9200 domove_core() out of domove(); assess domove_core() results
new domove_core() assessment results

potentially smudge engravings

Proceed to wipe engraving after domove_core() now, but only under
all of the following conditions:
    - you can reach the floor
    - preceding domove_core() move attempt was marked as
      having succeeded in domove_core()
    - there is actually an engraving there to impact at
      your original spot, or your new spot, or both
2019-01-27 11:55:23 -05:00
PatR
97b28bd846 level arrival
The check I added to make sure that a monster was at the hero's
coordinates before deciding to move one or the other would have been
confused by a long worm's tail.  Check that they're at that spot but
not by comparing monst.<mx,my> coordinates with <ux,uy>.

Also, don't have wiz_makemap() assume that each level of the Wizard's
Tower has the same boundary coordinates.  Keep track of whether hero
is inside that tower before discarding the old level.
2019-01-14 16:35:19 -08:00
PatR
992f141ab7 \#wizmakemap followup
Both u_on_rndspot() and losedogs() might result in having a monster
and the hero be at the same location.  Have wiz_makemap() use the
same fixup for that as goto_level().
2019-01-14 09:28:10 -08:00
PatR
d735d04b5b \#wizmakemap update
The need for resetting lock picking when swapping in a new level made
me wonder whether other things should be reset too, and there were a
bunch:  digging, travel destination, polearm target, being in water,
being swallowed or held, hiding.  Hero placement was ignoring arrival
region.  Also, it turned out to be pretty easy to fix the FIXME about
steed.
2019-01-13 15:24:08 -08:00
Pasi Kallinen
abcdb713d5 wizmakemap should reset lockpicking 2019-01-13 17:27:17 +02:00
PatR
600261d81f fix github #172 - ^T inconsistencies; add m^T
Fixes #172

Casting teleport-away via ^T used different requirements for energy,
strength, and hunger than casting it via 'Z'.  The strength and hunger
requirements were more stringent, the energy one more lenient.  When
it rejected a cast attempt due to any of those, it used up the move,
but 'Z' didn't.

When testing my fix, I wanted an easier way than a debugger to control
how ^T interacts with wizard mode, so finally got around to a first
cut at being able to invoke it via wizard mode but not override those
energy/strength/hunger requirements.  It uses the 'm' prefix to ask
for a menu.  'm^T' gives four options about how to teleport.  (There
are other permutations which aren't handled.)

Also noticed while testing:  ^T wouldn't attempt to cast teleport-away
if you didn't know the corresponding spellbook.  'Z' will attempt that
because it is possible to forget a book and still know its spell.
2019-01-03 17:37:00 -08:00
PatR
5846aee283 memory #stats
obj->oextra->omonst might contain monst->mextra plus mextra->edog, &c.
That was being ignored when summing up memory allocated for objects.
2018-12-28 15:06:45 -08:00
PatR
83e35a73bd remove dead code from parse()
From Jessie's old static analysis report.  'prezero' was used in 3.4.3
when processing a count for 'multi', but count handling is now done in
a separate routine and 'prezero' in parse() never changes value, so
get rid of it.
2018-12-18 02:24:19 -08:00
nhmall
bebc92f6fb more win32 gui fuzzer work 2018-12-15 19:31:07 -05:00
Bart House
266b5e3891 Small improvements to fuzzer for NetHackW.
Can toggle fuzzer on/off using "Pause" key if attached to debugger.
Extended command selected randomly.
2018-12-15 14:49:59 -08:00
PatR
3165f7af8d spell "autopickup" consistently
The '@' command doesn't hyphenate 'auto-pickup' so 'O' and ^X shouldn't
either.
2018-12-13 16:54:52 -08:00
PatR
cf7536b167 random_response() buffer overflow
'sz' is the size of the buffer; 'if (count < sz) buf[count++] = c;'
can fill the entire buffer, leaving count==sz, so buf[count] = '\0';
would be out of bounds.

Formatting was way off.  Indentation these days should be multiples
of 4 spaces, never tabs.
2018-12-13 02:12:31 -08:00
nhmall
f9beca06dc core code style 2018-12-13 01:36:36 -05:00
Bart House
106cc8acde Merge branch 'win-minor' of https://rodney.nethack.org:20040/git/NHsource into win-minor 2018-12-12 21:46:32 -08:00
Bart House
0cd50847fb Changes to get fuzzer working in NetHackW. 2018-12-12 21:46:14 -08:00
PatR
05c253b6d8 show autopickup in ^X feedback
Gathers all the autopickup information in one place:

Auto-pickup is { off
               | on { for 'classes' [plus thrown]
                    | all types                   } [, with exceptions] }.
2018-12-12 18:55:06 -08:00
PatR
e5b232104e more green slime
When a hero dies due to turning into green slime, actually polymorph
him into a green slime monster before killing him off.  That way he'll
show as a green 'P' on the map instead of white '@' during final
disclosure.  Also, armor that gets destroyed by polymorphing into that
form will be absent from resulting bones file.
2018-12-05 14:56:03 -08:00
PatR
36c2aec2ff fix #H7667 - maybe_reset_pick(), other bad context
When deciding whether to discard interrupted lock/unlock context while
changing levels, maybe_reset_pick() checks whether xlock.box is being
carried.  But it was doing so after the old level had been saved and
memory for non-carried container there had been freed.

That led to a couple of other issues.  context.travelcc was using -1
for 'no cached value', but the fields of travelcc have type 'xchar' and
shouldn't be given negative values.  0 should be fine for 'no cache'.

Failed partial restore which occurred after old game's context had been
loaded would begin a new game with old game's stale context.  Restoring
goes out of its way to avoid that for 'flags' but didn't for 'context'.
2018-12-04 17:10:15 -08:00
PatR
13ef86488a command handling for !SHELL and !SUSPEND
Change the command list to always include #shell and #suspend so that
a user's preferred key bindings can span platforms without worrying
about whether those exist or not.  They're still effectively no-ops
when compiled out.

'#?' suppresses them from the list of displayed commands.  Interface-
specific extended command handling may want to check new extcmd.flag
value CMD_NOT_AVAILABLE to do the same, but failing to do so shouldn't
pose a problem.  They behave sanely if executed when not supported.
2018-12-02 16:43:53 -08:00
nhmall
4a4b3fb8f1 add a macro to ease conditional testing based on active window port
Add WINDOWPORT macro

example:
if (WINDOWPORT("tty"))
	pline("Look at me, I'm on tty at the moment!");
2018-12-02 09:56:44 -05:00
nhmall
38b31dd9ca fix a build error in cmd.c 2018-12-02 09:45:07 -05:00
PatR
f12565398a debug_fuzzer vs '!' and ^Z
My sysconf allows shell escape, and the fuzzer seems fond of that.
Suppress '!' and also '^Z', although I didn't notice it execute the
latter.  Without this hack, the sequence '!', sub-shell exit, '&'
causes nethack to be killed via SIGTTOU while fiddling with terminal
settings for introff().
2018-12-01 16:43:13 -08:00
nhmall
e19ad7d2bc Remove some Windows-specific code from src/cmd.c 2018-12-01 19:24:22 -05:00
nhmall
03ef9da591 Merge branch 'macosx-curses-fall2018' into NetHack-3.6.2-beta01 2018-11-20 21:01:48 -05:00
Bart House
7f4a4188a0 Added initialization of newlevel to quite compiler warnings. 2018-11-20 10:27:09 -08:00
PatR
46184c06af \#stats - delayed_killer
Include memory allocated to delayed killer(s) in #stats feedback.
2018-11-19 16:22:10 -08:00
nhmall
cb43061076 curses changes to existing files 2018-11-16 20:51:22 -05:00
PatR
e486d941ed couple of #wizintrinsic fixes
When #wizinstrinsic was expanded to be able to set any timed attribute,
some that need more than just a timeout counter were left inconsistent.
1) Timed Flying wasn't blocked by levitation, and existing flight
   wasn't becoming blocked by timed levitation.  Also, eventual flight
   timeout wasn't updating the status line, so false 'Fly' condition
   remained shown until a status update happened for some other reason.
2) Setting timer for Warn_of_mon didn't set up any type of monster to
   warn about so wouldn't do anything.  This sets that to grid bug
   unless already set due to polymorph form or artifact that warns.

The end.c portion is just a bit of formatting.
2018-11-10 18:22:38 -08:00
Pasi Kallinen
0bb6754998 Fuzz testing debug tool
Add code to run a fuzz tester, simulating (more-or-less) random
keyboard mashing. There's no option to turn it on, you need to
set iflags.debug_fuzzer on via a debugger or something along
those lines.
2018-11-08 15:55:49 +02:00
PatR
4f541fe216 ^X about armor
Enlightenment feedback for "nudist" was added 3.5 years ago.  Ever
since, ^X has been reporting "you are not wearing any armor" when
wearing a shield without any other armor.

Since Valkyrie starts in that situation, it's very surprising that no
one ever noticed 'til now (or did notice and didn't bother to report).
2018-11-07 14:50:44 -08:00
PatR
9ca519d9f7 yet another ^X revision...
Hopefully this will be the last one.  Change from a text window to
a menu so that it is possible to scroll backwards (without needing
scrollbars) via '^' and '<' keys.  End of game disclosure for
attributes still uses a single-forward-pass text window.

Also, move the recently added weapon proficiency line from the new
'basic' section to right after the "you are wielding" line at the
end of the 'status' section.
2018-11-03 02:01:11 -07:00
PatR
89a3f4a3fd ^X again
Add a new line for one last missing status field:  gold.
Also add one for proficiency with current weapon.

Move a few lines from 'characteristics' to 'background' and a few
more from 'characteristics' to new 'basics', leaving characteristics
with the six original characteristics:  Str, Con, Dec, &c.
2018-11-02 00:59:01 -07:00
PatR
1273d6817e provide dungeon location in ^X feedback
Dungeon level wasn't included in ^X output, so it wasn't actually
giving all status fields and attempting to rely on it when turning
off 'status_updates' was leaving a gap in feedback for the player.
Add an extra line to the first section where character's name and
patron deity are reported, giving current location.
|You are in the Dungeons of Doom, on level 5.
or
|You are in the endgame, on the Elemental Plane of Fire.

The information is more explicit than the basic status field, but
you can already get similar information via #overview so it isn't
giving away extra info.
2018-10-27 03:45:18 -07:00
PatR
3e19858edd fix #H6925 - being trapped vs Levitation/Flying
Make being trapped in/on/over floor block Levitation and Flying, the
way that being inside solid rock already does, and the way levitating
blocks flight.

Blocked levitation still provides enhanced carrying capacity since
magic is attempting to make the hero's body be bouyant.  I think that
that is appropriate but am not completely convinced.

One thing that almost certainly needs fixing is digging a hole when
trapped in the floor or tethered to a buried iron ball, where the
first part of digactualhole() releases the hero from being trapped.
If being released re-enables blocked levitation, the further stages
of digging might not make sense in some circumstances.

I recently realized that being held by a grabbing monster is similar
to being trapped so should also interfere with levitation and flying.
Nothing here attempts to address that.

Save files change, but in a compatible fashion unless trapped at the
time of saving.  If someone saves while trapped prior to this patch,
then applies it and restores, the game will behave as if the patch
wasn't in place--until escape from trap is achieved.  (Not verified.)
2018-09-30 01:06:59 -07:00
PatR
dc3f497d56 more extended command help
For the searching capability offered by '# ?', use ':' instead of 's'
to activate it.  Otherwise, if the player typed ':', menu processing
would handle that and would search the few menu entries (for selectors
'a', 's'--now ':', and maybe 'z') when we're interested in searching
the data displayed via many separator lines.

I left 's' as the selector for "show all, clear search" once a search
has been performed, but perhaps that ought to be switched to ':' too.
2018-09-27 03:52:23 -07:00
PatR
e0b7d2f5a9 monpolycontrol, wizdebug_*
Demote #monpolycontrol and #wizdebug_traveldisplay from commands to
simple boolean options.  The former has the same name, the latter
is called travel_debug.  Rename #wizdebug_bury to #wizbury; it
shouldn't matter that it goes away when compiled without DEBUG.

There are now five wizard-mode boolean options:  monpolycontrol,
sanity_check, and wizweight are documented in the Guidebook;
menu_tab_sep and travel_debug are commented out there.

Guidebook.mn has been tested; Guidebook.tex has not.
2018-09-26 18:40:13 -07:00
nhmall
cd0a29eae8 Merge branch 'flyif_fix' of https://github.com/copperwater/NetHack into copperwater-flyif_fix 2018-09-25 23:22:11 -04:00
copperwater
bab350f355 Fix "would flyif you weren't levitating" - missing space 2018-09-25 23:14:45 -04:00
nhmall
039ad51660 don't impact player stats with wizard mode ^T 2018-09-25 23:08:09 -04:00
PatR
d86e9eaec4 extended commands revision
Reorganize the logic for showing or suppressing an extended command
to avoid a slightly hairy 'foo || bar && quux' expression.

When searching and not finding anything, report "no matches" rather
just waiting for another menu selection.

Plus miscellaneous reformatting.
2018-09-25 03:44:24 -07:00
PatR
d119eca297 simplify #wizidentify
Get rid of bold/non-bold distinction in #wizidentify inventory menu
by only showing items which aren't yet fully identified instead of
full inventory with bold for unID'd.  Support for bold text might
be lacking.

I was considering this even before the report that X11 menus ignore
attribute.  The "_ - (use ^I for all)" menu entry is still present,
but it could be discarded in favor of '.' to pick everything via
ordinary menu selection.
2018-09-24 17:06:04 -07:00
nhmall
3f5ef9bdf3 make long extended commands list be more navigable 2018-09-24 16:45:38 -04:00
PatR
533234f13d arg type mismatch
This was right in 3.4.3 but got changed way back in 2004.
No effect on play and unlikely to be complained about by any
compiler.
2018-09-06 16:28:42 -07:00
nhmall
5a44a34420 wizidentify suppress unnecessary prompt; allow individual items for perm ID
Don't display the selection to identify all items if there are none.

Complete an item marked ToDo in cmd.c: allow selection of one or more
particular items to permanently identify rather than just all or nothing.
2018-09-01 10:43:26 -04:00
PatR
f1d0636ba0 fix wiz identify bugs
Fixes #124

Fix github pull request #124 which was also reported directly (but not
through the contact form so #Hxxx number).  Using ^I or #wizidentify
displays inventory with everything ID'd for that command only and adds
a menu entry "_ - use '^I' to identify" that can be chosen to make
those ID's persistent.  Picking underscore would work but picking the
alternate '^I' wouldn't work if the platform had unsigned characters
for plain 'char'.  Switch the return value from magic number -1 to
magic number ^I which isn't a valid inventory letter and isn't subject
to sign conversion.  Casting -1 to '(char) -1' would have worked too
despite some confusion expressed in discussion of the pull request.

If ^I has been bound to some other command and #wizidentify hasn't
been bound to any keystroke, temporary ID didn't disclose any extra
information (ie, acted like ordinary inventory display) and the extra
menu entry to make temporary ID become persistent wasn't available.
This fixes that too.
2018-08-29 19:19:49 -07:00
nhmall
81e422189c Windows wouldn't compile without TTY_GRAPHICS defined 2018-05-21 16:44:19 -04:00