]> granicus.if.org Git - nethack/log
nethack
2 years agounpaid sanity_check: leaving shop via recoil
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.

2 years agopaste error in Makefile.mingw32
nhmall [Tue, 6 Dec 2022 16:00:29 +0000 (11:00 -0500)]
paste error in Makefile.mingw32

2 years agotrap.h formatting
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 */

but
|code; /* start
|       * end */
stays as-is.

2 years agousage typo/thinko
PatR [Tue, 6 Dec 2022 07:24:18 +0000 (23:24 -0800)]
usage typo/thinko

2 years agoyet more shop sanity checking
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.

2 years agoclear up a few gcc warnings
nhmall [Tue, 6 Dec 2022 04:19:38 +0000 (23:19 -0500)]
clear up a few gcc warnings

2 years agoissue with mingw resolved; resume mingw build in CI
nhmall [Tue, 6 Dec 2022 00:03:11 +0000 (19:03 -0500)]
issue with mingw resolved; resume mingw build in CI

2 years agodisable mingw build for now
nhmall [Mon, 5 Dec 2022 20:11:26 +0000 (15:11 -0500)]
disable mingw build for now

2 years agoThis is cron-daily v1-May-8-2022. 000files updated: Files
nhw_cron [Mon, 5 Dec 2022 19:24:08 +0000 (14:24 -0500)]
This is cron-daily v1-May-8-2022.  000files updated: Files

2 years agoyet another follow-up after CI report
nhmall [Mon, 5 Dec 2022 19:12:36 +0000 (14:12 -0500)]
yet another follow-up after CI report

2 years agoanother mingw follow-up after CI report
nhmall [Mon, 5 Dec 2022 19:07:33 +0000 (14:07 -0500)]
another mingw follow-up after CI report

2 years agoanother mingw Makefile follow-up
nhmall [Mon, 5 Dec 2022 19:00:22 +0000 (14:00 -0500)]
another mingw Makefile follow-up

2 years agomingw Makefile updates
nhmall [Mon, 5 Dec 2022 18:54:09 +0000 (13:54 -0500)]
mingw Makefile updates

2 years agofix pair of prototype differences between date.c and mdlib.c
nhmall [Mon, 5 Dec 2022 18:39:46 +0000 (13:39 -0500)]
fix pair of prototype differences between date.c and mdlib.c

2 years agoMerge branch 'windows-makefile' into NetHack-3.7
nhmall [Mon, 5 Dec 2022 18:27:25 +0000 (13:27 -0500)]
Merge branch 'windows-makefile' into NetHack-3.7

2 years agorework windows nmake file
nhmall [Mon, 5 Dec 2022 18:21:19 +0000 (13:21 -0500)]
rework windows nmake file

Keep object files separate between gui and tty builds as they
are not the same binary on windows.

The stubs.c file will no longer be necessary.

2 years agono_charge items sanity - shop theft
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.

2 years agoman page and usage: -D
PatR [Sun, 4 Dec 2022 08:17:50 +0000 (00:17 -0800)]
man page and usage: -D

Mention the changed character name that happens when running in wizard
mode.

2 years agofarlook /[mMoO] feedback, take II
PatR [Sun, 4 Dec 2022 07:51:00 +0000 (23:51 -0800)]
farlook /[mMoO] feedback, take II

Redo the way coordinate pairs are lined up for /m /O &c.

Original
|   <8,9>  $  gold pieces
| <10,10>  *  rocks
|  <9,12>  %  newt corpse
Previous
|  <8, 9>  $  gold pieces
| <10,10>  *  rocks
|  <9,12>  %  newt corpse
Now
|  <8,9>   $  gold pieces
| <10,10>  *  rocks
|  <9,12>  %  newt corpse

Override right justification instead of inserting a space.  It looks
better for the situation where all y values are 1 digit.

2 years agoanother no_charge sanity check
PatR [Sun, 4 Dec 2022 01:57:29 +0000 (17:57 -0800)]
another no_charge sanity check

Kicking a no_charge item out of a shop wasn't clearing the item's
no_charge flag so trigger sanity warnings.

2 years agoobj->no_charge insanity
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.

2 years agofarlook /[mMoO] feedback
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).

2 years agoCI ms-dos build: 1 warning was logged as 2 due to set -x
nhmall [Fri, 2 Dec 2022 05:23:46 +0000 (00:23 -0500)]
CI ms-dos build: 1 warning was logged as 2 due to set -x

2 years agomore fetch-cross-compiler.sh tweaks
nhmall [Fri, 2 Dec 2022 05:20:41 +0000 (00:20 -0500)]
more fetch-cross-compiler.sh tweaks

2 years agoexit on fetch-cross-compile failure, not proceed
nhmall [Fri, 2 Dec 2022 04:58:14 +0000 (23:58 -0500)]
exit on fetch-cross-compile failure, not proceed

2 years agoexit return code
nhmall [Fri, 2 Dec 2022 02:46:19 +0000 (21:46 -0500)]
exit return code

2 years agoin fetch-cross-compiler.sh, stop if required piece failed to download
nhmall [Fri, 2 Dec 2022 01:36:10 +0000 (20:36 -0500)]
in fetch-cross-compiler.sh, stop if required piece failed to download

2 years agoalternate fix issue #938 - use-after-free
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.

2 years ago\#wizkill fix
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.

The hack.c and trap.c bits are just reformatting.

2 years agoRecalc mon-hits-you distance variables
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.

2 years agoAvoid segfault when null obj passed to water_damage
Pasi Kallinen [Thu, 1 Dec 2022 11:29:52 +0000 (13:29 +0200)]
Avoid segfault when null obj passed to water_damage

2 years agomore shop billing object sanity
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.

2 years agoUse-after-free with engulfer in xkilled #938
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.

Resolves #938

2 years agoMerge branch 'cursed-gold-detection' of https://github.com/vultur-cadens/NetHack...
nhmall [Thu, 1 Dec 2022 04:18:09 +0000 (23:18 -0500)]
Merge branch 'cursed-gold-detection' of https://github.com/vultur-cadens/NetHack into NetHack-3.7

2 years agoFix autodescribe after reading a cursed scroll of gold detection
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.

2 years agoanother manpage update
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?

2 years agofixes entry for pull request #937 - stale memory
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.

Fixes #937

2 years agoFix: potential use-after-free in expels()
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.

2 years agomore #936 - water vs potions of acid
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.

2 years agopull request #936 - feedback for grease wash off
PatR [Wed, 30 Nov 2022 20:56:16 +0000 (12:56 -0800)]
pull request #936 - feedback for grease wash off

Pull request from entrez:  if a greased item loses its grease after
being affected by water, say so.

Also, the post-water code could access freed memory for an item that
had been destroyed by the water (potion of acid).

Fixes #936

2 years agoFix: use-after-free when fountain dipping
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.

2 years agoTell player when water damage removes grease
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.

2 years agofixes entry for PR #940 - cursed gold detection
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.)

Fixes #940

2 years agoFix autodescribe after reading a cursed scroll of gold detection
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.

2 years agotypo in README
nhmall [Wed, 30 Nov 2022 15:21:41 +0000 (10:21 -0500)]
typo in README

2 years agofix a couple of ms-dos shadow declaration warnings
nhmall [Wed, 30 Nov 2022 04:43:42 +0000 (23:43 -0500)]
fix a couple of ms-dos shadow declaration warnings

2 years agoThis is cron-daily v1-May-8-2022. 000files updated: Files
nhw_cron [Wed, 30 Nov 2022 03:24:09 +0000 (22:24 -0500)]
This is cron-daily v1-May-8-2022.  000files updated: Files

2 years agosplit g into multiple structures
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
     ^ ^

2 years agounpaid object: sanity check, teleporting, 'I u'
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.

2 years agogithub issue #935 - disarming swallowed hero
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.

Fixes #935

2 years agogithub issue #934 - hearing unseem mon read scroll
PatR [Mon, 28 Nov 2022 09:44:19 +0000 (01:44 -0800)]
github issue #934 - hearing unseem mon read scroll

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.

Fixes #934

2 years agoparanoid-pray vs do-again
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.

2 years agofix a syntax error in Makefile.src
nhmall [Sat, 26 Nov 2022 22:03:53 +0000 (17:03 -0500)]
fix a syntax error in Makefile.src

2 years agogitpub issue #933: feedback for throwing w/ count
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.

Closes #933

2 years agousage text revisions
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.

2 years ago'nethack -s -v' usage feedback fix
PatR [Thu, 24 Nov 2022 09:00:59 +0000 (01:00 -0800)]
'nethack -s -v' usage feedback fix

The usage description of '-v' (for scores from all versions present
in 'record' vs only for the current version) was backwards.

2 years agoexpand support for noreturn declarations
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)

2 years agoquiet another warning that recently appeared
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.

2 years agoquiet a warning that has appeared recently
nhmall [Thu, 24 Nov 2022 04:34:47 +0000 (23:34 -0500)]
quiet a warning that has appeared recently

botl.c:1303:25: warning: variable 'notpresent' set but not used [-Wunused-but-set-variable]
    int i, updated = 0, notpresent = 0;
                        ^
1 warning generated.

2 years agounpaid object sanity checking
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.

2 years agoanother follow-up, don't cast hardcoded u.ux, u.uy
nhmall [Thu, 24 Nov 2022 00:10:28 +0000 (19:10 -0500)]
another follow-up, don't cast hardcoded u.ux, u.uy

2 years agofollow-up bit (in unused ms-dos code)
nhmall [Wed, 23 Nov 2022 23:57:14 +0000 (18:57 -0500)]
follow-up bit (in unused ms-dos code)

2 years agosome coordxy and other conversion warnings
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.

2 years agopull request #930 - Qt4 and older Qt5 support
PatR [Wed, 23 Nov 2022 21:42:55 +0000 (13:42 -0800)]
pull request #930 - Qt4 and older Qt5 support

Pull request form chasonr:  restore the capability of using old Qt 4.

I've added a brief Guidebook update.

Closes #930

2 years agoRestore compatibility with Qt 4
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.

2 years agosymbols tweaks
PatR [Wed, 23 Nov 2022 21:06:05 +0000 (13:06 -0800)]
symbols tweaks

Mostly formatting but a couple of minor code changes too.

2 years agopull request #924 - unicode symsets
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.]

Closes #924

2 years agoFree the whole list when freeing
Ray Chason [Sat, 12 Nov 2022 13:04:52 +0000 (08:04 -0500)]
Free the whole list when freeing

2 years agoFix use after free in Unicode mappings
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.

2 years agoParse only Unicode symbols in the current symset
Ray Chason [Mon, 7 Nov 2022 02:51:19 +0000 (21:51 -0500)]
Parse only Unicode symbols in the current symset

2 years agoexpand some 'struct obj' comments
PatR [Wed, 23 Nov 2022 08:46:30 +0000 (00:46 -0800)]
expand some 'struct obj' comments

2 years agoonbill() fix
PatR [Wed, 23 Nov 2022 08:21:04 +0000 (00:21 -0800)]
onbill() fix

Fix a typo/thinko pointed out by entrez.

2 years agomore unix command line: -?
PatR [Wed, 23 Nov 2022 07:55:41 +0000 (23:55 -0800)]
more unix command line: -?

The fix for 'u Name' earlier today broke '-?'.

2 years agoUnix: fix 'nethack -u name'
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.

2 years agoextend sanity_check to shop items
PatR [Mon, 21 Nov 2022 21:16:51 +0000 (13:16 -0800)]
extend sanity_check to shop items

Make object sanity checks examine obj->unpaid and obj->no_charge.

Shopping is complicated; there might be corner cases that aren't
handled correctly.

2 years agoQt pager doll inventory
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.

2 years agoanother man page revision
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

"  nethack [ -d|--directory directory ] [ -w|--windowtype interface ]
"  [ --nethackrc:RC-file | --no-nethackrc ] [ -n ] [ -dec | -ibm ]
"  [ -u playername ] [ -X | -D ] [ -p profession ] [ -r race ] [ -@ ]
"
"  Also [ -A|-Arc | -B|-Bar | -C|-Cav | -H|-Hea | -K|-Kni | -M|-Mon |
"  -P|-Pri | -R|-Rog | -Ran | -S|-Sam | -T|-Tou | -V|-Val | -W|-Wiz ]
"
"  nethack [ -d|--directory directory ] -s|--scores [ -v ]
"  [ -p profession ] [ -r race ] [ playernames ]
"
"  nethack [ --usage | --help ] [ --showpaths ] [ --version[:paste] ]

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.

2 years agofixes entry for PR #928 - remove '#if LINT'
PatR [Sat, 19 Nov 2022 08:50:36 +0000 (00:50 -0800)]
fixes entry for PR #928 - remove '#if LINT'

Pull request from argrath:  remove a bunch of '#ifdef LINT' code
snippets that no longer serve any useful purpose.

If a lint that handles C99 is ever produced, persumably it won't
need the fairly ridiculous hacks for 'static' and 'long'/'long *'.

Closes #928

2 years agoremove the code to silence lint
SHIRAKATA Kentaro [Thu, 17 Nov 2022 09:34:37 +0000 (18:34 +0900)]
remove the code to silence lint

Warning facilities on recent compilers are incredibly improved,
so the code to silence "good-old" lint is much less sense.

2 years agopull request #927 - charging vs undiscovered tools
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.

Fixes #927

2 years agoDon't leak ID of magic tools in charging prompt
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.

2 years agotweak PR #925 - don't expose shop bill details
PatR [Sat, 19 Nov 2022 08:38:20 +0000 (00:38 -0800)]
tweak PR #925 - don't expose shop bill details

Avoid use of 'struct bill_x' outside of shk.c.

2 years agofixes entry for PR #925 - shop boulders
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.

Fixes #925

2 years agoCharge hero for making off with shop-owned boulder
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.

2 years agoPR #926 tweak - mdistu()
PatR [Sat, 19 Nov 2022 08:08:44 +0000 (00:08 -0800)]
PR #926 tweak - mdistu()

Define mdistu() in terms of distu() rather than dist2().  It's an
extra level of macro expansion when compiling but that's negligible
overhead.

2 years agogithub pull request #926 - mdistu()
PatR [Sat, 19 Nov 2022 07:45:32 +0000 (23:45 -0800)]
github pull request #926 - mdistu()

Pull request from entrez.  Replace instances of
distu(mon->mx, mon->my) with new mdistu(mon).

Closes #926

2 years agoAdd 'mdistu' macro
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.

2 years agoFix: "a dry rattle comes from its throat"
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").

2 years agocontrol of command-line usage entry in '?' menu
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.

2 years ago'nethack --usage' and '?' menu
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.

doc/nethack.6 is already out of date again.

2 years agoyet more nethack -s
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.

2 years agomore nethack -s
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.

2 years agofix 'nethack --scores'
PatR [Thu, 17 Nov 2022 07:41:07 +0000 (23:41 -0800)]
fix 'nethack --scores'

The command line parsing in unixmain.c accepted --scores as an
alternative to -s but prscore() in topten.c didn't.

2 years agomanpage update
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.

2 years agoupdate tested versions of Visual Studio 2022-11-14
nhmall [Mon, 14 Nov 2022 17:56:06 +0000 (12:56 -0500)]
update tested versions of Visual Studio 2022-11-14

2 years agomove Makefile variable assignment
nhmall [Mon, 14 Nov 2022 05:22:32 +0000 (00:22 -0500)]
move Makefile variable assignment

2 years agofix path to djgpp c++ compiler in ms-dos cross-compile
nhmall [Mon, 14 Nov 2022 05:00:20 +0000 (00:00 -0500)]
fix path to djgpp c++ compiler in ms-dos cross-compile

2 years agosome follow-up for warnings experienced on macOS
nhmall [Mon, 14 Nov 2022 03:56:05 +0000 (22:56 -0500)]
some follow-up for warnings experienced on macOS

2 years agosome Makefile and hints tinkering
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.

2 years agoreset X11's "interface has been initialized" flag
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.