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.
This commit is contained in:
nhmall
2015-05-31 10:26:54 -04:00
parent b4d9aab90a
commit ef0c00d99b
4 changed files with 243 additions and 137 deletions

View File

@@ -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*/

View File

@@ -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*/