PatR [Tue, 6 Dec 2022 18:57:14 +0000 (10:57 -0800)]
unpaid sanity_check: leaving shop via recoil
Throwing while levitating or getting hit for knockback effect could
move hero carrying unpaid items out of a shop. If that happened,
sanity_check complained that unpaid items weren't in a tended shop.
Check for entering and leaving special rooms during recoil same as
gets done for ordinary movement. Leaving a shop via recoil or
knockback while owing a bill now gets treated as robbery immediately
rather than waiting until hero voluntarily moves to another spot
after recoil has finished.
PatR [Tue, 6 Dec 2022 08:49:52 +0000 (00:49 -0800)]
trap.h formatting
I don't know whether we'll ever run the code through clang-format
again, but in case we do, end-of-line comments which span lines
should begin continuation lines with '*', otherwise they get turned
into block comments beginning on the next line.
|code; /* start
| end */
gets changed to
|code;
|/* start end */
PatR [Tue, 6 Dec 2022 07:05:20 +0000 (23:05 -0800)]
yet more shop sanity checking
Reconcile boulder pushing with no_charge sanity checking. The hack.c
part comes from entrez.
Pushing a for-sale boulder from inside the shop to the shop's boundary
("free spot", doorway, or gap in wall) adds it to the shop bill even
though it's still on the floor. Leaving the shop without paying for
it is a robbery. Also, pushing an unpaid boulder that's on the shop
boundary to any spot that's all the way outside the shop is robbery.
PatR [Sun, 4 Dec 2022 16:59:22 +0000 (08:59 -0800)]
no_charge items sanity - shop theft
More unpaid/no_charge sanity checking. If a shop contained any
no_charge objects and was robbed, they would be left no_charge and
trigger sanity check warnings (no_charge in "untended shop") once
the shopkeeper got past any Kops in the way and exited the shop.
Earlier testing didn't wait around long enough for that exit to
happen.
Clear no_charge as soon as the robbery is detected.
PatR [Fri, 2 Dec 2022 23:13:57 +0000 (15:13 -0800)]
obj->no_charge insanity
An object in a shop that was marked no_charge and got removed from
the shop by means other than the hero picking it up (test case
teleported it out while hero was inside shop) was left with the
no_charge bit set. It's supposed to only be set for objects inside
shops so was triggering the recently added no_charge sanity checks.
Changing stolen_value() to have it pass the reset_nocharge arg to
billable() solves this but could have unanticipated results with
other stealing from shops.
PatR [Fri, 2 Dec 2022 09:40:54 +0000 (01:40 -0800)]
farlook /[mMoO] feedback
When /m or /M or /o or /O shows monsters or objects with locations
displayed as map coordinates, make those line up by their commas.
Old
| <8,9> $ gold pieces
| <10,10> * rocks
| <9,12> % newt corpse
New
| <8, 9> $ gold pieces
| <10,10> * rocks
| <9,12> % newt corpse
(The data is gathered by row so implicitly sorted by y.)
If someone is crazy enough to set ROWNO to three digits, values
will only line up by the comma when all values have row less than
100 or all are 100+. Setting COLNO to three digits isn't an issue
unless the total witdh of "<" + xxx + "," + yy ">" is more than 8
(which would push object class letter and object description one or
more extra columns to the right, messing up overall alignment but
still showing accurate data).
PatR [Fri, 2 Dec 2022 00:15:45 +0000 (16:15 -0800)]
alternate fix issue #938 - use-after-free
If you kill an engulfer and get dropped onto a level teleporter or
magic portal, wait until end of turn to perform the level change.
The code to finish off killing the engulfer was left with a stale
pointer for the monster when level change happens immediately.
The level change was being forced to be immediate so that something
noticable happened before being asked for what to name a teleport
scroll read while cursed or confused, but such scrolls become
discovered these days. So when no prompting for what to call the
scroll takes place, there's no need to change levels instantly.
This issue was just fixed but this commit is simpler. The previous
fix is left in place in case some other level change path is--or
becomes--possible.
PatR [Thu, 1 Dec 2022 23:36:40 +0000 (15:36 -0800)]
\#wizkill fix
When running #wizkill, if hero was swallowed and you killed the
engulfer and that dropped hero onto a level teleporter, the targetting
loop for selecting the next monster to kill kept going after changing
to another level. Terminate #wizkill if killing something sends you
to a different level.
Not fixed, and an old bug, or variation of one: the cursor got
positioned at the coordinates of your spot on the prior level even
though the part of the new level where you actually arrived was
displayed.
Pasi Kallinen [Thu, 1 Dec 2022 17:57:19 +0000 (19:57 +0200)]
Recalc mon-hits-you distance variables
When a monster could first knock you back and then grab you,
the game would emit impossible, because the knockback moved you
but the distance variables used for the grab attack were not
updated.
Update the range variables within the loop iterating through
the monster attacks.
PatR [Thu, 1 Dec 2022 10:23:01 +0000 (02:23 -0800)]
more shop billing object sanity
Used up items moved to the billobjs list still have obj->unpaid set.
That should probably be cleared since it has no meaning there, but
this hasn't done that.
For those keeping score: unpaid checking has triggered three false
positives (so far) and found one bug.
nhmall [Thu, 1 Dec 2022 08:48:11 +0000 (03:48 -0500)]
Use-after-free with engulfer in xkilled #938
If you were on a level teleporter, the spoteffects() call after
the hero gets expelled could end up going to a new level and
freeing all the monst chains from the level you were originally
engulfed on.
#0 0xba0507 in free
#1 0x87feda in dealloc_monst src/mon.c:2369
#2 0x880a02 in dmonsfree src/mon.c:2194
#3 0x9a7aa2 in savelev_core src/save.c:507
#4 0x9a7a21 in savelev src/save.c:466
#5 0x71eb9d in goto_level src/do.c:1483
#6 0x71833f in deferred_goto src/do.c:1903
#7 0xa2533f in level_tele src/teleport.c:1117
#8 0xa2567b in level_tele_trap src/teleport.c:1198
#9 0xa5c007 in trapeffect_level_telep src/trap.c:1861
#10 0xa5f856 in trapeffect_selector src/trap.c:2497
#11 0xa47497 in dotrap src/trap.c:2586
#12 0x7d669b in spoteffects src/hack.c:2859
#13 0x89d495 in xkilled src/mon.c:3187
The latter parts of xkilled() after the spoteffects() call would
then attempt to dereference the free'd monst pointer.
Save a copy of the monst struct prior to spoteffects() if you were
expelled, then point at the reference copy afterwards.
vultur-cadens [Thu, 1 Dec 2022 01:34:00 +0000 (17:34 -0800)]
Fix autodescribe after reading a cursed scroll of gold detection
Autodescribe was not updating during browse_map() when the cursor was
moved over a gold glyph that was actually a trap, causing the trap to
be described as the previous square that the cursor was on (probably
"unexplored area") instead of as gold pieces. This was especially
noticeable when using OPTIONS=whatis_coord:m, because the coordinate
was not updating when moving the cursor over the trap.
PatR [Thu, 1 Dec 2022 00:32:43 +0000 (16:32 -0800)]
another manpage update
Split some lines that began with one sentence and then continued with
another so that each sentence has its own line as per 'roff guidelines.
Change the continuation lines in the files and environment sections
to begin with <backslash><space><tab> instead of just <tab>, again to
meet the guidelines (don't begin lines with whitespace). This had a
side-effect of suppressing some space insertion for justifying right
margin of right-hand column on some of the lines. That hadn't looked
very good anyway.
Add new file 'usagehlp' to the files section.
Also add previously unmentioned Guidebook[.txt], but it's hard to
explain why it probably won't be present....
Update the bones file entry.
'cmdhelp' isn't used anymore. Should it be moved to outdated/dat and
the Makefile install steps be updated to stop bothering with it?
PatR [Wed, 30 Nov 2022 22:58:59 +0000 (14:58 -0800)]
fixes entry for pull request #937 - stale memory
Pull request from entrez: memory freed when changing levels could be
accessed if the level change happened when hero caused an engulfer to
expel him onto a level teleporter. Wouldn't happen when monsters are
moving because hero's level change will be deferred. Wouldn't happen
for trap doors and holes, but could happen for magic portal if hero
got swallowed while on one after coming through from other side.
Michael Meyer [Mon, 28 Nov 2022 22:16:21 +0000 (17:16 -0500)]
Fix: potential use-after-free in expels()
An engulfing monster can expel you onto a level teleporter or other
level-changing trap, in which case it may (under highly specific
circumstances[1]) no longer have been in memory by the time mtmp->mx/my
were accessed to see whether the "Brrooaa" message should be printed.
It also doesn't make much sense to print that message by the time you've
already fallen through a portal, trapdoor, etc, onto another level, so I
think moving it before the spoteffects() call kills two birds with one
stone.
[1] The highly specific circumstances: you must die due to illness or
some other timeout (or generally die on your own turn rather than the
monsters' turn, since this ensures the level change isn't deferred until
the end of the turn), while engulfed above a level teleporter [or maybe
another similar trap -- I tested with a level teleporter], and be
lifesaved, while positioned such that the engulfer can't follow you
through the levelport after expulsion (e.g. surrounded by other
monsters). It may happen under some other conditions too, but even if
so it's pretty rare and was tough to reproduce.
PatR [Wed, 30 Nov 2022 22:49:11 +0000 (14:49 -0800)]
more #936 - water vs potions of acid
Pull request #936 took away the destruction of potions of acid ("acid
and water don't mix") if they survived water_damage(). Restore that
by forcing them to not survive. Exception: if they're greased and
pass the 50:50 chance of retaining the grease, they aren't destroyed.
Michael Meyer [Mon, 28 Nov 2022 20:44:27 +0000 (15:44 -0500)]
Fix: use-after-free when fountain dipping
A potion of acid could be destroyed and freed by dipping into a
fountain, then dereferenced after the fact -- both when checking its
type immediately after the water_damage() call (as was noticed by
hackemslashem and amateurhour on IRC), and also in the later switch/case
a few lines further down in dipfountain().
I basically reversed the original 'er != ER_DESTROYED' test here: as it
was before this, I think the only thing that could hit it was a greased
potion of acid, which would survive the initial dip due to the grease.
Such a potion would be silently deleted. Potions of acid which were
actually destroyed by water_damage, on the other hand, could be allowed
to continue down to the switch/case of further effects (and associated
dereferences). I think this makes more sense in reverse, with potions
that were protected by grease actually being protected and producing
normal dip effects, and potions of acid which exploded causing an early
return with no further effects. This effectively prevents the various
use-after-free scenarios that were possible, too.
Michael Meyer [Mon, 28 Nov 2022 20:42:19 +0000 (15:42 -0500)]
Tell player when water damage removes grease
This was totally silent, which -- at least for me -- has led to quite a
few cases of believing my bag or cloak is still greased when it actually
wore off the last time I took a dip. I think telling the player that
the grease has worn off would be helpful, and is consistent with other
types of water damage.
The message is printed even if you are blind, since that seems to be
true of all the other messages in water_damage(). I am not sure if that
makes complete sense (especially for ones like a scroll fading -- some
like water getting into a bag could be sensed by touch) but I didn't
change anything there.
PatR [Wed, 30 Nov 2022 20:45:58 +0000 (12:45 -0800)]
fixes entry for PR #940 - cursed gold detection
Pull request from vultur-cadens: using autodescribe with cursor
movement to browse the map during gold detection didn't give any
feedback for fake piles of gold that get drawn at trap locations.
(After detection finishes, using autodescribe with ; or // reports
on such piles normally.)
vultur-cadens [Wed, 30 Nov 2022 19:11:16 +0000 (11:11 -0800)]
Fix autodescribe after reading a cursed scroll of gold detection
Autodescribe was not updating during browse_map() when the cursor was
moved over a gold glyph that was actually a trap, causing the trap to
be described as the previous square that the cursor was on (probably
"unexplored area") instead of as gold pieces. This was especially
noticeable when using OPTIONS=whatis_coord:m, because the coordinate
was not updating when moving the cursor over the trap.
nhmall [Wed, 30 Nov 2022 02:53:21 +0000 (21:53 -0500)]
split g into multiple structures
The consolidation of global variables from scattered source
files into decl.c and declared in decl.h was begun in 3.7.0.
Their placement in common files was done for centralized
initialization and potential re-initialization during a
"play again" scenario.
It wasn't really necessary for all of them to be housed in a
single huge structure to meet the "play again" requirement,
and the single huge structure has been a little unwieldy when
it comes to maintenance.
Following this commit, instead of one single extremely large structure
named 'g' to house all of the relocated global variables, they
are distributed into several ga through gz.
To make things easy for the developer, each variable is placed
into the struct corresponding to the starting letter of the variable.
That way, no lookup is required in order to know which struct houses
a particular variable, it is a simple match to the starting letter
for all the centralized global variables.
A global variable named 'amulets', would be found in ga.
ga.amulets
^ ^
A global varable named 'move', would be found in gm.
gm.moves
^ ^
A global variable named 'val_for_n_or_more' would be found in gv.
gv.val_for_n_or_more
^ ^
A global variable named 'youmonst' would be found in gy.
gy.youmonst
^ ^
PatR [Tue, 29 Nov 2022 21:55:42 +0000 (13:55 -0800)]
unpaid object: sanity check, teleporting, 'I u'
It turns out that there are some objects marked unpaid that aren't
carried by the hero, so the recent sanity check for unpaid/no_charge
could complain. Unpaid items dropped on the shop boundary (gap in
shop wall, doorway, shk's free spot) stayed unpaid when dropped onto
the floor, similar to recent change for pushed shop-owned boulders.
Don't give sanity complaints for those. They could be all the way
inside a shop too, where unpaid items in a gap in the shop wall got
pushed into the shop when the wall was repaired. (Possibly those
should come off the bill instead of remaining unpaid.)
Teleporting items out of a shop was marking them unpaid instead of
treating that as robbery. That's a bug caught by the sanity check.
rloco() was also marking shop items which got teleported from one
spot inside the shop to another spot inside the same shop as unpaid.
Fix both of those things. Also, if an unpaid item on the boundary
gets teleported all the way inside, take it off the bill.
Change 'I u' to mention whether there are additional unpaid items on
the floor somewhere since they won't be part of unpaid inventory and
they're not on the used-up bill either. It might occasionally help
the player figure out why the shopkeeper won't let the hero out of
the shop.
PatR [Mon, 28 Nov 2022 10:08:49 +0000 (02:08 -0800)]
github issue #935 - disarming swallowed hero
Issue reported by AndrioCelos: bullwhip using monster was able to
snatch hero's weapon when hero was engulfed.
Fix is trivial: when a monster is choosing an item to use, don't
pick bullwhip if hero is engulfed. Regular attack attempts already
skip engulfed hero.
Issue reported by Melon2007: when non-deaf hero heard an unseen
monster read a scroll, the monster's type was identified accurately
(unless distorted by hallucination). That was intentional but it
doesn't seem plausible for the hero's hearing to be that acute.
Change it to report the monster type accurately if not hallucinating
and monster is the same species as the hero (as the current form if
hero is poly'd), otherwise report it as "someone" when it's humanoid,
otherwise as "something".
Also, if the monster is heard at a spot that would be visible if
hero could see, draw a "remembered, unseen monster" glyph there.
PatR [Sat, 26 Nov 2022 23:59:01 +0000 (15:59 -0800)]
paranoid-pray vs do-again
If paranoid_confirm settings include praying, don't put the answer
to "are you sure you want to pray?" into the do-again buffer where ^A
would use it to ignore confirmation if prayer is repeated. And for
wizard mode, when confirmation is 'y' then the answer to "force the
gods to be pleased?" has to be suppressed from the do-again buffer too
or it would be used by subsequent ^A to answer "are you sure?".
This is basically a band-aid just for #pray. There are probably other
confirmations that should be suppressed from do-again instead of being
reusable. The rest of the paranoid_confirm ones should be ok because
they require "yes" and that doesn't end up in the do-again buffer, but
there are bound to be other confirmations that shouldn't automatically
be re-used during repetition.
PatR [Sat, 26 Nov 2022 10:25:27 +0000 (02:25 -0800)]
gitpub issue #933: feedback for throwing w/ count
Issue reported by Meklon2007: typing arrow keys when a menu is open
can end up with hidden counts. That's a Windows thing and this
makes no attempt to address it. (That's also a user error since
menus don't support arrow key use.) It shows up more for throwing
that for other things because fetching an object from inventory for
throwing attempts to enforce a count limit during item selection
that other actions don't.
But feedback could also be odd if you explicitly specify a count
since the rejection wasn't attempting to distinguish throwing more
than one from throwing more than you have. This changes things so
that with invent of
|$ - 3 gold pieces
|a - a dagger
|b - 3 darts
t4$ now yields "You only have 3." instead of throwing all 3
t4a now yields "You only have 1." instead of "you can only throw one"
t2b still yields "You can only throw one at a time."
t4b now yields "You only have 2 and can only throw one at a time."
In each case, it will reprompt rather than terminate the throw.
"Only one at a time" was already in place when multi-shot throwing/
shooting was introduced and became iffy then, but the way to try to
throw a specific amount is via a repeat count before t rather than
by choosing a subset when selecting the inventory item for t. The
count prefix method also works for f which doesn't otherwise provide
an opportunity to specify count since inventory item is preselected
via quiver.
Someone might want to reopen the arrow behavior as a Windows issue
but I'm not sure how that would be fixed other than by eliminating
its attempt to be user-friendly in converting arrows into movement
direction keystrokes.
PatR [Fri, 25 Nov 2022 21:44:43 +0000 (13:44 -0800)]
usage text revisions
Move the mention of viewing usage info via 'nethack --usage | more'
to the end, where it should remain visible if text has scrolled off
the top of the screen (which is nearly certain since it ended up
being much longer than originally intended).
Also, rephrase the text at the start about restore vs new game since
the previous description said "in all cases" which isn't applicable
for 'nethack --scores' or --version or --showpaths or --usage.
Move 'nethack --usage' to last so that 'nethack --scores' is first
among the non-playing command variants since -s is of more interest.
For 'nethack --scores', move -v before the other options since it
has to be next after -s|--scores to be processed correctly. Also,
avoid using "present" twice in the same sentence.
nhmall [Thu, 24 Nov 2022 05:51:42 +0000 (00:51 -0500)]
expand support for noreturn declarations
Although gcc specifies support for declaring a function as
noreturn after the function name and parameters, other compilers
do so via an attribute at the start of the declaration. Add some
macro support for the attribute-at-the-beginning method:
o MS Visual Studio compiler
o Upcoming C23 standard (untested at this point)
nhmall [Thu, 24 Nov 2022 05:49:51 +0000 (00:49 -0500)]
quiet another warning that recently appeared
../win/curses/cursinit.c:102:9: warning: variable 'min_message_height' set but not used [-Wunused-but-set-variable]
int min_message_height = 1;
^
1 warning generated.
PatR [Thu, 24 Nov 2022 00:41:12 +0000 (16:41 -0800)]
unpaid object sanity checking
Handle items in gaps of a wall shared between adjacent shops.
Make handling of shop boundaries more explicit: walls, the door,
and the "free spot" by the door aren't classified as 'costly' but
obj->unpaid and obj->no_charge are valid there.
Move unpaid/no_charge checking into its own routine to unclutter
objlist_sanity().
Pushing a shop-owned boulder to the free spot or doorway or gap in
wall triggers the sanity check for the time being.
nhmall [Wed, 23 Nov 2022 22:47:49 +0000 (17:47 -0500)]
some coordxy and other conversion warnings
When dist2() got changed to use coordxy parameters, a macro that uses
it in its definition was overlooked and it had (int) casts in it.
That caused a warning about possible data loss when the int
then got converted to coordxy for the dist2() call.
Give online2() coordxy parameters instead of int, like its bretheren.
Avoid a couple of implicit conversion warnings where ints were being assigned
to smaller uchar or ints being assigned to smaller short.
A couple of signed vs unsigned warnings on some rumor processing.
Avoid some signed vs unsigned warnings in mdlib/makedefs where a signed int
param eventually got used in an external call that took size_t.
Eliminate all of it by just having the outer NetHack routine also take
a size_t.
Lastly, insert some default C99 alternative time-related code
in mdlib/makedefs since asctime() and ctime() are being flagged as
deprecated in the upcoming C23 standard and will now start to trigger
warnings for anyone using a C23-compliant compiler.
Ray Chason [Sat, 19 Nov 2022 14:14:54 +0000 (09:14 -0500)]
Restore compatibility with Qt 4
The test system is Slackware 14.2, which uses Qt 4.8.7.
* WANT_WIN_QT4 is defined, and has the expected meaning. Qt 5 is still
the default.
* The QT_NO_SOUND macro now excludes all headers and declarations
relating to sound; the multimedia package is not needed to build
(on any Qt 4, 5 or 6).
* A new function, nh_qsprintf, replaces QString::asprintf, for Qt
older than 5.5. These versions do not have QString::asprintf.
* DYNAMIC_STATUSLINES is disabled for Qt older than 5.9. These versions
do not have QSplitter::replaceWidget.
PatR [Wed, 23 Nov 2022 20:11:24 +0000 (12:11 -0800)]
pull request #924 - unicode symsets
Pull request from chasonr: a symbols file with more than one set
having the unicode attribute effectively merged all unicode sets when
loading any of them. Also, freeing unicode glyphmap entries for gems
would attempt to free some of them more than once for those that had
colors cloned from other gems.
[This new code compiles but is otherwise untested by me.]
Ray Chason [Wed, 9 Nov 2022 04:41:40 +0000 (23:41 -0500)]
Fix use after free in Unicode mappings
Shuffling gem appearances can cause mappings from object to
appearance that are not one-to-one. Copy any multiple mappings and
free any mappings that are left unused.
PatR [Tue, 22 Nov 2022 22:53:43 +0000 (14:53 -0800)]
Unix: fix 'nethack -u name'
Using '-u name' rather than '-uname' was being treated as '--usage'
for any value of 'name'.
'-uname' worked as intended unless name was 'sage' (or leading
substring of it). That's still the case after this fix, where the
space after -u is now necessary for that special case name.
PatR [Mon, 21 Nov 2022 20:53:42 +0000 (12:53 -0800)]
Qt pager doll inventory
Change Qt's 6x3 grid of worn/wielded equipment so that it is facing
the player: hero's right hand side is shown in the grid's left column
and left hand side is shown in its right column. Middle column is
unchanged.
PatR [Sun, 20 Nov 2022 01:03:26 +0000 (17:03 -0800)]
another man page revision
Add new '--usage' and '--help'.
Add missing '--nethackrc:RC-file' and '--no-nethackrc'.
Explain -D and -X more precisely.
Reorder the options to manually produce a synopsis section that looks
like
to avoid instances of line breaks like "...[\n-foo ]..." and
"...[ -bar\n]...". With TeX it would be straightforward to favor line
breaks in front of "[" and after "]" but I don't know whether or how
'roff can do that.
PatR [Sat, 19 Nov 2022 08:43:16 +0000 (00:43 -0800)]
pull request #927 - charging vs undiscovered tools
Pull request from entrez: don't list undiscovered or unseen (picked
up while blind, still blind) tools as likely candidates for charging.
They're still eligible to be chosen for charging but using a scroll
to charge something else won't reveal not-yet-known tools as being
magic.
Michael Meyer [Wed, 16 Nov 2022 20:40:16 +0000 (15:40 -0500)]
Don't leak ID of magic tools in charging prompt
The getobj prompt for charging was presenting any chargeable tool in the
hero's inventory as a suggested charging target, even tools which were
unidentified and undistinguishable from their mundane counterparts
(e.g. bag of tricks, magic harp, horn of plenty...). This leaked
information about the identity of these items and made it possible to
determine whether a generic 'harp' was magic or not.
When suggesting chargeable tools, include only those which are actually
known to be chargeable (unidentified or unseen chargeable tools can
still be selected, they just won't be suggested targets). Basically the
same as what's done for a potion of oil in the apply prompt.
PatR [Sat, 19 Nov 2022 08:15:23 +0000 (00:15 -0800)]
fixes entry for PR #925 - shop boulders
Pull request from entrez: boulders owned by shops could be used up
(plugging hole in floor) or stolen (pushed through unrepaired gap in
shop wall) without cost. Not very common because shops rarely have
boulders in them.
Michael Meyer [Mon, 14 Nov 2022 19:59:29 +0000 (14:59 -0500)]
Charge hero for making off with shop-owned boulder
Pushing a shop-owned boulder out of the shop wouldn't charge the hero
anything. Remedy this (and remove the boulder from the bill if the hero
then pushes it back in). Also tried to handle a couple other uncharged
boulder "theft" scenarios: pushing a boulder into lava or water, into a
trapdoor or hole, or into a level teleporter (various other traps
already charged for the boulder -- it was pretty inconsistent).
I externified onbill() for this, since relying on otmp->unpaid by itself
impossibles if you push a boulder through a gap in a wall between two
adjoining shops.
Michael Meyer [Mon, 14 Nov 2022 23:37:17 +0000 (18:37 -0500)]
Add 'mdistu' macro
Short for distu(mtmp->mx, mtmp->my) (i.e. the distance between the hero
and the specified monster), which is a very common use of distu(). The
idea is that this would be a convenient shorthand for it; I actually
thought it (or something very similar) existed already, but couldn't
find it when I tried to use it earlier. Based on the number of uses of
fully-spelled-out 'distu(mtmp->mx, mtmp->my)' replaced in this commit
I'm guessing I just imagined it.
Michael Meyer [Mon, 14 Nov 2022 23:25:15 +0000 (18:25 -0500)]
Fix: "a dry rattle comes from its throat"
"A dry rattle comes from its throat" would be printed whenever a
canceled monster tried to spit at you or another monster while not in
the hero's line of sight. That seemed weird to me: you can't see the
monster and don't know what it is, but you can tell the sound is
definitely coming from "its throat".
Change the message if the monster isn't visible, and make sure it's
printed it only if the monster is nearby (within reasonable hearing
range for a "dry rattle").
PatR [Sat, 19 Nov 2022 01:54:17 +0000 (17:54 -0800)]
control of command-line usage entry in '?' menu
Instead of using a compile-time macro to suppress inclusion of the
menu entry to show UNIX command-line usage in the help menu, use a
sysconf setting instead.
Default is HIDEUSAGE=0, to include the entry for command-line usage.
Set HIDEUSAGE=1 to exclude that. Does not affect 'nethack --usage'
if player actually has access to the command-line.
PatR [Sat, 19 Nov 2022 00:07:15 +0000 (16:07 -0800)]
'nethack --usage' and '?' menu
Write up a description of how the command line works on UNIX and put
that in new file dat/usagehlp. Add support for
|nethack --usage | --help | -? | ?
to display it and exit.
Also add a menu entry for nethack's help command to show it during
play. That can be suppressed by uncommenting new '#define HIDE_USAGE'
in config.h since it won't be useful on servers that don't give
players access to command lines.
New genl_display_file() just writes to stdout. opt_usage(), which
calls it, might need some suid/sgid handling to make sure the output
is done as the player rather than as nethack.
PatR [Fri, 18 Nov 2022 00:37:45 +0000 (16:37 -0800)]
yet more nethack -s
For nethack -s name1 [name2 [name3]]
allow any or all of the name arguments to be preceded by -u. Both
'-u name1' and '-uname2' forms are accepted same as when specifying
character name at start of play.
It has been accepting '-s<anything>' and ignoring the <anything>.
Treat such as a separate argument instead. That means it will accept
'-s-v' which is silly but if used intentionally, <anything> would most
likely be a name.
'nethack -s' without any character name(s) supplied and PERS_IS_UID
set to 0 now defaults to "all" instead of to "hackplayer". For Unix,
the default name will be in place, so that gets used instead of "all".
'nethack -s all' or 'nethack -s -u all' can be used to see all scores.
When no matches are found, feedback is a full sentence but terminating
punctuation was omitted except for the special case of "Cannot find
any entries for you." Add the final period all the time.
PatR [Thu, 17 Nov 2022 21:19:19 +0000 (13:19 -0800)]
more nethack -s
For Unix, set plname[] to the default value (player's username)
before running prscore() for 'nethack -s'. Avoids reference to
mysterious "hackplayer" if no entries are found.
PatR [Wed, 16 Nov 2022 22:47:25 +0000 (14:47 -0800)]
manpage update
Add -w|--windowtype.
Also --scores and --directory as recognized variations of -s and -d.
Add -@. The existing description of '-p @' seems to be inaccurate,
and random role but still having to supply race+gender+alignment
isn't very useful anyway. The bit about maybe needing to quote @ with
backslash might still be useful if moved to -@ though.
Add -A|-Arc -B|-Bar ... -W|Wiz since they hadn't been listed. I put
them on their own line instead of cluttering up the main program
invocation even further.
Move '-u character-name' before '-D' since that order matters on some
platforms.
Move --showpaths and --version to a separate command invocation since
combining them with any other stuff ends up ignoring that other stuff.
I didn't add --dumpenums.
The description of config file name and location under '-dec and -ibm'
is out of date, particularly for Windows.
nhmall [Mon, 14 Nov 2022 03:25:07 +0000 (22:25 -0500)]
some Makefile and hints tinkering
1. remove all window interface bits from compiler.370, and have
the preceding include files set some variables to control
the behavior of compiler.370 when it comes to c++.
2. some more common Makefile lines into sys/unix/hints/include/multiw-3.370.
3. make it so you can pass cppregex=1 on the Make command line to build with
sys/share/cppregex.cpp instead of posixregex.c
4. fix sys/share/cppregex.cpp so that it will build with clang compiler
(required an additional header include). I don't know if it would have
worked with g++ without that change. The include can be placed into an #ifdef
block if there's an issue with the change on other compilers.
5. Anything that needs to compile using c++ (Qt, sys/share/cppregex.cpp) can
just ensure that CPLUSPLUS_NEEDED Makefile variable is set above the lines
in compiler.370 to ensure that things get set up for c++. It no longer
checks specifically for Qt. That is what sys/unix/hints/include/multiw-2.370
does now.
PatR [Sun, 13 Nov 2022 21:12:19 +0000 (13:12 -0800)]
reset X11's "interface has been initialized" flag
Reset 'x_inited' after the various widgets have been released
during shutdown.
This might prevent the second panic ('X11_mark_synch()' during
emergency save) in the double panic reported in a later comment of
github issue #569. It definitely doesn't address whatever caused
the first panic, nor the poor handling of missing fonts that was
apparently responsible for #569's initial report.