Commit Graph

12419 Commits

Author SHA1 Message Date
Michael Meyer
2abe08d0bf Formally block artifacts as random box contents
Another (latent) case of an artifact possibly being generated and
immediately deleted: part of the process of a mimic disguising itself as
an item involves generating a random object, then deleting it.  If this
item is a box or sack, it will generate with random contents, which will
be deleted along with the container. If artifacts are allowed as random
box contents, this can silently remove an artifact from being available
in the game.

This is effectively blocked already, since none of the artifacts
eligible for random generation are items from classes marked as valid
box contents (see boxiprobs[] in mkobj.c).  Nonetheless, formally
preventing artifacts from generating as box contents will guarantee this
issue won't crop up if a randomly generated artifact tool, ring, etc, is
added in the future.
2021-10-26 11:55:00 -07:00
Michael Meyer
b242fbce5a Fix: artifacts silently removed from the game
Death drops will generate a random item, which may be an artifact.
After the object is created, some rules are applied to check whether its
size matches the monster that dropped it; if it fails these checks,
the item is deleted.  aosdict recently pointed out that if the death
drop was an artifact, this would permanently remove it from the game.

Use artifact_exist(..., FALSE) in various cases where potential
artifact objects are created, then immediately removed.  This will
prevent artifacts from being removed from play by marking the artifact
as available to create again.
2021-10-26 11:54:59 -07:00
PatR
cffeecee26 fix #K3474 - "you detect it where <foo> was"
A vampire in bat form was seen via infravision or possibly telepathy,
then when it changed into fog cloud form the feedback was
|You now detect it where the vampire bat was.
The message substitutes "detect" for "see" when the new form can't
be seen and the monster name formatting yields "it" for that case.

Give a vanish message instead since that is effectively what happens.
2021-10-26 03:11:55 -07:00
PatR
b4908f6928 fix pull request #621 - potential divide by 0
The pull request by argrath changes weight_cap() to never return a
value less than 1 because try_lift() divides by that return value
and a 0 would trigger a crash.  The code involved is used when
attempting to pull a monster out of a pit via #untrap.

I'm fairly sure that weight_cap() can never produce a value that's
less than 1 already, but have put in a variation of the PR's fix.
I've also implemented a different fix that removes the division
from try_lift().  The original code seems to have gone out of its
way to avoid calculating inv_weight() twice, but doing the latter
(for the once in a hundred games where it might happen) greatly
simplifies things by removing details of carrying capacity.

Fixes #621
2021-10-25 14:51:26 -07:00
nhmall
27fcf8999f re-do the wounded legs fix 2021-10-24 21:41:49 -04:00
nhmall
a7eca53f53 wounded legs check in insight.c
close #620
2021-10-24 21:34:05 -04:00
nhmall
1d405c511d more comment accuracy 2021-10-24 18:04:57 -04:00
PatR
6edadc4884 fix github issue #614 - applying polearm at doors
Reported by G7Nation; attacking walls and such with a polearm just
gave lackluster "you miss; nobody's there" feedback.

Make applying a polearm at some non-monster locations give feedback
similar to using 'F'orcefight with melee weapons.  Was
|You miss; there is no one there to hit.
now
|You uselessly attack the closed door.

Also, extend the supported locations to include dungeon furniture.
Was
|You attack thin air. ('F')
now
|You harmlessly attack the throne. ('F')
|You uselessly attack the throne. ('a')

This doesn't address #613:  attempting to hit non-visible locations
with an applied polearm.

Closes #614
2021-10-24 10:06:30 -07:00
nhmall
0ea7e7aef4 comment accuracy
The function involved is a different one now, but the comment had not
been updated.
2021-10-24 09:31:31 -04:00
PatR
b97df3e9e4 closed door descriptions 2021-10-23 17:33:39 -07:00
nhmall
c6f5b41e51 move compiler override note above the autodetection 2021-10-23 12:30:02 -04:00
PatR
37e63f6829 breaking wielded fragile item against iron bars
Reported by entrez, wielding something fragile (potion of acid
perhaps), and using F to smash it against iron bars called breaktest()
directly, then a second time indirectly through hero_breaks() via
hit_bars().  There is a random chance to resist breaking (99% for
artifacts, 1% for other items) so breaktest() might say that something
will break on the first call and that it will not break on the second
call, or vice versa.  That could remove uwep from inventory then leave
it in limbo without destroying it, or destroy uwep without removing it
from inventory first triggering impossible "obfree: deleting worn obj".
2021-10-22 19:11:51 -07:00
nhmall
56f79dd207 Merge branch 'pr617' into NetHack-3.7 2021-10-22 15:24:37 -04:00
nhmall
df0ed882a8 use %lu in format string in timer_sanity_check()
closes #617
2021-10-22 15:23:07 -04:00
nhmall
7601e5709f Merge branch 'fix-format-char' of https://github.com/argrath/NetHack into pr617 2021-10-22 15:19:25 -04:00
nhmall
b44b5e35a8 re-enable -Wunreachable-code under clang
whitelist the valid cases showing up

If an earlier version of clang is showing more cases (particularly
if they don't make sense), the re-enabling of the warning in
sys/unix/hints/include/compiler.2020 can be made clang-version
specific instead. I had no way to test earlier versions.
2021-10-22 12:27:10 -04:00
SHIRAKATA Kentaro
bfd79f5c9d use %lu for unsigned long
`curr->tid` is unsigned long, so use `%lu`.
2021-10-23 01:07:40 +09:00
PatR
0617410ff3 feedback for monster jumping onto polymorph trap
Give feedback for "<Mon> jumps onto a polymorph trap" in more
circumstances.  It used to give the message if the monster could
be seen, and it would map the trap if the monster's location could
be seen.  That led to some confusion when an infra-visible monster
was at a spot in the dark so the trap was accurately described but
didn't get mapped.

Map the trap if either the monster's or the trap's location can be
seen.  If it isn't already known and isn't becoming known (the
infravision case), say "hidden trap" instead of "polymorph trap"
in the message.  Give the "jumps onto trap" message if either the
monster can be seen or the trap's spot can be seen.  When monster
can't be seen, it would normally be described as "It"; switch to
"Someone" (when humanoid) or "Something" (non-humanoid) instead.

Minor unrelated bit:  the use-container action was between the 2nd
and 3rd polymorph cases.  Move it, after the third one.
2021-10-21 12:07:19 -07:00
nhmall
6c114af629 Merge branch 'pr616' into NetHack-3.7 2021-10-21 13:36:50 -04:00
nhmall
090f1fb029 check for NULL Lua_State prior to lua_close()
fixes #616
2021-10-21 13:34:21 -04:00
nhmall
182d1837fa Merge branch 'guard-luaclose' of https://github.com/argrath/NetHack into pr616 2021-10-21 13:30:42 -04:00
nhmall
16443f0db9 gcc 11 warning
../win/tty/wintty.c:4043:39: warning: argument 2 of type ‘int[3]’ with mismatched bound [-Warray-parameter=]
 4043 | check_fields(boolean forcefields, int sz[3])
      |                                   ~~~~^~~~~
../win/tty/wintty.c:221:38: note: previously declared as ‘int *’
  221 | static boolean check_fields(boolean, int *);
      |                                      ^~~~~
2021-10-21 13:24:38 -04:00
SHIRAKATA Kentaro
62e6b5a336 guard lua_close()
nhl_done() can be called with L == NULL.
So lua_close() should be guarded.
2021-10-22 02:13:17 +09:00
nhmall
9b78ff740d clang 12 warning
makedefs.c:1560:5: warning: suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma? [-Wstring-concatenation]
    "  ",
    ^
makedefs.c:1559:5: note: place parentheses around the string literal to silence warning
    "currently available will not suffice for proving that P != NP or        "
    ^
1 warning generated.
2021-10-21 11:53:01 -04:00
nhmall
559a9cde21 fixes37.0 updates for pr612, 613, 615
closes #612
closes #613
closes #615
2021-10-21 08:48:23 -04:00
SHIRAKATA Kentaro
1f651f8f00 initialize attknum
`attknum` is declared without initialization, and is used on
find_roll_to_hit().  This leads unexpected result.
2021-10-21 08:48:23 -04:00
SHIRAKATA Kentaro
0f36d7ac6e revert MAX_RADIUS change
On 59818fb, MAX_RADIUS was changed from 15 to 16 to intend to support
"radius 0".  But MAX_RADIUS doesn't means the range but outer bound of
the radius table, so it should not be changed, and this change led
possible out-of-bound access on view_from() and do_clear_area() in
vision.c.

This commit reverts the change and avoids the problem.
2021-10-21 08:48:23 -04:00
SHIRAKATA Kentaro
ed543d7832 fix pointer precedence 2021-10-21 17:41:13 +09:00
PatR
1f9c8b8ef9 fix #K3472 - stale perm_invent when engraving
Engraving with a weapon which has known enchantment or with a magic
marker which has known charge count that decremented the amount did
so without updating the persistent inventory display.  Report was
for curses but applied to every interface that can show perm_invent.

This includes some reformatting (mostly
 if {
 }
 else {
 }
to
 if {
 } else {
 }
multiple times; also add some new braces after 'if' or 'else' where
one half already had those and the other didn't).  And removal of
some unnecessary 'register' designators.

Plus fix up one sanity check which complained if number of charges
being used was more than a marker had, but then let the engraving
continue and decrement the count by that large amount.  If that
impossible situation ever occurred, it would result in a marker
with negative charges.
2021-10-20 14:56:01 -07:00
PatR
f9be7a4b8a boulders vs vault walls
Noticed when testing the "wall_angle: unknown" fix, if there is a
boulder rather than a door in the breach in a vault's walls at the
spot where the guard arrives, the guard would walk onto it, tell the
hero to drop any gold and follow, then move back.  The boulder would
remain in the hero's way and couldn't be pushed because the guard was
in the boulder's way.  Have the guard smash any such boulder(s) into
rocks when arriving (with no explanation for how that is accomplished,
just a message about seeing or hearing boulder(s) shatter).  Later
when repairing the walls, delete any rocks or boulders at all vault
wall locations (even when no gap-to-wall repair is needed).
2021-10-18 12:55:28 -07:00
PatR
1d334b861f another "next boulder" bit
simpleonames() calls minimal_xname() which was setting up a dummy
object and making its corpsenm field be NON_PM.  For a boulder, that
yielded "next boulder" instead of the intended "boulder".
2021-10-18 12:10:38 -07:00
nhmall
7a3da50156 another melting ice follow-up 2021-10-17 09:52:42 -04:00
nhmall
592e00b981 melting ice follow-up 2021-10-17 08:20:50 -04:00
nhmall
17165e3b92 melting ice timeout issues
Reported directly to devteam by entrez via email:
>
> I noticed some potential issues with (melting) ice:
>
>   * Digging down into ice, or setting a land mine on the ice and
>   triggering it, doesn't remove the melt_ice timeout, so it can result
>   in a sequence like dig down -> pit fills with water -> freeze water
>   -> freezing water tries to set melt_ice timeout -> duplicate timeout
>   impossible.  Or if you don't freeze the water again, melt_ice will
>   run on a non-ice surface, which might at least produce strange
>   messages.
>
>   * Setting a land mine on ice: melting ice doesn't do anything with
>   the trap, so there is still a land mine which you can trigger by
>   flying over the water (the land mine's trigger is also still
>   described as being 'in a pile of soil', despite being underwater at
>   this point).  Similar thing happens with bear traps.
>
>   * Not really related to _melting_ ice, but an exploding land mine
>   doesn't reset the typ from ICE to FLOOR (like normal digging does),
>   so it will result in a square with a pit that is also an ice square,
>   where the ice can melt under the pit and produce a combination
>   pit/moat.  If you then freeze the moat, the pit reappears on top of
>   the ice.
2021-10-16 22:22:33 -04:00
PatR
91b4e4570d more github issue #606 - wall repair vs doors
Fix the vault repair issue that could lead to "wall_angle: unknown"
warning.  Unlike shop repair, the original wall info isn't available
so this recreates it.  The extra 'flags' field added yesterday could
be eliminated but this leaves it in place.

Fixes #606
2021-10-16 11:35:11 -07:00
PatR
07b1d9d396 travelling through boulders
If the hero can move to a boulder's location via m<dir>, allow travel
to do so too.  You will always stop on the boulder spot rather than
keep going toward the destination because of change in visibility at
a boulder spot.

Giants should be able to see over boulders, and doing that for poly'd
hero would probably be straightforward, but when not poly'd, seeing a
giant beyond a boulder and vice versa seems like it would be a can of
giant-sized worms.

A couple of other miscellaneous changes are mixed in with this.
2021-10-16 09:54:08 -07:00
nhmall
39713783d1 some trailing whitespace in src, include 2021-10-16 12:12:21 -04:00
nhmall
711007cd44 trailing blank 2021-10-16 11:29:19 -04:00
nhmall
44e95a14c2 Merge branch 'pr573' into NetHack-3.7 2021-10-16 10:53:40 -04:00
Michael Meyer
121290cde6 fix m-prefix movement into warning symbol (pr573)
https://github.com/NetHack/NetHack/pull/573 by entrez
Pull request comment states:
"Moving into a position containing a warning symbol with m-<direction> to
'safely' move would still attack as though the 'm' prefix was not
specified.  Ensure warning symbols are counted as 'detected' monsters
for this purpose, to avoid falling through to do_attack()."

Closes #573
2021-10-16 10:50:54 -04:00
nhmall
b1b06f8734 Merge branch 'pr602' into NetHack-3.7 2021-10-16 10:38:27 -04:00
HMM
e2be44f2dd variation of imp's pr 602 period-speak
This pr is not merged word-for-word from the original pull request
by Vivit-R

Closes #602
2021-10-16 10:36:13 -04:00
nhmall
ba64bb8ce2 out-of-bounds access in farlook pr592
https://github.com/NetHack/NetHack/pull/592 comment states:
"In commit db68395, most of the instances of xdir and ydir here were
changed to u.dx and u.dy, but not all of them. The remaining ones are
out-of-bounds on xdir and ydir, because i is always set to 12 from an
earlier loop and is no longer involved in handling user input. They
should be u.dx and u.dy like the rest."
2021-10-16 10:16:13 -04:00
nhmall
bb67bec0fd Merge branch 'fix-asan-issues' of https://github.com/copperwater/NetHack into pr592 2021-10-16 10:14:42 -04:00
PatR
d9bbad8e6e fix github issue #606 - shop wall repair
triggering an impossible warning about "wall_angle: unknown" due
to the known conflict between door state and wall info which both
overlay the flags field for map locations.

Reported and diagnosed by vultur-cadens:  if a shop's wall was dug
open, followed by use of locking magic to plug the gap with a door,
and then unlocking that door, the D_CLOSED door flag was left as
invalid wall_info when shop damage was repaired.  Map re-display
complained.  Leaving the door locked or opening it after unlocking
did not result in any complaint because the values for those door
states do not conflict with wall angle values.

The problem was reproducible and is now fixed by adding an extra
field to the shop damage structure.  A similar change has been
made to the vault guard's 'fake corridor' structure but I have no
test case for that so don't know whether it makes any difference.
At least it doesn't seem to have broken anything.

Existing save and bones files are invalidated by the fixes.

Fixes #606
2021-10-15 15:43:23 -07:00
nhmall
53bb04d9ad fixes entry for consoletty.c fix
Closes #604
2021-10-12 21:23:29 -04:00
nhmall
92f54e600d consoletty.c preprocessor directives
The preprocessing was a little messed up if VIRTUAL_TERMINAL_SEQUENCES was not
defined.
2021-10-12 21:15:54 -04:00
PatR
5350f049b2 remove unused globals: save_cm, was_waterlevel
From entrez.  Since restoring was removed separately it was easier
to edit the files manually than to use his diff.
2021-10-12 11:41:56 -07:00
nhw_cron
9c667501b6 This is cron-daily v1-Jan-20-2020. guidebook updated: doc/Guidebook.txt 2021-10-11 20:08:57 -04:00
nhmall
1e78c296f3 remove a warning with gcc on Windows
"braces around scalar initializer"
2021-10-11 18:14:09 -04:00