Commit Graph

13403 Commits

Author SHA1 Message Date
nhmall
cb0c21e91d ENHANCED_SYMBOLS
A new feature, enabled by default to maximize testing, but one which can
be disabled by commenting it out in config.h

With this, some additional information is added to the glyphmap entries
in a new optional substructure called u with these fields:
    ucolor          RGB color for use with truecolor terminals/platforms.
                    A ucolor value of zero means "not set." The actual
                    rgb value of 0 has the 0x1000000 bit set.
    u256coloridx    256 color index value for use with 256 color
                    terminals, the closest color match to ucolor.
    utf8str         Custom representation via utf-8 string (can be null).

There is a new symset included in the symbols file, called enhanced1.

Some initial code has been added to parse individual
OPTIONS=glyph:glyphid/R-G-B entries in the config file.

The glyphid can, in theory, either be an individual glyph (G_* glyphid)
for a single glyph, or it can be an existing symbol S_ value
(monster, object, or cmap symbol) to store the custom representation for
all the glyphs that match that symbol.

Examples:
   OPTIONS=glyph:G_fountain/U+03A8/0-150-255

(Your platform/terminal font needs to be able to include/display the
character, of course.)

The NetHack core code does parsing and storing the customized
entries, and adding them to the glyphmap data structure.

Any window port can utilize the additional information in the glyphinfo
that is passed to them, once code is added to do so.

Also, consolidate some symbol-related code into symbols.c, and remove it from
files.c and options.c
2022-05-07 10:25:13 -04:00
PatR
132e1d433a fix comment (copy/paste victim) 2022-05-07 00:38:44 -07:00
PatR
7d140c6a70 fix github issue #752 - characteristics init
Issue #752 by vultur-cadens:  initialization of characteristics had
off by one errors when reducing over-allocation and when increasing
under-allocation, biasing Str over Cha.

This simplifies the code very slightly but it still seems somewhat
confusing to me.

A couple of reformatting bits are included.

Closes #752
2022-05-07 00:25:03 -07:00
PatR
6ccb56638a autounlock parsing confusion
For char *next; don't compare (next = index(...)) != '\0'.
'\0' has value 0 and 0 used in a pointer context is a null pointer.
So the code worked as intended even though it wasn't written as
what was intended.  Fix: take off the char decoration.
2022-05-06 18:41:54 -07:00
PatR
f2f2644e30 busy hero ignoring monster threat
Fix the problem reported by entrez of a zombie corpse reviving and
crawling out of the ground while the hero was busy doing something
(searching, digging, &c) and having the hero fail to react and just
keep doing whatever the thing was because the zombie was already
inside the range where a monster changes from no-threat to threat.

Done in the monster creation routine so any new monster (including
one revived from a corpse) that is visible,&c will cause the hero's
action to be interrupted.  Teleport arrival probably needs this too.

Only interrupts an occupation, not other voluntary multi-turn
actitivy such as running or traveling.  That would be trivial to
change ['if (g.occupation...' to 'if ((g.occupation || multi > 0)...']
but I'm not sure whether it ought to be extended to that.
2022-05-06 18:30:06 -07:00
PatR
02207b967a autounlock:untrap
Implement 'untrap' as an 'autounlock' action.  Quite a bit more work
than anticipated.  The new documentation is rather clumsy; too many
if-this and if-not-that clauses have intruded.

I'll be astonished if all the return values are correct....

[A couple of places were checking for (rx != 0 && ry != 0) to decide
whether they were performating an autounlock action at <rx,ry> but
that erroneously excludes the top line of the map if the current
level extends that far.  Just check rx for zero/non-zero.]
2022-05-06 14:44:57 -07:00
PatR
a31dd26d8a minor trapped container changes
When probing a trapped container, report that it is trapped.
Done with a one-line message in the zap code and also in the title
of the contents display if it isn't empty.

For wizard mode wishing, if both "trapped" and "broken" are specified,
produce an untrapped container with a broken lock.

Also for wizard mode wishing, ignore "trapped" if player wishes for
"trapped secret door".
2022-05-06 13:27:11 -07:00
PatR
44d5be6eb4 autounlock overhaul
This gives the player more control over what autounlock does.  It is
now a compound option rather than a boolean, and takes values of
  autounlock:none
  !autounlock or noautounlock (shortcuts for none)
  autounlock:untrap + apply-key + kick + force (spaces are optional
    or can be used instead of plus-signs, but can't mix "foo bar+quux")
  autounlock (without a value, shortcut for autounlock:apply-key).
Default is autounlock:apply-key.

Untrap isn't implemented (feel free to jump in) so is suppressed from
the 'O' command's new sub-menu for autounlock.  It's parsed and
accepted from .nethackrc but won't accomplish anything.

[Just musing: it should be feasible to kick in direction '.' to break
open a container or #force to an adjacent spot to break open a door.
If that was done, autounlock:kick+force (or more likely autounlock:
apply-key+kick+force when lacking a key) would resort to force if hero
couldn't kick due to wounded legs or riding.

This changes struct flags so increments EDITLEVEL again.

This includes pull requests #750 from entrez and #751 from FIQ but was
entered from scratch rather than using use their commits.

Closes #750
Closes #751
2022-05-04 19:13:28 -07:00
PatR
d1b14e08c4 skipinvert handling in tty menus
Select all and unselect all were passing the wrong third argument to
menuitem_invert_test().  Select page and unselect page had it right.
2022-05-04 14:19:16 -07:00
nhmall
721b1cc9b9 unreferenced local variable warning 2022-05-04 08:48:56 -04:00
PatR
4c3d5e9db4 pull request #749 - MSGHANDLER for #if WIN32
github pull request #749 by argrath:  add support for MSGHANDLER for
WIN32 using spawn() rather than the fork()+exec() used on UNIX.

Closes #749
2022-05-03 14:43:44 -07:00
SHIRAKATA Kentaro
397476a8a1 update condition for displaying on #version 2022-05-03 14:39:24 -07:00
SHIRAKATA Kentaro
1a361af084 add msghandler support for win32 2022-05-03 14:39:24 -07:00
Pasi Kallinen
2a801538fa Fix warnings, add newline before function braces 2022-05-02 12:46:02 +03:00
nhkeni
79e04d3a65 nhlua.c: bugfix - remove the handler after calling lua_pcall() 2022-05-01 21:09:59 -04:00
PatR
a9559c01f4 pets and portals
Extend pull request #737,
commit d6ab241b8c, to magic portals.
If hero is on or next to a magic portal, have pets behave as if food
they want is being carried, like PR #737 did for hero standing on
stairs.  (To be on one, hero must have come through from the other
side and not moved off the receiving portal yet, or else is in the
endgame but no longer carrying the Amulet.)
2022-05-01 15:09:17 -07:00
nhmall
308dce273d warning bits on Windows build
src/nhlua.c(1606): warning C4127: conditional expression is constant
src/nhlua.c(2032): warning C4127: conditional expression is constant
2022-05-01 12:18:45 -04:00
Pasi Kallinen
71c55e4285 Remove extra full stop from SOUND error 2022-04-30 16:53:47 +03:00
PatR
7b577d4ad1 pull request #728 - high-altar desecration
Pull request from argrath:  move code to handle the desecration of a
high-altar out of dosacrifice() into a separate routine.

Closes #728
2022-04-29 23:22:45 -07:00
SHIRAKATA Kentaro
d6079b4ccb Separate some codes for desecratintg high altar
... and remove one goto.
2022-04-29 23:22:19 -07:00
PatR
b8ba768edc pull request #747 - tty_add_menu() defensiveness
Pull request by argrath:  remove an unneeded test for Null when
setting up a new menu entry for tty.

Closes #747
2022-04-29 23:10:55 -07:00
SHIRAKATA Kentaro
0be21a231c remove redundant condition on tty_add_menu()
`newstr` is assigned to `str` or `buf`.
`buf` is an address of an array, and `str` is guarded,
so both are non-NULL.
2022-04-29 23:08:17 -07:00
PatR
140077b163 avoid new "where are we?" panic
savelev() gets run to clean up memory even if the player quits before
level 1 is created, and a change made yesterday panicked if it couldn't
figure out what level the hero is on.  Caught by entrez, again....

If not actually writing a level's file, don't panic if both u.uz and
g.uz_save are 0.  Having one of those be non-zero is only essential
when the level being processed is the Plane of Water or Plane of Air.
2022-04-29 23:00:51 -07:00
PatR
0efa1d60b7 fix compatability checking for development
It is astounding that after all this time no one noticed that
incrementing EDITLEVEL wasn't doing the job it's intended to do.
Diagnosed by entrez:  since VERSION_COMPATIBILITY was defined as
3.7.0-0 and up, increasing the fourth component wasn't resulting in
old 3.7.0-x files being rejected.

This increments EDITLEVEL yet again, because my testing after
commenting out VERSION_COMPATIBILITY still wasn't rejecting older
files.  Proably because the oldest I had available already had the
verison info with the preceding EDITLEVEL so weren't actually out
of date yet.

Once I had old files be rejected, I discovered that the rejection
message was invisible (for tty on OSX).  The message line showed
spaces, matching the length of the intended message, followed by
--More--.  This fixes that too.
2022-04-29 22:37:13 -07:00
nhkeni
b8ee09b843 Merge branch 'NetHack-3.7' of https://rodney.nethack.org:20040/git/NHsource into NetHack-3.7 2022-04-29 21:11:10 -04:00
PatR
2e1555a0be command result handling
It's possible to get a strange command result of ECMD_CANCEL+ECMD_TIME.
If/when that happens don't just treat it as cancel, make sure that time
elapses.

If an invalid command is provided, clear the do-again queue so that ^A
won't attempt to try the same invalid command again.
2022-04-29 17:50:26 -07:00
nhkeni
6bd2172ba7 Lua sandbox
This is enough to prevent abuse by denying access to functions and
    denial of service (RAM and instruction step limits), but not enough
    to allow restricted use of things that require finer control (e.g.
    filesystem access).

    If something goes wrong, the whole thing can be turned off, for
    now, in config.h (see NHL_SANDBOX).

    None of the current functionality requires changes to build systems;
    some of the possible future functionality may require some #defines
    - TBD.  There is lots of dead code (#ifdef notyet) for bits of that
    additional functionality; we can rip it out if we don't want those
    additions or we can complete (parts of) it depending on our needs.

    All current uses of Lua are connected to sandboxes and guarded with
    nhl_pcall (sandbox and lua_pcall wrapper); options and limits can
    be set at the callsites in the passed nhl_sandbox_info.  Some of
    the error handling may be wrong - panic() vs.  impossible() vs
    silence.

    Memory and instruction step limits should be tuned prior to release;
    there's no point tuning them now.
2022-04-29 19:46:33 -04:00
PatR
5d56da3d32 bubble/cloud save/restore overhaul
The air bubbles on the Plane of Water and the clouds on the Plane of
Air were being saved and restored as part of the current level's state
(which is the 'u' struct and invent and such) rather than with the
current level itself.  That was ok for normal play, but for wizard
mode's ^V allowing you to return to a previously visited endgame level
after moving to a different one it meant a new set of bubbles for
Water and new set of clouds for Air.  Even that was ok since it only
applied to wizard mode, but using #wizmakemap to recreate Water or Air
while you were on it added a new set of bubbles or clouds to the
existing ones.  If repeated, eventually there wouldn't be much water
or air left.

Instead of just adding a hack to #wizmakemap, change save/restore to
keep the bubbles/clouds with the level rather than with the state.
That wasn't trivial and now I know why the old odd arrangement was
chosen.  Saving hides u.uz by zeroing it out for levels that the hero
isn't on and it is zero during restore so simple checks for whether a
given level is water or air won't work.

This also adds another non-file/non-debugpline() use of DEBUGFILES:
 DEBUGFILES=seethru nethack -D
will make water and clouds be transparent instead of opaque.  It also
makes fumaroles and other light-blocking gas clouds be transparent
which wasn't really intended, but avoiding it would be extra work that
doesn't accomplish much.

Increments EDITLEVEL for the third time this week....
2022-04-29 12:44:26 -07:00
PatR
5e1fba6e29 forcefight against edge of map
Noticed when testing the forcefight against obscured furniture fix:
if you attempted forcefight against the edge of the map, you got
feedback about having already moved as far in <direction> as possible
rather than about forcefight failing to attack anything.  Have the
can't move out bounds test check for forcefight before deciding to
give to its normal feedback.
2022-04-28 02:21:46 -07:00
PatR
10d42a2c55 fixes entry for pull request #746 - force-fight \
against "unknown obstacle"

Pull request #746 by entrez:  give better feedback when 'F' prefix
is used toward furniture covered by objects and towards solid rock
terrain on arboreal levels.

Fixes #746
2022-04-28 01:33:31 -07:00
Michael Meyer
d3d5f7f88b Fix: force-fight 'unknown obstacle' descriptions
This is intended to address a couple quirks with force-fighting an
unoccupied spot that I noticed:

 * Now that furniture is considered 'solid', an object is much more
   likely to be sitting on the square, obscuring the terrain glyph.  As
   a result, the current glyph is no longer sufficient to accurately
   describe the contents of the spot -- e.g., an altar with a corpse on
   top of it was being described as "an unknown obstacle", even when the
   hero knew exactly what furniture was there.

 * When blind and attacking an unexplored 'solid' square, the attacked
   position would always be described as 'the stone', even something
   like a fountain or sink which didn't seem likely to be confused with
   a stone wall.

 * The feedback for attacking stone was previously changed from 'solid
   rock' to 'stone' in order to be consistent with the feedback for
   attacking an unseen wall, but they still weren't quite the same
   ("stone" vs "the stone").

 * The 'stone' feedback for all STONE/SCORR spots was incorrect on
   levels flagged as arboreal, where stone is rendered and described as
   trees.

This relies on back_to_glyph for positions where the hero is aware of
the terrain and certain other spots (like stone, walls, etc) for which
back_to_glyph produces good results even if they're unseen, and falls
back to the generic "unknown terrain" in other cases.

Pretty long commit message for such a small commit, but oh well...
2022-04-28 01:10:46 -07:00
PatR
4ab68767bf show trapped doors,chests as themselves \
instead of as fake bear traps

Use the new traps and their tiles when confused gold detection finds
trapped doors and trapped chests.  (Large boxes can be trapped too;
they use the trapped chest trap and corresponding tile rather than
have their own.)

Usually these pseudo-traps go away when as soon as they are within
line of sight.  (While testing, I noticed that seeing a trapped door
from outside its room rather than inside didn't behave that way.
The door was created by wizard mode wishing; I don't know whether
that was a factor.)

I also discovered that secret doors weren't being handled correctly.
They can't be trapped because of their use of both the doormask and
wall_info overlays of levl[][].flags, but I had a secret door be
falsely displayed as a trap.  This fixes that.

We should have obj->tknown and rm->D_TRAPKNOWN so that the hero won't
forget about these traps after declining to attempt to untrap them.
But that's more work than I care to tackle.
2022-04-27 17:16:23 -07:00
nhmall
281d959b8b revisit Qt6 macOS QSoundEffect
- After reverting previous related commit, add the QtMultimedia folder to
the include search path as suggested by PatR, and leave qt_bind.cpp alone
2022-04-27 19:06:06 -04:00
nhmall
75f3008123 Revert "Qt6 QSoundEffect on macOS"
This reverts commit f6149904c3.
2022-04-27 19:00:18 -04:00
PatR
e8184663e0 extra traps followup
"add glyphs+tiles for door+chest traps",
commit d1217b9f25,
missed a couple of S_vibrating_square references, resulting in
screwed up rendering of zaps and explosions.
2022-04-27 15:43:18 -07:00
PatR
d1217b9f25 add glyphs+tiles for door+chest traps
When trap detection finds trapped doors and trapped chests, it shows
those as bear traps.  When the hero comes within view, they revert to
normal and the detected trap is forgotten.  This doesn't change that,
it is just groundwork to be able to show them distinctly.  Like the
TT_BEARTRAP patch, it increments EDITLEVEL so this seemed like a good
time to put the groudwork in place.

There shouldn't be any visible changes even though internal glyph and
tile values have been renumbered after inserting two new entries.
Adding traps after S_vibrating_square was quite a hassle and suffered
though a couple of off-by-one errors that weren't trivial to find and
fix.
2022-04-27 11:22:12 -07:00
PatR
d194459c7d u.utraptype, TT_BEARTRAP
Add 'FIXME' fix by entrez to change TT_BEARTRAP to non-zero.

Increments EDITLEVEL, invalidating existing save and bones files.
2022-04-27 11:04:12 -07:00
nhmall
f6149904c3 Qt6 QSoundEffect on macOS 2022-04-27 13:56:01 -04:00
nhmall
43158982c3 consolidate two fixes entries for QSoundEffect 2022-04-27 08:40:02 -04:00
nhmall
fd63deaa0d Qt comment update 2022-04-27 07:52:10 -04:00
nhmall
4f815d77ff add a fixes note on change from QSound to QSoundEffect 2022-04-27 07:45:43 -04:00
nhmall
e2bd117c61 QSoundEffect supported in Qt6 but needs conditional code rework 2022-04-27 07:40:40 -04:00
nhmall
4d62f418f0 fix Qt6 broken build 2022-04-27 07:35:31 -04:00
Pasi Kallinen
c3c60b0b2c When setting user sounds, allow also setting a MSGTYPE
The SOUND lines now have an optional msgtype parameter:

   SOUND=MESG hide "^You miss the " "swing.wav" 75

Fixes #571
2022-04-27 13:32:34 +03:00
Pasi Kallinen
5d20140b74 Qt: To play user sounds with volume, replace QSound with QSoundEffect 2022-04-27 12:40:59 +03:00
Pasi Kallinen
4cffa9700e Split trap statue creation into separate function 2022-04-26 18:09:36 +03:00
nhw_cron
caf00389e1 This is cron-daily v1-Feb-22-2022. 000files updated: Files 2022-04-26 08:19:19 -04:00
Pasi Kallinen
99efeafec7 Split trap note choosing into separate function 2022-04-26 14:00:09 +03:00
PatR
36af5a9a63 fix github issue #745 - two-weapon paralysis
Issue #745 by k2:  when using two-weapon combat, the second attack
would still take place even if the first attack caused the hero to
become paralyzed (hitting a floating eye or g.cube).

Cleaver's up-to-three attacks had the same problem but did stop if
the hero underwent life-saving after some fatally damaging counter-
attack.  Two-weapons didn't.  Make them both stop early if either
paralysis or life-save occurs.

Multiple attacking monster against monster and against poly'd hero
already deal with paralysis; life-saving doesn't apply.

Fixes #745
2022-04-26 02:02:31 -07:00
Pasi Kallinen
f10cdc2d9c Use get_mleash to find the leash attached to monster 2022-04-26 08:46:55 +03:00