Bart House [Sun, 14 Jul 2019 07:20:09 +0000 (00:20 -0700)]
Fuzzer improvements.
phase_of_moon and friday_13th determined using rn2() instead of local
time if fuzzing. Don't reseed using init_random() if fuzzing. Allow
set_random to be called outside of hacklib. rn2_on_display_rng uses
rn2 if fuzzing so that we have a single source of random that we can
ensure is reproducible. Implement rul() that returns a random unsigned
long. Fix bug in fuzzer handling of ntposkey which would cause us to use
unitialized values for x and y. Added command line arguments to allow
auto starting and stopping of fuzzer. Add a logging facility for the
fuzzer to use to record activity. Added some scripts used to automate
fuzzer testing on windows.
Bart House [Sat, 13 Jul 2019 23:00:14 +0000 (16:00 -0700)]
Add stopping in the debugger when nhassert() is hit in the windows port.
When stopping in the debugger after having called impossible, the windowing
state will have been modified since the assertion was hit. This made
examining state that caused the nhassert to fire no longer possible.
To avoid this issue, we now detect the debugger and stop in the debugger
prior to impossible.
Bart House [Sat, 13 Jul 2019 22:57:06 +0000 (15:57 -0700)]
Re-worked tty_putmsgistory and tty_getmsghistory.
When we were saving message history as part of a game save for insurance,
we were calling remember_topl() and thus inappropriately changing topline
state. This would cause us to mis-manage the topline in subsequent calls
to update the topline.
The code has been re-worked to fix the issue, reduce complexity and make
the code clearer.
Bart House [Sat, 13 Jul 2019 17:53:53 +0000 (10:53 -0700)]
Removing assertion that does not hold under all scenarios.
When we save gamestate as part of making an insurance snapshot, we will
save message history which will clear toplines but leaving window state
in tack including the need for more.
Bart House [Fri, 12 Jul 2019 04:04:29 +0000 (21:04 -0700)]
Fixed bug with inmore and toplin state management.
When fuzzing, we would increment ttyDisplay->inmore but then prematurely
exit more() leaving ttyDisplay->inmore set.
Under various conditions, we can request to remember the topline when
the topline had not yet been acknowledged leaving toplin state in an
inappropriate state.
Bart House [Fri, 12 Jul 2019 03:46:19 +0000 (20:46 -0700)]
Remove the remapping of snprintf to _snprintf when compiling with MSC.
_snprintf and snprintf have one very important semantic difference.
_snprintf does NOT add terminating null character when the buffer limit
is reached while snprintf guarantees a terminating null character. It
was a mistake to make this naming change hiding the fact that the
semantics don't match what the developer might expect.
I moved some stuff around after testing the changes in 58583cacf8511625fd805ecbb050481f28de9411 before committing it. It
accidentally ended up with 'gold' always being Null at the first
place it gets used (to vary the feedback when stealing everything
except gold).
Nymphs won't steal gold from the hero (so that their steal-item damage
isn't a superset of lerprechaun's steal-gold damage; straightforward
back when gold wasn't kept in inventory), but hero poly'd into a nymph
would steal gold from monsters.
3.6.2's attempts to fix turning off SEDUCE in 'sysconf' introduced
an unintentional change in behavior for hero poly'd into nymph form:
theft attack always angered the target. The actual change was
intentional but its ramifications were unexpected.
Asking curses to report whether the Ctrl key was being pressed during
a mouse click was sending mouse position reports--even those aren't
being requested--and actual Ctrl+Left_click was reporting a pair of
duplicate Ctrl+Mouse_position_report events when a click was actually
performed. So turn off Ctrl key reporting.
Mac with one-button mouse can be configured to send "secondary click"
for Ctrl+Click. A laptop trackpad handles that differently (press the
button while two fingers are on the touchpad to send secondary click)
and doesn't support Ctrl+Click as an alternate way to do that. If this
would work within curses then they could operate the same regardless
of how the user set the mouse or trackpad configuraiton. But I wasn't
able to make it work right.
The Guidebook claims that there's no symbol for 'S_strange_object'
which is literally true, but there is one for S_strange_obj. It has
been in place longer than the paragraph claiming that there's no way
to customize that symbol. I'm not sure why variant spelling was used.
Also, files.c doesn't use loadsyms[], it calls a routine which returns
a pointer to a specific element in that array.
would describe it as trapped if you could see its location, but if
the trap was unseen that trap would remain unseen, at least in some
circumstances. Mark the trap as seen.
Wizard mode ^E and any mode spell of detect unseen or wand of secret
door detection failed to find mon->mundetected monsters if they were
hiding under objects, and failed to find those or other hiders or
mimics when the hidden monster was at a trap location. The fix for
the latter initially only worked if the trap was known, so took two
tries when a monster hid at the location of an unseen trap. So this
makes the additional change to find both things at the same time; it
isn't manual searching that stops as soon as something is found.
Typing ^H actually passed a 16-bit value back to the core which got
interpreted as ^G after the extra bits were discarded. I don't think
any previous changes to the curses interface caused this. It's
astonishing that no one ever noticed; the world must be full of numpad
users.
Bart House [Sat, 6 Jul 2019 21:18:02 +0000 (14:18 -0700)]
mklev() set xxstairs_room pointers back to NULL upon completion.
When mklev() is called multiple times, previous state stored in the
xxstairs_room pointers can be mistakenly used when making decisions about
the new level being constructed. This caused non-deterministic level
creation behavior when replaying from a snapshot.
With 'popup_dialog' On, a prompt which exactly fills the available
width would start the next line with a space (to separate the prompt
from user's answer) and then have the cursor waiting after it. That's
unlike other behavior in the curses interface where the line split
would be instead of the separating space rather than in addition to it.
Old:
|long prompt?|
| X__________|
New:
|long prompt?|
|X___________|
where the X represents the cursor sitting over the start of blank space
waiting for user's answer.
When swallowed, you can take things from the engulfer's inventory, if
there are any, via pickup. Items might be worn by the engulfer and
when "picked up" those weren't being unworn before being added to
hero's inventory. Then they would be formatted as "(being worn)" and
could trigger warnings or worse.
Conceptually they should be worn on the outside and not be accessible
from the inside, so I've made attempts to pick up worn items fail
rather than fix up the unwearing.
Using ':' when swallowed to look at the engulfer's inventory describes
that inventory as "contents of <mon>'s stomach". That's weird for any
worn items, but the situation is so rare I haven't made any attempt to
deal with it.
Rescue some old code from bit rot. It may be useful if the shop
side of things ever gets fixed. (Itemized billing reveals container
contents. I'm sure that it's in the bugzilla list but can't find it.)
Noticed after building a curses-only binary; configuration setting
"terminal info library" is only of interest as an optional feature
when the build includes tty. There were several other settings that
apply to some interfaces and not others but would be listed if the
feature was defined (possibly after building for an interface which
supported it, then left in place when switching to another which
doesn't).
I left most of those with commented out conditionals in case other
interfaces start supporting them. So you might still get something
like "tiles file in XPM format" for a binary that doesn't support
tiles if USE_XPM has been defined for some reason.
Bart House [Wed, 3 Jul 2019 02:08:50 +0000 (19:08 -0700)]
Fix crash that can occur in decode_mixed.
If a player names an object with a name that ends in '\\', drops
that object on the floor nearby and does a look at nearby objects,
then the game will crash. This is caused by stack corruption when
the decode loop skips over the decode string terminator.
Extend support for highlight rules that specify percentages from HP
and spell power to experience level and experience points. For both
of those, the percentage is based on progress from the start of the
current Xp level to the start of the next Xp level. 100% isn't
possible so is used to enable highlighting a special case: 1 point
shy of next level, most likely to occur after losing a level.
This is something I had in mind a long time ago and then forgot all
about until fiddling with the final disclosure of experience points
recently. It turned out to be trickier than expected because it needs
to check whether Xp should have a status update when it hasn't changed
but Exp has gone up. The latter might hit a percentage threshold that
switches to another highlight rule. Fortunately changes to Exp, at
least that aren't part of level gain or loss (which always trigger
status updating), are all funnelled through a single place (I hope).
Highlighting via attributes got broken three months ago. May or
may not have been noticeable depending upon which attributes are
supported. Too many variations of attribute designations...
PatR [Sun, 30 Jun 2019 20:45:14 +0000 (13:45 -0700)]
wishing vs EDIT_GETLIN
If you ask for help when wishing, don't leave "help" in the buffer
for EDIT_GETLIN to use as default answer on next retry. It does still
leave anything rejected as unknown so that the player has a change to
review the spelling and conceivably add and/or remove from the end
witout having to retype everything.
PatR [Sun, 30 Jun 2019 18:50:08 +0000 (11:50 -0700)]
curses message history vs dumplog message history
When I implemented getmsghistory()/putmsghistory() for curses I was
assuming that DUMPLOG would only be used with tty, but it is interface
neutral and can be used with curses (or others). So curses message
history needs to behave like tty message history and be sure to pass
along messages that bypass pline() and the normal message window.
(Mainly one-line summaries of long quest messages, but also old
messages fetched from a save file and available to be re-saved without
having been shown if new session doesn't generate enough new messages
to flush them.)
PatR [Sun, 30 Jun 2019 17:51:00 +0000 (10:51 -0700)]
attributes disclosure: experience points
Wizard mode shows the number of points needed to reach the next level
(unless already maxxed out at 30) for ^X and end of game disclosure.
Do it in normal play for the latter too. (I think it would ok to do
that for ^X too but haven't gone that far.)
Even when it was wizard mode only, the phrasing for past tense had a
minor grammar bug, and it could make the line a little too long for
tty and curses (not sure about others) when level was high, resulting
in wrapped text. That looked bad for tty, which first tries removing
indentation (just 1 space in this case), making that line outdented
as well as wrapped. So change the phrasing slightly when experience
level is 'too high'. I had a version which formatted, measured, and
re-formatted if necessary but that was overkill; simple hardcoded
rephrasing suffices particularly when measuring was against assumed
display width (80) rather than actual width.
nhmall [Sun, 30 Jun 2019 14:19:16 +0000 (10:19 -0400)]
TRAVIS CI updated to include Windows and osx testing
TRAVIS CI added Windows to their platform list in late 2018.
Update the .travis.yml file to include a pair of Windows in
machines in the testing suite, one built with visual studio
command line tools and the other with mingw gcc tools.
The visual studio build is currently using nmake with the
sys/winnt/Makefile.msc Makefile from our distribution,
That's the same process we've been using for building
our binaries, pretty much.
BRH may be able to modernize it over the next couple of
weeks to use the msbuild process instead.
I went with the HINTS environment variable on windows
for consistent self-documenting purposes, even though
the environment variable isn't used on windows.
included:
os: linux
Compiler: gcc C
HINTS=linux
os: linux
Compiler: clang C
HINTS=linux
os: linux
Compiler: gcc C
HINTS=linux-x11
os: linux
Compiler: gcc C
HINTS=linux-qt5
os: linux
Compiler: gcc C
HINTS=linux-minimal
os: windows
language: shell
HINTS=Windows-visual-studio
os: windows
HINTS=Windows-mingw
excluded:
os: osx
Compiler: clang
Xcode: xcode10.2 C
HINTS=macosx10.14
PatR [Sat, 29 Jun 2019 00:00:20 +0000 (17:00 -0700)]
curses+EDIT_GETLIN again
Turns the "fix" in commit 319dcf4746a81ef0ca413491bdf30b4c08f931c2
handled removing the default answer for single-line-prompt plus
multi-line-answer but not for multi-line-prompt plus long-enough-
answer-to-reach-another-line. The logic wasn't quite right and I
misunderstood what is stored in linestarts[] so even correct logic
wouldn't have solved things.
PatR [Fri, 28 Jun 2019 19:50:08 +0000 (12:50 -0700)]
^I vs perm_invent again
A recent fix for #wizidentify showing "Not carrying anything" after
listing inventory items still showed "Not carrying anything" after
"(all items are already identified)". Fix is easy.
Trickier bug was that ^I performs object ID on selected items while
the inventory routine is still in progress (but after it has processed
every item) and the ID routine will call update_inventory() which
will call the inventory routine to reformat invent. So the inventory
display routine was called recursively without having returned to
wizidentify where iflags.override_ID gets cleared to revert to normal
inventory. The nested call was unintentionally narrowing the contents
of persistent inventory window to whatever items were still unIDed.
(Any inventory update, including ^R, restored it to full inventory.)
PatR [Fri, 28 Jun 2019 19:28:40 +0000 (12:28 -0700)]
curses popup single char input
With 'popup_dialog' On, a one line popup with question and likely
responses and default answer was shown, but without having the
cursor displayed at the end of emphasize that it was waiting for an
answer. Make the popup be one character wider so that there is room
to show the cursor. No effect when 'popup_dialog' is Off and prompts
are shown at the bottom of the message window; those already have the
cursor sitting at the end.
PatR [Fri, 28 Jun 2019 18:59:14 +0000 (11:59 -0700)]
curses menu and text window size
Make final inventory disclosure use a full width menu instead of
the default 38-column width with lots of wrapping. Also, increase
that default from 38 to 40 for the rest of the time. Commit 9f6588af49766c00998291ff79735922199c8563 made the 38 vs 40 portion
matter much less but I decided to keep it in anyway.
When a menu or 'things that are here' popup has only a couple of
lines and they happen to be narrow, a sized-to-fit window isn't
always easy to spot when it is shown over the ends of old messages
rather than over the map, even with a border box around it. Give
such windows a minimum size of 5x25 so that they always stand out
enough to be immediately seen. This will cause more message text to
be rewritten occasionally (after dismissing the menu or text window)
but the curses interface seems to discount that as something to be
concerned about.
PatR [Fri, 28 Jun 2019 10:08:30 +0000 (03:08 -0700)]
Merge 'curses-mouse_support' into NetHack-3.6
Fully support the mouse_support option for curses, via 'O' as well as
via config file. At the moment, mouse_support:1 and mouse_support:2
are equivalent.
Also, fix the screen-to-map coordinate translation. When the mouse
is active and over the map, the pointer's cursor becomes a cross-hair
(may very by platform) and the character cell chosen for a click
seems to be a few pixels to the right of the center of the '+'.
PatR [Fri, 28 Jun 2019 00:18:07 +0000 (17:18 -0700)]
curses erase char and kill char
Support user's terminal settings for erase char and for kill char.
Erase char is typically <delete> or <backspace>, both of which are
already explicitly handled so probably no effect there. Kill char
(generally ^U these days) will be honored unless it is a printable
character (don't know whether there are any troglodytes out there
who still use '@' for that...). The current handling for ESC works
the same if there is any input to kill, but yields 'cancelled' when
there isn't.
That's for message window getline(), which operates char-by-char.
The popup getline() uses a curses routine to get an entire string
and already honors kill char but treats ESC as input of ^[.
PatR [Thu, 27 Jun 2019 22:02:49 +0000 (15:02 -0700)]
curses mouse right-click
Right button is button3 rather than button2. Accept either and treat
both as "not left" to pass CLICK_2 back to the core.
Treat <Ctrl>+left-click as "not left" too, to simplify usage with Mac
one-button mouse (where <Ctrl>+left-click can be configured to send
"secondary click" but might not be set do so) or one-button laptop
trackpad (where having two fingers on the scrolling portion of the pad
while clicking the button is necessary to send "secondary click").
PatR [Wed, 26 Jun 2019 22:37:17 +0000 (15:37 -0700)]
coalescing partly eaten globs
Another one which has been around for a while. When merging two
globs, the result is partly eaten if either (or both) of them was
partly eaten, not just when the one that's going to stick around as
the combined glob already was.
PatR [Wed, 26 Jun 2019 22:33:40 +0000 (15:33 -0700)]
mpickobj sanity, ball&chain theft feedback
Something I've had sitting around for quite a while. Add a sanity
check to mpickobj(). (It will need tweaking if b&c are changed to be
in engulfer's inventory.)
Also, include more information in the feedback when a nymph steals
attached iron ball: "Nymph removed your chain and stole a heavy iron
ball".
And don't set the avenge-ok flag if uball is the item stolen since
thief was doing hero a favor, or for anything when the thief is under
the influence of Conflict.
PatR [Tue, 25 Jun 2019 18:02:07 +0000 (11:02 -0700)]
ball&chain bit
A check for bad restoration (ball without chain or vice versa) issued
a warning but then left the problem around to trip up other code.
'Fix' the problem by clearing those owornmask slots and their pointers.
Doesn't try to recover memory if the one that's found is OBJ_FREE.
PatR [Tue, 25 Jun 2019 10:17:47 +0000 (03:17 -0700)]
curses clipped map 'scrollbars'
The position bars shown by curses when the map is clipped weren't
being drawn as intended (integer arithmetic). Changing parentheses
was enough to get it working, but it didn't handle the edge case
where non-zero got rounded to 0 (so when map was panned down, the
uppermost character of the vertical position bar still showed '*',
falsely indicating that top of map was currently within view.
PatR [Tue, 25 Jun 2019 09:30:27 +0000 (02:30 -0700)]
curses cursor
Followup to 1c03d0970115c776d1c4791fea3c33f70b0b5378; that had been
too easy. When map was clipped and panned to the side, the highlight
for hero's spot was shown next to the '@' instead of on it.
PatR [Tue, 25 Jun 2019 02:28:50 +0000 (19:28 -0700)]
fix #H7840 - curses ':' menu search+toggle
Using ':' to have search string matching toggle items chosen for
selection would show selection highlighting on the current page for
items matched off-page.
PatR [Tue, 25 Jun 2019 01:54:38 +0000 (18:54 -0700)]
'sortpack' vs 'perm_invent'
The persistent inventory window wasn't being updated if you toggled
the 'sortpack' option interactively. (The new setting was honored
once something else triggered a 'perm_invent' update.)
The logic for toggling 'fixinv' seemed backwards. I hope this "fix"
for that hasn't actually broken it.
PatR [Tue, 25 Jun 2019 01:39:24 +0000 (18:39 -0700)]
curses 'perm_invent' fixes
I noticed the wrapping issue while testing out the 'bad fruit' fix,
then the other things while fixing it.
1) inventory entries too wide for narrow persistent inventory window
wrapped without any control; normally can't be seen except for the
last entry when the list is short enough to leave at least one line
available; it looked fairly reasonable with window borders Off, but
when On the last char of the first line and first char of second
line were clobbered by the border box;
2) when there were too many entries to fit within the height, those
after the last one which fit were appended to it for borders Off
(or written on bottom line and then overwritten by the border box
for borders On); noticed because the selector letter is highlighted
with inverse video, even when written at an unexpected place;
3) suppress the inverse video hightlighting of inventory letters since
they can't be selected from that 'menu';
4) for borders Off, the top line was left blank as if a border was
going to be drawn there;
5) since the entries are truncated due to the narrow window (on a
modest sized display), strip off leading "a", "an", or "the" prefix
for inventory entries (written to curses perm_invent window only);
lets a couple more characters of more interesting stuff be seen.
PatR [Mon, 24 Jun 2019 22:11:51 +0000 (15:11 -0700)]
fix "Bad fruit #N" warnings when saving bones
savebones() sets all the fruit indices negative, then resets to the
normal positive value for each fruit it actually writes into the bones
file. But if 'perm_invent' is enabled and something triggers an
update_inventory() while bones saving is in progress, object formatting
for the inventory display won't be able to find any fruits, resulting
in impossible "Bad fruit #N". Fix is to turn off 'perm_invent' when
the game ends, so it won't be On when bones are written. Disclosure
uses a popup for inventory so persistent window is obsolete by then
anyway.
[I don't know what is triggering update_inventory() while savebones()
is executing. Also, I don't see where the fruits whose index stayed
negative--because there aren't any on level being saved--get purged.
Maybe when those bones are loaded by another game?]
Bart House [Mon, 24 Jun 2019 04:39:22 +0000 (21:39 -0700)]
Fix dangling chain bug.
If a punished player picks up the iron ball, gets engulfed and
saves, then the saved game will have missed saving the dangling
chain since it was not on the floor or in the inventory. Upon
restoring the saved game, the game will be in a bad state since
the ball will be worn but the chain will be missing.
PatR [Mon, 24 Jun 2019 01:48:13 +0000 (18:48 -0700)]
worm segment placement
random_dir() for picking a spot to put a segment of a long worm's tail
(when it is being placed on the map, perhaps after teleport, not when
movement allows it to grow) had mistakes in three of the four compass
directions. The one for the top of the map was benign; it just
neglected to use the top row (#0). But it could pick a value off the
edge of the map for bottom and right or both.
This doesn't explain a couple of long worm [segment] oddities on the
Astral level because that level doesn't go all the way to the edge.
PatR [Mon, 24 Jun 2019 00:27:15 +0000 (17:27 -0700)]
level overcrowding tweaks
A couple changes dealing with overcrowded levels. So many monsters
are moving from the Plane of Water to the Astral Plane that the
latter can start out completely full.
Give monsters who trigger the endgame portals a 6/7 chance to not go
through ('home' elementals or any monster carrying the Amulet already
wouldn't go through). They should learn about magic portal trap in
the process and not voluntarily step on that afterward.
When the Wizard or other covetous monster tries to teleport next to
the hero and fails, he was being sent to limbo. There's no need for
that; he's already on the map and can just stay where he is. That
doesn't actually help with the endgame population issue, it just
fixes a couple of uses of mnearto().
I have significant changes for mnearto() and elemental_clog() that
also help with this but will test those more before committing.
PatR [Sun, 23 Jun 2019 18:31:21 +0000 (11:31 -0700)]
\#wizidentify bug - 'Not carrying anything.'
when carrying things. The fuzzer toggled on 'perm_invent' and after
interrupting it I used ^I. Having 'perm_invent' enabled makes the
inventory code avoid having a totally empty inventory display (by
supplying "Not carrying anything" instead--in the menu rather than
via normal pline) so that interface code will see a change and know
that an update is needed. But to decide whether the menu was empty,
the inventory code was testing union 'any' field 'a_char' to check
whether some item had used the union (implying that something had
been passed to add_menu()), but wizidentify (^I) uses field 'a_obj'
instead. Apparently the a_char bits stayed 0 because the menu ended
up with "Not carrying anything" after a list of inventory items.
Switch to a separate variable to track whether anything has been put
into the menu instead of trying to rely on the union.
Unrelated but noticed when checking other "Not carrying anything"
instances, the #adjust command ends early when there's no inventory
but it was asking for a letter to adjust even when the only thing in
inventory was gold in '$' slot, which isn't allowed to be adjusted
away from that slot. Treat gold-only like no-invent.