Commit Graph

313 Commits

Author SHA1 Message Date
nhmall
4e19221e55 variable 'display' causes shadow variable warnings in X11 build
display.botl      -> disp.botl
display.botlx     -> disp.botlx
display.time_botl -> disp.time_botl
2024-01-05 05:58:51 -05:00
nhmall
22e52ee905 bundle the display-related hints, that tell bot() and others
that an update is required, into a struct. Remove it from
context since there is no reason to save those.
2024-01-04 23:16:27 -05:00
nhkeni
9bcff7b896 Merge branch 'keni-luabits2' into NetHack-3.7 2024-01-04 10:40:27 -05:00
nhkeni
c7ab9a0565 Some lua catchup and cleanup
- add nhl_pcall_handle() to wrap all nhl_pcall calls that didn't check
  return value and either panic() or impossible()
- add --loglua (unix only) to dump Lua memory and steps info to livelog
- remove old logging
- set memory and step limits on all Lua VMs
2024-01-04 10:37:38 -05:00
PatR
1cfa966871 pull request #1143 - menustyle:Full 'A' choice
Pull request from entrez:  in the class filtering menu for multi-drop
and for loot in-or-out of a container, make choosing 'A' without any
other filter choices (such as all, specific class(es), cursed, unpaid,
just-picked-up, &c) become a no-op.

I started with the pull request and then undid much of it.  It would
have been simpler to start from scratch.  If you don't have option
paranoid_confirmation:AutoAll set, when choosing 'A' for all-without-
prompting as the only selection, operate as the PR has made things
work:  effectively, 'A' by itself is ignored and the operation ends
with nothing happening.

However, if you do have paranoid_confirm:A set, then continue treating
'A' by itself as if 'A'+'a':  everything.  Since paranoid confirmation
is specified, that will be followed by a confirmation prompt.

This also adds a context-sensitive hint to the menu about how the 'A'
entry works, shown every time when 'cmdassist' is On or just once (per
session) when that is Off.

The documentation probably needs some updating.

Closes #1143
2023-12-30 16:33:27 -08:00
nhmall
3bf2f0daee Revert "allow readobjnam arg to be nonnull"
This reverts commit 10f29a9760.
2023-12-17 07:20:35 -05:00
nhmall
10f29a9760 allow readobjnam arg to be nonnull
Have it key on &do_random_str instead of NULL,
and modify makewish() in zap.c for the new protocol.
2023-12-16 19:30:34 -05:00
nhmall
3cfd579d37 init NhRect, before passing to selection_getbounds
selection_getbounds() has a check and early return.
Initialization will ensure a known state if that early return
were ever taken.

This is an alternative approach to pr #1163.
2023-12-13 00:21:32 -05:00
PatR
c8c963afe6 refine PR #1135 - encumbrance messages
When picking up multiple items (or looting multiple items) in one
operation, only show encumbrance for the first item that causes that
to change instead of complaining about non-zero encumbrance on every
item.  The very first item is treated as if it caused a change, so
you get "you have a little trouble lifting <obj>" even if you were
already burdened, same as before.

Only lightly tested.
2023-11-21 14:59:08 -08:00
PatR
18962b41d9 decl.h comment
Sync with decl.c.  dbridge.c never had anything to do with these
variables.  They were part of decl.c before they got collected into
struct g, then split among struct ga to gz.  (This only fixes up
the comment in gl; there may be more, possibly quite a few more.)

These might be better classified as /*dungeon.c*/ although they
weren't defined there.
2023-11-20 16:23:51 -08:00
nhmall
0a13d759a3 more bot() tinkering 2023-11-17 09:47:39 -05:00
nhmall
bb10f9a5d0 more menu header tweaking re options
<color>
off: map, menu items, menu headings, menu prompt/title all, everything should have color suppressed.

<curses guicolor>
on: map, menu items, menu headings, menu prompt/title can all feature color, as can
menu borders, menu-selector letters.
off: map, menu headings, menu prompt and menu items (menucolors on) can still feature color,
but all other non-map features such as menu borders, menu-selector
letters will not have color.

<menucolors>
on: menu items can have colors if they match one of the regex in config
file; menu headings, menu prompt can also be in color (based on menu_headings option).
off: menu items won't have colors, but menu headings, menu prompt still
will feature colors (based on menu_headings option); those are not impacted by turning
off menucolors.
2023-11-16 13:41:07 -05:00
nhmall
76d328d86a gi.invalid_obj -> hands_obj 2023-11-11 19:49:38 -05:00
nhmall
314a2a9489 use gi.invalid_obj instead of cg.zeroobj
cg.zeroobj was originally added (under its previous unprefixed name)
for providing a one-line way to zero out the fields of a struct obj.

    struct obj tempobj;
    tempobj = cg.zeroobj;

    initfn(struct obj *otmp)
    {
        if (otmp)
            *otmp = cg.zeroobj;
    }

More recently, the address of cg.zeroobj began to be used as a return
flag to indicate some things, but the 'const struct obj zeroobj' wasn't
an ideal fit for the purpose and required a number of casts, including
casting away const.

Provide a better fitting variable (gi.invalid_obj) and eliminate a
number of casts.
2023-11-10 11:07:49 -05:00
Michael Meyer
674b8c6b07 Add additional sink potion #dipping effects
Also put "Nothing seems to happen." into c_common_strings, since it's
used all over several files.
2023-11-09 16:41:05 -08:00
PatR
04d6789c98 report ice's thaw state
Classify nearby ice as "solid" (no melt timer), "sturdy" (more than
1000 turns left), "steady" (101 to 1000 turns left), "unsteady" (51
to 100 turns left), "thin" (15 to 50 turns left), or "slushy" (1 to
14 turns left, matching walking on ice with the Warning attribute).
[I'm not thrilled with "steady" and particularly "unsteady".]

I was originally going to do this just for probing downward, but ended
up also doing it for look-here and getpos's autodescribe.  It nearly
got out of hand and touched more files than anticipated.

'mention_decor' ought to treat moving from ice firmer than thin to
thin or slushy, from thin to slushy, from slushy to any other, and
from thin to firmer as if moving onto different terrain but I haven't
attempted to tackle that.

The melt timer could work more like a candle's burn timer, triggering
at intermediate stages and resetting itself, so that ice which changes
to a weaker state under the hero could be reported to the player.  But
this doesn't implement that.
2023-10-25 13:26:03 -07:00
PatR
284452796c redo tty resizing
Rest of 'not PR #1102'.  Resizing the terminal while getpos was in
operation recalculated the map from scratch instead of redrawing what
the core considers to already be shown.  And it was always operating
while an asynchronous signal was excuting which could potentially
clobber whatever was running at the time the signal arrived.

This uses same redrawing as the prior '^R during getpos()' fix.  It
also only performs the resize while tty_nhgetch() is waiting for
input.  If that is the situation at the time that the signal arrives
then it will resize immediately (while in the asynchronous signal
handler); if not, it will set a flag and tty_nhgetch() will do the
resize the next time it gets called.

This builds with TTY_PERM_INVENT enabled and doesn't seem to be any
worse than before, but there are bugs with that.  The only way I could
get perminv to appear was to save and restore, then perm_invent was
honored for both RC file and mO command.  And once I managed to get it
to display, moving an item from a lower case slot to slot 'A', made
that item vanish; nothing appeared in the invent's right hand panel.

Both of those misbehaviors already happen prior to this commit.  I
also saw an abort+panictrace if I resized while at the "Dump core?"
prompt when running the pre-commit code and didn't see that with the
post-commit code (although the prompt wasn't shown so I couldn't tell
that it was waiting for an answer).  The abort probably sounds scarier
than it warrants; I suspect that the pre-commit code just treated the
resize as answering 'y' for some reason, possibly a stale value in the
variable it uses.
2023-10-12 18:45:14 -07:00
Pasi Kallinen
e407af4477 Allow defining random-teleport exclusion zones in lua
Adds a new lua command

  des.exclusion({ type = "teleport", region = { x1,y1, x2,y2 } });

which allows defining "exclusion zones" in the level, areas where
random teleports (or falling into the level) will never place the hero.
Does not prevent targeted teleportation into the area.

Breaks saves and bones.
2023-08-24 18:38:39 +03:00
PatR
60c1956850 revamp 'special' combat
This is a re-creation of a project that was lost years ago while not
quite finished.  The old version included some instrumentation to
measure how many hits it takes to kill things during actual play; that
wasn't ready for prime time and this hasn't attempted to redo it.

Changes:
1) improves martial arts and bare-handed combat:  they now have a
   chance to hit twice when skill is better than 'basic'; 20% chance
   for second hit at skilled, 40% at expert, 60% at master, and 80% at
   grandmaster; when attacking more than once, strength bonus is
   handled as in #2;
2) nerfs two-weapon combat a bit:  hitting twice uses only 3/4 strength
   bonus on each hit, but when both attacks hit that's 3/2 bonus from
   strength which is still more than you get for one hit at a time;
3) beefs up two-handed weapons:  hitting via melee with a two-handed
   weapon uses 3/2 of stength bonus to reflect the increased influence
   of strength; isn't done for applied polearms though.

The reduction in strength bonus for two-weapon has far less impact
than it might sound, due to rounding up with the low values involved.
| full   3/4
|  +1 -> +1
|  +2 -> +2
|  +3 -> +2
|  +4 -> +3
|  +5 -> +4
|  +6 -> +5
The small reduction also doesn't matter if/when current hit happens to
deal a killing blow anyway.

Rings of increase damage apply at full value to every hit, same as
before.

When hitting bare-handed (#1 without gloves), a silver ring on either
hand continues to give a damage bonus against silver haters when you
make an ordinary single attack.  However if you attack twice, a silver
ring only applies on the first hit when it is worn on the right hand
and only applies on the second hit when worn on the left hand.  (Two
hits with a silver ring on each hand will give silver bonus for both.)

We might conceivably need to add support for a count prefix of 1 to
let player explicitly avoid a second bare-handed/martial-arts hit
attempt (similar to how throw and fire accept a count to limit missile
volley amount).

Kicking has been ignored.
2023-07-30 14:08:30 -07:00
PatR
bbba8b82d2 fix issue #1062 - monster hiding messages
Reported by Umbire:  if a statue of a hider-under was activated by
a statue trap, it would hide underneath its own statue.  Also, the
hero saw a snake hide under unseen submerged kelp.

Both of those things were exposed by new "you see <monster> hide"
message rather than caused by it.  It also led to the [re-]discovery
that an existing monster hiding under a statue that was a not-yet-
triggered trap prevented the trap from producing a monster.

This redoes yesterday's can't-hide-under-statue change:  hiders can
hide under statues again, but they can't hide under anything at trap
locations.  [Pits containing one or more objects are an exception,
although it seems silly that a hero is prevented from falling into
one by the presence of a tiny creepy-crawly hiding under a ring or
dart in there.]  So, hider-underers won't be able to interfere with
statue traps by being present at the trap location.  [Trappers and
lurkers-above probably need a similar restriction; I didn't look.
They avoid trap spots rather than get lured to such by objects.]

It also prevents newly created hider-underers from becoming hidden
as part of the their creation (except when that creation is part
of level creation) whether their creation uses up an object (statue
activation, egg hatching) or there are simply other items present.
That will prevent statue of a hider producing a monster that hides
under the activated statue (which was happening due to the sequence
create monster, transfer any statue contents to monster inventory,
destroy statue).

The can't-hide-under-statues code has been repurposed to prevent
hiding under gold pieces unless there are at least 10 (arbitrary
threshold) of those or they're in a pile with some other object(s).

Sea monsters hide in water regardless of the presence of objects.
Prevent other swimmers from hiding under objects at water locations.
Such creatures don't have gills and shouldn't be able to stay
submerged in hiding for an arbitrary length of time.  [No exception
is made for non-breathers.  The overlap between swimmers and hider-
underers is limited to small snakes, even though it is feasible for
a creature wearing an amulet of magical breathing to polymorph into
one.  Heros don't spend enough time underwater to worry about snakes
hiding under kelp or thrown junk.]

Lastly, alter the "suddenly, you notice a <monster>" message if
monster-vs-monster activity causes one you've just seen going into
hiding comes back out again without any intervening messages.  [I'm
not sure whether something similar is needed for the "Wait.  There's
something there" message in the you-vs-monster case.]

Fixes #1062
2023-06-16 21:19:43 -07:00
PatR
1bd966f826 fix issue #1061 - dipping container into water
Issue reported by loggersviii:  dipping a container into an uncursed
potion of water mentions water getting into the container.  That
happens even when that type of potion hasn't been discovered yet.

Make POT_WATER become discovered if this occurs.  Doesn't apply when
hallucinating where a random liquid is mentioned instead of water.

Fixes #1061
2023-06-15 02:29:51 -07:00
PatR
fb0509a6b3 fix #3841 - steed and engulfer on same map spot
Reported five months ago, a save was performed while a mounted hero
was engulfed.  Restore issued a warning about the engulfer being
placed on top of the steed (who shouldn't have been on the map).

The report arrived at about the same time as engulfing a riding
hero was changed to force a dismount instead of engulfing both hero
and steed so nothing further was done about it.  This changes
restore to not put a steed on the map and then take it off again.
It also attempts to simplify usteed and ustuck handling during save
and restore.

Testing so far indicates that things are still working correctly.
Keep makeplural(body_part(FINGER)) crossed.

Existing save and bones files are invalidated.
2023-06-14 00:04:21 -07:00
PatR
ca02bc4898 fix #K3917 - fuzzer stuck in endless lifesave loop
Life-saving from being burned up in lava attempts to teleport the
hero to safely.  If that fails, hero immediately burns up again.
For fuzz testing, that results in an infinite loop.

While implementing a fix (in done(), not just lava-specific), I
noticed that hangup while running interactively in explore or
wizard mode could be subject to similar effect.

For the fuzzer, if hero dies 15 times without advancing the move
count (not 'moves', the turn count), don't life-save again.  With
hangup, don't prompt for "Die?" more than once.

Normal interactive declining to die still works.  The more exotic
situations aren't tested.
2023-05-06 16:51:59 -07:00
Pasi Kallinen
0ac9309e1e Simple options menu shows help for each entry 2023-04-17 15:47:50 +03:00
nhmall
2185d325c4 header file changes hack.h, decl.h/.c, system.h, wintty.h
- Move secondary preprocessor defines down further in config.h
so that they can be overridden via [platform]conf.h which is
included from global.h, specifically:
    LIVELOGFILE when LIVELOG is defined
    DUMPLOG_FILE when DUMPLOG is defined

- Minimize platform-specific, or compiler-specific code in hack.h and decl.h.

- reorganize src/decl.c to align with include/decl.h.

- a new header file cstd.h added, containing calls to C99
standard header files.

- hack.h, decl.h, and decl.c have been cleaned up and had code
moved so that things line up as follows:

     hack.h     defines values that are available to all
                NetHack source files, contains enums for use in all
                NetHack source files, and contains a number of
                struct definitions for use in all NetHack source files.
                It does not contain variable declarations or variable
                definitions.

     decl.h     contains the extern declarations for variables that
                are defined in decl.c. These variables are global and
                available to all NetHack source files. The location of
                the variables within decl.h was random, so give it some
                order for now.

     decl.c     contains the definition of the variables declared in
                decl.h, and initializes them where appropriate. The
                variable definitions are laid out in much the
                same order as their declarations in decl.h.

- wintty.h: There were some varying terminal-related prototypes in
system.h, and that was the only thing left that demanded that
system.h be included. Those have been replaced by an #include
<term.h> in include/wintty.h to get the more current (and hopefully
more correct) prototypes, rather than hardcoding them in NetHack
sources.

For edge-case platform compatiblity, there is no #include <term.h>
if the build defines NO_TERMCAP_HEADERS. In that case one set of
hardcoded prototypes is still used in include/wintty.h.

The added #include "term.h" is also bypassed for NO_TERMS builds (builds
that don't link to terminfo/termcap at all, but still present a tty
interface using platform or window-port specific functions to fulfill
the same role as that of terminfo/termcap).

- some scattered, unnecessary #include "integer.h" were removed from
various files, since that's always included in current NetHack-3.7
sources, either directly from config.h or indirectly from #include
"hack.h".

- system.h references removed.

- new cstd.h added; the #include "system.h" references in Makefiles
and project files (Xcode, visual studio), were replaced
with #include "cstd.h" references. A "make depends" is probably
warranted.

Also:

 - Use of <term.h>, which defines clear_screen() as a macro, conflicts
with an actual function with that name in win/tty/termcap.c. The most
straight-forward course of action was to rename the NetHack function,
and change the references to it, from clear_screen() to
term_clear_screen(), so that was done.
2023-04-05 11:49:09 -04:00
nhmall
de79240dea some comment spelling fixes 2023-03-16 22:27:01 -04:00
PatR
3a30e434d8 "<mon> hits [again]"
Add "again" to the hit message when an attack sequence has
consecutive attacks of same type and they hit.  A {bite, claw, claw}
sequence won't give that for first claw attack regardless of whether
the bite hits but will give it for the second claw attack when both
of the claw attacks hit.

The message sequence
|The fire ant bites!  The fire ant bites!  You're on fire!
or |The fire ant bites!  The fire ant bites!  You avoid harm.
when the first bite was for physical damage and the second was
for fire damage seemed a little confusing.

This changes that to be
|The fire ant bites!  The fire ant bites again!  You're on fire!
or |The fire ant bites!  The fire ant bites again!  You avoid harm.
It still isn't crystal clear that both bites are from a single
attack and that the second bite is for different type of damage
but I think it's an improvement.
2023-03-16 01:54:29 -07:00
PatR
4021a63bcf wand/spell/breath killer reason
Extend "killed by the touch of death inflicted by <monster>" to buzz().
"Killed by a bolt of cold" becomes "killed by a bolt of cold zapped by
<monster>" or "killed by a blast of cold" becomes "killed by a blast
of cold exhaled by <monster>" and so forth.

More work than expected; the zap code isn't passed enough context.

BZ_M_WAND() was producing the wrong value for wands zapped by monsters.
2023-03-07 02:47:42 -08:00
Pasi Kallinen
fc7a32b86e Tutorial level
Add a tutorial level to teach commands to new players.
Very much a WIP.

Breaks save and bones compat.
2023-03-01 14:00:29 +02:00
nhmall
fbd9a7bae8 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.
2023-02-07 00:44:36 -05:00
nhmall
ea4a81901d add an interface for sound libraries
Groundwork for a more versatile interface for using
sound libraries. A lot of sound libraries work across
multiple platforms.

The current NetHack sound stuff is quite limited.

Binaries can have a variety of window ports linked into
them, and it makes sense to have something similar for
sound.

This tries to set things up in a more soundlib-centric way,
rather than inserting things in a platform-centric way.

It establishes a new top-level directory sound (akin to win
for the window interface routines, or "window-port") where
sound-related additions and sndprocs and support files can be
added and used across platforms.

The default interface is nosound and the 'nosound' interface
is in src/sounds.c

The interface for 'windsound', which contains the same minimal
USER_SOUNDS support using built-in routines that has been in the
windows port for a long time is added to
sound/windsound/windsound.c.

For now, the sound interface support for 'qtsound' has been added
to the existing Qt files win/Qt/qt_bind.h and win/Qt/qt_bind.cpp,
and a note has been placed in sound/qtsound/README.md to avoid
confusion.

New header file added: include/sndprocs.h.
2023-01-19 18:51:42 -05:00
PatR
85c908cb03 displaying generic objects
Add 17 fake objects to objects[], one for each object class.  All
specific color as gray.  They're grouped at the start--actually near
the start since "strange object" is still objects[0]--rather than
being among the objects for each class.  init_object() knows to start
at [MAXOCLASSES] instead of [0]; other code that loops through every
object might need adjusting.

For potions, non-stone gems, and non-novel/non-Book_of_the_Dead
spellbooks that don't have obj->dknown set, display the corresponding
generic object rather the object itself.  Fixes the longstanding bug
of seeing color for not-yet-seen objects whose primary distinguishing
characteristic is their color.  Walking next to a generic object
while able to see its spot will set dknown and redraw as specific.
It's slightly disconcerting to have objects change as you reach them;
I hope it's just a matter of becoming used to that.  (If there is any
code still changing the hero's location manually instead of using
u_on_newpos(), it should be changed to use that routine.)

Most of the new tiles are just a big rendering of punctuation
characters.  The potion, gem, and spellbook ones could be cloned from
a specific object in their class and then have the color removed.  I
started out that way but wasn't happy with the result.  I'm not
artisticly inclined; hopefully someone else will do better.  Each of
them is preceded by a comment beginning with "#_"; the underscore
isn't required, just being used to make the comments stand out a bit.

Invalidates existing save and bones files.
2023-01-10 14:33:21 -08:00
nhmall
2fc0d25d45 introduce support for coloring the frame behind a map location
Also includes support by paxed for polearm targeting using the
frame color.

Also renames USE_TILES to TILES_IN_GLYPHMAP which is a more
accurate description.

Not all window interfaces have full support for the color framing
of the background square yet.

MS-DOS needs further work (to bring it to both VESA and VGA, with
and without tiles.

Windows GUI is missing support.

X11 and Qt have been started, but may require further refinement.
2023-01-01 19:55:02 -05:00
PatR
ddd358aa03 miscellaneous objects[] macros
Replace FIRST_GEM and LAST_GEM with FIRST_REAL_GEM, LAST_REAL_GEM,
FIRST_GLASS_GEM, and LAST_GLASS_GEM and define those along with
objects[] rather than separately.  Do the latter for FIRST_AMULET
and LAST_AMULET too.  Also new FIRST_SPELL and LAST_SPELL used to
compute MAXSPELLS.  (That value looks wrong to me, but this defines
it with the same value as before.  If it gets fixed, EDITLEVEL will
need to be incremented.)

This started as just proof of concept that extra information could
be collected as objects[] gets initialized at compile time.
2022-12-28 01:50:24 -08:00
PatR
249e431e46 new 'sortvanquished' option
Allow the preferred sort order for the vanquished monsters list to
be specified in the run-time config file
|OPTIONS=sortvanquished:X
where X is t, d, a, c, n, or z.  It can also be set to 'A' or 'C'
but those aren't documented and aren't offered as choices when
setting the value interactively, which can be done via 'm O' or by
using 'm #vanquished'.

Guidebook.mn has been updated but Guidebook.tex is lagging again.
2022-12-26 14:56:12 -08:00
PatR
91e2ab13b2 last? role/race/&c option values update
Keep track of how a role|race|gender|alignment option got its value
so that role:!Tourist in .nethackrc and role:!Priest in NETHACKOPTIONS
yield 'role:!Priest' rather than merging into 'role:!Priest !Tourist'.
It also doesn't write the value into new config file for #saveoptions
if that value comes from environment or command line (not applicable
since the command line arguments for role,&c don't go through options
handling).  Also, the old config file value takes precedence over
the current game's value file so that 'role:random' doesn't become
'role:Healer' or such in a new config after the random value gets
picked for play.

This only tracks the role, race, gender, and alignment options but the
concept could be extended to all options.  The data would need to be
saved and restored if values set interactively need to be retained in
restore sessions (doesn't apply to role,&c since those don't change
during play).
2022-12-22 15:07:33 -08:00
PatR
7096c68492 more interactive role selection
This ended up combining several unrelated changes.

Add missing 'fixes' entry for curses-specific item in New Features.

When answering "Shall I pick ... for you? [ynaq]", accept \m as well
as \n and space for choosing the default of 'y', same as normal
ynaq() would.  Also add '*' to '@' as not-shown potential answers;
they force 'random'.

When tty tore down any of the menus, things were reasonable if they
were short enough for corner windows, but tall ones that switch to
full screen weren't fully erased.  The parts of those outside of the
map window stayed behind when the tall menu was closed and cleared.
Mainly affects picking the "~ - reset filtering" choice but also
affected the role menu on 24 line tty screens.  (Didn't affect curses
because it tracks and refreshes its base window when some overlaying
window goes away.)

The role menu used 25 lines so required a second page for the case
of a 24 line screen on tty.  Dealing with that is a bit ugly but it
wasn't an issue when this form of role selection was tty-only (because
the info about choices made so far was displayed on the base window
rather than in an extra menu line back then) so I added a hack for it.
If the role menu will take one more line than the screen height, the
separator between 'random' (below 'Wizard') and 'pick race first' gets
squeezed out.  If the menu needs two more lines (doesn't happen now,
except by changing screen size to 23 lines for testing), a second line
gets squeezed out.  (Not attempted for curses because it wouldn't
help.  'windowborders' and one or two extra separators it adds make
menus taller.  I doubt if many players use curses on 24-line screens
but if they do, they'll be using something new rather than going from
something that used to fit on one page with 3.6.x.)
2022-12-13 15:59:05 -08:00
PatR
4a965bbd83 boulder pushing feedback
Redo the details about giving or suppressing "with great effort you
push the boulder".  It works the same except that if push a different
boulder than previously, you'll get a new message.  If you do it
while riding, you have the same lack-of-message for successive pushes
instead of getting a message every turn.

Don't exercise strength when pushing a boulder if poly'd into a giant.
2022-12-07 16:45:35 -08:00
nhmall
02a48aa8cf 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
     ^ ^
2022-11-29 21:53:21 -05:00
nhmall
d80e8d9569 adjust 4 line lengths from previous commit 2022-11-03 15:50:32 -04:00
nhmall
fac75f5ae4 purge more E for extern 2022-11-03 15:42:24 -04:00
PatR
1572877429 build fix for NODUMPENUMS and more issue #916
I made more things in dump_enums() static and/or const.  In the
process I discovered both compile problems for NODUMPENUMS and when
fixed, link problems for NODUMPENUMS+ENHANCED_SYMBOLS.

The uft8map.c portion has no changes, just reformatting.
2022-10-31 15:43:14 -07:00
nhmall
88f6df2d8b some tabs to spaces
cd src
    grep -P -n '\t' *.c | grep -v "1:"
    cd ../include
    grep -P -n '\t' *.h | grep -v "1:"
    cd ..

side note: win/Qt/*.cpp are full of tabs
2022-10-26 14:21:23 -04:00
Michael Meyer
c78e7af013 Digestion attack can grant hero intrinsics
Monster purple worms can now gain intrinsics from swallowing foes whole,
so maybe the hero should be able to do so too.  Intrinsics aren't
granted immediately upon swallowing (that would probably have been
easier), but only once a corpse is created and then entirely digested.

I'm not sure if this is too powerful and was being avoided deliberately
for that reason, since it includes potential level gain from wraith
corpses in addition to other intrinsics.  That's consistent with monster
purple worms but may be a bit too much in the hands of the hero, though
it is limited by needing the corpse creation roll to succeed.
2022-10-08 16:06:50 -07:00
Pasi Kallinen
a733004912 Remove the per dungeon level door limit
Number of doors in a room-and-corridor style level was fixed
at 120; now the doors-array is dynamically allocated when needed.

Breaks saves and bones.
2022-09-09 19:40:45 +03:00
PatR
d4f0450afe fix the tty message spacing anomaly for messages \
delivered across level change checkpointing

Reported by entrez.  Simplest test case:  give level 1 a short
annotatation, level teleport to level 2, and level teleport back to
level 1.  The message window will show

|You materialize on another level.  You remember this level as <note>.

but ^P message history will show

|You materialize on another level.
|  You remember this level as <note>.

Spaces inserted to separate two messages that fit together on the
top line become part of the second message when saving a checkpoint
during level change flushes the top line into message history.

Change insurance checkpointing to record the full message history
without flushing the current top line so that toggling 'checkpoint'
doesn't affect what shows up on the screen or in message recall.
2022-08-30 15:01:49 -07:00
PatR
11c8d5cd5e Unix: command line --windowtype:foo fix
initoptions(), including initoptions_finish(), was running to
completion with the default window system before windowtype from the
command was parsed and activated.  When the default window system
is tty without MS-DOS the map type gets set to ascii; command line
--windowtype:X11 doesn't switch it back to the X11 default of tiled.

So,
| NETHACKOPTIONS=windowtype:X11 nethack
ran nethack in tiles mode but
| nethack --windowtype:X11
ran it in text mode (assuming .nethackrc left tiles vs text with the
default setting).

I think this fix is quite iffy but it seems to work as intended....
It reclassifies '--windowtype' as an "early option" in unixmain.c,
and the options.c code ultimately processes it twice.
2022-08-28 00:09:50 -07:00
Pasi Kallinen
5e9ed7a290 Some selection optimizations
- Add bounds, so that we don't process any locations outside
  as those locations are known to be unset
- The bounds are only recalculated if needed
- Replace instances of selection_not where we actually want
  a new selection with all locations set
2022-08-26 12:43:40 +03:00
Pasi Kallinen
c42e73fd9c Allow binding mouse buttons
Instead of hardcoding mouse button actions, allow the user to
bind mouse buttons to extended commands.  For example the new
defaults are:

BIND=mouse1:therecmdmenu
BIND=mouse2:clicklook

Currently a bit rudimentary; the defaults should be OK, but
documentation is bit lacking, and in-game binding and option
saving are missing.

Allowed commands to bind are "nothing", "therecmdmenu", "clicklook",
and "mouseaction". Clicklook replaces the "clicklook" boolean option,
and mouseaction does what mouse 1 button used to do - a context sensitive
action.
2022-08-23 23:27:21 +03:00
Pasi Kallinen
d91915dba3 Migration-safe monster movement iteration
The monster knockback could mess with the monster linked list while
the code was going through it for monster movements. (For example,
a monster knocked back another into a level teleport trap)

Add iter_mons_safe, which first grabs all the monster pointers in
the list into an array, and goes over that array instead of relying
on the "next monster" pointer. This is possible because dead monsters
are not removed from the linked list until after all the monsters
have moved.

Testing is very minimal, and I'm not sure the vault guard check
for migration is correct - it should probably check for more states?

Also the iterator could be improved by not continually allocating
and freeing the monster pointer array.
2022-08-10 11:04:04 +03:00