From: nhmall Date: Sun, 31 May 2015 15:54:06 +0000 (-0400) Subject: more status_hilite work X-Git-Tag: NetHack-3.6.0_RC01~321 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e4074b61f217cc07d1e71c8f7b555fb4f79436b;p=nethack more status_hilite work Changes to be committed: modified: include/extern.h modified: src/botl.c modified: src/options.c modified: src/windows.c defer notification of the window port until after proper initialization. Options are processed very early in 3.6.0 --- diff --git a/include/extern.h b/include/extern.h index 901326707..8b270d8c1 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 extern.h $NHDT-Date: 1432890461 2015/05/29 09:07:41 $ $NHDT-Branch: master $:$NHDT-Revision: 1.498 $ */ +/* NetHack 3.6 extern.h $NHDT-Date: 1433087625 2015/05/31 15:53:45 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.499 $ */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -152,14 +152,9 @@ E void NDECL(bot); #ifdef STATUS_VIA_WINDOWPORT E void FDECL(status_initialize, (BOOLEAN_P)); E void NDECL(status_finish); -E void NDECL(genl_status_init); -E void NDECL(genl_status_finish); -E void FDECL(genl_status_update, (int, genericptr_t, int, int)); -E void FDECL(genl_status_enablefield, - (int, const char *, const char *, BOOLEAN_P)); +E void FDECL(status_notify_windowport, (BOOLEAN_P)); #ifdef STATUS_HILITES -E void FDECL(genl_status_threshold, (int, int, anything, int, int, int)); -E boolean FDECL(set_status_hilites, (char *op)); +E boolean FDECL(set_status_hilites, (char *op, BOOLEAN_P)); E void NDECL(clear_status_hilites); E char *FDECL(get_status_hilites, (char *, int)); E boolean NDECL(status_hilite_menu); @@ -2629,6 +2624,16 @@ E void FDECL(genl_putmsghistory, (const char *, BOOLEAN_P)); #ifdef HANGUPHANDLING E void NDECL(nhwindows_hangup); #endif +#ifdef STATUS_VIA_WINDOWPORT +E void NDECL(genl_status_init); +E void NDECL(genl_status_finish); +E void FDECL(genl_status_enablefield, + (int, const char *, const char *, BOOLEAN_P)); +E void FDECL(genl_status_update, (int, genericptr_t, int, int)); +#ifdef STATUS_HILITES +E void FDECL(genl_status_threshold, (int, int, anything, int, int, int)); +#endif +#endif /* ### wizard.c ### */ diff --git a/src/botl.c b/src/botl.c index 3ab396320..df7e1ed38 100644 --- a/src/botl.c +++ b/src/botl.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 botl.c $NHDT-Date: 1433082365 2015/05/31 14:26:05 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.53 $ */ +/* NetHack 3.6 botl.c $NHDT-Date: 1433087631 2015/05/31 15:53:51 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.54 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -96,20 +96,6 @@ STATIC_DCL void NDECL(bot1); STATIC_DCL void NDECL(bot2); #endif -/* MAXCO must hold longest uncompressed status line, and must be larger - * than COLNO - * - * longest practical second status line at the moment is - * Astral Plane $:12345 HP:700(700) Pw:111(111) AC:-127 Xp:30/123456789 - * T:123456 Satiated Conf FoodPois Ill Blind Stun Hallu Overloaded - * -- or somewhat over 130 characters - */ -#if COLNO <= 140 -#define MAXCO 160 -#else -#define MAXCO (COLNO + 20) -#endif - STATIC_OVL NEARDATA int mrank_sz = 0; /* loaded by max_rank_sz (from u_init) */ STATIC_DCL const char *NDECL(rank); @@ -1049,6 +1035,7 @@ bot() struct hilite_s { boolean set; + unsigned anytype; anything threshold; int behavior; int coloridx[2]; @@ -1065,8 +1052,9 @@ struct hilite_s status_hilites[MAXBLSTATS]; * strings, then calls assign_hilite() to make the adjustments. */ boolean -set_status_hilites(op) +set_status_hilites(op, from_configfile) char *op; +boolean from_configfile; { char hsbuf[4][QBUFSZ]; boolean rslt, badopt = FALSE; @@ -1080,7 +1068,7 @@ char *op; if (c == ' ') { if (fldnum >= 2) { rslt = assign_hilite(&hsbuf[0][0], &hsbuf[1][0], &hsbuf[2][0], - &hsbuf[3][0]); + &hsbuf[3][0], from_configfile); if (!rslt) { badopt = TRUE; break; @@ -1101,7 +1089,7 @@ char *op; } if (fldnum >= 2 && !badopt) { rslt = assign_hilite(&hsbuf[0][0], &hsbuf[1][0], &hsbuf[2][0], - &hsbuf[3][0]); + &hsbuf[3][0], from_configfile); if (!rslt) badopt = TRUE; } @@ -1125,8 +1113,9 @@ clear_status_hilites() } STATIC_OVL boolean -assign_hilite(sa, sb, sc, sd) +assign_hilite(sa, sb, sc, sd, from_configfile) char *sa, *sb, *sc, *sd; +boolean from_configfile; { char *tmp, *how; int i = -1, dt = -1, idx = -1; @@ -1253,13 +1242,35 @@ char *sa, *sb, *sc, *sd; status_hilites[idx].threshold = threshold; status_hilites[idx].set = TRUE; } + status_hilites[idx].anytype = dt; /* Now finally, we notify the window port */ - status_threshold(idx, dt, threshold, status_hilites[idx].behavior, - status_hilites[idx].coloridx[0], - status_hilites[idx].coloridx[1]); + if (!from_configfile) + status_threshold(idx, status_hilites[idx].anytype, + status_hilites[idx].threshold, + status_hilites[idx].behavior, + status_hilites[idx].coloridx[0], + status_hilites[idx].coloridx[1]); + return TRUE; } + +void +status_notify_windowport(all) +boolean all; +{ + int idx; + + for (idx = 0; idx < MAXBLSTATS; ++idx) { + if (status_hilites[idx].set) + status_threshold(idx, status_hilites[idx].anytype, + status_hilites[idx].threshold, + status_hilites[idx].behavior, + status_hilites[idx].coloridx[0], + status_hilites[idx].coloridx[1]); + } +} + /* * get_status_hilites * diff --git a/src/options.c b/src/options.c index e418add02..14cb4c0c9 100644 --- a/src/options.c +++ b/src/options.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 options.c $NHDT-Date: 1432974335 2015/05/30 08:25:35 $ $NHDT-Branch: master $:$NHDT-Revision: 1.207 $ */ +/* NetHack 3.6 options.c $NHDT-Date: 1433087636 2015/05/31 15:53:56 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.208 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -3153,7 +3153,7 @@ boolean tinitial, tfrom_file; badoption(opts); return; } - if (!set_status_hilites(op)) + if (!set_status_hilites(op, tfrom_file)) badoption(opts); return; } diff --git a/src/windows.c b/src/windows.c index 7b054c7fc..d5c5dd95f 100644 --- a/src/windows.c +++ b/src/windows.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 windows.c $NHDT-Date: 1433082382 2015/05/31 14:26:22 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.29 $ */ +/* NetHack 3.6 windows.c $NHDT-Date: 1433087641 2015/05/31 15:54:01 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.30 $ */ /* Copyright (c) D. Cohrs, 1993. */ /* NetHack may be freely redistributed. See license for details. */