]> granicus.if.org Git - nethack/commitdiff
more status_hilite work
authornhmall <mjnh@persona.ca>
Sun, 31 May 2015 15:54:06 +0000 (11:54 -0400)
committernhmall <mjnh@persona.ca>
Sun, 31 May 2015 15:54:06 +0000 (11:54 -0400)
 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

include/extern.h
src/botl.c
src/options.c
src/windows.c

index 901326707c9b6fe1f207a874e5a526b6b496845d..8b270d8c1289924b01c3396fb79fa38ce24a6d9a 100644 (file)
@@ -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 ### */
 
index 3ab396320acc38d9f3415697ac9f8022d8c45bfc..df7e1ed387157703164e1bfa6716acc25672acf5 100644 (file)
@@ -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
  *
index e418add02e3e0bac56c1398925924ae6e9bb591b..14cb4c0c9779a6807e4c69759a9a8f98ecd3c531 100644 (file)
@@ -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;
     }
index 7b054c7fcb539c9f5f695bbd0a1ced9fb1e9cc5a..d5c5dd95f3000d13157ce53dd6a511588cd57056 100644 (file)
@@ -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. */