Commit Graph

4909 Commits

Author SHA1 Message Date
PatR
f7bf56555e fix pull request #227 - running over engravings
Fixes #227

Travel, <ctrl><direction>, <g|G><direction> all stop on engravings,
but <shift><direction> told the player what the engraving said and
kept going.  The message output is buffered until map update or
another message, so player couldn't tell where hero was at the time
the engraving got shown.  Make <shift> running stop on engravings.
2019-10-05 16:42:13 -07:00
PatR
8443f73265 glob pricing
get_pricing_units() returns a long, so use long for intermediate steps
of the calculation.  Part of github issue 229, about mixing signed and
unsigned.
2019-10-04 17:53:01 -07:00
PatR
c6b7540712 potion mixing - healing vs "bad" potions
Another part of github issue 229, mixtype() didn't have either 'break'
or '/*FALLTHRU*/' separating healing from extra healing, extra healing
from full healing, and full healing from unicorn horn.  So dipping
"bad" potions (sickness, confusion, blindness, hallucination) into
healing/extra healing/full healing or vice versa operated the same as
dipping a unicorn horn into the bad potion (producing fruit juice for
sickness and water for the others).  It wasn't clear from the code
whether or not that was intentional.  It actually seems reasonable
(albeit suboptimal use of {plain, extra, full} healing), so continue
to allow it and make the code clear that it's intentional.
2019-10-04 17:28:32 -07:00
PatR
f11f4de057 sortloot of tools
Fix the first part of github issue 229.  sortloot_classify() tries to
group musical instruments separately from other tools, but missing
'break' in a 'switch' prevented that from happening--they were mixed
together.

Since that grouping isn't documented anywhere, only source divers
would ever notice that it wasn't working as intended.
2019-10-04 16:37:14 -07:00
PatR
f3bc5e5c78 fix #H9272 - "object lost" panic
when polymorph causes loss of levitation boots or water walking boots
while over water.  If discarding stuff while trying to crawl out got
rid of the taken-off boots, they wouldn't be in inventory any more
when break_armor() tried to drop them after taking them off.
2019-10-04 16:12:08 -07:00
PatR
8fa38ec8fb fix 'b&c distance' sanity check warning
when attempting to crawl out of water fails and hero is life-saved
or wizard-/explore-mode player declines to die.  If the hero is saved
by positioning him/her one step further away from ball and chain,
teleds() tries to drag them, but if 'emergency disrobe' left the hero
stressed or worse, dragging fails.  Ball and chain were being left
where they were, with chain no longer being adjacent to hero.

If drag_ball() fails, have teleds() teleport ball and chain to hero's
new spot, same as when that isn't within range of a one step drag.
2019-10-04 15:16:51 -07:00
PatR
d9a1bbb203 fix #H9269 - potential panic due to window slots
A couple of early returns could result in temporary windows getting
left around instead of being released for re-use, which in turn might
lead to a panic due to lack of available window slots.  The first
one is accompanied by an 'impossible' warning which no one has ever
reported and the second one could only happen if data file 'keyhelp'
was missing, so panic due to either of these is hypothetical as far
as released versions go.  Somebody making modifications could run
afoul of either of them though.

query_category() - switch from early return to 'goto' so that the
  temporary window used for a menu will always be destroyed;
whatdoes_help() - defer creating the display window until after the
  data file has been successfully opened so that early return won't
  need any window cleanup.
2019-10-03 15:45:43 -07:00
nhmall
5400c6796a yet more orc obj init 2019-10-02 14:58:21 -04:00
nhmall
c10bd97e1a more orc obj init 2019-10-02 14:55:28 -04:00
nhmall
1df652683e allow orctown booty items to be initialized in mksobj 2019-10-01 21:06:07 -04:00
nhmall
72252d5dc6 follow-on bits 2019-10-01 17:47:45 -04:00
nhmall
29946b551b autopickup exception priority in pull request 226
The pull request #226 commentary follows:

One major limitation of the autopickup exception system is that you can't
define an exception from an exception, despite both menucolors and msgtypes
prioritizing rules based on the order they are defined in .nethackrc. This
is because the "always pickup" and "never pickup" exceptions are tracked in
different lists, and at runtime, when the player steps over an object, the
game checks these lists seperately, with "never pickup" taking precedence.
This means that if you want to pick up some but not all items matching a
given expression, you may need to write a long and kludgy list of regexes
to get the behavior you want.

I've edited the autopickup exception code to remove this necessity: now
the exceptions are stored in one list, and conflicts between them are
resolved based on their relative position in that list. Whether an
exception was inclusive or exclusive was already tracked individually;
I don't know why they were stored separately in the first place. This
edit makes the system both more convenient and more consistent with the
semantics of menucolors and msgtypes.

With these changes, the 33 autopickup exception rules in the wiki article
linked above may be replaced with the following 7 much simpler rules for
the exact same effect:

AUTOPICKUP_EXCEPTION=">.* corpse.*"
AUTOPICKUP_EXCEPTION="<.* newt corpse.*"
AUTOPICKUP_EXCEPTION="<.* lichen corpse.*"
AUTOPICKUP_EXCEPTION="<.* lizard corpse.*"
AUTOPICKUP_EXCEPTION="<.* floating eye corpse.*"
AUTOPICKUP_EXCEPTION="<.* wraith corpse.*
AUTOPICKUP_EXCEPTION=">.*\>.*"

closes #226
2019-09-30 10:54:03 -04:00
nhmall
657b65bd3c Merge https://github.com/Vivit-R/NetHack into Vivit-autopickup-exceptions-3.6 2019-09-30 10:48:18 -04:00
HMM
ca95246903 Remove redundant function "count_ape_maps" 2019-09-30 02:12:06 -04:00
HMM
1f5e619887 Delete unusued local variable 2019-09-27 15:42:50 -04:00
HMM
f68561fbe1 Fix check_autopickup_exceptions to return null pointer if no exception is found 2019-09-27 15:17:53 -04:00
nhmall
da6c393e43 fix errant verb tense in some messages if pet or mon name ends in 's'
Report stated:
"Poes deliberately slither onto a polymorph trap!" ... it's only one cat, er,
black naga. Why does the parser treat the name as plural? There are lots of
singular words and names that end in -s or -es!

H9249 1780
2019-09-26 11:49:15 -04:00
HMM
234e5f38f2 Clean up stray comments 2019-09-24 20:05:37 -04:00
HMM
098e3e5b3e Merging in autopickup exception rework 2019-09-24 19:12:54 -04:00
HMM
2fb9cf7a1c Rework autopickup exceptions to override one another like menucolors 2019-09-24 18:20:49 -04:00
nhmall
9361e872b2 fix uarmh null pointer dereference
uarmh null pointer dereference if a helm of opposite alignment came off due
to being polymorphed

fixes #225
2019-09-24 12:32:58 -04:00
PatR
348f968132 fix add_to_minv panic when aklys kills enfulger
Reported directly to devteam rather than via the web contact form:
throwing wielded aklys while swallowed would hit the engulfer and
return to the hero's hand but leave a stale 'thrownobj' pointer if
the monster survived.  Under usual circumstances, throwing anything
else or throwing the aklys again when not engulfed would clear that
pointer, putting things back to normal.  However, killing any engulfer
with the same weapon would try to add it to engulfer's inventory to
be dropped as it died.  If the killing blow was via melee rather than
another throw, the object in question would still be in hero's
inventory instead of free, hence panic.

The initial returning-aklys implementation shared Mjollnir's code
which doesn't have this issue.  This reverts from having attached
aklys always returning successfully when thrown while swallowed to
Mjollnir's 99% chance of return and 99% to be caught when it does
come back.  (That was already the case if the engulfer was killed by
the throw, where hero wasn't swallowed anymore after the damage was
inflicted.)
2019-09-23 15:16:39 -07:00
nhmall
bd26d2edbe correct spelling mistake on stupefied
As reported in github issue 224

Fixes #224
2019-09-23 14:19:15 -04:00
PatR
0434437e99 fix #H9232 - message phrasing for openholdingtrap
Zapping wand of opening or spell of knock at self while trapped:
"You are released from pit."
ought to be
"You are released from the pit."
Likewise for most of the other held-in-place situations.

Also, when released like that vision wasn't being recalculated right
away to update line of sight to reach beyond the edge of the pit.
2019-09-22 15:03:52 -07:00
PatR
b1154399f1 fix github issue 223 - rubbing ring on touchstone
Fixes #223

The touchstone code treated all rings as if they had gemstones, but
quite a few don't and feedback could be unexpected.  Cited case was
an iron ring yielding a cyan (hi_metal) streak instead of the normal
iron result ("scritch, scritch").  A gold ring yielded a yellow
streak rather than a golden scratch.  I didn't test silver ring but
suspect it yielded a silver streak rather than a silvery scratch.

This changes touchstones to treat non-gemstone rings like other
classes of objects instead of like gems.  I made mineral rings keep
acting like gemstone rings--I'm not sure whether that's right.
2019-09-19 12:48:41 -07:00
PatR
6569631180 fix github issue 221 - unfixable troubles
Fixes #221

Routine unfixeable_trouble_count() is used for both applying a unicorn
horn (possibly internally via #monster if poly'd into a unicorn) and
drinking a blessed potion of restore ability.  For the latter case, it
always gave the wrong answer (unless the hero happened to be all of
Sick and Stunned and Confused and Hallucinating and Vomiting and Deaf).
Since the actual count wasn't used to decide whether hero felt "great"
or just "good", having any of those conditions would hide the problem.
2019-09-18 11:37:11 -07:00
PatR
5589a16d74 github pull request - "You are <a foo>[.]"
Fixes #215

A post-3.6.2 change added a message for life-saving which lack its end
of sentence punctuation.
2019-09-14 18:00:39 -07:00
PatR
7c2b7d4417 github pull request - fake mail
Fixes #216

A github pull request changed one of the fake mail messages so that
our web site's URL is added at compile time instead of being hard-
coded.  However, it wouldn't compile with a pre-ANSI compiler since
it relied on concatenating adjacent string literals.  This is more
complex but achieves the same result, and also makes the existing
run-time subsitution be a bit clearer.

Testing was a hassle but eventually successful.
2019-09-14 17:52:02 -07:00
PatR
1a97dce727 fix github issue 218 = hallu vs passive gaze
Fixes #218

Hallucinating hero has 75% to be unaffected by a gaze counterattack
that paralyzes.  Check for that before checking free action (100%
chance to be unaffected).  The only change is that player might get
different feedback when both forms of protection against the gaze.
2019-09-06 14:39:25 -07:00
PatR
c53a72162c fix github issue 210 - dead code in sp_lev.c
Fixes #210

Subject was 'Bad loop condition in sp_lev.c'.  Some object creation
code had handling for something that couldn't happen due to the logic
leading up to it.  I couldn't figure out any way to make it useful so
just remove the dead code.
2019-09-06 14:27:40 -07:00
Pasi Kallinen
6426e61860 Prevent a possible impossible when guard relocated a monster 2019-09-06 22:09:03 +03:00
PatR
8cf70f7771 fix github issue 217 - monster spellcasting feedback
Fixes #217

Feedback when spellcasting monster aimed at the wrong spot due to not
being able to see an invisible hero only gave the intended message if
hero couldn't see self.  The code was using 'if (Invisible)' which
checks whether the hero is invisible and can't see invisible, when it
should have been using 'if (Invis)' which just tests whether the hero
is invisible.

It wouldn't surprise if the same problem occurs elsewhere.  Those
macros are rather error prone.

The issue report mentions that one of the affected messages might be
unreachable.  I didn't investigate that.
2019-09-02 02:59:09 -07:00
PatR
d8598bd6bb 'O' vs perm_invent (mostly)
Update persistent inventory window if 'implicit_uncursed', 'menucolors',
or 'guicolor' is toggled.  (curses should be changed to use menucolors
instead of guicolor to decide whether menu coloring is used.  Right now
it requires that both be On.)

Also, EDIT_GETLIN was providing junk default response when message type
or menu color looped and prompted for another entry after handling one.

Mixed in with this is a fix for easily induced buffer overflow which
has security ramifications....
2019-08-31 01:38:19 -07:00
PatR
3e0d029a45 fix #H9164 - crash during restore when swallowed
Subject was "display crash while in curses mode".  Restoring with
perm_invent set in config file or NETHACKOPTIONS when the save was
made while swallowed (regardless of perm_invent at that time) resulted
in a crash when invalid u.ustuck was referenced before restoration had
done its pointer fixups.

init_nhwindows() is called with perm_invent On;
restgamestate() temporarily turns it Off (3.6.2 restore hack);
if/when update_inventory() gets called, curses notices that the
persistent window has been disabled so it tears down all its windows
in order to redraw the screen without that one;
docrt() sees non-Null u.ustuck and calls swallowed();
swallowed() tries to use the value of that pointer rather than just
Null/non-Null but the value is from the previous game session, not
valid for the current session;
crash.

Make yet another attempt to prevent update_inventory() from being
called during restore.  curses won't try to redraw and the crash
won't happen.  But the invalid pointer is still lurking (until an
eventual fixup later during restore).

An earlier fix for update_inventory() during restore actually handled
this problem (for the most common trigger, setworn(), but not in
general), so the 3.6.2 behavior is a regression.
2019-08-30 18:11:43 -07:00
nhmall
8a328ff7eb quite some Xcode warnings 2019-08-17 12:55:48 -04:00
PatR
a995929168 fix #H9118 - stoning a sandestin
causes "dmonsfree: N removed doesn't match N+1 pending" warning.  The
sandestin monster definition flags it as MR_STONE, immune to being
turned to stone.  If the hero hit it with a cockatrice while it was
shape-changed into something which isn't MR_STONE, it had its mon->mhp
set to 0, so died, and its form (mon->data) was set back to sandestin.
known_hitum() decided that it didn't turn to stone because of MR_STONE
for that form so proceeded to kill it off due to lack of hit points,
causing it to die twice.

I started to change that so that it didn't kill off the critter a
second time, bit it really shouldn't be able to kill it by stoning in
the first place.  So sandestin how shares some vampire code to revert
to innate form and not turn to stone when "killed" by stoning.  It
only yields the normal visible polymorph message:  "the <foo> turns
into a <bar>" without any attempt to explain why.  Once in sandestin
form, smacking it with a cockatrice corpse doesn't do anything special
(due to MR_STONE now being unambiguously in effect).  It will soon
shape-change to some other form and then become subject to being
forced back to innate shape by stoning again.
2019-08-14 18:49:16 -07:00
PatR
c814ca8e04 fix #H9117 - bookeeping for fatal status condition
When Stoned, Slimed, Strangled, Sick (TermIll or FoodPois or both)
counts down to 0 without being cured, keep it listed as an active
condition while killing off the hero.  It will show in the status
section when disclosing final attributes and in both that section
and map's status lines when producing a dumplog.
2019-08-11 18:56:43 -07:00
PatR
a2a257a512 fix github issue #211 - wrong parentheses
Fixes #211

dopickup() was getting the wrong value from pickup_checks() due
to misplaced closing parenthesis.  But it didn't actually impact
play; picking things up from engulfer's minvent while swallowed
worked even though the special check for that was failing.  The
code which was accidentally being skipped can probably go away but
I haven't gone that far.
2019-08-08 11:25:36 -07:00
PatR
cc3d97d9b3 fix github issue #209 - typo in end_of_input()
Fixes #209

Fix typo:  program_statue should be program_state.  Apparently
NOSAVEONHANGUP+INSURANCE isn't used by anyone since it wouldn't
compile.
2019-08-08 11:01:56 -07:00
PatR
508af05e42 fix #H9084 - teleported boulder left stale screen
Report was for Sokoban but it applied anywhere:  if a teleported
boulder landed in a pit or trap door or hole and flooreffects() used
it up (so returned True), rloco() didn't update the location it was
teleported from and it appeared not to have moved.  (Line of sight was
updated to reflect its absence but map spot wasn't redrawn without it.)
2019-08-02 11:51:26 -07:00
PatR
55e166ba08 fix #H9082 - post-3.6.2 monster throwing crash
Changing
  if (ammo_and_launcher(otmp, uwep) && mwep->otyp == ELVEN_BOW)
(with 'uwep' typo) to
  if (mwep->otyp == ELVEN_BOW && ammo_and_launcher(otmp, mwep))
(with fixed 'mwep') moved ammo_and_launcher()'s hidden non-null
test to after 'mwep->otyp'.  If mwep was Null (so monster must be
throwing non-ammo such as darts or daggers rather than shooting
with a launcher), a crash occurred.  (Throwing such things while
the monster is wielding any weapon doesn't have this problem.)

I don't think 3.6.2 can crash here.  If hero's uwep is a bow, otmp
must be arrows to get past pre-3.6.3's incorrect ammo_and_launcher()
check.  And a monster won't shoot arrows unless wielding a bow, so
monster's mwep would be non-Null regardless of what uwep is.

I tested a kobold with darts and an elven bow.  But I also gave it
one elven arrow to provoke it into wielding the bow and my test
didn't throw darts with nothing wielded....
2019-08-02 10:42:26 -07:00
PatR
31c8038344 bad weapon check for monster multi-shot shooting
A typo caused the bow and arrow check when a monster was wielding an
elven box to test the hero's weapon with monster's ammo.  [I looked
at the old slash'em code where I think this came from and it doesn't
have the typo but does have a different bug.  A monster could get a
multi-shot volley by wielding an elven bow when throwing darts or
spears.  The extra bow and arrow check is intended to prevent that.
The typo was probably by me but I have no memory of that code....]

Elves with bows (or other monsters who manage to pick up and wield an
elven bow) will shoot bigger volleys after this fix.  That will make
them more dangerous but also cause them to run out of arrows more
quickly.
2019-07-31 14:22:09 -07:00
PatR
6dffe52a27 Glory of Arioch vs spellbook
From the newsgroup (reported for slash'em but applies to nethack too):
a chaotic monk was crowned and told he or she had been "chosen to
steal souls for My Glory!" while being given a spellbook of restore
ability which has nothing whatever to do with soul stealing.  There's
alternate wording for when Stormbringer can't be given because it
already exists; also use that for when it's not going to be given
because the character is discouraged against wielding weapons.
2019-07-30 17:24:33 -07:00
PatR
ed18ebc545 timer validations
Add the contributed code that checks for attempting to start a
duplicate timer.  It's based on a comment which must have been there
at least 25 years and doesn't solve any known problems, but it is
conceptually similar to the large amount of sanity checking which has
gone into 3.6.x.

It didn't work as is because it was comparing two unions with '=='.
I don't know offhand whether C++ supports that but C doesn't (through
C11 at least; don't know about C17).  The union ('anything') is simple
enough that two instances can be compared without jumping through hoops.

I've also added another check for timer 'kind' (level, object, monster,
or global).
2019-07-27 16:12:24 -07:00
Bart House
a607ea2b7f Revert "When fuzzing, use the number of moves as a proxy for the hour."
This reverts commit f75deae0bc.
2019-07-14 21:29:41 -07:00
Bart House
5870cb6a92 Revert "Added experimental feature NEW_KEYBOARD_HIT."
This reverts commit bc65112ce0.
2019-07-14 21:28:55 -07:00
Bart House
fe9fc4cac1 Revert "Added nhassert to core."
This reverts commit 0ca299acb3.
2019-07-14 21:15:54 -07:00
Bart House
a90f9d4365 Revert "Fixed sign/unsigned comparisions."
This reverts commit 0e8e5aac93.
2019-07-14 21:15:31 -07:00
Bart House
177bd39646 Revert "Tweaks to nhassert implementation. Change to warnings on MSC build."
This reverts commit 2f3da35c68.
2019-07-14 21:15:01 -07:00
Bart House
ec05e1ec70 Revert "Fix compiler warnings."
This reverts commit 90f5aa91b7.
2019-07-14 21:13:43 -07:00