Commit Graph

1167 Commits

Author SHA1 Message Date
nhmall
c3b89f775e Merge branch 'NetHack-3.6.2' 2019-03-21 18:18:34 -04:00
PatR
5efea7115a curses options and status groundwork
More groundwork for overhauling the status display for curses, plus
a few functional changes.  It was doing a full status update for
every changed field (except conditions), instead of waiting for a
flush directive after gathering multiple changes at a time.  Since
it already does gather every change, the fix to wait is trivial.

This decouples 'hitpointbar' from 'statushilites'.  When highlighting
is off, it uses inverse video only.  When on, it behaves as before:
using inverse video plus the most recent color used to highlight HP
(which can vary if that has rules to highlight changes or percentage
thresholds) but ignoring any HP attribute(s).  This also enables the
latent 'statuslines' option and changes 'windowborders' option from
being settable at startup only to changeable during play.

'statuslines' can have a value of 2 (the default) or 3 and applies to
'align_status:bottom' or 'top'; it's ignored for 'left' and 'right'.
At the moment, setting it to 3 only allows status condition overflow
to wrap from the end of line to 2 to the beginning of line 3, and if
window borders are drawn they'll clobber the last character on line 2
and first one on line 3.  There's no point in trying to fix that
because it will go away when the main status overhaul changes go in.
Condition wrapping for vertical orientation (left or right placement)
was already subject to the same phenomenon and will be superseded too.

This also changes the meaning of the 'windowborders' value so could
impact players using source from git (or possibly beta binaries for
Windows, but not for OSX where curses interface wasn't included).
Old:
 0 = unspecified, 1 = On, 2 = Off, 3 = Auto (On if display is big
     enough, Off otherwise; reevaluated after dynamic resizing);
 Unspecified got changed to 3 during curses windowing initialization.
New:
 0 = Off, 1 = On, 2 = Auto;
 0 gets changed to 2 for default value at start of options processing.
So old value of 2 is changing meaning and explicit old value of 3 is
becoming invalid.  Implicit 3 changes to default 2.  Explicit 3 could
be the subject of a fixup but there isn't much point since 2 can't
have a similar fix.  Users who are using old 2 or explicit 3 will need
to update their run-time config files.

This adds 'statuslines' to the Guidebook and moves some other recently
added documentation of curses options from among the general options
(section 9.4) to "Window Port Customization options" (section 9.5).
None of them have been added to dat/opthelp which seems to be missing
all the wincap options.

Originally I made a lot of changes (mostly moving C99 declarations to
start of their blocks) to the old '#if 0' code at end of cursstat.c,
but have tossed those, except for one subtle bug that assumed 'int'
and 'long' are the same size.
2019-03-21 14:33:39 -07:00
nhmall
5a7d780db6 Merge branch 'NetHack-3.6.2' 2019-03-20 09:28:48 -04:00
PatR
7049145712 curses update
Miscellaenous stuff either groundwork for or noticed while updating
curses status.  The status changes themselves need some more testing.
One or two of the comments refer to that revised status which hasn't
been checked in yet.
2019-03-18 15:08:01 -07:00
nhmall
d52ab63f33 Merge branch 'NetHack-3.6.2' 2019-03-15 20:57:59 -04:00
PatR
3d4164bcce curses STATUS_HILITES
Honor hilite_status rules specifying color even if curses-specific
option 'guicolor' is off.

Update status from scratch when 'O' is used to manipulate hilite_status
rules.
2019-03-15 01:12:59 -07:00
nhmall
fc9dde7ae1 Merge branch 'NetHack-3.6.2' 2019-03-13 20:21:56 -04:00
nhmall
963cb352bc Merge branch 'NetHack-3.6.2-beta01' of https://rodney.nethack.org:20040/git/NHsource into NetHack-3.6.2-beta01 2019-03-13 20:04:50 -04:00
nhmall
12aedbd60f Merge branch 'NetHack-3.6.2-beta01' of https://rodney.nethack.org:20040/git/NHsource into NetHack-3.6.2-beta01 2019-03-13 20:04:16 -04:00
nhmall
acc92bcacb yet more mingw w64 build
Fix:
../sys/winnt/nhraykey.c: In function 'CheckInput':
../sys/winnt/nhraykey.c:459:37: warning: type of 'mode' defaults to 'int' [-Wimplicit-int]
 int __declspec(dllexport) __stdcall CheckInput(hConIn, ir, count, numpad,
                                     ^~~~~~~~~~
2019-03-13 19:55:43 -04:00
PatR
ccd6d1407e curses: hilite_pet, hilite_pile without color
The curses interface was ignoring video attributes (bold, inverse, &c)
when color is toggled off or if built with TEXTCOLOR disabled.  Honor
attributes regardless of whether color is displayed.

Also, toggling 'hilite_pet' On during play wouldn't do anything if the
curses-specific 'petattr' option had been left as None.  (It worked as
intended if set in starting options.)
2019-03-13 16:50:56 -07:00
PatR
62a34040bd X11 graphical tombstone tweak
Add some bullet-proofing to the X11 graphical tombstone sanity check.
Probably not necessary but better safe than sorry.
2019-03-12 18:37:15 -07:00
nhmall
9604e50e3d more mingw 2019-03-12 21:30:22 -04:00
nhmall
fa186b49a1 Merge branch 'NetHack-3.6.2' 2019-03-12 21:18:46 -04:00
PatR
8e7fe38dae avoid crash for X11 tombstone
If nethack is built to use graphical tombstone but file rip.xpm is
missing from the playground, there would be a crash if the rip output
was shown.  My first attempt to fix it prevented the crash but didn't
display any tombstone, just the last couple of lines of output which
follow the tombstone.  This keeps that in case of some other Xpm
failure, but checks for rip.xpm via stdio and reverts to genl_outrip
for text tombstone if it can't be opened.
2019-03-12 13:31:00 -07:00
PatR
53777fa03a win/curses comment
Twice I've gone through the curses code to deal with CHAR_P, BOOLEAN_P,
and so forth.  Both times I eventually changed my mind.  This time I'm
just adding an explanatory comment instead.
2019-03-10 16:06:29 -07:00
PatR
683226c3c5 curses vs extended commands
Extend the earlier support for Delete/Rubout in getline() to the
text entry for extended commands.  In other words, treat <delete>
and <backspace> as synonyms in both places.

Some reformatting too, but only in a couple of the files.
2019-03-10 14:53:31 -07:00
nhmall
4f679352b7 Merge branch 'NetHack-3.6.2' 2019-02-27 08:20:38 -05:00
PatR
1a028d1197 curses run-time options
This started out as an attempt to document the curses options in the
Guidebook, but I didn't actually get that far.  Instead, integrate
the curses options better via more consistent WC/WC2 usage.  This
prevents 'guicolor' from showing up as a boolean option for non-curses
interface in curses+other binary.

For curses itself, let 'petattr' be set/reset via 'O'.  Also, accept
'Dim' as a possible pet highlight attribute since it already handles
all the other ordinary attributes.  I'm not sure what leftline and
rightline highlighting are supposed to do.  They were missing for
ncurses (or maybe they're misspelled for PDcurses?) but adding them
didn't produce any visible effect (using TERM=xterm-256color on OSX
with default font/character set).

Not addressed:
1) general confusion about compile-time vs run-time option filtering;
2) curses pet highlighting only works if 'color' option is enabled.
2019-02-26 15:16:42 -08:00
nhmall
99b965ddee Merge branch 'NetHack-3.6.2' 2019-02-20 08:54:52 -05:00
PatR
8b08378bf7 DECgraphics vs eight_bit_tty
The fuzzer likes to set options randomly; the combination of
DECgraphics symbol set (on a display capable of rendering it) plus
eight_bit_tty produces a bizarre map display.  Make DECgraphics
override eight_bit_tty rather than the other way around.
2019-02-19 18:25:02 -08:00
nhmall
30645bd075 Merge branch 'NetHack-3.6.2' 2019-02-16 14:22:28 -05:00
nhmall
d5d4aed4e1 NetHack Windows curses port build with Jan 2019 PDCurses update
Clear up some NetHack warnings with updated PDCurses by using
-DCHTYPE_32

..\win\curses\cursinvt.c(98): warning C4244: 'function': conversion from 'attr_t' to 'int', possible loss of data
..\win\curses\cursinvt.c(101): warning C4244: 'function': conversion from 'attr_t' to 'int', possible loss of data
..\win\curses\cursinvt.c(105): warning C4244: 'function': conversion from 'attr_t' to 'int', possible loss of data
2019-02-16 14:15:35 -05:00
nhmall
7d703fa978 Merge branch 'NetHack-3.6.2' 2019-02-10 00:08:07 -05:00
PatR
2d62513b1b minor nitpicks
A couple of trivial things I noticed while looking at status cleanup.
2019-02-09 15:33:16 -08:00
PatR
d80fd8a014 curses status cleanup
Stop the last of the memory leaks occuring during basic usage.
2019-02-09 15:30:53 -08:00
nhmall
0d63372a48 Merge branch 'NetHack-3.6.2' 2019-02-08 19:58:58 -05:00
nhmall
a3527e7eab fix some merge fallout from 3.6.2 curses changes 2019-02-08 19:54:09 -05:00
PatR
d4d7901eff more curses memory
Message history now cleaned up at game end.  Status window cleanup is
not taking place because the core is suppressing it #if STATUS_HILITES.
2019-02-08 16:51:33 -08:00
nhmall
988a6e8c6b Merge branch 'NetHack-3.6.2' 2019-02-08 19:03:39 -05:00
nhmall
abf87e30ca Merge branch 'NetHack-3.6.2' 2019-02-08 19:02:06 -05:00
PatR
f3072cdb43 curses: plug most memory leaks
This takes care of a lot of the leaked memory in the curses interface.
It still needs to free memory allocated for status fields when the
status window is destroyed at game end; likewise for message history
when the message window is destroyed.
2019-02-08 15:50:59 -08:00
PatR
e991dd1b0c curses: getline vs DEL, ESC
Support <delete> (aka <rubout>) during getline().  It doesn't actually
honor the current erase_char value set up for the terminal, just
treats DEL the same as ^H.  (The previous lack of support had nothing
to do with terminfo specifying ^H; the handling is hard-coded.)

tty treats escape while there's already some input as kill_char (erase
the input but get more from scratch) and returns ESC if there isn't.
curses was doing the first half but not the second, so not providing
any way to communicate "cancel" back to the core.  Fix is simple.

Other getline() bug fixes:
1] there was a wprintw("%*something") which was passing the value from
strlen (type 'size_t') to the "%*" argument (type 'int').  That's
always wrong (size_t is guaranteed to be unsigned) and could be severe
(if size_t is different width than int--as on current OSX systems--
depending upon the internals of argument passing).
2] strncpy() only supplies a terminating '\0' if the input is shorter
than the number of characters specified.

A lot of reformatting is warranted but I only did the getline routine
(manually, so might have missed stuff).
2019-02-08 14:54:40 -08:00
nhmall
88683be479 Merge branch 'NetHack-3.6.2' 2019-02-08 14:53:22 -05:00
PatR
1d5b59ab7e curses memory: 'anything identifier'
Three or four instances of one simple memory leak.  Allocating a union
'anything' to pass to add_menu(), then not doing anything with it.  The
value gets copied so there's no reason for the original to stick around.

[There are still lots of other memory leaks.]
2019-02-07 17:10:55 -08:00
nhmall
c2d3fb816a Merge branch 'NetHack-3.6.2' 2019-02-07 20:06:22 -05:00
PatR
19d737951e curses: change from malloc() to nethack's alloc()
There was no provision for malloc() potentially returning Null and it
wasn't integrated with nethack's MONITOR_HEAP.  'heaputil' shows that
the curses interface is leaking like a sieve.  If some things are
actually being allocated separately and then freed from within curses,
those need to be thoroughly documented and maybe switched back to
malloc().
2019-02-07 16:48:37 -08:00
PatR
b1de94f922 custompline(SUPPRESS_HISTORY,...) for curses
The curses interface already has a hack to keep 'Count: 12', 'Count:
123' intermediate multi-digit counts out of its message recall history
for ^P, but it was flushing real messages when getpos()'s 'autodescribe'
reported what the cursor moved over.  Overload the count hack to support
 putstr(WIN_MESSAGE, ATR_NOHISTORY, text)
(which is what custompline(SUPPRESS_HISTORY, ...) eventually calls).

The conditional logic for when to create the 'count_window' was pretty
convoluted.  This simplification has the same semantics but I don't
have PDCURSES to actually verify that.
2019-02-07 16:04:24 -08:00
nhmall
72226b4189 Merge branch 'NetHack-3.6.2' 2019-02-04 21:40:16 -05:00
PatR
a8a187f89b tty ^P recall for dolook/whatis feedback
Noticed while testing the history suppression:  if you have DECgraphics
enabled and look at a graphics character on the map, the topline shows
x      description of x
where 'x' is displayed as it appears on the map (line drawing char).
^P for msg_window:single knows about that and reproduces the effect if
you recall such a line.  But msg_window:full/combination/reverse didn't
know about that and dumped it as-is into text output, ending up with a
strange 8-bit character for 'x' instead of the line drawing one.

I think other rendering schemes will be unaffected by this.  It's just
duplicating what is done for msg_window:single.
2019-02-04 18:24:17 -08:00
nhmall
44e13885be Merge branch 'NetHack-3.6.2' 2019-02-04 20:08:30 -05:00
PatR
190c90e95e tty ^P message recall
Extend 'putstr(WIN_MESSAGE, attribute, string)'s attribute so that
'custompline(SUPPRESS_HISTORY, ...)' can work with ^P's message
history like DUMPLOG history, in order to keep autodescribe feedback
and intermediate prompts for multi-digit count ('Count: 12', 'Count:
123') prompts out of recall history.  The old autodescribe behavior
could easily push all real messages out of the recall buffer when
moving the cursor around for getpos, and the count behavior looked
silly for a four or five digit gold count if you set the msg_window
option to 'full' or 'combination' and viewed them all at once.

Other interfaces may want to follow suit, but this doesn't force them
to make any changes.  I added a hook for "urgent messages" that might
be rendered in bold or red or some such and/or override the use of
ESC at --More-- from suppressing further messages, but there aren't
any custompline(URGENT_MESSAGE, ...) calls (potentially "You die...",
for instance) to exercise it.  Other people have implemented similar
feature it different ways and I'm not sure whether this one is really
the way to go since the core needs to categorize each message that it
deems to be urgent.  MSG_TYPE:stop may be sufficent, although MSG_TYPE
matching can entail a lot of regexp execution overhead at run-time.
2019-02-04 16:46:04 -08:00
nhmall
05ec7f36a8 Merge branch 'NetHack-3.6.2' 2019-01-29 22:34:07 -05:00
PatR
37e5a9cad2 randrole() fix
Give all the calls to randrole() its new argument.
2019-01-29 17:14:55 -08:00
nhmall
b367b4e868 Merge branch 'NetHack-3.6.2' 2019-01-29 17:23:22 -05:00
nhmall
ccc14a038b more window port code uses of obj_to_glyph() 2019-01-29 17:21:55 -05:00
nhmall
f935331285 try fix for Qt4 using a core macro
../win/Qt4/qt4inv.cpp:41:26: error: macro "obj_to_glyph" requires 2 arguments, but only 1 given
  glyph=obj_to_glyph(nhobj);
                          ^
../win/Qt4/qt4inv.cpp: In member function ‘void nethack_qt4::NetHackQtInvUsageWindow::drawWorn(QPainter&, obj*, int, int, bool)’:
../win/Qt4/qt4inv.cpp:41:8: error: ‘obj_to_glyph’ was not declared in this scope
  glyph=obj_to_glyph(nhobj);
        ^
2019-01-29 17:07:00 -05:00
nhmall
97fdc3f3e4 build bits - mostly for Windows
Allow sys/share/random.c to be included in the build
always, even if USE_ISAAC64 is defined, by making most
of its contents conditional in that case.

That avoids Makefile tinkering when going back and
forth between USE_ISAAC64 and not during testing.
2019-01-29 11:31:41 -05:00
nhmall
fd410148c5 Merge branch 'NetHack-3.6.2' 2019-01-29 07:27:56 -05:00
nhmall
0a430cab11 every platform provides sys_random_seed() and SYS_RANDOM_SEED goes away 2019-01-28 10:32:57 +01:00