Commit Graph

8460 Commits

Author SHA1 Message Date
PatR
8d0edeb4ff curses+EDIT_GETLIN again
Turns the "fix" in commit 319dcf4746
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.
2019-06-28 17:00:20 -07:00
nhmall
7c7f29a2e3 build fix for Windows if pdcurses is included after recent changes
cursmain.o : error LNK2001: unresolved external symbol _erase_char
cursmesg.o : error LNK2001: unresolved external symbol _erase_char
cursmain.o : error LNK2001: unresolved external symbol _kill_char
cursmesg.o : error LNK2001: unresolved external symbol _kill_char
2019-06-28 18:59:06 -04:00
PatR
7013563415 ^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.)
2019-06-28 12:50:08 -07:00
PatR
bed5570e3b 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.
2019-06-28 12:28:40 -07:00
PatR
2145387ac8 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
9f6588af49 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.
2019-06-28 11:59:14 -07:00
PatR
119f0365f7 curses mouse_support bit for fixes36.3 2019-06-28 03:17:25 -07:00
PatR
80374d46b5 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 '+'.
2019-06-28 03:08:30 -07:00
nhmall
39eed81aa2 PDCurses behaves the same as ncurses 2019-06-27 23:22:34 -04:00
nhmall
bd2cd75f7a PDCurses requires PDC_NCMOUSE for compatibility with ncurses
The PDC_NCMOUSE has to be defined on the command line
or above the #include entries in win/curses/cursmisc.c.

This does the former command line change.
2019-06-27 23:12:06 -04:00
PatR
928534509f UNIX|VMS compile warning
So no one on Unix or Unix-like ever builds without tty support?

options.c:694:11: warning: unused variable 'opts' [-Wunused-variable]

Noticed when producing a curses-only binary to verify that erase_char
and kill_char weren't relying on tty being present.
2019-06-27 17:42:56 -07:00
PatR
df8eac79b5 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 ^[.
2019-06-27 17:18:07 -07:00
PatR
56387dccb6 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").
2019-06-27 15:02:49 -07:00
PatR
aada9e2706 mouse_support for win/curses using ncurses 2019-06-26 15:46:44 -07:00
PatR
fa4f9bb8ae 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.
2019-06-26 15:37:17 -07:00
PatR
54e2e71319 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.
2019-06-26 15:33:40 -07:00
PatR
88f19c57e4 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.

Also some formatting.
2019-06-25 11:02:07 -07:00
PatR
d0a32762ab keyhelp typo 2019-06-25 03:27:42 -07:00
PatR
4f0b1262c5 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.
2019-06-25 03:17:47 -07:00
PatR
3bd46a3536 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.
2019-06-25 02:30:27 -07:00
PatR
6506f769a6 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.
2019-06-24 19:28:50 -07:00
PatR
8a9c06f5c1 '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.
2019-06-24 18:54:38 -07:00
PatR
e3af33c9db 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.
2019-06-24 18:39:24 -07:00
PatR
cfc8599e69 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?]
2019-06-24 15:11:51 -07:00
Bart House
ed08938ada 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.
2019-06-23 21:39:22 -07:00
PatR
87be6fad43 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.
2019-06-23 18:48:13 -07:00
PatR
68d28bd748 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.
2019-06-23 17:27:15 -07:00
PatR
83410a3d4f \#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.
2019-06-23 11:31:21 -07:00
PatR
c968f03af3 makemon() and clone_mon()
Express the logic of various early returns more consistently.

clone_mon() wasn't handling mon->isminion correctly.  I'm not sure
whether it is actually possible to clone a minion (maybe after
polymorphing it into a gremlin or blue jelly?).  When it wasn't tame,
which is the case for every minion other than the guardian angel on
Astral, the emin structure wasn't being allocated for the clone but
its isminion flag was left set.

Also, clones inherited mon->mtrack[] so would unnecessarily avoid
moving onto spots the original had recently moved across.

Cloned pets are inheriting various pet-specific fields that they
probably should be starting with a clean slate on but I haven't made
any attempt to address that.
2019-06-22 13:47:35 -07:00
PatR
456996509b fix #H8922 - no "you finish eating" message
after being interrupted and then resuming.  Resuming a multi-turn
food when it only had one bite left was the culprit.
2019-06-22 13:03:50 -07:00
nhmall
eaa8c278c8 code in parse_conf_file() to trim trailing blanks/cr was missing them
Observed on a text file with crlf endings on Linux, where the
so-called blank lines weren't being ignored as they should
have been, despite there being a line to remove \r from the
end.

A pointer was being pre-decremented before the check for a
matching whitespace character.
2019-06-22 00:05:16 -04:00
PatR
2fe57af3f3 fix #H8833 - wishing for "<foo> amulet"
and receiving a random amulet instead of an "amulet of <foo>".
Although the failure to produce the 'right' amulet wasn't a regression
compared to earlier versions as the report indicated, supporting that
wish is straightforward.
2019-06-20 18:42:35 -07:00
PatR
2da552e22f fix #8924 - demonic bribery while hero is deaf
Even though it isn't using verbalize() to make a specific statement,
don't let a demon ask the hero for a bribe when the hero is deaf.

Also, give alternate setup messages in a couple of places where a
divine voice is overriding deafness.
2019-06-20 13:08:47 -07:00
PatR
05958e9b3a comment typo for "transient" 2019-06-20 10:59:48 -07:00
PatR
72afb0d4f6 muse wand/horn feedback for monst zapping at self
Recent commit 5d59b288c9 changed monster
zapping a fire horn at self to cure sliming to not use the wand-zap
feedback routine, but inadvertently did for zaps of wands of fire too.
Use the zap routine for wand and play-instrument routine for horn.
2019-06-20 10:54:59 -07:00
PatR
8bfe6f82f1 Re-do the formatting for help on menu control keys
and add the non-configurable keys:  space, return, and escape.
2019-06-20 02:26:48 -07:00
PatR
2a5080e6f9 update contact URL
Reviewing the help choices revealed an out of date one.
2019-06-20 01:24:10 -07:00
PatR
9f6588af49 curses text windows
Most of the entries for '?' looked awful because curses was using
((terminal_width / 2) - 2) for the window width ('- 2' was to make
for for a border around the popup window, regardless of what the
'windowborder' option was set to).  Splitting text that has been
manually formatted for 80 columns "worked" but looked bad when not
required.

Some of the help files are using 79 characters on a few lines,
producing wrapped text when displayed.  Those would look better if
limited them to 78 or if curses can be modified to suppress the
window border when the entire display is being covered by a popup.
2019-06-20 01:14:50 -07:00
PatR
3ea0cc1483 fuzzer tweak tweak
Recent fuzzer tweak had an unintended side-effect:  NUL character is
used to indicate a mouse click and we weren't setting up fake value
for one of those.  Go back to avoiding NUL when obtaining a random
value for user's keystroke.
2019-06-20 00:53:45 -07:00
PatR
1c03d09701 curses map window
tty ignores map column #0 (0-based index), like the core, and draws
the map in screen columns 1 (1-based index) through 79, leaving screen
column 80 blank.  curses was drawing all 80 map columns and since #0
was always unused, screen column 1 was blank and the map was shown in
2 through 80.  Change curses to work like tty.

This was too easy; there may be problems lurking.  One known issue: it
should be made smarter about when clipping/panning is necessary since
it thinks that a full 80 columns are needed but 79 suffice.
2019-06-18 03:52:28 -07:00
PatR
c9962c9d34 mkroom.h update
Give room type enums explicit values so that it is easier to find
them when searching by value rather than by name.

Also some reformatting.
2019-06-18 02:43:41 -07:00
PatR
7e1f020846 curing green slime bit
A recent change to make_slimed() overlooked a different recent change
in how mon->m_ap_type and youmonst.m_ap_type are referenced.  In this
case it had no impact; fix on general principles.
2019-06-18 02:39:45 -07:00
PatR
273662c58c monster overflow on Plane of Air
Make Air behave the same as Earth, Fire, and Water if monsters are
forced off the level for some reason.
2019-06-17 10:09:16 -07:00
PatR
24d6d6b070 fuzzer tweaks
Prevent the fuzzer from randomly toggling the 'silent' option.  If
you use the default value of True then this eliminates most--but not
all--of the beeping that happens when it is running.  I'm not sure
where the remaining beeps are coming from.

Modify the random keystroke selection to implement some bias towards
direction keys that I thought had already been there, plus a higher
chance to entering digits to initiate number responses.
2019-06-17 09:31:01 -07:00
PatR
820320ba55 EDIT_GETLIN when naming monsters and objects
Like #annotate, #name monster, #name individual object, and #name
object type are places where it makes some sense to have an existing
name be the default for the new name, in case taking off from the end
and/or adding to the end is more convenient than retyping everything.

When there is an existing name used as default, clearing that default
and hitting <return> is not enough to remove the name, you still need
to 'assign a new name' of <space> to do that.
2019-06-15 08:19:32 -07:00
PatR
747981d0c5 take two: tty bug with long 'autodescribe' text
Messages on tty which bypass message history weren't handling long
lines properly.  If the text wrapped to line 2, that continuation
portion was left on the screen after whatever operation that put it
here was finished.  (To reproduce:  assign a long name to a monster
with a long type name so that the combined length exceeds the display
width, then move the cursor over it with ';' or '/' while autodescribe
is On.)

This time prompting isn't adversely affected.
2019-06-15 07:18:47 -07:00
PatR
9cbc8ace42 tty bug with multi-line prompts
This effectively reverts 1ad2415315
because it was interfering with prompts that spanned more than one
line (by inserting '--More-- + erase' between displaying of prompt and
getting input for the answer).

So we're back to the situation where autodescribe feedback when moving
the cursor will leave text on the second line if it generates text too
wide for one line.  (^R redraws the screen correctly.)
2019-06-15 05:11:08 -07:00
PatR
f0633e6541 EDIT_GETLIN vs monpolycontrol
For wizard mode 'monpolycontrol', the getlin() answer buffer for the
"Change <monster> @ <x,y> into what kind of monster?" prompt is also
used to format the coordinate portion of that prompt, so when
EDIT_GETLIN is enabled getlin() was inadvertently given "<x,y>" to use
as default response.  Clear it after the prompt is formatted instead
of via an initializer.  Also, shorten the prompt on the first try:
"Change <monster> @ <x,y> into what?", expanding to the old prompt if
retry is needed.

This also allows specifying 'chameleon' when <monster> is a chameleon,
'doppelganger' when it's a doppelganger, and 'sandestin' when it's one
of those (but not 'doppelganger' when it's a chameleon or sandestin,
and so forth), instead of blanket refusal to accept any non-vampire
shapechanger as the choice.
2019-06-15 04:13:34 -07:00
PatR
a336caf461 do_mname bit
Couple of tweaks I made to do_mname() while investigating the tty
autodescribe wrapping issue.
2019-06-12 18:04:00 -07:00
PatR
1ad2415315 tty bug with displaying long 'autodescribe' text
Messages on tty which bypass message history weren't handling long
lines properly.  If the text wrapped to line 2, that continuation
portion was left on the screen after whatever operation that put it
here was finished.  (To reproduce:  assign a long name to a monster
with a long type name so that the combined length exceeds the display
width, then move the cursor over it with ';' or '/' while autodescribe
is On.)
2019-06-12 17:57:24 -07:00
PatR
cf088d2126 mklev.c formatting and comments
I made these to 3.7.0- and decided to bring them back to 3.6.2+
because of the 'TODO'.
2019-06-11 18:54:32 -07:00