Reverts 690e072, which changed the various is_foo macros from this:
| #define is_elf(ptr) ((((ptr)->mflags2 & M2_ELF) != 0L)
to this:
| #define is_elf(ptr) ((((ptr)->mflags2 & M2_ELF) != 0L) \
| || ((ptr) == g.youmonst.data && \
| !Upolyd && Race_if(PM_ELF)))
This is a problem because g.youmonst.data is not unique to the hero:
the '(ptr) == g.youmonst.data' test will also be true of all player
monsters of the same role. For this reason, any of those player
monsters will be treated as sharing the hero's race, producing strange
results. For example, if the player is an elven ranger, any ranger
player monster generated will be considered 'elven' too (so will get a
to-hit bonus when attacking orcs, etc) -- but only while the hero is
unpolymorphed.
There are already other ways of checking the hero's race in addition to
her current polyform, most notably the maybe_polyd() macro. maybe_polyd
or something similar is already used in nearly all the cases where the
hero's race is being evaluated, meaning Race_if gets used instead when
the hero is in her natural form. So I think the check of the hero's
race in is_foo had very little effect except for the unintended
side-effects on player monsters.
In reviewing all the uses of is_{elf,dwarf,gnome,orc,human}, I noticed
only one case that relied on the hero-race-checking behavior. That has
been changed in this commit to use maybe_polyd (there's another 'raw'
is_human(g.youmonst.data) a few lines down, but it doesn't need
maybe_polyd since it already distinguishes between 'hero in nonhuman
polyform' vs 'nonpolyd or human polyform'). same_race(mondata.c) is
another case where &g.youmonst.data can be passed to is_foo, but
everywhere that calls it for the hero also calls your_race() or
same_race(&mons[Race_switch]) to handle the racial case.
Make changes similar to the suggested patch from entrez: support
for 'youmonst' as the monster passed to m_carrying(). This doesn't
change carrying(otyp) to call m_carrying(&g.youmonst,otyp) though.
Also, treat being on the Plane of Air or in an air bubble on the
Plane of Water similar to flying or levitating: wielded Giantslayer
(or carried loadstone) doesn't prevent knockback there.
Pull request from chasonr: remove NUL characters from constructed
prompt for Qt_yn_function(). I couldn't see any with Qt 5.11 on
OSX 10.11.6, but with some font(s) or Qt newer versions they were
visible as reported in issue #566 about 15 months ago.
Closes#909
The #wizborn command shows 'E' for an extinct species and 'G' for a
genocided one, but if a species first becomes extinct and then later
gets genocided, instead of showing both flags it stopped showing
either. I was going to add a second flag column and show 'E' and 'G'
separately but decided to stick with one column and display 'X' for
the unlikely 'both extinct and genocided' case.
More PR #882; give a different message for empty input than "such
creatures do not exist".
The new message mentions 'none' (with single quotes) as a potential
choice so recognize "'none'" as well as "none" to decline.
Reissuing getlin() with a different prompt wasn't reliably resizing the
X11 prompt widget. After a lot of hacking away at win/X11/dialogs.c I
eventually tried setting the response portion of the widget first and
got much better results, enough to throw away the tentative changes to
dialogs.c.
There's still a lot of room from improvement but I think it would need
to replace the ghostview prompting instead of trying to massage that.
If someone gets hit for a knockback effect but resists it due to
wielding Giantslayer or carrying a loadstone, give feedback saying
so, otherwise the lack of knockback is indistinguishable from an
ordinary hit.
The message is not likely to appear for non-hero target since that
target needs to have special equipment. A hero wielding Giantslayer
might see it enough for the player to become annoyed; if so,
MSGTYPE=hide could be used to suppress it.
mhitm.c: In function 'hitmm':
mhitm.c:583:30: warning: '%s' directive writing between 8 and 9 bytes into a region of size between 0 and 255 [-Wformat-overflow=]
583 | Sprintf(buf, "%s %s", magr_name,
| ^~
In file included from ../include/config.h:671,
from ../include/hack.h:10,
from mhitm.c:6:
../include/global.h:279:24: note: 'sprintf' output between 10 and 266 bytes into a destination of size 256
279 | #define Sprintf (void) sprintf
mhitm.c:583:13: note: in expansion of macro 'Sprintf'
583 | Sprintf(buf, "%s %s", magr_name,
| ^~~~~~~
Add minor detail to recently added map description in doc/window.txt:
origin is in upper left and positive y goes downward, so not typical
Cartesian x,y coordinate plane.
Issue reported by vultur-cadens: one of the checks for whether a
shade would be harmed by an attack was erroneously inside a block
of code that only executed when you could see the attack. Basic
physical damage wasn't affected but some monster (or poly'd hero)
damage types that shouldn't affect shades didn't when seen but did
when unseen.
Could also get "attack passes harmlessly through the shade" when
an unseen attack for physical damage hit and failed to deal damage.
fixes#907
Pull request from entrez: rename update_mon_intrinsics() to
update_mon_extrinsics() since it deals with properties conferred
by equipment in use rather than internal capabilities.
fixes#908
There was a TODO about this; not exactly a great challenge but it feels
like a worthwhile change since the name was misleading. I also updated
the name of the do_intrinsics parameter of extract_from_minvent(worn.c),
since it was in a similar situation (and directly related, since it
controls whether to call update_mon_{in/ex}trinsics).
Pull request from entrez: explicitly throwing 1 out of stack of more
than 1 and then having the throw be rejected by tageting yourself did
not recombine the split, resulting in stacks of 1 and N-1 that both
had the same inventory letter. Undo the split if throwing fails.
A similar fix was made for gold a year and a half ago by commit
c3ccd93a88.
fixes#904
Specifying a count of 1 when throwing an object could leave you with two
stacks sharing one inventory letter. The second stack gets split off
when the player specifies a count (e.g. 't1o'), but keeps its original
invlet. Some early returns, like trying to throw at yourself with '.',
could fail to unsplit the stack. Theoretically, specifying multiple
items to multishot and then failing to throw them all could also leave a
partial stack; I don't think this is actually possible right now with
't' but I tried to make sure it won't become a problem if greater counts
than 1 are ever allowed.
The fix doesn't affect 'f', which can be a combined "create a quiver
stack and throw" action and doesn't have the issue with duping invlets.
Specifying a count to split off a new quiver stack with 'f' shouldn't be
reverted if the throwing fails or only part of the stack is thrown,
because the newly created stack may be intended for continued use as the
quiver in future turns. This slightly changes the behavior of the
existing unsplit when cancelling the throw (which previously unsplit the
newly created quiver and quivered the entire parent stack), but I think
this actually makes more sense -- the player only declined to throw the
new stack, not to create it (as if they canceled earlier in the action).
I routed a couple early returns through the stack unsplitting that
shouldn't actually need it (like Mjollnir and welded items) for
consistency's sake; I don't think it hurts anything.
Pull request by Theyflower: carrying a loadstone prevents big
monsters from hitting their target for knockback effect, same as
wielding Giantslayer.
The PR code needed fixing (unintended switch from 'otmp' to 'obj')
so I didn't use the commeit. The PR code also required that the
loadstone be blessed which sounds nethackish but would mean that
nobody would ever notice. Allow carrying any loadstone to prevent
being knocked back. It will still be a rare accident or uncommon
tactical decision. (It doesn't happen if the target is flying or
levitating because those checks deliberately come first.)
supersedes #906closes#906
A giant mummy starts out with a mummy wrapping but couldn't wear it.
Allow humanoids who are bigger than human size (including poly'd hero
when applicable) to wear such cloaks. They won't do so if they are
invisible and the cloak would let hero start seeing them.
cansee(), couldsee(), and templit() are macros which are described
as boolean and used as if boolean, but they've been using bit
masking to return integer values greater than 1. That works since
C treats any non-zero as True but doesn't match boolean intent.
Something that FIQ once pointed out: the fact that map column 0 is
not shown wasn't explicitly described anywhere. Add a paragraph for
NHW_MAP to doc/window.txt and describe it there.
Some routines return ECMD_TIME|ECMD_CANCEL (for instance when 'a'pply
wields an item and player cancels the attempt to use it) so change
drop_menu() to test that properly. I don't think drop() ever returns
that combined mask value but be prepared to handle time passage if it
ever does.
When not carrying any contained gold, or the only contained gold is
inside container(s) whose contents aren't known, ^X writes one line
about the hero's "wallet". When known contained gold is present, it
writes two lines for gold, first one about wallet with the second
one about contained gold being a continuation of the first. Move
the conjunction that combines them from the start of the second line
to the end of the first.
So change
|Your wallet contains M zorkmids,
|and you have N more contained in your pack.
to
|Your wallet contains M zorkmids, and
|you have N more contained in your pack.
and
|Your wallet is empty,
|but you have N zorkmids contained in your pack.
to
|Your wallet is empty, but
|you have N zorkmids contained in your pack.
It evens out the line lengths a little bit and starting the second
line with uncapitalized "you" seems slightly less jarring than with
"and" or "but".
Reported by entrez: using ^A instead of #retravel after interrupted
travel can pick wrong location if cursor was previously positioned
with movement commands rather than feature targeting because it
won't be starting from the original spot. Also, ^A after ';' will
just redescribe whatever was examined previously instead of having
the player pick a new spot.
This suppresses cursor positioning from the do-again queue so that
repeating travel or quick-look or other command that needs player
to choose a position will repeat the command but then need to have
a position chosen. For interrupted #travel, the cursor will already
be placed on the previous destination so that's relatively painless,
but also allows a different destination to be chosen.
It adds iflags.remember_getpos that callers of getpos() could set to
be able to restore the old behavior but none do so far.
Fixes#905
Issue reported by vultur-cadens: Elbereth used to be effective in
inhibiting monster movement when an object was present on the same
spot, but since 3.6.0 it isn't. It only functions that way when the
hero--or hero's displaced image--is present these days. So special
levels that have been using engraved Elbereth to try to protect
objects from monsters haven't been providing any useful protection.
This makes Elbereth that's engraved during level creation work like
it used to in 3.4.3 and earlier: when there's at least one object
on the engraving's spot, monsters who are affected by Elbereth will
be affected. [I'm fairly sure that that behavior started out
unintentionally, as a side-effect of an optimization to only check
for scroll of scare monster when there was at least one item present
which is a necessary condition for such a scroll.]
Old-style Elbereth includes Elbereth chosen as a random engraving
during level creation in addition to engravings specified in special
level definitions. Engravings by the player don't have the required
attribute and player-engraved Elbereth behaves in the 3.6 way.
This ought to be replaced by something more general. Perhaps a new
engraving type not usable by the player?
Fixes#900