Commit Graph

15796 Commits

Author SHA1 Message Date
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
PatR
069855eefc yet more #1112 - slippery hands vs sink
Fake object used for 'hands' has an address, so checking for a Null
pointer won't recognize it.
2023-11-10 09:38:40 -08:00
nhmall
27e727d7d7 another missed cast removal 2023-11-10 11:31:24 -05:00
nhmall
24b6f6a03e follow-up cast removal in eat.c 2023-11-10 11:28:08 -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
nhmall
17dd51d922 Merge branch 'discard-broken-wand' of https://github.com/argrath/NetHack into NetHack-3.7 2023-11-10 09:14:20 -05:00
nhmall
b63c2ecc2b Merge branch 'fix-options' of https://github.com/argrath/NetHack into NetHack-3.7 2023-11-10 09:13:45 -05:00
PatR
915da30c9d more PR #1112 - dipping in sinks
Suggestion from entrez:  If dipping something in a sink while hands
are slippery happens to cause that sink to break, only remind player
about still being Glib if the item was '-' or uarmg.

Redo one of the fixes entries:  dipping a potion into a sink does not
dilute it.  The potion is used up and gives a hint about what it does
so player might discover it.
2023-11-10 01:14:24 -08:00
SHIRAKATA Kentaro
3db06f4c6d split discarding broken wand into separate function 2023-11-10 16:46:06 +09:00
PatR
d0ade3b085 streamline PR #1124
Get rid of an extra 'if'.
2023-11-09 21:58:58 -08:00
PatR
5481657792 pull request #1124 - streamline dosacrifice()
Pull request from argrath.

Closes #1124
2023-11-09 21:50:02 -08:00
SHIRAKATA Kentaro
637db78cea streamline dosacrifice(): early return when offering other than corpse 2023-11-09 21:32:32 -08:00
PatR
394fa24666 refine PR #1112 - washing, dipping in sinks
If hero has slippery hands, include '-' among likely candidates for
item to #dip when dipping at a pool, fountain, or sink location.

When dipping an item (including hands), have a modest chance for the
sink to be destroyed--which turns it into a fountain--each time so
that it can't be used to blank scrolls an unlimited number of items.
(Pools can already be used for that, but you need to obtain water
walking ability or else drop most of your stuff and enter the water;
sinks weren't imposing any such requirements or risks.)
2023-11-09 18:22:06 -08:00
PatR
f86dbf13b5 fixes entry for PR #1112- wash hands, dip in sink
Pull request from entrez:  when at a fountain, pool, or sink location,
the #dip command will allow #dip to pick terrain and player to choose
pseudo-item '-' for hands.  Also allow dipping actual items in sinks.

Closes #1112
2023-11-09 16:46:36 -08: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
PatR
33034ebaba revise the two engraving tiles
With 16x16 tiles on X11 or Qt, I couldn't see the (dark blue?)
engraving marks on either the room engraving tile or the corridor one.
Change those marks to yellow so that the contrast with floor more.

The corrdidor engraving tile was based on the lit corridor tile.
Change that to be midway between the lit (centered solid dot) and
unlit corridor (centered hollow dot) tiles.  It no longer directly
matches either one but it also can't sometimes match the wrong one.
2023-11-09 13:52:19 -08:00
Pasi Kallinen
2e8adda028 Clouds cannot have engravings in them
... so delete the existing engraving if a cloud is put on the map.
2023-11-09 18:08:00 +02:00
SHIRAKATA Kentaro
eb03b1a6db remove unnecessary condition on parseoptions()
`opts` here is always non-null, otherwise it leads segv at earlier code.
2023-11-09 12:37:25 +09:00
PatR
e783c82b84 pull request #1116 - mon->mstate flags
Pull request from entrez:  the mstate field in struct mon defines many
bits but didn't use some of them consistently.

Initially they were intended to be examined via debugger, where being
inconsistent might lead to confusion but not have a negative impact on
gameplay.  However, some of them have morphed into affecting gameplay.

Closes #1116
2023-11-08 10:41:40 -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
SHIRAKATA Kentaro
7d007ea365 null-check argument bl before using it 2023-11-09 00:10:23 +09:00
PatR
bd2f8b4b8c pull request #1121 - remove unused variable
Pull request from argrath:  'sel' is assigned but then never used.

Closes #1121
2023-11-07 16:26:44 -08:00
SHIRAKATA Kentaro
7e735d9386 remove unused assignments 2023-11-07 16:26:12 -08:00
PatR
ffc6aa06cc pull request #1123 - back-on-solid-ground
Pull request from entrez:  update some terain-change messaging and be
more consistent with "you find yourself back on solid ground."

Closes #1123
2023-11-07 16:16:09 -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
53be8be3e9 Fix: mention_decor preposition vs unusual terrain
When moving off a body of water with mention_decor on, describe_decor()
would produce messages like "You are back on cloud", "You are back on
wall", and "You are back on air bubble."  For those types of terrain
that were producing odd sentences like this, change the format to "You
are back in a cloud", "You are back in a wall", "You are back in an air
bubble", and "You are back in the air."
2023-11-07 16:13:54 -08:00
Michael Meyer
702f914306 pooleffects messaging vs mention_decor
With mention_decor enabled, exiting the water on the Plane of Water
would produce the series of messages "You pop into an air bubble.  You
are back on air bubble."  Suppress the second message.  The lack of
article there seems like a problem too...

Also, acknowledge flight/levitation and use ice_descr in the pooleffects
"solid land" message.  This should make it more consistent with how
mention_decor does a similar message, especially changes to how it
describes ice based on its melt timer.
2023-11-07 16:13:54 -08:00
Michael Meyer
346cd9e35b Revert part of "Fix: hurtling into wall of water"
Turns out this change to more accurately describe the wall of water in a
situation that shouldn't come up in-game messed up some uses of
dfeature_at which do a string comparison between the result and "pool of
water" to determine how to behave.
2023-11-07 16:13:54 -08:00
PatR
ffd9843ad4 pull request #1110 - explore mode access
Pull request from entrez:  sysconf's EXPLORES=user-list is checked by
the #exploremode command but was no checked by -X on the command line
or 'playmode=explore' in the RC file.  Also a save file from wizard mode
that wasn't allowed to be restored in wizard mode (different user or
change in sysconf's WIZARDS=user-list) would 'downgrad' to explore mode
with checking whether the current user is allowed to use that.

Closes #1110
2023-11-07 15:49:17 -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
1e237e4b8f Fix: shunt to explore mode after wizmode auth fail
If an unauthorized player requests the game launch in wizard mode, it
will try to put her in explore mode instead.  If this happened during
restoration of a previous (normal) saved game, the setting of discover
in wd_message() would bypass iflags.deferred_X, allowing the player to
select to keep the non-explore-mode save file.  [Actually, when I tested
it I always got an error when answering yes to the "keep the save file?"
prompt, but that's a problem too...]  Because deferred_X was still 1
after this, the pline "You are already in explore mode" would also be
printed following the prompt (when moveloop_preamble() attempted to set
explore mode).

Fix this so that loading a normal game with -D, then failing the
authorization, boots into explore mode via iflags.deferred_X and the
"really enter explore mode?" prompt, as it would have if -X were
specified on the command line to begin with.
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
4f405b77ce Remove pw check in authorize_wizard_mode
Now that CHECK_PLNAME is a sysconf option, it can be possible to
authorize wizard mode even if get_unix_pw() fails to return the user's
login name, so I think the call to check_user_string() should go out
either way in case that's what's happening.
2023-11-07 15:38:08 -08:00
nhw_cron
484cd86ce3 This is cron-daily v1-May-8-2022. 005guidebook updated: doc/Guidebook.txt 2023-11-06 16:53:12 -05:00
G. Branden Robinson
44c012e9cf doc/Guidebook.mn: Fix overset lines in nroff mode
One can observe the following problems when generating or viewing plain
text versions of the Guidebook.  (There are three; "Guidebook" and
"Guidebook.txt" are identical, and are paginated; "Guidebook.dat" is not
paginated.)

1.  The line "(Edited and expanded for NetHack 3.7.0 by Mike Stephenson
    and others)" is overset.

2.  So are Figures 1 and 2, by one character cell, when rendered with
    groff 1.23.0 because of the way it handles boxed tables and those
    with vertical rules at table boundaries.

    https://git.savannah.gnu.org/cgit/groff.git/commit/?id=8f066786ea3cb5e1dbade1149e7d50ae978da202

3.  When viewing the Guidebook in an 80-column terminal, the left and
    right margins are asymmetric; you get 10 columns on the left but
    only 5 on the right.

So:

* doc/Guidebook.mn: In nroff mode, set page offset to 5n and increase
  line and title line lengths by 5n to 70n.

Now, the margins are symmetric, there's ample room for the figures, and
the expansion credit fits.

(One diagnostic remains when formatting with groff 1.23.0.

troff:tmac.n:762: error: cannot load font 'S' for emboldening

This is a groff bug and will be fixed in the next release.  The
diagnostic is spurious and can be ignored.

See <https://savannah.gnu.org/bugs/?64866>.)
2023-11-06 14:44:58 -06:00
G. Branden Robinson
4eeab8824d doc/Guidebook.txt: Update table annotations
Explain behavior of GNU tbl when setting boxed tables on terminals.
Drop reference to bug fixed in groff 1.23.0
<https://savannah.gnu.org/bugs/?49390>.

There's not much to say about other tbls except that they handle boxed
tables _terribly_ on terminals.

$ cat ./hello-table.roff
.TS
box;
L.
hello
.TE
$ ./bin/tbl ./hello-table.roff|./bin/nroff|cat -s # Heirloom Doctools
_______
 hello
_______
|
|     |

DWB tbl behaves the same way.  I expect all System V Unix-descended
tbls/nroffs do the same.
2023-11-06 14:44:54 -06:00
G. Branden Robinson
0571cb395e doc/Guidebook.mn: Completely revamp Figure 3
This is my attempt to revise the figure by working _with_ tbl(1)
and nroff(1)/troff(1) features instead of fighting them or enduring
suffering and significant maintenance challenges.

* Stop using mn(7) display macros; the other two figures didn't and they
  don't appear to be buying much.
* Use `tr` character translation feature to temporarily remap characters
  for clarity of input.  It's convenient to input ordinary characters
  here since the table's contents are (mostly) character-cell art.
  Remap `-` to minus sign and `@` to the "reverse solidus" special
  character.  (`\` is the default *roff escape character.  It can be
  changed, but attempting that seems hopeless inside a tbl(1) table.)
  Revert the translations after the table.  (There's nothing special
  about `@`; you could choose any other character that isn't otherwise
  needed in the table.)
* Use `box` region option as with Figures 1 and 2.  Perhaps this wasn't
  done because those are meant to depict a terminal window, but Figure 2
  depicts only part of one, so its top border is a fib.
* Use `expand` region option to obtain roughly the same spread-out
  effect that the table was laboriously using empty columns and the `e`
  column modifier for.
* Consequently, reduce the column count to 2; both have real content.
* Annotate both keycap diagrams--in part for clarity, but also to make
  it more obvious that the columns will balance in width.

These changes don't require GNU extensions to *roff or tbl except,
arguably, the \(rs special character.  But support for that special
character identifier is easily added to any device-independent troff;
see §23.2 of CSTR #54 (Kernighan 1992 revision) or groff_font(5).  Or I
can prepare a patch--just ask me.  But given that no one seems to have
complained about the disaster that AT&T tbl/nroff must have been making
of Figures 1 and 2 for decades, I'm guessing this isn't a practical
concern.  Any if it _is_ a problem, `\e` can be used instead of `\(rs`.
(I didn't use it because what is wanted is the backslash glyph
specifically [to mirror `/`], not "the escape character".  But given the
constraints imposed by use of tbl(1), it's an academic point.)
2023-11-06 14:44:09 -06:00
G. Branden Robinson
9658f6769d doc/Guidebook.mn: Caption figures consistently
On my system, the figure captions in Guidebook.ps were getting set in
Courier roman.  This was clearly unintentional.  Here's why it didn't
work.

1.  Figures 1 and 2 selected the previous font, but only after a table
    had been set.  But tbl(1) does not preserve identity of the previous
    font.  I investigated, and none of GNU, Heirloom Doctools, nor
    Documenter's Workbench tbl implementations preserve it.  So the user
    can't rely on it.  See
    <https://savannah.gnu.org/bugs/index.php?64862>.

2.  Figure 3 attempted to select the roman font (typically Times), but
    did so in a table cell that was empty of text.  It therefore did not
    have any visible effect.

* doc/Guidebook.mn: Explicitly select font `R` after setting tables.  On
  typesetters, put half a vee of space between the table's box border
  and the figure caption.
2023-11-06 14:43:59 -06:00
G. Branden Robinson
93dd1a09d5 doc/Guidebook.mn: Improve roff character reference
And point people to a more authoritative reference.
2023-11-06 14:43:56 -06:00
G. Branden Robinson
363f8db139 Use *roffier method of producing Guidebook.dat
doc/Gbk-1pg-sfx.mn is already using one half of a sound technique: set
the page length to a very large value, guaranteed to overshoot the
vertical space required by the document's text.  The other half is to,
at the end of the document, set the page length to the current vertical
position, so that it ends immediately.

https://www.gnu.org/software/groff/manual/groff.html.node/Manipulating-Spacing.html
2023-11-06 14:43:50 -06:00
G. Branden Robinson
b35350d7d3 doc/Guidebook.mn: Drop junk argument to TS
The "S" argument has no meaning.  tbl(1) doesn't interpret it, and the
"n" and "nh" macro packages don't, either.
2023-11-06 14:43:47 -06:00
G. Branden Robinson
9a96e0a198 Fix *roff string usage nit
String definitions were being used with a pointless leading double
quote.  This syntax is used only to define strings containing leading
space characters.  (You might also use it defensively if you're defining
one string whose contents start with the interpolation of another, and
the latter might interpolate leading space--but that is not the case
here.)

Remove unnecessary leading quotes from string definitions.

* doc/Guidebook.mn: Do it.  Also annotate empty strings with comment.
* sys/unix/hints/include/gbdates-post.370: Don't put them back.

https://www.gnu.org/software/groff/manual/groff.html.node/Strings.html
2023-11-06 14:43:34 -06:00
nhmall
1538b401e9 quiet a new warning after pull request #1119
hack.c
.\hack.c(1607): warning C4018: '<': signed/unsigned mismatch
2023-11-06 07:37:34 -05:00
nhw_cron
62ea71bd6b This is cron-daily v1-May-8-2022. 005guidebook updated: doc/Guidebook.txt 2023-11-06 07:31:47 -05:00
PatR
6e137628fb perminv_mode in Guidebook
Tweak the new entry in Guidebook.mn and catch up with that entry in
Guidebook.tex (untested).
2023-11-06 00:46:18 -08:00
PatR
ac57c070be simplified menu_headings fix
Reported by entrez, some putstr() to text window got changed to
add_menu_str().  I didn't test with curses; with tty some headers
ended up in limbo:  "Artifacts" header for '` a y' (wizard mode show
artifacts, something I had forgotten even existed) and also monster
class headers for 'm #vanquished by-class' (available to everyone).
Qt lost them too, but at least it didn't panic.

Not due to over-simplification:  end of game disclosure suppresses
header line highlighting, except when disclosing final inventory.
Change it to do so, although it would be simpler overall to just not
bother with any menu_headings highlight suppression.
2023-11-05 23:50:12 -08:00
PatR
a40dbe791e pull request #1119 - refine impact vs zombies
Pull request by entrez:  refine the recent change to have buried
zombies be affected (emerge from ground sooner) by objects that
impact the ground on or near their burial spot.

Closes #1119
2023-11-05 21:56:31 -08:00