-/* NetHack 3.6 botl.h $NHDT-Date: 1432512780 2015/05/25 00:13:00 $ $NHDT-Branch: master $:$NHDT-Revision: 1.10 $ */
+/* NetHack 3.6 botl.h $NHDT-Date: 1433082340 2015/05/31 14:25:40 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.12 $ */
/* Copyright (c) Michael Allison, 2003 */
/* NetHack may be freely redistributed. See license for details. */
#ifndef BOTL_H
#define BOTL_H
+/* 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
+
#ifdef STATUS_VIA_WINDOWPORT
#if 0
/* clang-format off */
-/* NetHack 3.6 botl.c $NHDT-Date: 1432512764 2015/05/25 00:12:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.50 $ */
+/* NetHack 3.6 botl.c $NHDT-Date: 1433082365 2015/05/31 14:26:05 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.53 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
update_all = FALSE;
}
+#ifdef STATUS_HILITES
+
/*****************************************************************************/
/* Core status hiliting support */
/*****************************************************************************/
-#ifdef STATUS_HILITES
-
struct hilite_s {
boolean set;
anything threshold;
text = "updown";
}
- anything_to_s(tmp, &status_hilites[i].threshold,
+ if (status_hilites[i].behavior != BL_TH_UPDOWN) {
+ anything_to_s(tmp, &status_hilites[i].threshold,
blstats[0][i].anytype);
- text = tmp;
+ text = tmp;
+ }
k = strlen(text);
if (k < (bufsiz - 1)) {
Strcat(buf, text);
return set_status_hilites(buf);
}
#endif /*STATUS_HILITES*/
-
-/*****************************************************************************/
-/* genl backward compat stuff - probably doesn't belong in botl.c any longer
- */
-/*****************************************************************************/
-
-const char *fieldnm[MAXBLSTATS];
-const char *fieldfmt[MAXBLSTATS];
-char *vals[MAXBLSTATS];
-boolean activefields[MAXBLSTATS];
-NEARDATA winid WIN_STATUS;
-
-void
-genl_status_init()
-{
- int i;
- for (i = 0; i < MAXBLSTATS; ++i) {
- vals[i] = (char *) alloc(MAXCO);
- *vals[i] = '\0';
- activefields[i] = FALSE;
- fieldfmt[i] = (const char *) 0;
- }
- /* Use a window for the genl version; backward port compatibility */
- WIN_STATUS = create_nhwindow(NHW_STATUS);
- display_nhwindow(WIN_STATUS, FALSE);
-}
-
-void
-genl_status_finish()
-{
- /* tear down routine */
- int i;
-
- /* free alloc'd memory here */
- for (i = 0; i < MAXBLSTATS; ++i) {
- if (vals[i])
- free((genericptr_t) vals[i]);
- vals[i] = (char *) 0;
- }
-}
-
-void
-genl_status_enablefield(fieldidx, nm, fmt, enable)
-int fieldidx;
-const char *nm;
-const char *fmt;
-boolean enable;
-{
- fieldfmt[fieldidx] = fmt;
- fieldnm[fieldidx] = nm;
- activefields[fieldidx] = enable;
-}
-
-#ifdef STATUS_HILITES
-void
-genl_status_threshold(fldidx, thresholdtype, threshold, behavior, under, over)
-int fldidx, thresholdtype;
-int behavior, under, over;
-anything threshold;
-{
- return;
-}
-#endif /* STATUS_HILITES */
-
-void
-genl_status_update(idx, ptr, chg, percent)
-int idx, chg, percent;
-genericptr_t ptr;
-{
- char newbot1[MAXCO], newbot2[MAXCO];
- long cond, *condptr = (long *) ptr;
- register int i;
- char *text = (char *) ptr;
-
- enum statusfields fieldorder[2][15] = {
- { BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH, BL_ALIGN,
- BL_SCORE, BL_BOGUS, BL_BOGUS, BL_BOGUS, BL_BOGUS, BL_BOGUS, BL_BOGUS},
- { BL_LEVELDESC, BL_GOLD, BL_HP, BL_HPMAX, BL_ENE, BL_ENEMAX,
- BL_AC, BL_XP, BL_EXP, BL_HD, BL_TIME, BL_HUNGER,
- BL_CAP, BL_CONDITION, BL_BOGUS}
- };
-
- if (idx != BL_BOGUS) {
- if (!activefields[idx])
- return;
- switch (idx) {
- case BL_CONDITION:
- cond = *condptr;
- *vals[idx] = '\0';
- if (cond & BL_MASK_BLIND)
- Strcat(vals[idx], " Blind");
- if (cond & BL_MASK_CONF)
- Strcat(vals[idx], " Conf");
- if (cond & BL_MASK_FOODPOIS)
- Strcat(vals[idx], " FoodPois");
- if (cond & BL_MASK_ILL)
- Strcat(vals[idx], " Ill");
- if (cond & BL_MASK_STUNNED)
- Strcat(vals[idx], " Stun");
- if (cond & BL_MASK_HALLU)
- Strcat(vals[idx], " Hallu");
- if (cond & BL_MASK_SLIMED)
- Strcat(vals[idx], " Slime");
- break;
- default:
- Sprintf(vals[idx], fieldfmt[idx] ? fieldfmt[idx] : "%s", text);
- break;
- }
- }
-
- /* This genl version updates everything on the display, everytime */
- newbot1[0] = '\0';
- for (i = 0; fieldorder[0][i] != BL_BOGUS; ++i) {
- int idx1 = fieldorder[0][i];
- if (activefields[idx1])
- Strcat(newbot1, vals[idx1]);
- }
- newbot2[0] = '\0';
- for (i = 0; fieldorder[1][i] != BL_BOGUS; ++i) {
- int idx2 = fieldorder[1][i];
- if (activefields[idx2])
- Strcat(newbot2, vals[idx2]);
- }
- curs(WIN_STATUS, 1, 0);
- putstr(WIN_STATUS, 0, newbot1);
- curs(WIN_STATUS, 1, 1);
- putmixed(WIN_STATUS, 0, newbot2); /* putmixed() due to GOLD glyph */
-}
-
#endif /*STATUS_VIA_WINDOWPORT*/
/*botl.c*/
-/* NetHack 3.6 windows.c $NHDT-Date: 1432512768 2015/05/25 00:12:48 $ $NHDT-Branch: master $:$NHDT-Revision: 1.28 $ */
+/* NetHack 3.6 windows.c $NHDT-Date: 1433082382 2015/05/31 14:26:22 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.29 $ */
/* Copyright (c) D. Cohrs, 1993. */
/* NetHack may be freely redistributed. See license for details. */
#endif /* HANGUPHANDLING */
+#ifdef STATUS_VIA_WINDOWPORT
+
+/*****************************************************************************/
+/* genl backward compat stuff */
+/*****************************************************************************/
+
+const char *fieldnm[MAXBLSTATS];
+const char *fieldfmt[MAXBLSTATS];
+char *vals[MAXBLSTATS];
+boolean activefields[MAXBLSTATS];
+NEARDATA winid WIN_STATUS;
+
+void
+genl_status_init()
+{
+ int i;
+ for (i = 0; i < MAXBLSTATS; ++i) {
+ vals[i] = (char *) alloc(MAXCO);
+ *vals[i] = '\0';
+ activefields[i] = FALSE;
+ fieldfmt[i] = (const char *) 0;
+ }
+ /* Use a window for the genl version; backward port compatibility */
+ WIN_STATUS = create_nhwindow(NHW_STATUS);
+ display_nhwindow(WIN_STATUS, FALSE);
+}
+
+void
+genl_status_finish()
+{
+ /* tear down routine */
+ int i;
+
+ /* free alloc'd memory here */
+ for (i = 0; i < MAXBLSTATS; ++i) {
+ if (vals[i])
+ free((genericptr_t) vals[i]);
+ vals[i] = (char *) 0;
+ }
+}
+
+void
+genl_status_enablefield(fieldidx, nm, fmt, enable)
+int fieldidx;
+const char *nm;
+const char *fmt;
+boolean enable;
+{
+ fieldfmt[fieldidx] = fmt;
+ fieldnm[fieldidx] = nm;
+ activefields[fieldidx] = enable;
+}
+
+void
+genl_status_update(idx, ptr, chg, percent)
+int idx, chg, percent;
+genericptr_t ptr;
+{
+ char newbot1[MAXCO], newbot2[MAXCO];
+ long cond, *condptr = (long *) ptr;
+ register int i;
+ char *text = (char *) ptr;
+
+ enum statusfields fieldorder[2][15] = {
+ { BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH, BL_ALIGN,
+ BL_SCORE, BL_BOGUS, BL_BOGUS, BL_BOGUS, BL_BOGUS, BL_BOGUS, BL_BOGUS},
+ { BL_LEVELDESC, BL_GOLD, BL_HP, BL_HPMAX, BL_ENE, BL_ENEMAX,
+ BL_AC, BL_XP, BL_EXP, BL_HD, BL_TIME, BL_HUNGER,
+ BL_CAP, BL_CONDITION, BL_BOGUS}
+ };
+
+ if (idx != BL_BOGUS) {
+ if (!activefields[idx])
+ return;
+ switch (idx) {
+ case BL_CONDITION:
+ cond = *condptr;
+ *vals[idx] = '\0';
+ if (cond & BL_MASK_BLIND)
+ Strcat(vals[idx], " Blind");
+ if (cond & BL_MASK_CONF)
+ Strcat(vals[idx], " Conf");
+ if (cond & BL_MASK_FOODPOIS)
+ Strcat(vals[idx], " FoodPois");
+ if (cond & BL_MASK_ILL)
+ Strcat(vals[idx], " Ill");
+ if (cond & BL_MASK_STUNNED)
+ Strcat(vals[idx], " Stun");
+ if (cond & BL_MASK_HALLU)
+ Strcat(vals[idx], " Hallu");
+ if (cond & BL_MASK_SLIMED)
+ Strcat(vals[idx], " Slime");
+ break;
+ default:
+ Sprintf(vals[idx], fieldfmt[idx] ? fieldfmt[idx] : "%s", text);
+ break;
+ }
+ }
+
+ /* This genl version updates everything on the display, everytime */
+ newbot1[0] = '\0';
+ for (i = 0; fieldorder[0][i] != BL_BOGUS; ++i) {
+ int idx1 = fieldorder[0][i];
+ if (activefields[idx1])
+ Strcat(newbot1, vals[idx1]);
+ }
+ newbot2[0] = '\0';
+ for (i = 0; fieldorder[1][i] != BL_BOGUS; ++i) {
+ int idx2 = fieldorder[1][i];
+ if (activefields[idx2])
+ Strcat(newbot2, vals[idx2]);
+ }
+ curs(WIN_STATUS, 1, 0);
+ putstr(WIN_STATUS, 0, newbot1);
+ curs(WIN_STATUS, 1, 1);
+ putmixed(WIN_STATUS, 0, newbot2); /* putmixed() due to GOLD glyph */
+}
+
+#ifdef STATUS_HILITES
+void
+genl_status_threshold(fldidx, thresholdtype, threshold, behavior, under, over)
+int fldidx, thresholdtype;
+int behavior, under, over;
+anything threshold;
+{
+ return;
+}
+#endif /* STATUS_HILITES */
+#endif /* STATUS_VIA_WINDOWPORT */
+
/*windows.c*/
-/* NetHack 3.6 wintty.c $NHDT-Date: 1432536533 2015/05/25 06:48:53 $ $NHDT-Branch: master $:$NHDT-Revision: 1.94 $ */
+/* NetHack 3.6 wintty.c $NHDT-Date: 1433082408 2015/05/31 14:26:48 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.95 $ */
/* Copyright (c) David Cohrs, 1991 */
/* NetHack may be freely redistributed. See license for details. */
return strcpy((char *) alloc((unsigned) (strlen(s) + 1)), s);
}
+#ifdef STATUS_VIA_WINDOWPORT
+
+/*
+ * These come from the genl_ routines
+ * in src/windows.c
+ */
+extern const char *fieldnm[MAXBLSTATS];
+extern const char *fieldfmt[MAXBLSTATS];
+extern char *vals[MAXBLSTATS];
+extern boolean activefields[MAXBLSTATS];
+extern winid WIN_STATUS;
+
+void
+tty_status_update(idx, ptr, chg, percent)
+int idx, chg, percent;
+genericptr_t ptr;
+{
+ char newbot1[MAXCO], newbot2[MAXCO];
+ long cond, *condptr = (long *) ptr;
+ register int i;
+ char *text = (char *) ptr;
+
+ enum statusfields fieldorder[2][15] = {
+ { BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH, BL_ALIGN,
+ BL_SCORE, BL_BOGUS, BL_BOGUS, BL_BOGUS, BL_BOGUS, BL_BOGUS, BL_BOGUS},
+ { BL_LEVELDESC, BL_GOLD, BL_HP, BL_HPMAX, BL_ENE, BL_ENEMAX,
+ BL_AC, BL_XP, BL_EXP, BL_HD, BL_TIME, BL_HUNGER,
+ BL_CAP, BL_CONDITION, BL_BOGUS}
+ };
+
+ if (idx != BL_BOGUS) {
+ if (!activefields[idx])
+ return;
+ switch (idx) {
+ case BL_CONDITION:
+ cond = *condptr;
+ *vals[idx] = '\0';
+ if (cond & BL_MASK_BLIND)
+ Strcat(vals[idx], " Blind");
+ if (cond & BL_MASK_CONF)
+ Strcat(vals[idx], " Conf");
+ if (cond & BL_MASK_FOODPOIS)
+ Strcat(vals[idx], " FoodPois");
+ if (cond & BL_MASK_ILL)
+ Strcat(vals[idx], " Ill");
+ if (cond & BL_MASK_STUNNED)
+ Strcat(vals[idx], " Stun");
+ if (cond & BL_MASK_HALLU)
+ Strcat(vals[idx], " Hallu");
+ if (cond & BL_MASK_SLIMED)
+ Strcat(vals[idx], " Slime");
+ break;
+ default:
+ Sprintf(vals[idx], fieldfmt[idx] ? fieldfmt[idx] : "%s", text);
+ break;
+ }
+ }
+
+ /* This genl version updates everything on the display, everytime */
+ newbot1[0] = '\0';
+ for (i = 0; fieldorder[0][i] != BL_BOGUS; ++i) {
+ int idx1 = fieldorder[0][i];
+ if (activefields[idx1])
+ Strcat(newbot1, vals[idx1]);
+ }
+ newbot2[0] = '\0';
+ for (i = 0; fieldorder[1][i] != BL_BOGUS; ++i) {
+ int idx2 = fieldorder[1][i];
+ if (activefields[idx2])
+ Strcat(newbot2, vals[idx2]);
+ }
+ curs(WIN_STATUS, 1, 0);
+ putstr(WIN_STATUS, 0, newbot1);
+ curs(WIN_STATUS, 1, 1);
+ putmixed(WIN_STATUS, 0, newbot2); /* putmixed() due to GOLD glyph */
+}
+
+#ifdef STATUS_HILITES
+void
+tty_status_threshold(fldidx, thresholdtype, threshold, behavior, under, over)
+int fldidx, thresholdtype;
+int behavior, under, over;
+anything threshold;
+{
+ return;
+}
+#endif /* STATUS_HILITES */
+#endif /*STATUS_VIA_WINDOWPORT*/
+
#endif /* TTY_GRAPHICS */
/*wintty.c*/