From 2724c881917b2a860dc14f1e91e44049d299649d Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 9 Apr 2019 15:46:19 -0700 Subject: [PATCH 1/3] Guidebook update Tweak the status hilites section. Add a bit of detail about how to specify both color and attribute and/or multiple attributes. Also, change the Guidebook's table of status fields to be column-oriented. With the exception of 'score', reading down the three columns now matches going across the status lines. The previous ordering started row-oriented but then became scrambled compared to the usual display. As usual, Guidebook.tex is best guess.... --- doc/Guidebook.mn | 95 +++++++++++++++++++++++++++++------------------ doc/Guidebook.tex | 94 +++++++++++++++++++++++++++------------------- 2 files changed, 114 insertions(+), 75 deletions(-) diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index 5992a75c0..d7dcd76c4 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -1,4 +1,4 @@ -.\" $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.303 $ $NHDT-Date: 1554134322 2019/04/01 15:58:42 $ +.\" $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.304 $ $NHDT-Date: 1554849951 2019/04/09 22:45:51 $ .\" .\" This is an excerpt from the 'roff' man page from the 'groff' package. .\" NetHack's Guidebook.mn currently does *not* adhere to these guidelines. @@ -24,7 +24,7 @@ .ds vr "NetHack 3.6 .ds f0 "\*(vr .ds f1 -.ds f2 "March 24, 2019 +.ds f2 "April 9, 2019 . .\" A note on some special characters: .\" \(lq = left double quote @@ -4112,9 +4112,12 @@ If no attribute is defined, no attribute is used. The pattern should be a regular expression. .lp "" Allowed colors are black, red, green, brown, blue, magenta, cyan, gray, -orange, lightgreen, yellow, lightblue, lightmagenta, lightcyan, and white. +orange, light-green, yellow, light-blue, light-magenta, light-cyan, and white. +And \f(CRno-color\fP, the default foreground color, which isn't necessarily +the same as any of the other colors. .lp "" Allowed attributes are none, bold, dim, underline, blink, and inverse. +\(lqNormal\(rq is a synonym for \(lqnone\(rq. Note that the platform used may interpret the attributes any way it wants. .lp "" @@ -4179,36 +4182,62 @@ If so, you can customize your game display by setting thresholds to change the color or appearance of fields in the status display. .pg The format for defining status colors is: -.si -.lp "OPTION=hilite_status: field-name/behavior/color&attributes" -.ei +.SD n +\f(CROPTION=hilite_status:\fIfield-name\fP/\fIbehavior\fP/\fIcolor\fP&\fIattributes\fP\fP +.ED .pg -For example, the following line in your config file will cause +For example, the following line in your configuration file will cause the hitpoints field to display in the color red if your hitpoints drop to or below a threshold of 30%: -.si -.lp "OPTION=hilite_status: hitpoints/<=30%/red/normal" -.ei +.SD n +\f(CROPTION=hilite_status:hitpoints/<=30%/red/normal\fP +.ED +(That example is actually specifying \f(CRred&normal\fP for <=30% +and \f(CRno-color&normal\fP for >30%.) .pg -For another example, the following line in your config file will cause -wisdom to be displayed red if it drops and green if it rises. -.si -.lp "OPTION=hilite_status: wisdom/down/red/up/green" -.ei +For another example, the following line in your configuration file will cause +wisdom to be displayed red if it drops and green if it rises: +.SD n +\f(CROPTION=hilite_status:wisdom/down/red/up/green\fP +.ED .pg -You can adjust the display of the following status fields: +Allowed colors are black, red, green, brown, blue, magenta, cyan, gray, +orange, light-green, yellow, light-blue, light-magenta, light-cyan, and white. +And \(lqno-color\(rq, the default foreground color on the display, which +is not necessarily the same as black or white or any of the other colors. +.pg +Allowed attributes are none, bold, dim, underline, blink, and inverse. +\(lqNormal\(rq is a synonym for \(lqnone\(rq; they should not be used in +combination with any of the other attributes. +.pg +To specify both a color and an attribute, use \(oq&\(cq to combine them. +To specify multiple attributes, use \(oq\+\(cq to combine those. +For example: \(lqmagenta&inverse\+dim\(rq. +.pg +Note that the display may substitute or ignore particular attributes +depending upon its capabilities, and in general may interpret the +attributes any way it wants. +For example, on some display systems a request for bold might yield +blink or vice versa. +On others, issuing an attribute request while another is already +set up will replace the earlier attribute rather than combine with it. +Since NetHack issues attribute requests sequentially (at least with +the \f(CRtty\fP interface) rather than all at once, the only way a +situation like that can be controlled is to specify just one attribute. +.pg +You can adjust the appearance of the following status fields: .TS S center; c c c. .\"TABLE_START -title strength dexterity -constitution intelligence wisdom -charisma alignment score -carrying-capacity gold power -power-max experience-level armor-class -HD time hunger -hitpoints hitpoints-max dungeon-level -experience condition +title dungeon-level experience-level +strength gold experience +dexterity hitpoints HD +constitution hitpoints-max time +intelligence power hunger +wisdom power-max carrying-capacity +charisma armor-class condition +alignment score .\"TABLE_END Do not delete this line. .TE .lp "" @@ -4274,20 +4303,14 @@ and \(lqtitle\(rq. For title, only the role's rank title is tested; the character's name is ignored. .ei -.lp "" -Allowed colors are black, red, green, brown, blue, magenta, cyan, gray, -orange, lightgreen, yellow, lightblue, lightmagenta, lightcyan, and white. -.lp "" -Allowed attributes are bold, inverse, underline, blink, dim, and normal. -Note that the platform used may interpret the attributes any way it -wants. -.lp "" +.pg The in-game options menu can help you determine the correct syntax for a config file. -.lp "" -The whole feature can be disabled by setting option -statushilites to 0. -.lp "" +.pg +The whole feature can be disabled by setting option +.op statushilites +to 0. +.pg Example hilites: .sd .si diff --git a/doc/Guidebook.tex b/doc/Guidebook.tex index 9230ac309..2f9e17bb0 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -45,7 +45,7 @@ %.au \author{Original version - Eric S. Raymond\\ (Edited and expanded for 3.6 by Mike Stephenson and others)} -\date{March 24, 2019} +\date{April 9, 2019} \maketitle @@ -4582,12 +4582,15 @@ The pattern should be a regular expression. %.lp "" Allowed colors are {\it black}, {\it red}, {\it green}, {\it brown}, {\it blue}, {\it magenta}, {\it cyan}, {\it gray}, {\it orange}, -{\it lightgreen}, {\it yellow}, {\it lightblue}, {\it lightmagenta}, -{\it lightcyan}, and {\it white}. +{\it light-green}, {\it yellow}, {\it light-blue}, {\it light-magenta}, +{\it light-cyan}, and {\it white}. +And {\itno-color}, the default foreground color, which isn't necessarily +the same as any of the other colors. %.lp "" Allowed attributes are {\it none}, {\it bold}, {\it dim}, {\it underline}, {\it blink}, and {\it inverse}. +{\it Normal\/} is a synonym for {\it none}. Note that the platform used may interpret the attributes any way it wants. @@ -4657,40 +4660,68 @@ The pattern should be a regular expression. \subsection*{Configuring Status Hilites} %.pg -Your copy of {\it NetHack\/} may have been compiled with support for {\it Status Hilites}. +Your copy of {\it NetHack\/} may have been compiled with support +for {\it Status Hilites}. If so, you can customize your game display by setting thresholds to change the color or appearance of fields in the status display. -%.pg -The format for defining status colors is: + +The format for defining status colors is:\\ \begin{verbatim} - OPTION=hilite_status: field-name/behavior/color&attributes +OPTION=hilite_status:field-name/behavior/color&attributes \end{verbatim} -%.pg -For example, the following line in your config file will cause + +For example, the following line in your configuration file will cause the hitpoints field to display in the color red if your hitpoints -drop to or below a threshold of 30%: +drop to or below a threshold of 30%:\\ \begin{verbatim} - OPTION=hilite_status: hitpoints/<=30%/red/normal -\end{verbatim} -%.pg -For another example, the following line in your config file will cause -wisdom to be displayed red if it drops and green if it rises. +OPTION=hilite_status:hitpoints/<=30%/red/normal +\end{verbatim}\\ +(That example is actually specifying {\tt red\&normal} for <=30\% +and {\tt no-color\&normal} for >30\%.)\\ + +For another example, the following line in your configuration file will cause +wisdom to be displayed red if it drops and green if it rises:\\ \begin{verbatim} - OPTION=hilite_status: wisdom/down/red/up/green +OPTION=hilite_status:wisdom/down/red/up/green \end{verbatim} + +Allowed colors are black, red, green, brown, blue, magenta, cyan, gray, +orange, light-green, yellow, light-blue, light-magenta, light-cyan, and white. +And {\it no-color}, the default foreground color on the display, which +is not necessarily the same as black or white or any of the other colors. + +Allowed attributes are none, bold, dim, underline, blink, and inverse. +``Normal'' is a synonym for ``none''; they should not be used in +combination with any of the other attributes. + +To specify both a color and an attribute, use `\&' to combine them. +To specify multiple attributes, use `+' to combine those. +For example: {\tt magenta\&inverse+dim}. + +Note that the display may substitute or ignore particular attributes +depending upon its capabilities, and in general may interpret the +attributes any way it wants. +For example, on some display systems a request for bold might yield +blink or vice versa. +On others, issuing an attribute request while another is already +set up will replace the earlier attribute rather than combine with it. +Since nethack issues attribute requests sequentially (at least with +the {\it tty} interface) rather than all at once, the only way a +situation like that can be controlled is to specify just one attribute. + You can adjust the display of the following status fields: %.sd \begin{center} \begin{tabular}{lll} %TABLE_START -title & strength & dexterity\\ -constitution & intelligence & wisdom\\ -charisma & alignment & score\\ -carrying-capacity & gold & power\\ -power-max & experience-level & armor-class\\ -HD & time & hunger\\ -hitpoints & hitpoints-max & dungeon-level\\ -experience & condition\\ +title & dungeon-level & experience-level\\ +strength & gold & experience\\ +dexterity & hitpoints & HD\\ +constitution & hitpoints-max & time\\ +intelligence & power & hunger\\ +wisdom & power-max & carrying-capacity\\ +charisma & armor-class & condition\\ +alignment & & score\\ %TABLE_END Do not delete this line. \end{tabular} \end{center} @@ -4764,26 +4795,11 @@ is tested; the character's name is ignored. %.ei \elist -%.lp "" -Allowed colors are {\it black}, {\it red}, {\it green}, {\it brown}, -{\it blue}, {\it magenta}, {\it cyan}, {\it gray}, {\it orange}, -{\it lightgreen}, {\it yellow}, {\it lightblue}, {\it lightmagenta}, -{\it lightcyan}, and {\it white}. - -%.lp "" -Allowed attributes are {\it bold}, {\it inverse}, {\it underline}, -{\it blink}, {\it dim}, and {\it normal}. -Note that the platform used may interpret the attributes any way it -wants. - -%.lp "" The in-game options menu can help you determine the correct syntax for a config file. -%.lp "" The whole feature can be disable by setting option {\it statushilites} to 0. -%.lp "" Example hilites: \begin{verbatim} OPTION=hilite_status: gold/up/yellow/down/brown From 2e30f6916fa3adcdeb195b5f5f23b3766e805865 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 9 Apr 2019 17:45:32 -0700 Subject: [PATCH 2/3] more !STATUS_HILITES No point in checking for timed out temporary highlights if there aren't any highlights. --- include/extern.h | 4 +-- src/allmain.c | 4 ++- src/botl.c | 90 +++++++++++++++++++++++------------------------- 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/include/extern.h b/include/extern.h index 29fdb3743..ee4731ad3 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 extern.h $NHDT-Date: 1554554180 2019/04/06 12:36:20 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.699 $ */ +/* NetHack 3.6 extern.h $NHDT-Date: 1554857123 2019/04/10 00:45:23 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.700 $ */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -159,13 +159,13 @@ E void NDECL(max_rank_sz); E long NDECL(botl_score); #endif E int FDECL(describe_level, (char *)); -E void NDECL(status_eval_next_unhilite); E void FDECL(status_initialize, (BOOLEAN_P)); E void NDECL(status_finish); E int NDECL(stat_cap_indx); E int NDECL(stat_hunger_indx); E const char *FDECL(bl_idx_to_fldname, (int)); #ifdef STATUS_HILITES +E void NDECL(status_eval_next_unhilite); E void NDECL(reset_status_hilites); E boolean FDECL(parse_status_hl1, (char *op, BOOLEAN_P)); E void FDECL(status_notify_windowport, (BOOLEAN_P)); diff --git a/src/allmain.c b/src/allmain.c index 84f9dfd0c..c50dc2ef8 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 allmain.c $NHDT-Date: 1554591223 2019/04/06 22:53:43 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.97 $ */ +/* NetHack 3.6 allmain.c $NHDT-Date: 1554857127 2019/04/10 00:45:27 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.98 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -320,7 +320,9 @@ boolean resuming; /* once-per-hero-took-time things go here */ /******************************************/ +#ifdef STATUS_HILITES status_eval_next_unhilite(); +#endif if (context.bypasses) clear_bypasses(); if ((u.uhave.amulet || Clairvoyant) && !In_endgame(&u.uz) diff --git a/src/botl.c b/src/botl.c index 0ae87df03..b961c75bc 100644 --- a/src/botl.c +++ b/src/botl.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 botl.c $NHDT-Date: 1554591223 2019/04/06 22:53:43 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.143 $ */ +/* NetHack 3.6 botl.c $NHDT-Date: 1554857126 2019/04/10 00:45:26 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.144 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2006. */ /* NetHack may be freely redistributed. See license for details. */ @@ -540,7 +540,9 @@ STATIC_VAR struct istat_s initblstats[MAXBLSTATS] = { struct istat_s blstats[2][MAXBLSTATS]; static boolean blinit = FALSE, update_all = FALSE; static boolean valset[MAXBLSTATS]; +#ifdef STATUS_HILITES static long bl_hilite_moves = 0L; +#endif /* we don't put this next declaration in #ifdef STATUS_HILITES. * In the absence of STATUS_HILITES, each array @@ -899,51 +901,6 @@ boolean *valsetlist; update_all = FALSE; } -/* called from moveloop(); sets context.botl if temp hilites have timed out */ -void -status_eval_next_unhilite() -{ - int i; - struct istat_s *curr; - long next_unhilite, this_unhilite; - - bl_hilite_moves = moves; /* simpllfied; used to try to encode fractional - * amounts for multiple moves within same turn */ - /* figure out whether an unhilight needs to be performed now */ - next_unhilite = 0L; - for (i = 0; i < MAXBLSTATS; ++i) { - curr = &blstats[0][i]; /* blstats[0][*].time == blstats[1][*].time */ - - if (curr->chg) { - struct istat_s *prev = &blstats[1][i]; - -#ifdef STATUS_HILITES - if (Is_Temp_Hilite(curr->hilite_rule)) - curr->time = prev->time = (bl_hilite_moves - + iflags.hilite_delta); - else - curr->time = prev->time = 0L; -#endif - curr->chg = prev->chg = FALSE; - context.botl = TRUE; - } - if (context.botl) - continue; /* just process other blstats[][].time and .chg */ - - this_unhilite = curr->time; - if (this_unhilite > 0L - && (next_unhilite == 0L || this_unhilite < next_unhilite) -#ifdef STATUS_HILITES - && hilite_reset_needed(curr, this_unhilite + 1L) -#endif - ) { - next_unhilite = this_unhilite; - if (next_unhilite < bl_hilite_moves) - context.botl = TRUE; - } - } -} - void status_initialize(reassessment) boolean reassessment; /* TRUE: just recheck fields w/o other initialization */ @@ -1436,6 +1393,47 @@ long augmented_time; return TRUE; } +/* called from moveloop(); sets context.botl if temp hilites have timed out */ +void +status_eval_next_unhilite() +{ + int i; + struct istat_s *curr; + long next_unhilite, this_unhilite; + + bl_hilite_moves = moves; /* simpllfied; used to try to encode fractional + * amounts for multiple moves within same turn */ + /* figure out whether an unhilight needs to be performed now */ + next_unhilite = 0L; + for (i = 0; i < MAXBLSTATS; ++i) { + curr = &blstats[0][i]; /* blstats[0][*].time == blstats[1][*].time */ + + if (curr->chg) { + struct istat_s *prev = &blstats[1][i]; + + if (Is_Temp_Hilite(curr->hilite_rule)) + curr->time = prev->time = (bl_hilite_moves + + iflags.hilite_delta); + else + curr->time = prev->time = 0L; + + curr->chg = prev->chg = FALSE; + context.botl = TRUE; + } + if (context.botl) + continue; /* just process other blstats[][].time and .chg */ + + this_unhilite = curr->time; + if (this_unhilite > 0L + && (next_unhilite == 0L || this_unhilite < next_unhilite) + && hilite_reset_needed(curr, this_unhilite + 1L)) { + next_unhilite = this_unhilite; + if (next_unhilite < bl_hilite_moves) + context.botl = TRUE; + } + } +} + /* called by options handling when 'statushilites' boolean is toggled */ void reset_status_hilites() From 14ad5356e5b454fc3cbbc953c328c75ff9af60ed Mon Sep 17 00:00:00 2001 From: PatR Date: Wed, 10 Apr 2019 04:29:10 -0700 Subject: [PATCH 3/3] another STATUS_HILITES optimization When highlighting is disabled due to 'statushilites' being 0, don't bother checking whether any temporary highlights are timing out. --- src/allmain.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/allmain.c b/src/allmain.c index c50dc2ef8..7e2770f4e 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 allmain.c $NHDT-Date: 1554857127 2019/04/10 00:45:27 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.98 $ */ +/* NetHack 3.6 allmain.c $NHDT-Date: 1554895741 2019/04/10 11:29:01 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.99 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -321,7 +321,8 @@ boolean resuming; /******************************************/ #ifdef STATUS_HILITES - status_eval_next_unhilite(); + if (iflags.hilite_delta) + status_eval_next_unhilite(); #endif if (context.bypasses) clear_bypasses();