Commit Graph

3256 Commits

Author SHA1 Message Date
nhmall
2f167a4672 allow clean build without using -Wno-missing-field-initializers 2023-11-20 14:25:09 -05:00
PatR
e723a4aafa rename engraving symbols and tiles
"engraved part of a room" and "engraved part of a corridor" sound
silly.  Change to "engraving in a room" and "engraving in a corridor".
Still displayed to player as just "engraving".

An orhpaned wintype.h tweak got dragged in.  Renumbers to_core_flags.
2023-11-20 00:47:12 -08:00
nhmall
d7ed474fa7 2nd follow-up to alternative fix for menu search (':') 2023-11-17 14:13:58 -05:00
nhmall
0a13d759a3 more bot() tinkering 2023-11-17 09:47:39 -05:00
nhmall
8d1001842d alternative fix for menu search (':')
This avoids clearing core context variables within a window port.
2023-11-17 08:37:54 -05:00
Michael Meyer
f5a22ff5f8 Print current level annotation when restoring
Sometimes I annotate a level with a note like "watch out, chameleon
below", which is useful to remind myself of some danger or thing to
remember when returning to the level -- but if saving and restoring on
the level itself there's no reminder of that annotation.  If you restore
on a level with an annotation, print it as part of the "welcome back"
message.
2023-11-16 23:15:04 -08: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
86067dcffd use ctrl_nhwindow() for menu prompt style
This implements the mechanics to use the ctrl_nhwindow() interface
capability to pass down a setting change from the core to the active
window port, without resorting to accessing a core global variable
from within the window port, and without altering the interface..

The passed setting is honored in the tty and curses window ports.

X11 and mswin receive and store the values, but no implementation
to change the menu prompt style is there yet.

Qt does not store the values or have an implementation.

The setting change is done in allmain.c immediately after
creating the WIN_INVEN window.
2023-11-16 00:10:06 -05:00
PatR
fc52f0ef42 'menu_headings' option
If the value is "no color&none" report it as "no-color&none" in 'm O'
and for #saveoptions.

Allow "OPTIONS=menu_headings" without any color or attribute value to
mean "no-color&inverse" as it once did before the player could choose
which attribute or color was supported, and matching the default used
when 'menu_headings' hasn't been specified at all.

Accept "OPTIONS=!menu_headings", meaning "no-color&none".

Explicitly reject "OPTIONS=!menu_headings:anything".  It was rejecting
that due to blanket rejection of negated option, but reporting "can't
both have a value and be negated" whether there was any value present
or not.

For preselected menu entries when interactively choosing a new value
via the submenu of 'm O', use the current color and attribute rather
than NO_COLOR and ATR_NONE.
2023-11-14 21:33:09 -08:00
Pasi Kallinen
830168f26e Update comment 2023-11-15 07:26:21 +02:00
nhmall
b4bb3b92a2 replace E with extern in the last file like that 2023-11-13 15:00:44 -05:00
nhmall
5b2ec5d6ee minor optomization - explicity avoid menucolors 2023-11-13 14:00:02 -05:00
Pasi Kallinen
d2ca1794df Move other add_menu routines to windows.c 2023-11-13 20:12:47 +02:00
nhmall
4b79baa55b add_menu follow-up, part 2 of interface adjustment
Remove menu_color support from the window port side of the interface.
The window port just has to honor the color parameter that was added
to the add_menu() interface definition in June 2022 commit
2770223d10, and let the core-side of
the interface handle things.

To that end, this does the following:

Removes the #define of add_menu() from include/winprocs.h and add a
real core-side add_menu() function to windows.c which acts as a
trampoline to the window port win_add_menu() function, while providing
a single location to adjust the parameters passed to the window port
function. get_menu_coloring() is now called in there.

Moves get_menu_coloring() from options.c into windows.c and makes it
static.

Removes all the calls to get_menu_coloring() from the tty, Qt, X11,
curses, and win32 interfaces and adjusts their code to simply honor
the color parameter in add_menu, similar to what the menu_headings
change from earlier today did.
2023-11-13 12:56:38 -05:00
Pasi Kallinen
dd5ca5b058 Change menu_headings to accept color and attribute
Instead of just accepting an attribute, it's now possible to
use a color, or both color and attribute, for example:

OPTIONS=menu_headings:inverse
OPTIONS=menu_headings:red
OPTIONS=menu_headings:red&underline

Default is still just inverse.
This lets the player change the menu heading color without
needing to use menu colors for them.

Also makes it so the core uses NO_COLOR instead of 0, for all
the menu lines which don't have any prefedefined color.

Tested for tty, curses, x11, qt, and win32
2023-11-13 07:33:56 +02:00
nhmall
76d328d86a gi.invalid_obj -> hands_obj 2023-11-11 19:49:38 -05:00
Michael Meyer
d42564bacd Better align drop_throw with hero ammo breakage
There is a comment above the function indicating that it should be
aligned with hero ammo breakage, but this wasn't the case.  One big
difference is that any monster-thrown or -shot object would be deleted
unconditionally if it hit another monster trapped in a pit.  I don't
know why that was in there, but it's not present in hero ammo breakage
chances, and it meant that a monster could sling the Mines luckstone at
the hero, hit a monster in the pit, and permanently lock the hero out of
getting the luckstone (as just happened to a player during the current
tournament).  This pulls the hero breakage rules out into their own
function and uses that for monster breakage as well, to make sure they
are aligned.  I also refactored drop_throw a bit to reduce the number of
separate variables tracking whether the object was deleted (was create,
objgone, and retvalu), and changed its (and ohitmon's) type to boolean.
2023-11-11 01:17:54 -08:00
PatR
b03e5c1ad7 ^G of unseen monster
I used ^G to create a monster and specified "invisible owlbear".  I
then got "An owlbear appears next to you."  Except it didn't; it was
invisible and I lacked see-invisible.  I imagine that newsym() was
called for the new-yet-invisible monster, but that remained buffered
and was gone overridden by the time pending map update got flushed
at some point after the monster was made invisible.

Add a new makemon() flag to turn a newly created monster invisible
during its creation, before "monster appears" message is delivered.
Since that message will now be suppressed in this situation, use the
cursor-flash hack that indicates where the new, unseen monster got
placed.  Creating "1000 invisible <mon>" is something you probably
won't do twice.
2023-11-10 15:43:02 -08:00
Michael Meyer
de2c3f033a Make WT_foo defines unsigned
These are meant to be 'cwt' values and directly comparable to a
particular pm->cwt, which is an unsigned short.  My concern here was
signed/unsigned comparison warnings like the one fixed in 1538b40, but
I'm not sure if this is actually necessary: there is already a
comparison between cwt and WT_HUMAN in max_mon_load() which apparently
doesn't produce the warning...
2023-11-10 10:04:06 -08: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
ca56b1d161 Make c_vision_clears const char *const
Everything else in c_commmon_strings had this qualifier, but
c_vision_clears was just const char *.  There doesn't seem to be any
reason for that so change it to be consistent with the others.
2023-11-09 16:41:06 -08: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
Michael Meyer
3fac63749a Add basic sink #dipping effects
This is largely taken from xNetHack with a few minor changes.  Dipping a
potion into a sink can help with item identification by producing the
potionbreathe effect (or a sink-specific effect, for a couple potions).
Dipping other items will just run water over them.  I also added the
capability to wash your hands at a sink.
2023-11-09 16:41:05 -08:00
Michael Meyer
5af1fad398 Enable hero to wash hands in fountains and pools
Dipping hands (with '-') or currently-worn gloves in a fountain or pool
will cause the hero to wash her hands, washing away any oil and clearing
the Glib intrinsic timeout.  This does mean bare hands can be used to
fish for fountain effects, without having to pick up a stray arrow and
carry it around as a dipping item, but having your hands be the only
thing that does not activate those effects felt weird.  If that would be
too unbalancing this could be scrapped.
2023-11-09 16:41:04 -08:00
Michael Meyer
a69ff06e85 Make mstate flag checks more mutually consistent
Various places checking for whether a monster was on the map based on
mstate flags were inconsistent about which ones they checked (and then
place_monster() was additionally inconsistent with all of them about
which bits were cleared when placing a monster onto the map).  I think
some places were also more convoluted than is now necessary because they
date back to mstate being an alias for mspare1, which it shared with
migflags before those became two separate dedicated fields (MSTATE_MASK
also dates back to this and is no longer used, so I removed it).

I tried to go through all the MON_foo mstate bits, understand when/why
they are set, and make the various functions I noticed more consistent
(with each other, and with my understanding of how the bits work) about
how they are treated.  I don't know for a fact that I understood
everything right -- some diagnostic bits that aren't used for much of
anything, like MON_OBLITERATE, had me mystified until I read the 5ee78c5
commit message -- but this patch hasn't caused any new problems (sanity
check or otherwise) with the fuzzer in my testing so far.  All the same,
it could probably use review by someone who has a good sense of what the
mstate bits mean.
2023-11-08 10:41:40 -08:00
Michael Meyer
a1b1f3b250 Try to unify "back on solid ground" messaging
Put everything through a single function that can handle all the
complicated parts of using the correct proposition for different terrain
types, and will not just call things "solid ground" indiscriminately.
This got complicated but I'm not sure if it's possible to do it much
simpler while still using the distinct names for each type of terrain
(unless you are OK with the sentences sounding sort of wonky).
2023-11-07 16:13:55 -08:00
Michael Meyer
b993edca74 Follow-ups on EXPLORERS authorization
I realized that failed explore-mode authorization on a special-mode
saved game cannot downgrade the game mode further down to a normal game,
because this would dump the player back into a state where she has
completed some part of the game in explore mode but is eligible for the
topten list.  This is even more true when the game was formerly a
wizard-mode game.  Unforunately, that was the state my previous commits
left the game in.

Instead, if restoring an explore-mode or wizard-mode savegame, and the
player is authorized via sysconf for neither of those modes, fail
restoration entirely and start a new game instead.  That's sort of
clunky and there could probably be more explanation provided, but it
should be an exceedingly rare occurance and I'm not sure what
alternative exists that would still honor the EXPLORERS and WIZARDS
restrictions.  This shouldn't affect the way they default 'down a mode'
in other circumstances, i.e. the overwhelming majority of situations in
which EXPLORERS authorization is needed/checked.

For the same reason, I realized that the player can't be prompted
whether or not to enter explore mode, if being downgraded from a
no-longer-authorized wizmode save while explore mode is authorized.  The
change from wizard mode to explore mode must be mandatory.  I have also
switched that up so that it will force the change -- unfortunately, this
has the side effect of allowing the preservation of the save, but it's
more important to make sure a wizard mode game doesn't get reverted to
normal mode.  They won't be able to load the save into wizard mode
anyway.
2023-11-07 15:38:10 -08:00
Michael Meyer
85b727c92c Apply sysconf EXPLORERS restriction on startup
The sysconf EXPLORERS list restricting access to explore mode was being
evaluated and used when a player used the #exploremode command in-game,
or when specifying -X or OPTIONS=playmode:explore on the command line
when resuming a normal game, but not when starting an entirely new game.
When SYSCF is avilable, check for authorization early, similar to debug
mode authorization, to restrict access to explore mode to EXPLORERS
under (hopefully) all circumstances.
2023-11-07 15:38:08 -08:00
Michael Meyer
98d2b0ecb3 Follow up on disturbing buried zombies
Change 852f8e4 by requiring a minimum impact before a buried zombie
nearby will be disturbed: light, but still excluding things like
scrolls, if it's a violent impact (dropped while levitating, thrown, or
kicked), and fairly heavy if the hero is just placing the item on the
ground normally.

Moving the call out of flooreffects meant it no longer applied to
pushing boulders around, so have moverock disturb nearby zombies.  I
additionally had wake_nearby do the same thing.

Finally, I renamed check_buried_zombies (which doesn't really reflect
what it does) to disturb_buried_zombies.
2023-11-05 21:51:45 -08:00
PatR
2ee7509945 replace getenv("TTYINV") with perminv_mode option
Add a new option 'perminv_mode' to augment perm_invent.  It handles
the same choices as the temporary TTYINV method:  show all items other
than gold, show full inventory including gold, or only show in-use
items (similar to the '*' command).

For tty, both the all-except-gold and full-inventory modes can add
the poorly named 'sparse' variation which populates unused slots in
its fixed grid with the inventory letter that would go in each.

For others, the default has been changed from full-inventory to
all-except-gold.  Note that gold is treated as part of 'all' or of
'in-use' if it is quivered because having the amount be shown on the
status line doesn't make that redundant.

Changing the default may mess up WinGUI if it assumes that perm_invent
is full inventory with gold.

Initially I was going to change perm_invent into a compound but this
leaves it as an on/off toggle and adds perminv_mode as a separate
option for how to show the inventory when the toggle is on.  It may
make sense to combine them since dual controls is a little confusing,
but right now setting perm_invent On when perminv_mode is 'none'
changes that to 'all' and changing perminv_mode away from 'none' when
perm_invent is Off toggles it to On.

Guidebook.mn has been updated but as usual Guidebook.tex is lagging.
2023-11-05 02:31:26 -08:00
Pasi Kallinen
a6051dae81 Simplify adding menu headings 2023-11-03 19:07:15 +02:00
Bernhard E. Reiter
733b41347a Doc: fix xpm scaling example in config.h
* Add conversion back to xpm in the example command, otherwise the error message is `Failed to load x11tiles: XpmFileInvalid`
2023-11-03 02:44:08 -07:00
Pasi Kallinen
852f8e4996 Dropping items disturbs buried zombies 2023-11-02 20:31:51 +02:00
PatR
c8a84acfa5 handle C++ vs enum arithmatic differently
The cast to (int) was much simpler but this seems better overall.
2023-10-31 15:04:14 -07:00
PatR
4ecc798d20 fix #4024 - C++ complaint about enum arithmatic
Not tested with a compiler that cares.  Still builds with Qt4 and an
older one.
2023-10-31 01:49:09 -07:00
PatR
6303141f1d fix #K4025 - #saveoptions vs cond_ options
Confusion between 'o_status_cond' and 'pfx_cond_'.  Still confusing
but I think now working as intended and expected.

If any cond_xyz option has been loaded from the RC file or changed via
'm O', #saveoptions still saves the full set rather than just the ones
that are different from their default value.
2023-10-31 01:19:20 -07:00
nhmall
a3f452bbe0 Verbose reversion follow-up 2023-10-29 21:02:47 -04:00
nhmall
6cbefc7c2d Revert "granular verbose message suppression mechanics"
This reverts commit be76727265.
2023-10-29 20:39:07 -04:00
nhmall
9bd9bbc57c Revert "granular verbose message suppression mechanics updated"
This reverts commit 95a39d0b71.
2023-10-29 20:29:11 -04:00
nhmall
67a695ac56 Revert "more Verbose"
This reverts commit 377be376fe.
2023-10-29 20:28:19 -04:00
Pasi Kallinen
16ed7e49c3 Separate level flags for premapped and sokoban 2023-10-29 12:35:32 +02:00
PatR
d7799279e4 reverse accidental config.h change
I thought these had been stashed so that I could use 'git commit -a'
but evidently I got careless.
2023-10-26 03:15:10 -07:00
PatR
4dc8429d9e thawing ice followup
Modifying an() [actually just_an()] to treat "<thickness> ice" and
"frozen <hallucinatory liquid>" as special cases which shouldn't be
prefixed with "a" or "an" affected using something like "shaved ice"
or "frozen yogurt" as named fruit.
 |a) shaved ice
 |b) frozen yogurt (weapon in hand)
now have article "a" preceding them:
 |a) a shaved ice
 |b) a frozen yogurt (weapon in hand)
However, the existing cases
 |c) iron bars
 |d) an iron bars (weapon in hand)
still get item 'c' wrong.  'd' is slightly odd but that's because the
fruit name is ambiguous as to whether it's singular or plural.
2023-10-26 01:28:56 -07: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
Pasi Kallinen
7bf3888118 Shopkeepers consider monster type for some items
Tins, eggs, and corpses will now cost different amounts
based on what intrinsics the monster type could give
2023-10-25 18:45:16 +03:00
nhmall
42348ac299 recent sound addition bit 2023-10-16 09:11:05 -04:00
PatR
9e65cd7d80 more not PR #1102 - reveal_terrain() args
From a comment w/ diff in the pull request by entrez, combine the
show-full-map flag (available in wizard mode and explore mode) with
the bitmask for map-only, map-and-traps, map-and-traps-and-objects
flags for #terrain mode (and getpos() help) instead of passing that
as a separate argument.  No change in behavior unless I messed up.
2023-10-13 18:17:08 -07:00
PatR
80b153638b refine #1106 - invent action: item lookup
Only show the '/' menu choice for context-sensitive inventory item
action if data.base look up for the item will find something.  Lack
of '/' is as informative as "you don't know anything about that".

Harder to implement than expected but seems to be working ok.

This also changes the menu for the '/' command, replacing cryptic /^
and /" with /t and /T so that listing near traps or all traps is more
like listing near|all objects|monsters.  I put caret and double-quote
in as group accelerators; double-quote works on tty, caret gets
intercepted as "menu first page" so doesn't.  I didn't check other
interfaces since supporting that doesn't seem to be worth the bother.

Also a little bit of reformatting.
2023-10-13 01:08:21 -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
PatR
f70f84aee7 not PR #1102 - map refresh during #terrain
This fixes the part of pull request #1102 by entrez dealing with the
map refresh side of things.  It was pulled out of a much larger patch
that also deals with terminal window resize for tty.

Using ^R when getpos() is in operation, whether actually picking a
position for something or browsing the map during #terrain or post
detection magic, it was reconstructing the known map and positioning
the cursor on the hero instead redrawing the selected terrain subset
or detected objects/monsters/whatever.  There's already a routine to
redraw the current view of the map without recalculating it, but it
wasn't being used for ^R during getpos operation.
2023-10-12 01:18:55 -07:00