Gcc 9 has become more vocal with sprintf buffer overflow
checking. Remove these sprintf warnings by changing the
offending calls to a snprintf wrapper that will explicitly
check the result.
Use a wrapper around snprintf to consilidate all use, add
error checking, and remove gcc 9 warnings about not checking
the result.
Replace the prevous use of snprintf added to weapon.c with the
new scheme.
Update a second spot that has a gcc sprintf warning. While
there, simplify the code.
when taming is used to pacify hostile shopkeeper. I haven't
figured out how to reproduce and eliminate the double dismissal,
but this will prevent the second one from issuing duplicate "the
Kops (disappointed) vanish into thin air" and also from trigging
the warning "dmonsfree: N removed doesn't match 2N pending."
The first dismissal leaves defunct Kops on the monster list, as
expected; second dismissal found them still there and sent them
away again instead of skipping them as already gone.
Text windows only accept a few keys (<escape>, <return>, ':', now
<space>) and if they got other keys they passed those up the call
chain, arriving at the map where they were treated as commands
and were executed while the text window was still displayed. The
cited example was ',' for pickup while the "things that are here"
popup was shown. The 'foreign' key's command might be executed
successfully but the undismissed popup could become hung.
This fixes that ('foreign' keys will be ignored). It also lets
<space> be used to dismiss text windows.
Slightly better but far from perfect: if you perform a search,
then after it runs you need to type <escape> once, or <return>
or <space> twice, or else search again and pick [done] on the
search popup and then <return> or <space> once, to dismiss a
text window via keyboard. (Prior to this, typing <escape> or
searching again and picking [done] followed by <return> were the
only ways.) Also, searching for an empty string will now be
treated as if [done] had been picked.
Fixes#400
I have to manually uncompress save files before running nethack
under gdb control or they can't be opened. Normally that works ok,
but if the 'selectsaved' option is enabled, the code to look up
character names from their save files was mangling the file names
when stripping off the non-existent compression suffix, so couldn't
open them.
Dipping a unicorn horn to transform a potion causes that potion
to be removed from and re-inserted into inventory. If the hero
was above 'pickup_burden' threshold prior to dipping and
removing the old potion brought encumbrance back under that,
attempting to add the new one back would drop it instead of
re-exceeding the threshold.
After reading a passage from a novel,
[<title>, by Terry Pratchett]
gets added to message history. Change that to be
[<title>, by Terry Pratchett; passage #n]
to make tracking down the seemingly endless mistakes a tiny bit
easier.
uball->spe used to be used during restore way back in 2.3e.
There hasn't been any any point in setting it when starting
punishment and clearing it when ending punishment for decades
so get rid of that.
Nearly as ancient--but not quite--back in 3.10 patchlevel N,
obj->spe was set to -1 when the Amulet of Yendor was saved in
a bones file. That was to flag it as fake, before the cheap
plastic imitation got added as a separate object.
So obj->spe isn't "special for uball and amulet" any more.
The inclusion shouldn't really come before *conf.h because the
things it sets up could depend on those. This is better, but
having Amiga 90% dead and 10% comatose seems to be more trouble
that it's worth.
Fix the popup versions of qt_yn_function() to handle control
characters by using the same key press event decoding routine
and menus and extended commands. Moves 'keyValue()' to
qt_key.cpp and its declaration to qt_key.h, requring several
files to start using #include "qt_key.h".
'make depend' update to follow.
The gone but still referenced state of amiconf.h broke 'make depend'.
Fixing that turns it into a comment in the generated dependencies
but that ran into a problem with it being followed by fnamesiz.h
instead of being last in the list containing it. So in addition to
the depend fix, move #include "fnamesiz.h" from config.h to global.h
in order to have it come before amiconf.h.
I noticed that the & command was claiming that ^A is an unknown
command. Unlike the old static version, or the replaced-before-
ever-released conditional version, the fully dynamic variation
of '&' didn't know about any of the special commands: prefix
letters, ESC, and ^A.
I can't take credit for this and still have no idea why it is
needed, but it fixes use of ^V as a command and as input to
to the regular version of yn_function(). In particular, '&'
command reports it as ^V. Unfortunately when 'popup_dialog' is
set, no control characters seem to be accepted by the part of
NetHackQtYnDialog(Exec+KeyPressEvent) responsible for arbitrary
input.
It also causes getlin() to terminate but I can't think of any
situation where ^V would be considered to be valid input for
getlin() so won't worry about that.
I put it in as '#if MACOSX' because I don't know whether any
other Qt platforms need it.
Started out adding spe==2 for eggs but ended up changing other
things too.
FIXME? The line "special for uball and amulet" baffles me:
uball->spe is set to 1 during punishment (with an ambiguous
comment "special ball (see save)"), and back to 0 afterwards, but
otherwise seems to be unused.
"and amulet" is ambiguous; it should either be "and the Amulet"
or "and amulets". I assume it probably referred to the former but
it doesn't seem to be used for either kind as far as I can tell.
Because landing_spot will select a square containing a boulder as a
last-resort option, provided no other squares are accessible, it is
possible for the player to maneuver into a place where this could be
exploited when completing Sokoban (e.g. to get into a corner that would
normally be inaccessible, from which position an otherwise-blocked
boulder can be pushed away). This behavior should incur the same penalty
as exploitation of other Sokoban 'loopholes'.
Dismounting a steed checked whether the target spot was accessible and
whether there was a monster on it, but not whether it could actually be
accessed by the hero through normal movement. As a result, dismounting
allowed the hero to pass between diagonal gaps that would normally cause
a "you are carrying too much to get through" pline; this could leave
them in a position where they are effectively stuck, unable to remount
their steed or move away without dropping their inventory.
This also could be abused by dismounting in Sokoban to squeeze between
boulders in a way that would normally be impossible.
Using a successful result test_move as one of the requirements for a
spot to be valid prevents this and limits valid dismount targets to
squares that would normally be accessible through standard movement.
This replaces the arcane system previously used by getobj where the
caller would pass in a "string" whose characters were object class
numbers, with the first up to four characters being special constants
that effectively acted as flags and had to be in a certain order.
Because there are many places where getobj must behave more granularly
than just object class filtering, this was supplemented by over a
hundred lines enumerating all these special cases and "ugly checks", as
well as other ugly code spread around in getobj callers that formatted
the "string".
Now, getobj callers pass in a callback which will return one of five
possible values for any given object in the player's inventory. The
logic of determining the eligibility of a given object is handled in the
caller, which greatly simplifies the code and makes it clearer to read.
Particularly since there's no real need to cram everything into one if
statement.
This is related to pull request #77 by FIQ; it's largely a
reimplementation of its callbacks system, without doing a bigger than
necessary refactor of getobj or adding the ability to select a
floor/trap/dungeon feature with getobj. Differences in implementation
are mostly minor:
- using enum constants for returns instead of magic numbers
- 5 possible return values for callbacks instead of 3, due to trying to
make it behave exactly as it did previously. PR #77 would sometimes
outright exclude objects because it lacked semantics for invalid
objects that should be selectable anyway, or give slightly different
messages.
- passing a bitmask of flags to getobj rather than booleans (easier to
add more flags later - such as FIQ's "allow floor features" flag, if
that becomes desirable)
- renaming some of getobj's variables to clearer versions
- naming all callbacks consistently with "_ok"
- generally more comments explaining things
The callbacks use the same logic from getobj_obj_exclude,
getobj_obj_exclude_too and getobj_obj_acceptable_unlisted (and in a few
cases, from special cases still within getobj). In a number of them, I
added comments suggesting possible further refinements to what is and
isn't eligible (e.g. should a bullwhip really be presented as a
candidate for readying a thrown weapon?)
This also removed ALLOW_COUNT and ALLOW_NONE, relics of the old system,
and moved ALLOW_ALL's definition into detect.c which is the only place
it's used now (unrelated to getobj). The ALLOW_ALL functionality still
exists as the GETOBJ_PROMPT flag, because its main use is to force
getobj to prompt for input even if nothing is valid.
I did not refactor ggetobj() as part of this change.
Document m\ and m`.
Several years ago there was a suggestion--aka complaint--that
"menustyle:Traditional was the only alternative for early versions"
was too vague and requested that the version be included. It was
probably accurate at the time it was included, but I've changed it
from "early versions" to "very early versions" now. :-}
Redo the fake ESC handling for curses' wgetnstr() so that it
applies to all popup prompts rather than just to "Who are you?",
in case the player sets the 'popup_dialog' option.
Land mine explosions did not call liquid_flow(dig.c), and as a result
the pit created by an exploding land mine would never fill with adjacent
water or lava, as pits created by other sources -- digging, breaking a
wand, and earthquake -- can do.
This commit adds the appropriate calls to liquid_flow and fillholetyp to
blow_up_landmine so that land mine explosions may fill with water like
other pits do.
The call to losehp in dotrap had to be moved from after to before
blow_up_landmine, since waiting to call losehp when the pit can fill
with water could lead to silly messages (``That was a close one. You
die...''). After this change, a land mine that killed a character would
be retained unexploded in a bones file, because death would occur before
the call to blow_up_landmine. To avoid this issue, the land mine is
converted to a pit before calling losehp; blow_up_landmine does not
check whether the target trap is in fact a landmine so works as usual
even if the trap is converted to a pit, and will delete the pit in cases
where it should not exist.
Move the check for monsters that want to stay away from hero
due to having a ranged attack into a separate function.
Add monsters with polearms and breath attacks to it.
Monsters with breath attacks stay away only if they haven't
used their breath recently, or if they are injured.
further adjustments to the window port interface to pass a pointer
to a glyph_info struct which describes not just the glyph number
itself, but also the ttychar, the color, the glyphflags, and the
symset index.
This affects two existing window port calls that get passed glyphs
and does the parameter consistently for both of them using the
glyph_info struct pointer:
print_glyph()
add_menu().
The recently added glyphmod parameter is now unnecessary and has been
removed.
Noticed when implementing restore-via-menu for curses a couple
of days ago: The "Who are you?" prompt wouldn't let me cancel
out via <escape>. I created a character named '\033' which was
displayed as "^[" during play and produced a save file shown by
'ls' as "501?.Z".
To fix this properly, we will need to replace use of wgetnstr()
with something of our own. That's more work than I feel like
tackling. This fakes ESC handling if the player is willing to
type <escape><return> rather than just <escape> when terminating
the prompt.
Update makdefs source and its man page.
Remove all mentions of the vision table files from:
o .gitattributes
o .gitignore
o Files
o Cross-compiling
Add a brief note in the fixes file.
Provide a reasonably straightforward way to leave lua alone when
changing git branches (which I precede with 'make spotless').
make clean-keep-lib
and
make spotless-keep-lib
are new alternate forms of top level 'make clean' and 'make spotless'
that won't touch lib/lua/.
Clone the tty SELECTSAVED code in curses. If you would be getting
the "who are you?" prompt (perhaps via 'nethack -u player') and
you have at least one save file, you'll get a menu of save files
(plus entries for 'new game' and 'quit') to choose from. Requires
'#define SELECTDSAVED' at build time (only ntconf.h does that by
default) and when present, can be disabled by setting 'selectsaved'
to False in NETHACKOPTIONS or .nethackrc.
Another one from several years ago. Document 'pickup_types:.'
as a way to set pickup_types to a value that won't ever cause
anything to be picked up, in order to leave all autopickup
decisions to player's autopickup exceptions.
Actually implementing pickup_types:none would require just as
much documentation plus extra code.
Reported by a beta tester four years ago: if you telepathically
observed a pet eat a mimic corpse and temporarily change shape,
you were told that you sensed it happening but the map continued
to show its true form (because telepathy overrides mimicking).
Attempting to force the map to show the alternate shape in that
situation was hopeless, so give an alternate message instead.
While trying to fix this, I noticed my dog mimicking a throne
several times. The list of alternate shapes for quickmimic
included SINK which happens to have the same value as S_throne.
Change that to S_sink.