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.
This commit is contained in:
PatR
2018-05-17 15:48:09 -07:00
parent 1641409d1c
commit 4b98266e25
2 changed files with 34 additions and 27 deletions
+9 -8
View File
@@ -9,9 +9,10 @@ General Fixes and Modified Features
----------------------------------- -----------------------------------
last line of config file wasn't being heeded if it had no newline last line of config file wasn't being heeded if it had no newline
list MSGTYPE values shows empty strings as reported in H7140 list MSGTYPE values shows empty strings as reported in H7140
Killing Vlad while he was in bat/fog cloud/wolf form gave poorly Killing Vlad while he was in bat/fog cloud/wolf form gave poorly worded
worded feedback when he reverted to vampire form feedback when he reverted to vampire form
spaces in hilite_status option title text field not working spaces in hilite_status option title text field not working
numeric hilite_status values didn't allow negative numbers (needed for AC)
Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository
@@ -25,11 +26,11 @@ windows-gui: In nethackw, there could be conflicts between menu accelerators
and an extra choice accelerator to fix H7132. and an extra choice accelerator to fix H7132.
windows-tty: Specify both width and height when creating font for width testing windows-tty: Specify both width and height when creating font for width testing
windows-tty: To counter lag problems that were occuring with the Win32 console windows-tty: To counter lag problems that were occuring with the Win32 console
port, implement a console back buffer to reduce the number of calls made to port, implement a console back buffer to reduce the number of calls
WriteConsoleOutputXXX made to WriteConsoleOutputXXX
windows-tty: Additional changes to xputc_core() and early_raw_print() to manage windows-tty: Additional changes to xputc_core() and early_raw_print() to
the cursor position correctly as that is needed to handle raw printing manage the cursor position correctly as that is needed to handle
correctly raw printing correctly
windows-tty: Added check for when we might be running off the bottom of the windows-tty: Added check for when we might be running off the bottom of the
screen when handling msmsg() screen when handling msmsg()
windows-tty: Added runtime checks to keep cursor always within bounds windows-tty: Added runtime checks to keep cursor always within bounds
@@ -38,7 +39,7 @@ windows-tty: Use nhraykey by default if the players keyboard layout is
non-english as reported in H4216 non-english as reported in H4216
windows-tty: We now support changing altkeyhandler in game windows-tty: We now support changing altkeyhandler in game
windows: Added ntassert() mechanism for Windows based port use windows: Added ntassert() mechanism for Windows based port use
tty: some optimizations for performance and per field rendering tty: significant optimizations for performance and per field rendering
General New Features General New Features
+16 -10
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 botl.c $NHDT-Date: 1526427319 2018/05/15 23:35:19 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.92 $ */ /* NetHack 3.6 botl.c $NHDT-Date: 1526597284 2018/05/17 22:48:04 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.93 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2006. */ /*-Copyright (c) Michael Allison, 2006. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1515,17 +1515,23 @@ boolean from_configfile;
return TRUE; return TRUE;
} }
/* is str in the format of "(<>)?[0-9]+%?" regex */ /* is str in the format of "[<>]?-?[0-9]+%?" regex */
STATIC_OVL boolean STATIC_OVL boolean
is_ltgt_percentnumber(str) is_ltgt_percentnumber(str)
const char *str; const char *str;
{ {
const char *s = str; const char *s = str;
if (*s == '<' || *s == '>') s++; if (*s == '<' || *s == '>')
while (digit(*s)) s++; s++;
if (*s == '%') s++; if (*s == '-')
s++;
/* note: this doesn't match the regexp shown above since it doesn't
require at least one digit; but it's adequate for how it gets used */
while (digit(*s))
s++;
if (*s == '%')
s++;
return (*s == '\0'); return (*s == '\0');
} }
@@ -1537,7 +1543,7 @@ const char *str;
const char *s = str; const char *s = str;
while (*s) { while (*s) {
if (!index("<>0123456789%", *s)) if (!index("<>-0123456789%", *s))
return FALSE; return FALSE;
s++; s++;
} }
@@ -1794,7 +1800,8 @@ boolean from_configfile;
(void) stripchars(tmpbuf, "%<>", tmp); (void) stripchars(tmpbuf, "%<>", tmp);
tmp = tmpbuf; tmp = tmpbuf;
while (*tmp) { while (*tmp) {
if (!index("0123456789", *tmp)) if (!index("0123456789", *tmp)
&& (*tmp != '-' || tmp > tmpbuf))
return FALSE; return FALSE;
tmp++; tmp++;
} }
@@ -1842,8 +1849,7 @@ do_rel:
else else
hilite.rel = LT_VALUE; hilite.rel = LT_VALUE;
if (initblstats[fld].anytype == ANY_STR if (initblstats[fld].anytype == ANY_STR && (percent || numeric)) {
&& (percent || numeric)) {
config_error_add("Field '%s' does not support numeric values", config_error_add("Field '%s' does not support numeric values",
initblstats[fld].fldname); initblstats[fld].fldname);
return FALSE; return FALSE;