Commit Graph

12428 Commits

Author SHA1 Message Date
nhmall
b6250b412d fix error checking during tile processing
noticed following a patch last night
2021-10-28 16:08:59 -04:00
PatR
49b2ea1b89 "someone"/"something" instead of "it"
I thought there were more places that checked for "it" and substituted
"someone" or "something".  Perhaps there are and I'm just not finding
them now.  Anyway, this extends x_monnam() and adds some_mon_nam() and
Some_Monnam() to do that during monster name formatting instead of
having various bits of code try fix it up after the fact.  The fixups
could be fooled by monsters given the name "it" or "It"; x_monnam()
won't be.
2021-10-28 12:55:32 -07:00
PatR
3a0f1bb1aa refine "next boulder"
Guard against any other places besides minimal_xname() that set up a
fake object without being aware that for boulders the corpsenm field
should be 0 rather than NON_PM.  If that field is unexpectedly -1,
xname() will format it as ordinary "boulder" rather than producing
special "next boulder".  An explict value of 1 is now required for
the latter.
2021-10-28 11:10:40 -07:00
PatR
d736cbd751 fix github issue #603 - guarding prize items
Reported by Vivit-R with comments by several others.  The prize item
in one of the closets off the Sokoban treasure zoo is sometimes
missing, most likely picked up by an elf who won't be dissuaded by
the presence of engraved Elbereth or a scroll of scare monster.

This fix prevents monsters from targetting the mines' and sokoban's
prizes for pickup (or for eating).  Once the hero picks either of the
prizes up, they stop being prizes and will be ordinary monster fodder
if dropped/stolen/stashed.

One of the comments by copperwater suggested this approach as a
possible way to fix things.  I had already implemented it from scratch
before noticing that.  It handles the usual monster behavior toward
items, but there could easily be some unusual cases still susceptible
to taking the prize before the hero gets to it.  Those are the breaks.

Fixes #603
2021-10-28 01:05:18 -07:00
PatR
5b91f81533 more baalz - digging in front of the "eyes"
like the leg hackery, if the baalz level gets flipped during creation
the fixup that modifies the locations in front of the eyes to allow
digging needs to deal with that too.
2021-10-27 16:21:03 -07:00
PatR
a5d3e03b3e fixes entry for pull request #598 - baalz level
If the baalz level got transposed during creation, the fixup for
a decorative portion of the map didn't work properly.  Monsters
eligible to be created at pool locations could end up trapped in
a couple of inaccessible locations.

[To be fair, the baalz hackery predates level flipping....]

Closes #598
2021-10-27 15:52:01 -07:00
Michael Meyer
00b3b955af Fix: baalz_fixup didn't account for level rotation
Because some spots in the fly's 'legs' on the Baalzebub lair level are
specified as pools in the level file, then later converted to walls in a
post-generation fixup routine, monsters can be generated on those spots
and then left walled up and inaccessible, Cask of Amontillado style.
For the love of God, makemon-tresor!

Some code already existed to relocate these monsters after generating
the level, but it depends on misorientated 'leg segments' being fixed up
in a particular way.  That wasn't being triggered because it didn't
account for the possible rotation of the level; as a result, the
monsters in the leg segments wouldn't be relocated, and the leg segments
themselves would continue to have the wrong orientation.

Account for possible level rotation so that the monsters are relocated
properly (and the leg segments are 'fixed').
2021-10-27 15:48:26 -07:00
PatR
da859c5eb8 fix github issue #623 - soldiers and mattocks
Reported by eakaye.  Selection of equipment when creating a soldier
or watchperson can pick a polearm, but random selection among those
had a chance to choose dwarvish mattock which doesn't use polearms
skill and isn't appropriate for a human soldier or watchperson.
Not mentioned, but lance was in the same boat.

Change the selection to only pick something which uses polearms
skill, then make that moot by moving lance and dwarvish mattock out
of the midst of the polearms so that they're no longer candidates
for special case rejection.

A couple of other things which might have had a similar issue were
already ok.  Giving a polearm when creating a troll selects between
a few choices rather than among all the polearms.  And wishing for
"polearm" only considers items which use polearms skill.

While changing objects.h to reorder the two non-polearms, I removed
a bunch of tabs that were present in the scroll definitions.

EDITLEVEL is incremented due to objects[] reordering, so existing
save and bones files will be invalidated.

Fixes #623
2021-10-27 15:36:32 -07:00
PatR
6b882609ac commit message for pull request #599 - artifacts
Explicitly un-create a randomly generated artifact if it gets
rejected (too big to include as a treasure drop with a small corpse)
so that it remains eligible for creation later.  And when generating
random contents for a new container, explicitly avoid artifacts
(which were already implicitly avoided).

Closes #599
2021-10-26 12:09:36 -07:00
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