From: nhmall Date: Sun, 31 May 2015 14:26:54 +0000 (-0400) Subject: interim updates X-Git-Tag: NetHack-3.6.0_RC01~322 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ef0c00d99baa0e1c1253713572b93fb27c2d90bc;p=nethack interim updates Changes to be committed: modified: include/botl.h modified: src/botl.c modified: src/windows.c modified: win/tty/wintty.c Move the windowport stuff out of botl.c and into windows.c where it belongs. --- diff --git a/include/botl.h b/include/botl.h index 6ffb75fb2..c1de2aa85 100644 --- a/include/botl.h +++ b/include/botl.h @@ -1,10 +1,24 @@ -/* 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 */ diff --git a/src/botl.c b/src/botl.c index 9ad736af3..3ab396320 100644 --- a/src/botl.c +++ b/src/botl.c @@ -1,4 +1,4 @@ -/* 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. */ @@ -1041,12 +1041,12 @@ bot() update_all = FALSE; } +#ifdef STATUS_HILITES + /*****************************************************************************/ /* Core status hiliting support */ /*****************************************************************************/ -#ifdef STATUS_HILITES - struct hilite_s { boolean set; anything threshold; @@ -1310,9 +1310,11 @@ int bufsiz; 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); @@ -1530,135 +1532,6 @@ status_hilite_menu() 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*/ diff --git a/src/windows.c b/src/windows.c index d9a9a5422..7b054c7fc 100644 --- a/src/windows.c +++ b/src/windows.c @@ -1,4 +1,4 @@ -/* 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. */ @@ -798,4 +798,134 @@ const char *string UNUSED; #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*/ diff --git a/win/tty/wintty.c b/win/tty/wintty.c index e3cebdfb9..6cfb08a57 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -1,4 +1,4 @@ -/* 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. */ @@ -3028,6 +3028,95 @@ const char *s; 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*/