PatR [Tue, 22 May 2018 17:40:55 +0000 (10:40 -0700)]
hilite_status, what else?
While deciding which highlights to apply, give 'percentage' and/or
'absolute' rules that match precedence over 'always' rules regardless
of order within the config settings.
When using 'O' to add 'up/down/changed' rule, don't include 'down'
as a choice for field 'time'.
When using 'O' to add rules, don't squeeze out spaces if adding a
'textmatch' rule for title (to support "field worker", "high priest",
"student of stones", and so forth).
While deciding which highlights to apply, ignore double quotes when
testing whether a 'textmatch' rule matches the current text of a
field. This allows rules to specify string values as '"value"'
instead of just 'value'. It not does validate them to ensure quotes
are paired at beginning and end, it just ignores them. New rules
created via 'O' for rank title include them when displaying what the
new rule would look like as a config file option. Other text fields
haven't been changed to show quotes but ignoring such applies to all
'textmatch' comparisons.
Expand the menu for adding 'textmatch' rules for title. When a rank
has separate male and female titles, list three entries instead of
just one
"male rank"
"female rank"
"male rank" or "female rank"
(the order of the first two entries and of the two titles in the
third entry is reversed if the current character is female). If the
user picks the third entry, two rules are added instead of just one,
identical to each other except for the text to match.
Further expand that menu with
"none of the above (polymorphed)"
at the end. When deciding which highlights to apply, "none of the
above" and "(polymorphed)" and the full string are treated as
equivalent (with spaces, quotes, and parentheses ignored). Rather
than comparing anything against the title text, it matches if the
hero is polymorphed (where title will be "<hero> the <monster-type>"
instead of "<hero> the <rank>"). Note that the user can have config
file 'textmatch' rules for title to match specific "<monster-type>"
values but the 'O' menu doesn't offer any opportunity for that.
(I've just realized that rules for specific monster types should be
given precedence over "none of the above" but at present that isn't
done; the order of the rules will determine which wins out.)
PatR [Tue, 22 May 2018 09:42:08 +0000 (02:42 -0700)]
hilite_status string comparison
Simplify the string comparison done when checking 'textmatch' rules
to decide whether to highlight something.
Fix the menu titles when setting up a textmatch via 'O': the title
for color referred to attribute and the one for attribute used the
default. The two tiles are set up in advance; the one for color was
set correctly but then the one for attribute was written into the
wrong buffer.
When using 'O' to manipulate hilite_status rules, if there are any
when you're done and the 'statushilites' option (iflags.hilite_delta)
is 0, give a message reminding that it needs to be non-zero for
highlighting to be activated.
PatR [Tue, 22 May 2018 02:11:18 +0000 (19:11 -0700)]
status_hilite: no more ANY_UINT
The fact that the index to the array of hunger strings is an unsigned
field in 'struct you' is unimportant as far as its usage for status
highlighting. Since it is the only ANY_UINT field, change BL_HUNGER
to plain 'int' so that there'll be no need for ANY_UINT handling.
And some more validation when setting up highlight rules. For 'O',
in the menu to choose a relationship after supplying a number N,
don't include "less than N" and "N or less" for percentage or
absolute--other than AC--unless N is greater than 0, and don't
include "N or more" and "more than N" for percentage unless N < 100.
Also, when 'O' prompted for a number, if you entered <X or =X (for X
not a sequence of digits), it remembered the '<' or '=' (or '>=', &c)
when reprompting for a valid number. If the 'X' portion is invalid,
discard the relationship operator before asking for another number.
PatR [Mon, 21 May 2018 12:58:01 +0000 (05:58 -0700)]
hilite_status support for <=, >=, explicit =
Add threshold relationships <= and >= so that the change to make <
and > perform their expected comparison can be resolved. "Point
release shouldn't force players to update their config files" does
not carry sufficient weight given that they already had to do that
to turn on status highlighting when going from 3.6.0 to 3.6.1. The
3.6.2 release notes can warn them about the need to update their
status highlight options if they're currently using '<' and/or '>'.
Entering new hilite rules via the 'O' command accepted '=' prefix
for numbers, but rules from config files did not. Now they do.
The '=' prefix is optional in both situations.
With 'O', percent rules and absolute rules had separate menu entries
so picking one was already choosing the rule type, but entering a
numeric value without percent sign (for percent) or with one (for
absolute) would change the type on the fly. If someone has already
picked percentage they shouldn't be required to append '%' to the
digits, so that is now optional. If explicitly included with the
number after having picked absolute, the value is rejected. It is
trivial to back up in those menus and choose the alternate type if
someone changes his/her mind part way through.
If a status field has both persistent (percent, absolute, always)
and temporary highlights (up, down, changed), give the temporary one
precedence when the value has changed. To do that with 3.6.1, the
rules for temporary had to follow the ones for persistent highlights
since whichever matched last was the one used. Now their order
relative to each other doesn't matter. If a value increases and
there is both an 'up' rule and a 'changed' rule, the more specific
'up' takes precedence, regardless of their relative order; likewise
for decreases and 'down' vs 'changed'.
There were a couple more tweaks needed to support negative values;
I overlooked the 'O' menu handling before. >-1% and <101% now work
for both the config file and interactive adding via 'O' methods of
defining highlight rules, although new >=0% and <=100% will be
clearer to anyone examining a rule set.
'enum relationship' was forcing LT_VALUE to be -1 but that fact was
never utilized anywhere, and the code was using magic number -2 to
mean "no relationship yet". This adds NO_LTEQGT to replace the
latter and gives it value -1. EQ_VALUE is still 0 so effectively
the default if a highlight hasn't been fully set up yet. LT_VALUE
is now just another positive value along with GT_VALUE, LE_VALUE, &c.
The Guidebook hasn't caught up with the code yet.
The rule choosing code used when deciding how to highlight something
only supports 'int' fields and relies on 'long' having the same bits.
It needs to be extended to support 'long' properly. Fixing should
be straightforward (except maybe for the initialization of min/max
best fit handling) but this doesn't address that. Also, data type
for encumbrance/carrying-capacity should be changed from unsigned to
plain int so that no extra handling for just one field will be needed.
PatR [Sun, 20 May 2018 08:20:51 +0000 (01:20 -0700)]
more status_hilite threshold handling
Negative AC needed one extra change to support >-N since there was
a place in the code that assumed 0 was the lowest possible value.
(My earlier testing was with <-N which didn't have that issue.)
Make '/<N/' work as 'val < N' instead of 'val <= N', and />N/ work
as 'val > N' instead of >=. The <= and >= behavior might have been
intentional but the only support for that I could find was that
the 'O' menu used "N or less" for '<' and "N or more" for '>' when
setting up 'absolute' rules. If we actually want <= and >= (and we
probably do...), we should add them as more relationship operators
instead of misusing < and >.
Simplify the is_ltgt_percentnumber() case when parsing options
since input has been fully validated by the point that that test
passes. Among other things, /<-0/ and />-0' are now accepted (as
synonums for 0; -0 doesn't mean anything special) instead of being
silently rejected and then discarding the rest of the config file.
(That bad behavior is a separate issue not dealt with here.)
PatR [Sat, 19 May 2018 22:46:09 +0000 (15:46 -0700)]
fix #H7155 - polearm can reveal hidden monster
The code to choose a likely target when applying a polearm was
basing its decision on visible spots which contained monsters,
so could expose the location of a hidden monster if there was
only one such spot within polearm range. Not mentioned in the
report: it also wouldn't pick remembered, unseen monster unless
there was a monster still at that spot.
I've changed it to choose candidate location based on the glyphs
shown rather than on the presence of monsters.
PatR [Sat, 19 May 2018 18:47:15 +0000 (11:47 -0700)]
fix #H7159 - orc hero can start with lembas wafers
Orc heroes get an extra food item ("to compensate for generally
inferior equipment") and it could randomly be lembas wafers (or
cram rations), and Ranger heroes always started with cram rations
even when they're orcs. Fixing the latter was simple, but the
normal race-based substitutions weren't applied to randomly
generated items, so the fix for the former required a bit of code
reorganization in ini_inv().
Elf heroes already get lembas instead of cram; do the reverse for
dwarves (although I don't think this case can happen--no role gets
lembas wafers and only orcs and always-human tourists get random
food); give orc heroes tripe instead of either lembas or cram.
PatR [Sat, 19 May 2018 11:19:18 +0000 (04:19 -0700)]
fix some of #H7156 - perm_invent issues
> [1. perm_invent is kept in flags so persists across save/restore, but
> perm_invent capability can change if player restores with a different
> interface--or same one running on a different-sized display--so it
> ought to be in iflags instead.]
Not addressed here.
> 2. perm_invent window does not get updated when charging a wand (or
> other chargeable item presumably), with a scroll of charging.
Most scrolls rely on useup() -> update_inventory(), but charging uses up
the scroll early so that it will be gone from inventory when choosing an
item to charge. It needed an explicit update_inventory() after charging.
> 3. update_inventory(), is called from setworn(), which is called from
> dorestore(), when loading a save. Segfaults have been observed in
> variants based on this code (though not yet in vanilla 3.6.1), so it's
> possible this may be unsafe. The update_inventory() call in setworn()
> could be protected with "if (!restoring) ..."
tty doesn't support perm_invent, so this might be a win32 issue.
I've made the suggested change, but a better fix would be to turn off
perm_invent as soon as options processing (new game) or options restore
(old game unless/until #1 gets changed) has finished setting things up,
then turn it back on at the end of moveloop()'s prolog when play is
about to start.
= =
Most of the read.c change is reordering prototypes to match the order
of the corresponding functions. I did this when adding a new static
routine, then ended up discarding that routine.
PatR [Fri, 18 May 2018 23:57:44 +0000 (16:57 -0700)]
commit test for renamed branch
Locally I've committed to NetHack-3.6.0 and haven't yet pulled from
upstream to get the branch rename. I expect this commit to be
rejected but it could conceivably go through to the new name.
PatR [Thu, 17 May 2018 22:48:09 +0000 (15:48 -0700)]
fix #H7160 - hilite thresholds reject negatives
There was a prior report about this but I can't find it; maybe it
didn't go through the web contact form. Anyway, status_hilite
threshold numeric values wouldn't accept a minus sign before the
digits, preventing negative AC values from being tracked.
PatR [Wed, 16 May 2018 00:09:47 +0000 (17:09 -0700)]
tty/wintty.c w/o TEXTCOLOR
With TEXTCOLOR disabled, compiler warnings about term_start_color()
and term_end_color() not being declared were followed by link failure
because they weren't available.
This tries to simplify color handling in the tty status code without
resorting to #if TEXTCOLOR (the proper fix, but somewhat intrusive).
For the usual case where TEXTCOLOR is defined, there were instances
of
if (color != NO_COLOR && color != CLR_MAX)
term_start_color();
...
if (color != NO_COLOR)
term_end_color();
and also of
if (color != NO_COLOR)
term_start_color();
...
if (color != NO_COLOR)
term_end_color();
I've changed both types to be
if (color != NO_COLOR && color != CLR_MAX)
term_start_color();
...
if (color != NO_COLOR && color != CLR_MAX)
term_end_color();
so that start/end pairing will always be consistent.
Also, ((color_and_attr & 0xFF00) >> 8) might not work as intended if
using 16-bit int and color_and_attr happened to have its sign bit set.
Change to ((color_and_attr >> 8) & 0x00FF) to ensure just the desired
bits.
PatR [Tue, 15 May 2018 11:16:40 +0000 (04:16 -0700)]
tty status
Started by removing two or three unused variables, ended up cleaning
up a lot of formatting (tabs, trailing spaces, indentation, a few
wide lines, 'if (test) return' on same line). Marked some static
functions as static in their definitions instead of leaving it hidden
in their prototypes. Moved a pair of short-circuit checks to skip
several initializations.
Bart House [Mon, 14 May 2018 03:46:43 +0000 (20:46 -0700)]
Additional changes to xputc_core() and early_raw_print() to manage
the cursor position correctly. This is needed to handle raw printing
correctly. Added check for when we might be running off the bottom
of the screen when handling msmsg(). Added runtime checks to keep
cursor always within bounds.
PatR [Sat, 12 May 2018 08:05:29 +0000 (01:05 -0700)]
fix #H7140 - list MSGTYPE values shows empty strings
The 'O' menu's 'list' for MSGTYPE settings showed truncated versions
of really long message strings but didn't show anything except the
hide/stop/norep setting for ordinary length ones. 3.6.0 showed the
latter correctly but suffered buffer overflow for the former; the
fix for that had a typo/thinko in it.
Bart House [Sun, 13 May 2018 01:06:23 +0000 (18:06 -0700)]
Fix for bug 324 (aka H4216). We now will use nhraykey by default if the
players keyboard layout is non-english. nhraykey properly handles
non-english input. We also now support changing altkeyhandler in game.
Bart House [Tue, 8 May 2018 14:25:24 +0000 (07:25 -0700)]
Fix for bug H7132.
In nethackw, there can be conflicts between menu accelerators and an extra
choice accelerator. For example, when engraving the using fingers options
conflicts with the unselect all menu accelerator. The extra choice
accelerator should take precedence.
Bart House [Sun, 6 May 2018 08:13:30 +0000 (01:13 -0700)]
Implemented a fix to the lag problems that are occuring with the Win32
console port. The fix implements a console back buffer which
significantly reduces the number of calls made to WriteConsoleOutputXXX
and eliminates the lag users have been experiencing.
Bart House [Sun, 6 May 2018 08:13:30 +0000 (01:13 -0700)]
Implemented a fix to the lag problems that are occuring with the Win32
console port. The fix implements a console back buffer which
significantly reduces the number of calls made to WriteConsoleOutputXXX
and eliminates the lag users have been experiencing.