Commit Graph

13640 Commits

Author SHA1 Message Date
PatR
00fd2b79de simulated mouse click for #therecmdmenu
The #therecmdmenu command calls getdir() which issues an "in what
direction?" prompt.  This allows you to answer with "_" instead of a
regular direction, then it will call getpos() to allow you to move
the cursor and type "," (or ";") to behave as if a left-click had
been done or type "." (or ":") to behave as right-click.

Ordinarily I would think of the 'normal' getpos() response of "."
as suitable for left-click, then one of the other getpos finishers
for right-click, but comma is left of period on a standard keyboard
and that seems useful for remembering which is used for which click.

Left clicking on a spot farther than one step away offers travel,
throw iff lined up, and also click-look as choices.  If you right
click farther than one step away, it will only offer click-look.
The look choice for either left or right click isn't inhibited by
having the clicklook option set to False.  After all, player is
explicitly choosing the menu entry to look at something.

New getdir.mouse can be bound to some other key than "_" and the
getpos.pick* responses could already be re-bound, but there's no
separate getdir.left/right that could be used to bind different keys
from those used for the four getpos responses.
2022-06-13 16:06:06 -07:00
PatR
145232a16f fix 'simplify streamlined act_on_act()'
Still more PR #777.  Commit c4c6c3d73a broke #therecmdmenu travel,
throw, and far-look.  It was restricting dx and dy unnecessarily
and that resulted in not specifying the correct location when the
destination was farther than one step away.

Testing those properly requires a mouse.  I've implemented a way
to simulate a left or right click at getdir()'s prompt (only useful
for #therecmdmenu).  That will be committed separately.
2022-06-13 14:44:20 -07:00
Patric Mueller
193d0c4332 Color check for 256 and 24 bit color output with enhanced symbols
Adding a check for using the 256 or 24 bit color escape sequnces only if
the terminal supports it.
2022-06-13 20:52:58 +02:00
Patric Mueller
1685b5e16b Fix wrong glyph for tuwall in Enhanced1 symset 2022-06-13 20:52:58 +02:00
PatR
c4c6c3d73a simplify streamlined act_on_act()
More PR #777:  there's no need for there_cmd_menu() to pass absolute
<x,y> instead of <dx,dy> for a couple of actions.  Those actions can
reconstruct <x,y> by adding <dx,dy> to <u.ux,u.uy>.
2022-06-13 11:30:59 -07:00
PatR
778eb2603d better feedback for '& m' and '? f m'
For the description of what a keystroke does, augment 'm' (or whatever
key has been bound to #reqmenu) to replace the default description
|m      prefix: request menu or modify command (#reqmenu).
with
|m      movement prefix: move without autopickup and without attacking
|m      non-movement prefix: request menu or modify command (#reqmenu).

The text is delivered by pline so tty will issue --More-- between the
two lines.
2022-06-13 04:41:31 -07:00
PatR
20c43287eb hack.c reformatting
Mostly adjusting some wide lines.  Should be no change in generated
code.
2022-06-13 03:35:46 -07:00
PatR
b49e8bdfb6 streamline act_on_act()
Refine the code from pull request #777 by changing act_on_act() to
take 3 arguments instead of 6.  x,y and dx,dy are mutually exclusive
so it doesn't need both pairs provided that the caller is adjusted
to pass the ones appropriate for the action, and dir is easily
derived from dx,dy for the couple of cases that use it.
2022-06-13 03:13:11 -07:00
PatR
fe34d4e3e3 noxious quest nemeses
Refine the code added by pull request #763 to check the quest nemesis
death message for reference to noxious fumes rather than having the
three relevant roles be hardcoded.
2022-06-12 13:19:13 -07:00
nhmall
ca3e406601 some Qt6 Makefile tinkering
Adjust for a package available on ubuntu jammy jellyfish 22.04 LTS,
but one that doesn't seem to follow the norm.
2022-06-12 11:59:34 -04:00
PatR
14fec29c13 fixes entry for pull request #770 - wizard splbook
Pull request from matteverett:  for generating starting equipment,
mark a wizard as having received a level 1 spellbook when getting
guaranteed force bolt so that the random second spellbook can be
level 1, 2, or 3 as intended rather than unintentionally be forced
to be level 1.

Closes #770
2022-06-11 15:32:37 -07:00
Matthew Everett
f2bef98dac Move check for starting L1 spellbook to include non-random spellbooks 2022-06-11 15:29:37 -07:00
PatR
fbd7d5cd37 pull request #798 - fix typo in disclosure \
of vanquired monsters.

Pull request from janne-hmp:  the test for how many spaces to insert
in front of "the <unique monster>" couldn't match prefix "the "
because it was specifying a length of 3 instead of the 4 required to
include the trailing space.

Despite that clear error, the code worked as intended because the
default value of 0 is the same as an explicit value of 0 it would
have gotten if it had matched "the ".  So there is no change in the
resulting vanquished monsters display.

Closes #798
2022-06-11 15:13:30 -07:00
janne-hmp
dd949cf185 Changed the comparison length of "the " from 3 to 4 to account for the space in the end. 2022-06-11 14:59:57 -07:00
PatR
ad3aa545dc monsters less likely to dig in Sokoban
Make monsters being created in Sokoban that are given a random
defensive item be less likely to receive a wand of digging.  Should
result in fewer extra holes needing to be plugged.

Resurrected from an old stash entry.  I have no recollection of why
I didn't consider it to be ready for prime time way back then.
2022-06-11 11:38:52 -07:00
nhmall
ccddb9156a cut-and-paste error follow-up 2022-06-11 14:00:15 -04:00
nhmall
6c61004b06 g++-12 bits, mostly Qt5 related
I forced a test compile to -std=c++20 mostly to see what we would
be up against. There was only a small number of things and they
are corrected in this commit.

c++20 has some issues with comparisons and bit twiddling between
different enums.

The vendor-supplied Qt5 header files triggered some of those issues as
well, so the qt_pre.h and qt_post.h NetHack header files were adjusted
to make those new warnings go away.  I have not tested Qt6 under the
new compiler and c++ version yet.

Because there are multiple pragmas in qt_pre.h now, the conditional
ifdef structure in there was modified a little to make maintenance
simpler and have a single pragma push at the top. The pragma pop
comes after the Qt vendor-supplied header files, and is done
in qt_post.h.

The display.h macro cmap_to_glyph() was used in
a Qt c++ file and triggered a series of warnings because of that.
Rather than write c++20-friendly versions of those macros, the
simple fix is to provide a function on the C side of things
to front the cmap_to_glyph() macro, so fn_cmap_to_glyph()
was added.

Also thrown into this commit, PatR picked up on the fact that for
yesterday's new warning in qt_menu.cpp, the compiler had correctly
picked up on the fact that the format range of the variable 'cash'
had been correctly upper-capped at 999999999L in the warning message
because of an assignment prior. He suggested that perhaps by also adding
    if (cash < 0)
       cash = 0;
the warning might be eliminated altogether.
After a test, that was proven to be correct, so yesterday's
more-kludgy change is reverted and replaced with that variable
variable restriction ahead of the snprintf().
2022-06-11 13:52:58 -04:00
nhmall
46e58c8e95 Merge branch 'pr791' into NetHack-3.7 2022-06-11 11:07:42 -04:00
nhmall
18fe0bef02 cleaning-up on gd_move() pr #791
Closes #791
2022-06-11 11:06:08 -04:00
nhmall
7b17659f58 Merge branch 'fix-vault' of https://github.com/argrath/NetHack into pr791 2022-06-11 11:02:23 -04:00
SHIRAKATA Kentaro
20fa315bfc fix warnings 2022-06-11 17:18:34 +09:00
PatR
7c732e64a0 simplify unpunish()
unpunish() duplicated much of delobj() in order to use dealloc_obj().
Switch to delobj().  That required a fix to feel_location() when it
was called by savebones() after vision is turned disabled.
2022-06-11 00:11:48 -07:00
PatR
01fb6a703f Some cleanup for saving bones 2022-06-11 00:09:14 -07:00
PatR
542ab25da1 saving/freeing ball and chain
Reported by entrez:  fix memory being accessed after having been
freed by trying to keep ball&chain data up to date when they're
processed by the save code.  This fix is a little more elaborate
than this suggested one.  I'm crossing my fingers on this one....
2022-06-11 00:08:17 -07:00
nhmall
03c19762d6 new warnings showed up in old code
A test build with gcc-12 cause two new warnings to appear.

mkmaze.c: In function ‘makemaz’:
mkmaze.c:983:44: warning: ‘sprintf’ may write a terminating nul past the end of the destination [-Wformat-overflow=]
983 |                 Sprintf(protofile, "%s%d-%d", g.dungeons[u.uz.dnum].proto,
    |                                            ^
In file included from ../include/config.h:665,
                 from ../include/hack.h:10,
                 from mkmaze.c:6:
../include/global.h:262:24: note: ‘sprintf’ output between 4 and 31 bytes into a destination of size 20
262 | #define Sprintf (void) sprintf
mkmaze.c:983:17: note: in expansion of macro ‘Sprintf’
983 |                 Sprintf(protofile, "%s%d-%d", g.dungeons[u.uz.dnum].proto,
    |                 ^~~~~~~-+

As usual, that one can easily be rectified by replacing it with an Snprintf() call.
There were several Sprintf calls in the vicinity, targeting the same destination
buffer, so I figured that I might as well replace the several.

../win/Qt/qt_menu.cpp: In member function
‘virtual void nethack_qt_::NetHackQtTextWindow::UseRIP(int, time_t)’:
../win/Qt/qt_menu.cpp:1082:63: warning:
‘%ld’ directive output may be truncated writing between 1 and 20 bytes into a region
of size 17 [-Wformat-truncation=]
1082 |     (void) snprintf(rip_line[GOLD_LINE], STONE_LINE_LEN + 1, "%ld Au", cash);
     |                                                               ^~~
../win/Qt/qt_menu.cpp:1082:62: note: directive argument in the range [-9223372036854775808, 999999999]
1082 |     (void) snprintf(rip_line[GOLD_LINE], STONE_LINE_LEN + 1, "%ld Au", cash);
     |                                                              ^~~~~~~~
../win/Qt/qt_menu.cpp:1082:20: note: ‘snprintf’ output between 5 and 24 bytes into a destination of size 17
1082 |     (void) snprintf(rip_line[GOLD_LINE], STONE_LINE_LEN + 1, "%ld Au", cash);
     |            ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

That one was a little different. It wasn't complaining about the destination buffer
size in the way -Wformat-overflow was on the previous warning from gcc, and it
was already using snprintf().

It looks like what the C++ compiler was warning about there, was that snprintf()
informs you after-the-call that the destination buffer was too small for the
result string to be fully written. It informs the developer of that by returning
the number of characters that would have been written if the buffer had been big
enough. Presumably, the C++ compiler picked up on the fact that the return value
was being cast to void, thus throwing away that truncation information from the
return value.

Worked around it by putting the return value into a variable, and flagging the
variable with nhUse(variable) so as not to exchange the -Wformat-truncation
warning with a variable-set-but-not-used warning.
2022-06-11 00:18:27 -04:00
PatR
cdf82a8a7a \#wizkill while engulfed
Targetting any of the eight surrounding spots while swallowed will
kill the engulfer.  Picking a spot farther away reports "no monster
there" even if there does happen to be one at the chosen spot.
2022-06-10 15:19:01 -07:00
PatR
188f9f86af left out of commit e2d694ed32 2022-06-10 14:36:55 -07:00
PatR
e2d694ed32 fix github issue #769 - revive panic
Issue #769, reported by k2 and diagnosed by entrez:  eating a troll
corpse that revives on the last turn of the meal was using up the
corpse while the revival was in progress (unless the hero couldn't
observe the resulting monster), leading to a panic when trying to
use it up at the end of revival.  Brought on by a recent change to
interrupt an occupied hero who can observe a hostile monster being
created nearby.

The fix isn't perfect.  If revival fails because there's no place
to put the revived troll, the meal will be interrupted with one bite
left instead of finishing.  If that happens, the interruption will
include a "you stop eating" message, just with no explanation why.
The partly eaten--almost completely eaten--corpse will remain.

Closes #769
2022-06-10 11:35:07 -07:00
PatR
95dece1a2b object splitting bit
Something else noticed while hunting for the revive() panic.  Like
the zap.c change (56b791f7cc), doesn't fix that or impact its
eventual fix.
2022-06-10 10:14:06 -07:00
PatR
56b791f7cc couple of revive() bits
Noticed while hunting for the panic.  They don't fix it but also
won't interfere with the eventual fix.
2022-06-10 10:11:10 -07:00
nhmall
828de37450 suppress warnings during vs 3rd party x64 builds
These warning are in 3rd party library builds (one
in Lua relating to padding due to alignment), and
a few in pdcurses. We won't be addressing the code
in  those.
2022-06-09 20:02:19 -04:00
nhmall
95a39d0b71 granular verbose message suppression mechanics updated
update the macro definition

[re-do full commit message due to errors in last one]

Switch to using a macro invocation Verbos(n, s) in place of the
flags.verbose checks.

Provide the mechanics for individual suppression of any of the
existing messages that were considered verbose.

Mechanics only - this code update does not provide any means of
setting the suppression bits.

flags.verbose = 0
is still a master suppression of all the verbose messages.

flags.verbose = 1
turns on the verbose messages only for those whose suppression
bit is 0 (not set).
2022-06-09 15:16:28 -04:00
nhmall
be76727265 granular verbose message suppression mechanics
Switch to using a macro invocation Verbos(n, s) in place of the
flags.verbose checks.

Provide the mechanics for individual suppression of any of the
existing messages that were considered verbose.

Mechanics only - this code update does not provide any means of
setting the suppression bits.

iflags.verbose = 0
is still a master suppression of all the verbose messages.

iflags.verbose = 1
turns on the verbose messages only for those whose suppression
bit is 0 (not set).
2022-06-09 13:53:20 -04:00
nhmall
fe235b7292 correct an assignment value in restore.c 2022-06-09 08:16:58 -04:00
PatR
c8ceb2b860 add reset_justpicked() comment 2022-06-09 00:37:14 -07:00
PatR
3d35e54414 utf8 warning fix
Avoid gcc/clang warning about mixing || with && without parentheses.
The code already worked as intended despite the warning.
2022-06-09 00:28:44 -07:00
nhmall
62131b96ba remove extraneous file 2022-06-09 00:46:49 -04:00
nhmall
ed5f03301e Merge branch 'argrath-20220609' into NetHack-3.7 2022-06-09 00:45:59 -04:00
nhmall
0ba9278b69 a couple of argrath pull requests
Closes #777 https://github.com/NetHack/NetHack/pull/777
Closes #793 https://github.com/NetHack/NetHack/pull/793
2022-06-09 00:43:35 -04:00
nhmall
131247e674 Merge branch 'fix-symbols' of https://github.com/argrath/NetHack into argrath-20220609 2022-06-09 00:41:34 -04:00
nhmall
c797b2c052 Merge branch 'fix-cmd-3' of https://github.com/argrath/NetHack into argrath-20220609 2022-06-09 00:39:13 -04:00
nhmall
7e143b3e3e Merge branch 'pr794' into NetHack-3.7 2022-06-09 00:36:57 -04:00
nhmall
3b0fbb6601 fixes entry: vampire shapeshifting in a door #794
Closes #794
2022-06-09 00:35:00 -04:00
nhmall
a476f560f6 Merge branch 'vampire-door' of https://github.com/entrez/NetHack into pr794 2022-06-09 00:33:13 -04:00
nhmall
b11007968b fixes entry for pr #783
Resolves #783
2022-06-08 23:45:02 -04:00
nhmall
e2e3c1f8de Re: [NetHack/NetHack] Prompts can overwrite copyright notice on the
starting screen (Issue #783)

On 2022-06-01 12:22 p.m., NetSysFire wrote:
> Steps to reproduce:
>
>1. Get any prompt and answer it. In my case it was a horribly old
>   save I forgot about or when I wiztested something and forgot
>   about that save, too.
>2. See that the copyright information got overwritten by the prompt:
>
>There is already a game in progress under your name. Destroy old game? [yn] (n)
>         By Stichting Mathematisch Centrum and M. Stephenson.
>         Version 3.7.0-59 Unix Work-in-progress, built May 31 2022 12:28:31.
>         See license for details.
>
>
> Shall I pick character's race, role, gender and alignment for you? [ynaq]
>
> Expected behavior:
>
> Redraw after a prompt was answered, so the prompt vanishes and the
> entirety of the starting screen will be shown.
>
> NetHack, Copyright 1985-2022
>          By Stichting Mathematisch Centrum and M. Stephenson.
>          Version 3.7.0-59 Unix Work-in-progress, built May 31 2022 12:28:31.
>          See license for details.
>
>
> Shall I pick character's race, role, gender and alignment for you? [ynaq]
>
> Proposed severity: low. Not gamebreaking, it is cosmetic only and does
> not have any other consequences.
>

The Copyright notice is placed by tty internal routines writing onto
the BASE_WINDOW fairly early in the startup sequence.

The prompt to "Destroy old game? [yn] (n)" is using the in-game
routine to write to the message window at the top of the screen and
prompt there, just like in-game prompts and messages.

If the player answered 'y' to that, the prompt for
"Shall I pick character's race, role, gender and alignment..."
appeared immediately after. That one, however, is written using
the BASE_WINDOW routines in tty, like the copyright notice.

This change does the following:

It moves the copyright lines down a little bit leaving room for the
"Destroy.." prompts.

It places the "Shall I pick characters's..." prompt further down the
screen by default, leaving some room for about 3 raw_print startup
messages after the copyright notice, just in case there are any.
The "Shall I pick character's..." prompt will still appear immediately
if there is a prompt such as "Destroy old game?..."

There were a couple of other issues around raw_print startup messages
too. Those are delivered using a raw_print mechanism to ensure they
are written even if the window-port is not fully operational. However,
they were only on the screen for the blink of an eye. This call
sequence in restore.c made them disappear almost immediately:
     docrt() -> cls()

Put in a mechanism to detect the presence of raw_print messages
from the early startup, and if there were some, wait for a
keypress before obliterating the unread notifications.
2022-06-08 23:41:45 -04:00
Michael Meyer
bc2427167a Fix: vampire shapeshifting in a door
Someone mentioned in #nethack today that a vampire had turned into a fog
cloud, moved under a door, then turned back into a vampire while still
sharing a space with a closed door.  There already existed some code
intended to prevent this in cases where the vampire is killed in one
form and revives in another, but voluntary transformations (from
decide_to_shapeshift) weren't included.  The existing code in mondead
and vamp_stone also apparently missed a minor edge case: because the
code between the definition of in_door and its use included an expels
call, it would be outdated/incorrect in cases where expels() placed the
fog cloud onto a closed door.
2022-06-08 20:23:24 -04:00
PatR
faf3d6f08a death from touching silver ring or wand
From a reddit thread:  NAO's list of causes of death shows
|killed by handling a(n) ring of shock resistance
|killed by handling a(n) wand of fire
along with various other rings and wands and the poster wondered how
that could have killed characters.  Someone quickly figured out that
the heroes involved had lycanthropy and the items listed happened
to be silver in those games.

Avoid that sort of confusion in future by specifying "handling a
silver ring" or "handling a silver wand" instead of the specific
type of item when inflicting silver damage.  It still uses specific
item for other classes of objects where silver isn't shuffled among
potential items at start of game.
2022-06-08 12:50:49 -07:00
PatR
f710a3175f magic portal traversal feedback
Replace the old message "you feel dizzy for a moment, but the sensation
passes" when going through a magic portal.  The sensation doesn't just
pass anymore; you arrived stunned these days.  Suggested by entrez.
2022-06-08 10:46:51 -07:00
SHIRAKATA Kentaro
d23f26077b remove unnecessary null-check on parsesymbols()
`strval` here is always non-null,
because the null-check is done in earlier code.
2022-06-08 05:28:32 +09:00