Commit Graph

14486 Commits

Author SHA1 Message Date
PatR
270f4ceeef gitpub issue #933: feedback for throwing w/ count
Issue reported by Meklon2007:  typing arrow keys when a menu is open
can end up with hidden counts.  That's a Windows thing and this
makes no attempt to address it.  (That's also a user error since
menus don't support arrow key use.)  It shows up more for throwing
that for other things because fetching an object from inventory for
throwing attempts to enforce a count limit during item selection
that other actions don't.

But feedback could also be odd if you explicitly specify a count
since the rejection wasn't attempting to distinguish throwing more
than one from throwing more than you have.  This changes things so
that with invent of
|$ - 3 gold pieces
|a - a dagger
|b - 3 darts
t4$ now yields   "You only have 3."  instead of  throwing all 3
t4a now yields   "You only have 1."  instead of "you can only throw one"
t2b still yields "You can only throw one at a time."
t4b now yields   "You only have 2 and can only throw one at a time."
In each case, it will reprompt rather than terminate the throw.

"Only one at a time" was already in place when multi-shot throwing/
shooting was introduced and became iffy then, but the way to try to
throw a specific amount is via a repeat count before t rather than
by choosing a subset when selecting the inventory item for t.  The
count prefix method also works for f which doesn't otherwise provide
an opportunity to specify count since inventory item is preselected
via quiver.

Someone might want to reopen the arrow behavior as a Windows issue
but I'm not sure how that would be fixed other than by eliminating
its attempt to be user-friendly in converting arrows into movement
direction keystrokes.

Closes #933
2022-11-26 02:25:27 -08:00
PatR
940f98c223 usage text revisions
Move the mention of viewing usage info via 'nethack --usage | more'
to the end, where it should remain visible if text has scrolled off
the top of the screen (which is nearly certain since it ended up
being much longer than originally intended).

Also, rephrase the text at the start about restore vs new game since
the previous description said "in all cases" which isn't applicable
for 'nethack --scores' or --version or --showpaths or --usage.

Move 'nethack --usage' to last so that 'nethack --scores' is first
among the non-playing command variants since -s is of more interest.

For 'nethack --scores', move -v before the other options since it
has to be next after -s|--scores to be processed correctly.  Also,
avoid using "present" twice in the same sentence.
2022-11-25 13:44:43 -08:00
PatR
d51c1b4691 'nethack -s -v' usage feedback fix
The usage description of '-v' (for scores from all versions present
in 'record' vs only for the current version) was backwards.
2022-11-24 01:00:59 -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
nhmall
ddf1dfde29 quiet another warning that recently appeared
../win/curses/cursinit.c:102:9: warning: variable 'min_message_height' set but not used [-Wunused-but-set-variable]
    int min_message_height = 1;
        ^
1 warning generated.
2022-11-24 00:49:51 -05:00
nhmall
6ab7cafb25 quiet a warning that has appeared recently
botl.c:1303:25: warning: variable 'notpresent' set but not used [-Wunused-but-set-variable]
    int i, updated = 0, notpresent = 0;
                        ^
1 warning generated.
2022-11-23 23:34:47 -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
9efa5d5b44 follow-up bit (in unused ms-dos code) 2022-11-23 18:57:14 -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
4b9044f053 pull request #930 - Qt4 and older Qt5 support
Pull request form chasonr:  restore the capability of using old Qt 4.

I've added a brief Guidebook update.

Closes #930
2022-11-23 13:42:55 -08:00
Ray Chason
890853a03d Restore compatibility with Qt 4
The test system is Slackware 14.2, which uses Qt 4.8.7.

* WANT_WIN_QT4 is defined, and has the expected meaning. Qt 5 is still
  the default.

* The QT_NO_SOUND macro now excludes all headers and declarations
  relating to sound; the multimedia package is not needed to build
  (on any Qt 4, 5 or 6).

* A new function, nh_qsprintf, replaces QString::asprintf, for Qt
  older than 5.5. These versions do not have QString::asprintf.

* DYNAMIC_STATUSLINES is disabled for Qt older than 5.9. These versions
  do not have QSplitter::replaceWidget.
2022-11-23 13:11:14 -08:00
PatR
47ace5d10a symbols tweaks
Mostly formatting but a couple of minor code changes too.
2022-11-23 13:06:05 -08:00
PatR
ccec83e8ce pull request #924 - unicode symsets
Pull request from chasonr:  a symbols file with more than one set
having the unicode attribute effectively merged all unicode sets when
loading any of them.  Also, freeing unicode glyphmap entries for gems
would attempt to free some of them more than once for those that had
colors cloned from other gems.

[This new code compiles but is otherwise untested by me.]

Closes #924
2022-11-23 12:11:24 -08:00
Ray Chason
5a80a437a2 Free the whole list when freeing 2022-11-23 12:05:04 -08:00
Ray Chason
913a7dc0e0 Fix use after free in Unicode mappings
Shuffling gem appearances can cause mappings from object to
appearance that are not one-to-one. Copy any multiple mappings and
free any mappings that are left unused.
2022-11-23 12:05:04 -08:00
Ray Chason
5181c287d3 Parse only Unicode symbols in the current symset 2022-11-23 12:05:04 -08:00
PatR
0be8f85d2c expand some 'struct obj' comments 2022-11-23 00:46:30 -08:00
PatR
997210f7ea onbill() fix
Fix a typo/thinko pointed out by entrez.
2022-11-23 00:21:04 -08:00
PatR
d1ccc337e6 more unix command line: -?
The fix for 'u Name' earlier today broke '-?'.
2022-11-22 23:55:41 -08:00
PatR
e0867661b4 Unix: fix 'nethack -u name'
Using '-u name' rather than '-uname' was being treated as '--usage'
for any value of 'name'.

'-uname' worked as intended unless name was 'sage' (or leading
substring of it).  That's still the case after this fix, where the
space after -u is now necessary for that special case name.
2022-11-22 14:53:43 -08:00
PatR
6bf42b8891 extend sanity_check to shop items
Make object sanity checks examine obj->unpaid and obj->no_charge.

Shopping is complicated; there might be corner cases that aren't
handled correctly.
2022-11-21 13:16:51 -08:00
PatR
c3a8850a86 Qt pager doll inventory
Change Qt's 6x3 grid of worn/wielded equipment so that it is facing
the player: hero's right hand side is shown in the grid's left column
and left hand side is shown in its right column.  Middle column is
unchanged.
2022-11-21 12:53:42 -08:00
PatR
8bab5546bd another man page revision
Add new '--usage' and '--help'.
Add missing '--nethackrc:RC-file' and '--no-nethackrc'.
Explain -D and -X more precisely.
Reorder the options to manually produce a synopsis section that looks
like

"  nethack [ -d|--directory directory ] [ -w|--windowtype interface ]
"  [ --nethackrc:RC-file | --no-nethackrc ] [ -n ] [ -dec | -ibm ]
"  [ -u playername ] [ -X | -D ] [ -p profession ] [ -r race ] [ -@ ]
"
"  Also [ -A|-Arc | -B|-Bar | -C|-Cav | -H|-Hea | -K|-Kni | -M|-Mon |
"  -P|-Pri | -R|-Rog | -Ran | -S|-Sam | -T|-Tou | -V|-Val | -W|-Wiz ]
"
"  nethack [ -d|--directory directory ] -s|--scores [ -v ]
"  [ -p profession ] [ -r race ] [ playernames ]
"
"  nethack [ --usage | --help ] [ --showpaths ] [ --version[:paste] ]

to avoid instances of line breaks like "...[\n-foo ]..." and
"...[ -bar\n]...".  With TeX it would be straightforward to favor line
breaks in front of "[" and after "]" but I don't know whether or how
'roff can do that.
2022-11-19 17:03:26 -08:00
PatR
d5dc5402f6 fixes entry for PR #928 - remove '#if LINT'
Pull request from argrath:  remove a bunch of '#ifdef LINT' code
snippets that no longer serve any useful purpose.

If a lint that handles C99 is ever produced, persumably it won't
need the fairly ridiculous hacks for 'static' and 'long'/'long *'.

Closes #928
2022-11-19 00:50:36 -08:00
SHIRAKATA Kentaro
0d441b0c2f remove the code to silence lint
Warning facilities on recent compilers are incredibly improved,
so the code to silence "good-old" lint is much less sense.
2022-11-19 00:49:11 -08:00
PatR
7d55e71d24 pull request #927 - charging vs undiscovered tools
Pull request from entrez:  don't list undiscovered or unseen (picked
up while blind, still blind) tools as likely candidates for charging.
They're still eligible to be chosen for charging but using a scroll
to charge something else won't reveal not-yet-known tools as being
magic.

Fixes #927
2022-11-19 00:43:16 -08:00
Michael Meyer
db4785b27f Don't leak ID of magic tools in charging prompt
The getobj prompt for charging was presenting any chargeable tool in the
hero's inventory as a suggested charging target, even tools which were
unidentified and undistinguishable from their mundane counterparts
(e.g. bag of tricks, magic harp, horn of plenty...).  This leaked
information about the identity of these items and made it possible to
determine whether a generic 'harp' was magic or not.

When suggesting chargeable tools, include only those which are actually
known to be chargeable (unidentified or unseen chargeable tools can
still be selected, they just won't be suggested targets).  Basically the
same as what's done for a potion of oil in the apply prompt.
2022-11-19 00:41:52 -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
PatR
fa0b2b7e94 fixes entry for PR #925 - shop boulders
Pull request from entrez:  boulders owned by shops could be used up
(plugging hole in floor) or stolen (pushed through unrepaired gap in
shop wall) without cost.  Not very common because shops rarely have
boulders in them.

Fixes #925
2022-11-19 00:15:23 -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
PatR
28a984e897 github pull request #926 - mdistu()
Pull request from entrez.  Replace instances of
distu(mon->mx, mon->my) with new mdistu(mon).

Closes #926
2022-11-18 23:45:32 -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
Michael Meyer
a0dfc94bbe Fix: "a dry rattle comes from its throat"
"A dry rattle comes from its throat" would be printed whenever a
canceled monster tried to spit at you or another monster while not in
the hero's line of sight.  That seemed weird to me: you can't see the
monster and don't know what it is, but you can tell the sound is
definitely coming from "its throat".

Change the message if the monster isn't visible, and make sure it's
printed it only if the monster is nearby (within reasonable hearing
range for a "dry rattle").
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
PatR
75eaf59354 yet more nethack -s
For  nethack -s name1 [name2 [name3]]
allow any or all of the name arguments to be preceded by -u.  Both
'-u name1' and '-uname2' forms are accepted same as when specifying
character name at start of play.

It has been accepting '-s<anything>' and ignoring the <anything>.
Treat such as a separate argument instead.  That means it will accept
'-s-v' which is silly but if used intentionally, <anything> would most
likely be a name.

'nethack -s' without any character name(s) supplied and PERS_IS_UID
set to 0 now defaults to "all" instead of to "hackplayer".  For Unix,
the default name will be in place, so that gets used instead of "all".
'nethack -s all' or 'nethack -s -u all' can be used to see all scores.

When no matches are found, feedback is a full sentence but terminating
punctuation was omitted except for the special case of "Cannot find
any entries for you."  Add the final period all the time.
2022-11-17 16:37:45 -08:00
PatR
472f293b84 more nethack -s
For Unix, set plname[] to the default value (player's username)
before running prscore() for 'nethack -s'.  Avoids reference to
mysterious "hackplayer" if no entries are found.
2022-11-17 13:19:19 -08:00
PatR
a96b3d0b03 fix 'nethack --scores'
The command line parsing in unixmain.c accepted --scores as an
alternative to -s but prscore() in topten.c didn't.
2022-11-16 23:41:07 -08:00
PatR
76a94db88c manpage update
Add -w|--windowtype.

Also --scores and --directory as recognized variations of -s and -d.

Add -@.  The existing description of '-p @' seems to be inaccurate,
and random role but still having to supply race+gender+alignment
isn't very useful anyway.  The bit about maybe needing to quote @ with
backslash might still be useful if moved to -@ though.

Add -A|-Arc -B|-Bar ... -W|Wiz since they hadn't been listed.  I put
them on their own line instead of cluttering up the main program
invocation even further.

Move '-u character-name' before '-D' since that order matters on some
platforms.

Move --showpaths and --version to a separate command invocation since
combining them with any other stuff ends up ignoring that other stuff.
I didn't add --dumpenums.

The description of config file name and location under '-dec and -ibm'
is out of date, particularly for Windows.
2022-11-16 14:47:25 -08:00
nhmall
8badbc06d4 update tested versions of Visual Studio 2022-11-14 2022-11-14 12:57:21 -05:00
nhmall
dcb1250ed6 move Makefile variable assignment 2022-11-14 00:22:32 -05:00
nhmall
0666a1c5da fix path to djgpp c++ compiler in ms-dos cross-compile 2022-11-14 00:00:20 -05:00
nhmall
583d124735 some follow-up for warnings experienced on macOS 2022-11-13 22:56:05 -05: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
d957d70d15 reset X11's "interface has been initialized" flag
Reset 'x_inited' after the various widgets have been released
during shutdown.

This might prevent the second panic ('X11_mark_synch()' during
emergency save) in the double panic reported in a later comment of
github issue #569.  It definitely doesn't address whatever caused
the first panic, nor the poor handling of missing fonts that was
apparently responsible for #569's initial report.
2022-11-13 13:12:19 -08:00
PatR
7caa6ab8c7 winX.c
Mostly reformatting, but also initialize all output arguments in
get_window_frame_extents() in case it makes an early return.
2022-11-13 12:43:34 -08:00
nhw_cron
dbb440d86c This is cron-daily v1-May-8-2022. 000files updated: Files 2022-11-13 12:34:51 -05:00
nhmall
21203c950e multiw-3.370
Add a 3rd multi-window include file that comes after compiler.370.

Relocate a small section of Makefile lines common to both macOS.370
and linux.370 to multiw-3.370.

Also relocate a section near the tail of compiler.370 that really
has nothing to do with compilers or compiler flags, but was
related to Qt which is one of the supported multi-window interfaces.
2022-11-13 12:17:27 -05:00