nhmall [Tue, 28 Feb 2023 05:05:04 +0000 (00:05 -0500)]
return correct ALT-key sequences with PDCurses
They weren't working at all because the values of ALT_A through ALT_Z
were out of the normal char range with PDCurses, and caught by the default
case in the switch, where reject got set.
/* use key as-is unless it's out of normal char range */
reject = ((uchar) ret < 1 || ret > 255);
nhmall [Mon, 27 Feb 2023 16:08:51 +0000 (11:08 -0500)]
fix a 'make bundle' error
make[1]: *** No rule to make target `../util/uudecode', needed by `/Users/testuser/nethack/NHsource/bundle/NetHackTerm.app/Contents/Resources/NetHackTerm.icns'. Stop.
make: *** [bundle] Error 2
PatR [Sat, 25 Feb 2023 15:02:19 +0000 (07:02 -0800)]
fix #H2694 - egg hatching feedback
A bug report from ten and half years ago...
If a carried egg hatches, the message is
|<foo> drops from your pack.
and if tame, is followed by
|Its cries sound like {mommy,daddy}.
The latter was issued even when <foo> has no speech capability.
Replace "its cries sound like" with "its <vocalize>ing sounds like"
for suitable value of <vocalize>.
This adds two new monster sounds, MS_BELLOW and MS_CHIRP, also two
new sound effect codes, se_chirp and se_croc_bellow.
We had MS_SILENT for crocodile. On wikipedia, crocodile is described
as the most vocal reptile. Adult males make a load bellowing noise
and hatchlings make a chirping noise.
This changes crocodile, titanothere, and baluchitherium from MS_SILENT
to MS_BELLOW and baby crocodile from MS_SILENT to MS_CHIRP. Chirp
might be appropriate for lizards and lizard-like amphibians but I've
left those as MS_SILENT.
[Noticed but not changed: lizards and lizard-like amphibians aren't
flagged as oviparous. Shouldn't they be?]
PatR [Thu, 23 Feb 2023 22:02:28 +0000 (14:02 -0800)]
address github issue #987 - curses: arrow keys
Issue reported by jeremyhetzler: left and right arrows produced
unexpected characters when trying to use them to edit text that is
being entered.
The curses interface converts arrow keys and function keys related
to the keypad into movement keys (hjkl or 4286 depending on the
number_pad setting). But it was doing that all the time, not just
when nethack wanted movement keys. This extends the existing
program_state.getting_a_command flag to getdir() so that it can be
used for controlling that in addition to 'altmeta' support.
Typing an arrow when interacting with the map (actual command or
getpos, now getdir too) will still work. Typing one when making a
wish or naming a pet will issue a beep and be treated as if '\0' had
been typed, and that normally gets treated as if ESC had been typed.
[Possible room for improvement there. Losing the whole text when
trying to back up a character feels a bit harsh.]
Treating left arrow as escape rather than as h or 4 will probably be
enough to train players not to try to edit text with it after they
get burned by that a time or two.
Bonus fix: curses' keystroke conversion only supported traditional
number_pad behavior, not the inverted phone number pad layout.
PatR [Tue, 21 Feb 2023 22:00:31 +0000 (14:00 -0800)]
tty_display_file()
For the !defined(DEF_PAGER) config, if the file to be displayed
can't be opened, refresh the screen after complaining about that
rather than when no complaint is issued.
PatR [Mon, 20 Feb 2023 21:04:44 +0000 (13:04 -0800)]
fixes entry for PR #978 - suppress monster's name
for <new form> portion of messages "<old form> turns into <new form>"
to avoid named vampires yielding "Dracula turns into Dracula".
Pull request from entrez: a couple of engulf messages used regular
monster naming for vamp-shifters transforming rather than dying.
3.6.1 had fixes for this for basic monster death but didn't handle
engulfing.
Michael Meyer [Fri, 10 Feb 2023 19:07:49 +0000 (14:07 -0500)]
Avoid "It turns into [Name]" on vamp engulf
Apply a similar fix as a791b4b and f441696 ended up settling on for
normal vampire transformation to the vampire transformation that happens
when their shapeshifted form is engulfed.
PatR [Mon, 20 Feb 2023 20:22:14 +0000 (12:22 -0800)]
fix #K3863 - replace 'for (int i=0;...' in core
The Makefiles and some of the hints have already been updated to
specify that C99 is required in response to #K3863. The code was
evidently being compiled in the default mode of an old version of
gcc and that mode complained that C99 was required to specify a
declaration in the initializer clause of a
'for(initialize;test;update)statement'. Other C99 features used
by nethack were apparently accepted as extensions in the default
conformance mode.
There's only one such declaration in the core code so replace it
with a separate declaration and ordinary 'for' loop.
win/Qt/{lots}.cpp and win/win32/{few}.c have these declarations but
the core didn't.
PatR [Sun, 19 Feb 2023 19:18:56 +0000 (11:18 -0800)]
[un]compress wait() feedback
At some point this may need to be commented out, but for the time
being report failure by wait() during the fork()+exec()+wait()
sequence when compressing or uncompressing a save file.
For the benefit of 'git log': uncompressing an old save file or
compressing a new one fails when running nethack under control of
gdb (GNU Project's debugger) on OSX. Noticed and reproducible on
OSX 10.11.6; no idea about more recent versions. wait() returns -1
and sets errno to 4, "interrupted system call", and leaves the
variable that receives the child process's exit status as is.
NetHack has been relying on that exit status variable without
checking whether wait() returns success or failure.
This changes nethack's behavior when wait() fails. It is now
intentionally failing compress/uncompress (by init'ing the status
to 1) after it was briefly treated as success (due to a recent
commit that set status to 0 before calling wait()), after a long
time of accidentally failing due to not setting varible 'i' (was 2
after being used for another purpose). In addition to initializing
to failure prior to calling wait(), replace use of 'i' with a new
variable that is only used for this, possibly making the code more
comprehensible.
By the way, the issue with compress and uncompress failure when
running under control of gdb on OSX is not new. I don't use gdb
a lot and have gotten tired of rediscovering this misbehavior.
Pasi Kallinen [Sun, 19 Feb 2023 13:44:29 +0000 (15:44 +0200)]
Tips and option to disable them
Adds a more general way to handle gameplay tips, and adds
a boolean option "tips", which can be used to disable all
tips. Adds a helpful longer message when the game goes
into the "farlook" mode.
Also adds a lua binding to easily show multi-line text
in a menu window.
PatR [Sun, 19 Feb 2023 02:03:21 +0000 (18:03 -0800)]
reverse main bit of 'build fix: COMPRESS_OPTIONS'
I realized that I put opts[] inside a block that would go out of
scope while it was still needed. When I went to fix that, I
discovered that it is already present where it ought to be. My
'experimentation' should have defined COMPRESS_OPTIONS sooner so
that the outer scope would see it.
This doesn't revert the previous commit because a couple of comments
and a bit of reformatting from it are still useful.
nhmall [Sat, 18 Feb 2023 16:35:40 +0000 (11:35 -0500)]
expand C99=1 with macOS.370 and linux.370 hints
In addition to C99=1 on the make command line, also allow
C89=1 or C11=1 or C23=1.
NOTE: Those won't all lead to a successful build of NetHack,
and the use of C23=1 (-std=c2x) will only be valid on recent
compiler versions (clang-15, for one, accepts it).
PatR [Fri, 17 Feb 2023 22:40:26 +0000 (14:40 -0800)]
pyrolisk feedback
From a report 9 years ago, a pet pyrolisk was repeatedly gazing at a
grey-elf and nothing happened. It turned out that the elf was wearing
an elven cloak which was negating damage some of the time (most of the
time back then) but with no indication that that's what was happening.
This makes many types of damage that are negated by MC say so.
Probably other types of damage should do likewise.
Issue reported by entrez: when getpos() is being used to have the
player pick a map location, if player types '$' (for some operations
like jumping or applying a polearm) then valid spots are highlighted
but the highlighting obscures what was shown on the map. I'm not
sure whether this 'fixes' the issue but it's probably good enough.
Allow typing another '$' to toggle the highlighting back off,
redisplaying the map in the process, without needing to move the
cursor or type ^R to accomplish that. Toggling seems more intuitive.
This is a lot more complicated than it needs to be because I assumed
that the background aspect of highlighting stayed visible when the
glyphs were reverted. It doesn't work that way but I haven't thrown
out the effort to make toggling the highlights work sanely. Prior
to this, typing '$' again just redrew the highlighting again, with
no visible effect.
nhmall [Fri, 17 Feb 2023 15:23:40 +0000 (10:23 -0500)]
allow setting the standard
CSTD can be manually set near the top of src/Makefile, util/Makefile
or by including c99=1 or C99=1 on the build make command line if
using the linux.370 or macOS.370 hints files.
Pasi Kallinen [Wed, 15 Feb 2023 09:24:01 +0000 (11:24 +0200)]
Fix angering monsters with non-hero magic rays
Can't use gc.context.mon_moving to check if the ray was caused
by hero, as some rays can happen while hero is moving in response
to their action - for example a bolt of lightning from a god.
dobuzz() uses positive type values for magic rays caused by hero,
so just use that.
Michael Meyer [Mon, 13 Feb 2023 22:11:07 +0000 (17:11 -0500)]
Don't anger target via mon vs mon zap/breath
dobuzz() was modified in 677b32c2a7 to anger the target, but beams
handled by dobuzz() don't necessarily originate from the hero. Monsters
can zap wands that hit other monsters, dragons can use their breath
attacks, etc. Those things were causing the targets to become angry at
the hero.
Michael Meyer [Mon, 13 Feb 2023 19:21:44 +0000 (14:21 -0500)]
Fix: message when pet moves from water to eat
The <x,y> params of dog_eat are the pet's starting position that turn,
not necessarily the position of the object being eaten. If the pet is
doing a combined move-and-eat action, <x,y> will be its original spot,
but it will have already moved to <mtmp->mx,mtmp->my>, where the food
object also is.
The attempt to check whether the eating was happening out-of-sight
underwater (to suppress the message in that case) was checking the pet's
starting location, not its new location/the location of the food object.
So if a pet moved from water to land to eat something, the chowing-down
message would be improperly suppressed (and presumably the message for a
pet moving from land to water to eat would be improperly left
_un_suppressed, though I didn't actually try to reproduce that).
copperwater [Fri, 10 Feb 2023 22:23:32 +0000 (17:23 -0500)]
Fix: Change gradient math to avoid isqrt
isqrt adds some noticeable distortion artifacts to gradients (test case
I used is to draw a line from 10,10 to 20,15 with mindist = maxdist = 2
and see how the gradient is biased towards the upper right); changing
the distance calculations to use the square of the distance rather than
the raw distance avoids this. This makes radial gradients more radial,
and square gradients more square.
There still appears to be a bit of bias, but I think this is due to the
line algorithm not lining up perfectly with the tiles.
copperwater [Fri, 10 Feb 2023 12:38:22 +0000 (07:38 -0500)]
Invert the behavior of selection.gradient
selection.gradient has some pretty unintuitive behavior, in that it
selects points that are NOT close to the defined center. I've used
gradient selections several times and so far all of them have had to be
negated, because I wanted to select points close to the center with a
decreasing probability further out.
This implements that behavior, and also fixes a bug in which the x,y
coordinates of the gradient center(s) were not converted properly when
used within a des.room or des.map. Also updated the lua documentation
for gradient.
I removed the "limited" argument, as it was previously used to control
whether the rest of the map outside the max given distance would be
included in the selection; now that the area beyond maxdist is naturally
never in the selection, it doesn't have much use. (And I can't think of
a reasonable use case for the inverse: wanting to select points close to
the center, with decreasing chance towards maxdist, but then select the
entire map beyond maxdist.)
Currently this does not affect any special levels or themed rooms
because none of them use selection.gradient.
PatR [Sat, 11 Feb 2023 19:35:06 +0000 (11:35 -0800)]
add #genocided command
Comparable to #vanquished, be able to view info normally available
during end of game disclosure while the game is still in progress.
The new #genocided command lists all genocided and extincted types
of monsters. Unlike #vanquished, there aren't any sorting choices.
Potential future enhancement: provide a way to view the genocided
list at the "what do you want to genocide?" prompt.
PatR [Sat, 11 Feb 2023 00:42:01 +0000 (16:42 -0800)]
Makefile management
Have 'make clean' and 'make spotless' in 3.7 cleanup include/tile.h
from 3.6. Otherwise use of 'cc -I../include -I../win/share' in
util/Makefile will get 3.6's include/tile.h instead of 3.7's
win/share/tile.h; use of FDECL() causes the old header to break when
used in various tiles utilities.
PatR [Fri, 10 Feb 2023 23:19:13 +0000 (15:19 -0800)]
X11_hangup()
I was looking at backporting an X11 build fix to 3.6 and decided
that the hangup handling wasn't correct if SAFERHANGUP is defined
(which it is by default). It didn't attempt to perform a hangup
save. Also, the handler might return when the X code calling it
expected it to not do so.
I don't know how to force a hangup within X11 so haven't tested
this properly. It works fine when there's no hangup. :-/
* doc/Guidebook.mn: Remove workaround, in favor of...
* doc/tmac.n: ...setting automatic hyphenation mode appropriate to
hyphenation systems used by AT&T-descended troffs on the one hand
("suftab") and groff (TeX hyphenation patterns) on the other.
modify results of pull request #977 to target tmac.nh instead.
Guidebook update to trigger the process following pull request 977.
PatR [Thu, 9 Feb 2023 23:48:45 +0000 (15:48 -0800)]
pull request #976 - D of AP
Pull request from entrez: combining just-picked-up (P) with explicit
accept without confirmation (A) for multi-drop (D) ignored the
just-picked-up part and dropped everything.
Affects menustyle:Full. For menustyle:Traditional, 'A' operates very
differently and combining 'a' with 'P' or vice versa already does the
right thing.
Michael Meyer [Thu, 9 Feb 2023 19:40:52 +0000 (14:40 -0500)]
Fix: 'A'+'P' regression when dropping by type
Selecting both 'P' (the just-picked-up items category) and 'A' (the
'auto-select relevant items' flag) when dropping items by type with 'D'
was automatically dropping every item in inventory instead of only items
that were marked as just having been picked up. Basically, it was
causing 'A' to act like it did before b65c93c amended its functionality.
This commit is more-or-less identical to 991e739, both in terms of the
problem and the fix, except that it applies to dropping items instead of
looting.
PatR [Thu, 9 Feb 2023 23:31:41 +0000 (15:31 -0800)]
pull request #975 - maybe_unhide_at()
Pull request from entrez: mayby_unhide_at() operating on the hero
rather than on a monster was buggy because it was looking at the wrong
fields when checking for being hidden (recently fixed) and for being
trapped (fixed here) because those are tracked by fields in 'u' rather
than in 'youmonst'.
Michael Meyer [Thu, 9 Feb 2023 16:38:59 +0000 (11:38 -0500)]
Tweak maybe_unhide_at() a bit more
A monster may be unhidden if it's caught in a trap, but maybe_unhide_at
was checking mtmp->mtrapped across the board, which wouldn't work for
the hero. Use u.utrap instead under those circumstances. Also refactor
a bit so it shouldn't need the repeated guards against mtmp being null.
nhmall [Wed, 8 Feb 2023 22:17:43 +0000 (17:17 -0500)]
add new macOS target 'bundle'
This creates a new target 'bundle' for make on macOS, when using
sys/hints/macOS.370.
The 'bundle' recipe:
- creates a subdirectory of src called 'bundle', and creates
a bundle (nethack.app/ etc) below that.
- the executable that is placed inside the bundle
(bundle/nethack.app/Contents/MacOS/nethack) will find resources
within the bundle, including the sounds, so a manual placement
of the sounds into your '~/Library/Sounds' is no longer
required when using the executable that's inside the bundle.
- the sounds are included in the bundle if a soundlib option is
chose at build time (for example 'make WANT_MACSOUND=1'), such
that the bundled executable supports sounds.
- the executable inside the bundle seems to find the resources
it needs, even if invoked through a symlink elsewhere that points
to the executable that's inside the bundle (only limited testing of that
has been done).
- at some point, its probably appropriate to add a
'mv bundle/nethack.app <proper location>', possibly under
a subsequent 'make install' step.
- right now, the bundle step has a dependency on 'update'. I don't
know if that's the right ordering or not, yet.
make WANT_MACSOUND=1 update
make WANT_MACSOUND=1 bundle
or, you can probably get away with:
make WANT_MACSOUND=1 bundle
if the nethack bundle is the goal anyway.
make clean
will clear the bundle subdirectory and everything below it.
PatR [Wed, 8 Feb 2023 20:59:47 +0000 (12:59 -0800)]
mread() in restore.c
Update and apply an old stashed commit: hide the casts in calls to
mread() made in restore.c. Some split lines get recombined and there
is less clutter when reading the code.
Pasi Kallinen [Wed, 8 Feb 2023 15:08:20 +0000 (17:08 +0200)]
Fix hero unhiding
maybe_unhide_at tried to handle both a monster and hero, but
hero being hidden is in u.uundetected flag, and the code was
only checking the monster mundetected field.
The code should probably be changed, either to change all uses
of the u.uundetected to gy.youmonster.mundetected, or perhaps
use a macro ... but these changes are all too big for me
to tackle for now.
PatR [Wed, 8 Feb 2023 00:47:42 +0000 (16:47 -0800)]
generic objects refinement
Give generic objects a name as well as a description to avoid some
potential object formatting problems. Also remove the 'unique' flag
from them to avoid confusion. Not exhaustively tested.
PatR [Tue, 7 Feb 2023 22:02:06 +0000 (14:02 -0800)]
still more shop shared wall
Neither my fix for #969 nor the followup by entrez dealt with this:
if you were in one shop and dug the wall it shared with another shop,
sometimes the shopkeeper for the room your were in would teleport to
you and demand payment--or attack if you lacked funds--other times the
one from the far room would do so. For the latter, if you maneuvered
to the gap in the wall (possibly declining to die if angry shopkeeper
managed to kill you) you would get "this shop is deserted" (which is
accurate) but if you subsequently died there, you could get "Welcome
to so-and-so's shop" when the shopkeeper who abandoned her shop was
returned to occupancy after one of them took possession of invent.
And the welcome message might come from the shop that hadn't been
deserted and that you had never left. (Perhaps always from that one;
I'm not sure.)
Possibly the shopkeeper for the room you're in should get priority
when demanding payment for repairs so that the other one won't
abandon the far shop, but I didn't attempt to tackle that. This
just suppresses room entry messages when returning the shopkeeper to
her shop if the game is ending.
Not fixed, but amusing: in one of the tests, the 'far' shopkeeper
who had teleported into the near shop to demand payment for the dug
wall picked up an item from the near shop (in the case I noticed, a
hardware store shk picked up a food ration; just an ordinary item
owned by the stop) while pursuing me to the wall gap. One shk was
stealing from the other. :-)
PatR [Tue, 7 Feb 2023 21:49:44 +0000 (13:49 -0800)]
pull request #969 - dying in shared shop wall
Pull request by entrez, following up issue by k2: when deciding
whether a shopkeeper should taken possession of dying heros invent,
check all rooms the hero is in rather than just the first. Deals
with dying in a gap of a wall shared by two shops.
Original issue was about "place_object: <item> off map <0,0>" but
an earlier commit fixed that (I hope). That commit had a typo in
the issue number and closed #965 (which was already closed) instead
of #969 (which this pull request reopened anyway).
Michael Meyer [Mon, 6 Feb 2023 18:41:55 +0000 (13:41 -0500)]
More #969: handle shared walls in inherits()
inherits() only examined the first item in u.ushops, so some shopkeepers
that should have had first dibs were ignoring the hero, one of the
causes of #969. Examine the entire u.ushops array instead of just the
first item so that the hero's position within the shop will be correctly
identified (and do the same in set_repo_loc, though it's probably not
really necessary there).
nhmall [Tue, 7 Feb 2023 05:44:36 +0000 (00:44 -0500)]
another update to the soundlib interface
sound_verbal(char *text, int32_t gender, int32_t tone, int32_t vol,
int32_t moreinfo);
-- NetHack will call this function when it wants to pass text of
spoken language by a character or creature within the game.
-- text is a transcript of what has been spoken.
-- gender indicates MALE or FEMALE sounding voice.
-- tone indicates the tone of the voice.
-- vol is the volume (1% - 100%) for the sound.
-- moreinfo is used to provide additional information to the soundlib.
-- there may be some accessibility uses for this function.
It may be useful for accessibility purposes too.
A preliminary implementation has been attempted for macsound to test
the interface on macOS. No tinkering of the voices has been done.
Use of the test implementation requires the following at build time with make.
WANT_SPEECH=1
That needs to be included on the make command line to enable the test code,
otherwise just the interface update is compiled in.
I don't know for certain when AVSpeechSynthesizer went into macOS, but older versions
likely don't support it, and would just leave off the WANT_SPEECH=1.
If built with WANT_SPEECH=1, the 'voices' NetHack option needs to be enabled.
It was a bit strange, when I first started up the test, to hear Asidonhopo,
the shopkeeper, talking to me as I entered his shop and interacted with him.