Commit Graph

2992 Commits

Author SHA1 Message Date
PatR
7c72c1f141 identifying via menu
From the newsgroup:  identifying by menu pops up multiple menus in
succession if the player picks fewer invent entries than are being
granted, but the second and subsequent ones could cover up the
message window and hide the feedback from prior ones.

If multiple popup menus are needed when identifying, issue --More--
before each menu after the first.  The code seemed to be trying to
do this already, but it should have used wait_synch() rather than
mark_synch(), or perhaps used display_nhwindow(WIN_MESSAGE, TRUE)
instead of either one of those.  For curses, both mark_synch() and
wait_synch() were no-ops.  Now they do something.  X11's behavior
wasn't right either; it seemed to be lagging one message behind
(something I had noticed recently and then forgotten about; I still
don't remember the context then so don't know whether this fixes
that earlier situation).
2023-01-09 23:34:32 -08:00
Pasi Kallinen
030fc0036a Remove NO_VSNPRINTF
Affects only ancient VMS where vsnprintf wasn't available.
2023-01-06 15:53:06 +02: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
nhmall
1972c8447f update year in copyright 2023-01-01 17:31:34 -05:00
Michael Meyer
15274fcca1 Make paralysis intefere with seduction attempts
tinklebear on IRC noticed that a hero paralyzed by a floating eye was
still "charmed" and capable of "removing her armor" as part of a nymph's
theft attack.  The same thing was true of foocubus seduction: a
paralyzed hero was still able to respond to the questions about whether
particular pieces of armor should be removed (and also do whatever else
may be involved in a successful attack...).

I think paralysis should prevent both those things.  Nymph theft will
still work, unless she needs the hero's active cooperation in removing a
bulky piece of armor.  Foocubus attacks will be prevented entirely by
paralysis, making it interfere like unconsciousness already does.

Apply a similar constraint to hero vs monster seduction, as well.
2022-12-31 11:25:53 -08:00
PatR
077fdcfaac followup for miscellaneous objects[] macros
The DUMP_ENUMS definition of 'MARKER()' had the expansion of its
arguments backwards but isn't even needed, so get rid of it rather
than reverse them.  nethack --dumpenums handles them separately
from object definitions.
2022-12-28 11:33:39 -08: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
Pasi Kallinen
d7e90fbae2 Expand safe_wait to deadly status afflictions
Searching or waiting with safe_wait on will now consider
sliming, stoning, or deadly illness to be hazardous and prevent
the command.
2022-12-18 00:40:38 +02:00
PatR
96f5f03287 revise the role, race, gender, align options
Using role:!wizard to limit which roles would be candidates for
random selection didn't work as I expected.  It required a separate
option setting for role to exclude.  This implements how I thought
it worked:
|OPTIONS=role:!ranger !samurai !wizard
will exclude multiple roles with a space-separated list in a single
option setting.  It also adds support for
|OPTIONS=!role:ranger samurai wizard
to do the same thing.  (OPTIONS=!role:!ranger isn't allowed.)

I thought 'OPTIONS=role:barbarian caveman knight' could be used to
limit random selection to those choices, but that doesn't work and
I haven't attempted to implement it.

This also renames the 'align' option to 'alignment'.  That made the
truncation to 'align' become ambiguous, so it got added back as an
alias for the full name.

Guidebook.tex is lagging; I'm burned out.
2022-12-14 13:14:54 -08:00
PatR
daeec9291c refine PR #946 - named armor
Move the new stuff from PR #946 out of xname() into new routine
armor_simple_name().

Noticed while testing:  tweak 'call object type' so that it doesn't
list instances of pre-discovered armor as likely candidates since
assigning a name to such wasn't showing up in the discoveries list.

Add "silver shield" as wishing synonym for "polished silver shield".
2022-12-14 07:37:04 -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
b2fe51490d tty-style role selection for curses
Move the tty role/race/&c selection from wintty.c to role.c and remove
its references to BASE_WINDOW.  Have curses call the same routine now
so that the player has the option to choose role, race, gender, and
alignment in any order and to confirm or override random settings
prior to starting play.  Also if you went through "who are you?" then
final confirmation includes an extra menu choice to rename the hero.

It still has the quirk of sometimes remembering some of the previous
aspects when you re-pick a new value for some aspect which already
been selected.

The menus pop up on top of the copyright screen and that looks a bit
strange.  I don't think core code has any way to erase that base
window without erasing the entire screen so to fix the strangeness
the window ports would need to do that before calling the selection
routine.  I didn't do that because the very first prompt, "Shall I
pick ... for you? [ynaq]" shows up in that window rather than in a
popup over it, and having it be all by itself on an otherwise blank
screen seemed to be even stranger.

X11 and Qt both have more sophisticated selection routines so I
haven't tried to switch either of them to use this.  They both use a
fancy role-selection-specific menu with all the aspects present at
once so this wouldn't fit without more work than I care to tackle.
2022-12-12 16:30:27 -08:00
PatR
cefd9a0c0a 'generic username' checking
Don't require the list of generic usernames in sysconf to need to be
ordered to guard against false substring matches.  If the list was
"nethacker nethack" and the tentative character name was "nethack",
it wouldn't be recognized as generic.  The old code forced the list
to be "nethack nethacker" for the matching to work correctly because
it only checked the first matching substring.  Either order works now.

It also failed to recognize a generic name if the player used
|nethack -u nethack-samurai-human-male-lawful
because it checked for generic names before stripping off the role
aspects.  Now that will at least recognize the name as generic and
prompt with "who are you?", but the role/race/&c info gets discarded.
2022-12-12 14:53:07 -08:00
nhmall
bc13b52d32 windconf.h mingw bit 2022-12-12 15:20:22 -05:00
nhmall
9e91064659 makedefs temp files issue with mingw
The unlink call wasn't operating the same on a makedefs built
on mingw, and dat/mdXXXX files were being left behind post-build.

Provide an alternative way of doing the temporary files if
MD_USE_TMPFILE_S is defined during the compile of makedefs.c
2022-12-12 12:53:51 -05:00
PatR
0e1f1c653b fix #K3802 - sanity_check: boulder not on top
This should fix the problem of polymorphing or stone-to-fleshing a
pile of multiple boulders and having some underneath ones which get
changed resist and not get changed, producing a pile with one or more
non-boulders above one or more boulders.  If that situation arises,
re-stack the pile so that boulders are moved to the top.

This also revises zapping up or down while hiding under something
(if that is even possible; the types of creatures which can hide
under things can't zap wands or cast spells; maybe there are some
exceptions?).  Zapping up used to hit only the top item, but zapping
down hit the whole stack.  Now up still hits only the top, but down
skips the top and hits the rest.

Caveat: not adquately tested.
2022-12-10 17:48:55 -08:00
Ray Chason
aa1d130345 Revert adding bsearch to system.h 2022-12-10 12:27:18 -05:00
Ray Chason
b9ef6e6bb9 Define a tail pointer for the glyph list
Use the tail pointer to add new glyphs, avoiding the need to traverse
the list.
2022-12-10 12:27:18 -05:00
Ray Chason
7dc1106ec1 Sort the glyph cache and search it with bsearch
Also, recognize G_slime_mold and G_piletop_slime_mold when the fruit
has been set.
2022-12-10 12:25:55 -05:00
PatR
6a1f875b17 some extern.h reformatting
Wrap or re-wrap some wide lines.
2022-12-10 00:48:38 -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
d18ce24320 more continuation alignment after g to g? (.h) 2022-12-07 11:31:11 -05:00
PatR
2b5ed0b6b9 trap.h formatting
I don't know whether we'll ever run the code through clang-format
again, but in case we do, end-of-line comments which span lines
should begin continuation lines with '*', otherwise they get turned
into block comments beginning on the next line.

|code; /* start
|         end */
gets changed to
|code;
|/* start end */

but
|code; /* start
|       * end */
stays as-is.
2022-12-06 00:49:52 -08:00
nhmall
215808abd1 clear up a few gcc warnings 2022-12-05 23:19:38 -05:00
nhmall
485797ee8c rework windows nmake file
Keep object files separate between gui and tty builds as they
are not the same binary on windows.

The stubs.c file will no longer be necessary.
2022-12-05 13:21:19 -05: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
PatR
e64ed2859d unpaid object: sanity check, teleporting, 'I u'
It turns out that there are some objects marked unpaid that aren't
carried by the hero, so the recent sanity check for unpaid/no_charge
could complain.  Unpaid items dropped on the shop boundary (gap in
shop wall, doorway, shk's free spot) stayed unpaid when dropped onto
the floor, similar to recent change for pushed shop-owned boulders.
Don't give sanity complaints for those.  They could be all the way
inside a shop too, where unpaid items in a gap in the shop wall got
pushed into the shop when the wall was repaired.  (Possibly those
should come off the bill instead of remaining unpaid.)

Teleporting items out of a shop was marking them unpaid instead of
treating that as robbery.  That's a bug caught by the sanity check.
rloco() was also marking shop items which got teleported from one
spot inside the shop to another spot inside the same shop as unpaid.
Fix both of those things.  Also, if an unpaid item on the boundary
gets teleported all the way inside, take it off the bill.

Change 'I u' to mention whether there are additional unpaid items on
the floor somewhere since they won't be part of unpaid inventory and
they're not on the used-up bill either.  It might occasionally help
the player figure out why the shopkeeper won't let the hero out of
the shop.
2022-11-29 13:55:42 -08:00
PatR
73f69a99cb paranoid-pray vs do-again
If paranoid_confirm settings include praying, don't put the answer
to "are you sure you want to pray?" into the do-again buffer where ^A
would use it to ignore confirmation if prayer is repeated.  And for
wizard mode, when confirmation is 'y' then the answer to "force the
gods to be pleased?" has to be suppressed from the do-again buffer too
or it would be used by subsequent ^A to answer "are you sure?".

This is basically a band-aid just for #pray.  There are probably other
confirmations that should be suppressed from do-again instead of being
reusable.  The rest of the paranoid_confirm ones should be ok because
they require "yes" and that doesn't end up in the do-again buffer, but
there are bound to be other confirmations that shouldn't automatically
be re-used during repetition.
2022-11-26 15:59:01 -08:00
nhmall
4b04b1e6ac expand support for noreturn declarations
Although gcc specifies support for declaring a function as
noreturn after the function name and parameters, other compilers
do so via an attribute at the start of the declaration. Add some
macro support for the attribute-at-the-beginning method:
  o MS Visual Studio compiler
  o Upcoming C23 standard (untested at this point)
2022-11-24 00:51:42 -05:00
PatR
e49c772f13 unpaid object sanity checking
Handle items in gaps of a wall shared between adjacent shops.

Make handling of shop boundaries more explicit:  walls, the door,
and the "free spot" by the door aren't classified as 'costly' but
obj->unpaid and obj->no_charge are valid there.

Move unpaid/no_charge checking into its own routine to unclutter
objlist_sanity().

Pushing a shop-owned boulder to the free spot or doorway or gap in
wall triggers the sanity check for the time being.
2022-11-23 16:41:12 -08:00
nhmall
3398b34cc7 another follow-up, don't cast hardcoded u.ux, u.uy 2022-11-23 19:10:28 -05:00
nhmall
937355038d some coordxy and other conversion warnings
When dist2() got changed to use coordxy parameters, a macro that uses
it in its definition was overlooked and it had (int) casts in it.
That caused a warning about possible data loss when the int
then got converted to coordxy for the dist2() call.

Give online2() coordxy parameters instead of int, like its bretheren.

Avoid a couple of implicit conversion warnings where ints were being assigned
to smaller uchar or ints being assigned to smaller short.

A couple of signed vs unsigned warnings on some rumor processing.

Avoid some signed vs unsigned warnings in mdlib/makedefs where a signed int
param eventually got used in an external call that took size_t.
Eliminate all of it by just having the outer NetHack routine also take
a size_t.

Lastly, insert some default C99 alternative time-related code
in mdlib/makedefs since asctime() and ctime() are being flagged as
deprecated in the upcoming C23 standard and will now start to trigger
warnings for anyone using a C23-compliant compiler.
2022-11-23 17:49:55 -05:00
PatR
0be8f85d2c expand some 'struct obj' comments 2022-11-23 00:46:30 -08:00
PatR
546930e05e tweak PR #925 - don't expose shop bill details
Avoid use of 'struct bill_x' outside of shk.c.
2022-11-19 00:38:20 -08:00
Michael Meyer
b8472af927 Charge hero for making off with shop-owned boulder
Pushing a shop-owned boulder out of the shop wouldn't charge the hero
anything.  Remedy this (and remove the boulder from the bill if the hero
then pushes it back in).  Also tried to handle a couple other uncharged
boulder "theft" scenarios: pushing a boulder into lava or water, into a
trapdoor or hole, or into a level teleporter (various other traps
already charged for the boulder -- it was pretty inconsistent).

I externified onbill() for this, since relying on otmp->unpaid by itself
impossibles if you push a boulder through a gap in a wall between two
adjoining shops.
2022-11-19 00:13:13 -08:00
PatR
fa0cc01ae7 PR #926 tweak - mdistu()
Define mdistu() in terms of distu() rather than dist2().  It's an
extra level of macro expansion when compiling but that's negligible
overhead.
2022-11-19 00:08:44 -08:00
Michael Meyer
619781dbb8 Add 'mdistu' macro
Short for distu(mtmp->mx, mtmp->my) (i.e. the distance between the hero
and the specified monster), which is a very common use of distu().  The
idea is that this would be a convenient shorthand for it; I actually
thought it (or something very similar) existed already, but couldn't
find it when I tried to use it earlier.  Based on the number of uses of
fully-spelled-out 'distu(mtmp->mx, mtmp->my)' replaced in this commit
I'm guessing I just imagined it.
2022-11-18 23:42:47 -08:00
PatR
3278d7e0c1 control of command-line usage entry in '?' menu
Instead of using a compile-time macro to suppress inclusion of the
menu entry to show UNIX command-line usage in the help menu, use a
sysconf setting instead.

Default is HIDEUSAGE=0, to include the entry for command-line usage.
Set HIDEUSAGE=1 to exclude that.  Does not affect 'nethack --usage'
if player actually has access to the command-line.
2022-11-18 17:54:17 -08:00
PatR
9a7f8418ee 'nethack --usage' and '?' menu
Write up a description of how the command line works on UNIX and put
that in new file dat/usagehlp.  Add support for
|nethack --usage | --help | -? | ?
to display it and exit.

Also add a menu entry for nethack's help command to show it during
play.  That can be suppressed by uncommenting new '#define HIDE_USAGE'
in config.h since it won't be useful on servers that don't give
players access to command lines.

New genl_display_file() just writes to stdout.  opt_usage(), which
calls it, might need some suid/sgid handling to make sure the output
is done as the player rather than as nethack.

doc/nethack.6 is already out of date again.
2022-11-18 16:07:15 -08:00
nhmall
3f93d54b66 some Makefile and hints tinkering
1. remove all window interface bits from compiler.370, and have
   the preceding include files set some variables to control
   the behavior of compiler.370 when it comes to c++.
2. some more common Makefile lines into sys/unix/hints/include/multiw-3.370.
3. make it so you can pass cppregex=1 on the Make command line to build with
   sys/share/cppregex.cpp instead of posixregex.c
4. fix sys/share/cppregex.cpp so that it will build with clang compiler
   (required an additional header include). I don't know if it would have
   worked with g++ without that change. The include can be placed into an #ifdef
   block if there's an issue with the change on other compilers.
5. Anything that needs to compile using c++ (Qt, sys/share/cppregex.cpp) can
   just ensure that CPLUSPLUS_NEEDED Makefile variable is set above the lines
   in compiler.370 to ensure that things get set up for c++. It no longer
   checks specifically for Qt. That is what sys/unix/hints/include/multiw-2.370
   does now.
2022-11-13 22:25:07 -05:00
PatR
a83ef812a4 streamline defsym.h
Condense the setup of PCHAR/PCHAR2 and OBJCLASS/OBJCLASS2 (last one
renamed from OBJCLASS7) so that it's easier to see the variations
at once on an ordinary size terminal/window.  Revise some of the
indentation and other spacing, also to try to enhance readability
a little.

Unrelated:  remove a trailing space that crept in with a recent pull
request.
2022-11-10 15:44:53 -08:00
SHIRAKATA Kentaro
99d974333c remove GCC_WARN
Now, the only usage of GCC_WARN is for the guard of PRINTF_F in wincurs.h.
This guard can be removed safely, as PRINTF_F is already used unconditionally in extern.h.
2022-11-08 12:09:26 -08:00
nhmall
9e92fefdd8 keep propertynames static in timeout.c 2022-11-06 10:02:27 -05:00
nhmall
993a82858b Merge branch 'old-software-compatibility' of https://github.com/chasonr/NetHack into NetHack-3.7 2022-11-05 19:30:20 -04:00
nhmall
779d0b2f20 Merge branch 'unicode-X11-2' of https://github.com/chasonr/NetHack into pr923 2022-11-05 19:23:18 -04:00
nhmall
185322421a relocate mstrength() and supporting function again
Also, purge the code for makedefs -m
2022-11-05 18:40:57 -04:00
nhmall
242c05ccf3 Revert "ranged_attk() - there can be only one"
This reverts commit b399e3f2f5.
2022-11-05 15:26:29 -04:00
nhmall
b399e3f2f5 ranged_attk() - there can be only one
Relocate the newer code for the function to mdlib.c
where makedefs can still use it.
2022-11-05 13:07:10 -04:00