Merge branch 'NetHack-3.6.0'

This commit is contained in:
nhmall
2018-05-15 19:43:24 -04:00
7 changed files with 227 additions and 196 deletions
+2
View File
@@ -11,10 +11,12 @@ last line of config file wasn't being heeded if it had no newline
list MSGTYPE values shows empty strings as reported in H7140 list MSGTYPE values shows empty strings as reported in H7140
Killing Vlad while he was in bat/fog cloud/wolf form gave poorly Killing Vlad while he was in bat/fog cloud/wolf form gave poorly
worded feedback when he reverted to vampire form worded feedback when he reverted to vampire form
spaces in hilite_status option title text field not working
Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository
------------------------------------------------------------------ ------------------------------------------------------------------
fix access violation when --debug:xxxx has no other args after it
Platform- and/or Interface-Specific Fixes Platform- and/or Interface-Specific Fixes
+13 -5
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 botl.c $NHDT-Date: 1525696908 2018/05/07 12:41:48 $ $NHDT-Branch: tty-status $:$NHDT-Revision: 1.91 $ */ /* NetHack 3.6 botl.c $NHDT-Date: 1526427319 2018/05/15 23:35:19 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.92 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2006. */ /*-Copyright (c) Michael Allison, 2006. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1477,10 +1477,18 @@ boolean from_configfile;
c = lowc(*op); c = lowc(*op);
if (c == ' ') { if (c == ' ') {
if (fldnum >= 1) { if (fldnum >= 1) {
rslt = parse_status_hl2(hsbuf, from_configfile); if (fldnum == 1 && strcmpi(hsbuf[0], "title") == 0) {
if (!rslt) { /* spaces are allowed in title */
badopt = TRUE; hsbuf[fldnum][ccount++] = c;
break; hsbuf[fldnum][ccount] = '\0';
op++;
continue;
} else {
rslt = parse_status_hl2(hsbuf, from_configfile);
if (!rslt) {
badopt = TRUE;
break;
}
} }
} }
for (i = 0; i < MAX_THRESH; ++i) { for (i = 0; i < MAX_THRESH; ++i) {
+3 -5
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 files.c $NHDT-Date: 1524950534 2018/04/28 21:22:14 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.238 $ */ /* NetHack 3.6 files.c $NHDT-Date: 1526382938 2018/05/15 11:15:38 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.240 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */ /*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -3579,7 +3579,6 @@ const char *reason; /* explanation */
return; return;
} }
/*ARGSUSED*/
void void
testinglog(filenm, type, reason) testinglog(filenm, type, reason)
const char *filenm; /* ad hoc file name */ const char *filenm; /* ad hoc file name */
@@ -3589,14 +3588,13 @@ const char *reason; /* explanation */
FILE *lfile; FILE *lfile;
char fnbuf[BUFSZ]; char fnbuf[BUFSZ];
if (!filenm) return; if (!filenm)
return;
Strcpy(fnbuf, filenm); Strcpy(fnbuf, filenm);
if (index(fnbuf, '.') == 0) if (index(fnbuf, '.') == 0)
Strcat(fnbuf, ".log"); Strcat(fnbuf, ".log");
lfile = fopen_datafile(fnbuf, "a", TROUBLEPREFIX); lfile = fopen_datafile(fnbuf, "a", TROUBLEPREFIX);
if (lfile) { if (lfile) {
time_t now = getnow();
int uid = getuid();
(void) fprintf(lfile, "%s\n%s\n", type, reason); (void) fprintf(lfile, "%s\n%s\n", type, reason);
(void) fclose(lfile); (void) fclose(lfile);
} }
+1 -1
View File
@@ -343,7 +343,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
argv++; argv++;
} }
if (!strncmp(argv[1], "-d", 2) && argv[1][2] != 'e') { if (argc > 1 && !strncmp(argv[1], "-d", 2) && argv[1][2] != 'e') {
/* avoid matching "-dec" for DECgraphics; since the man page /* avoid matching "-dec" for DECgraphics; since the man page
* says -d directory, hope nobody's using -desomething_else * says -d directory, hope nobody's using -desomething_else
*/ */
+5 -5
View File
@@ -23,14 +23,14 @@ x) hints=/dev/null
;; ;;
*) hints=$prefix/$1 *) hints=$prefix/$1
hfile=$1 hfile=$1
# sanity check
if [ ! -f "$hints" ]; then
echo "Cannot find hints file $hfile"
exit 1
fi
;; ;;
esac esac
if [ ! -f "$hints" ]; then
echo "Cannot find hints file $hfile"
exit 1
fi
/bin/sh ./mkmkfile.sh Makefile.top TOP ../../Makefile $hints $hfile /bin/sh ./mkmkfile.sh Makefile.top TOP ../../Makefile $hints $hfile
/bin/sh ./mkmkfile.sh Makefile.dat DAT ../../dat/Makefile $hints $hfile /bin/sh ./mkmkfile.sh Makefile.dat DAT ../../dat/Makefile $hints $hfile
/bin/sh ./mkmkfile.sh Makefile.doc DOC ../../doc/Makefile $hints $hfile /bin/sh ./mkmkfile.sh Makefile.doc DOC ../../doc/Makefile $hints $hfile
+1 -1
View File
@@ -119,7 +119,7 @@ char *argv[];
argv++; argv++;
} }
if (!strncmp(argv[1], "-d", 2) && argv[1][2] != 'e') { if (argc > 1 && !strncmp(argv[1], "-d", 2) && argv[1][2] != 'e') {
/* avoid matching "-dec" for DECgraphics; since the man page /* avoid matching "-dec" for DECgraphics; since the man page
* says -d directory, hope nobody's using -desomething_else * says -d directory, hope nobody's using -desomething_else
*/ */
+202 -179
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 wintty.c $NHDT-Date: 1525885919 2018/05/09 17:11:59 $ $NHDT-Branch: tty-status $:$NHDT-Revision: 1.146 $ */ /* NetHack 3.6 wintty.c $NHDT-Date: 1526382995 2018/05/15 11:16:35 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.164 $ */
/* Copyright (c) David Cohrs, 1991 */ /* Copyright (c) David Cohrs, 1991 */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -209,7 +209,8 @@ int i, c, d;
if (iflags.vt_tiledata) { if (iflags.vt_tiledata) {
if (c >= 0) { if (c >= 0) {
if (i == AVTC_SELECT_WINDOW) { if (i == AVTC_SELECT_WINDOW) {
if (c == vt_tile_current_window) return; if (c == vt_tile_current_window)
return;
vt_tile_current_window = c; vt_tile_current_window = c;
} }
if (d >= 0) if (d >= 0)
@@ -354,7 +355,7 @@ char **argv UNUSED;
setftty(); /* calls start_screen */ setftty(); /* calls start_screen */
/* set up tty descriptor */ /* set up tty descriptor */
ttyDisplay = (struct DisplayDesc *) alloc(sizeof(struct DisplayDesc)); ttyDisplay = (struct DisplayDesc *) alloc(sizeof (struct DisplayDesc));
ttyDisplay->toplin = 0; ttyDisplay->toplin = 0;
ttyDisplay->rows = hgt; ttyDisplay->rows = hgt;
ttyDisplay->cols = wid; ttyDisplay->cols = wid;
@@ -2376,13 +2377,13 @@ register int x, y; /* not xchar: perhaps xchar is unsigned and
s = "[base window]"; s = "[base window]";
break; break;
} }
debugpline4("bad curs positioning win %d %s (%d,%d)", window, s, x, debugpline4("bad curs positioning win %d %s (%d,%d)", window, s, x, y);
y); /* This return statement caused a functional difference between
/* This return statement caused a functional difference between DEBUG and DEBUG and non-DEBUG operation, so it is being commented
non-DEBUG operation, so it is being commented out. It caused tty_curs() out. It caused tty_curs() to fail to move the cursor to the
to fail to move the cursor to the location it needed to be if the x,y location it needed to be if the x,y range checks failed,
range checks failed, leaving the next piece of output to be displayed leaving the next piece of output to be displayed at whatever
at whatever random location the cursor happened to be at prior. */ random location the cursor happened to be at prior. */
/* return; */ /* return; */
} }
@@ -3439,7 +3440,7 @@ char *posbar;
* -> render_status() * -> render_status()
* *
* make_things_fit * make_things_fit
* *
* Called from tty_status_update(). It calls check_fields() * Called from tty_status_update(). It calls check_fields()
* (described next) to get the required number of columns * (described next) to get the required number of columns
* and tries a few different ways to squish a representation * and tries a few different ways to squish a representation
@@ -3458,7 +3459,7 @@ char *posbar;
* account. It returns number of columns needed back to * account. It returns number of columns needed back to
* make_things_fit(), so make_things_fit() can make attempt * make_things_fit(), so make_things_fit() can make attempt
* to make adjustments. * to make adjustments.
* *
* render_status * render_status
* *
* Goes through each of the two status row's fields and * Goes through each of the two status row's fields and
@@ -3492,8 +3493,8 @@ const char *fieldnames[] = {
}; };
#ifdef STATUS_HILITES #ifdef STATUS_HILITES
static int FDECL(condcolor, (long, unsigned long *)); STATIC_DCL int FDECL(condcolor, (long, unsigned long *));
static int FDECL(condattr, (long, unsigned long *)); STATIC_DCL int FDECL(condattr, (long, unsigned long *));
static unsigned long *tty_colormasks; static unsigned long *tty_colormasks;
static long tty_condition_bits; static long tty_condition_bits;
int cond_disp_width[2]; /* 2: current and previous */ int cond_disp_width[2]; /* 2: current and previous */
@@ -3505,7 +3506,7 @@ static struct condition_t {
long mask; long mask;
const char *text[3]; /* 3: potential display values, progressively const char *text[3]; /* 3: potential display values, progressively
* smaller */ * smaller */
} conditions[] = { } conditions[] = {
/* The sequence order of these matters */ /* The sequence order of these matters */
{ BL_MASK_STONE, {"Stone", "Ston", "Sto"}}, { BL_MASK_STONE, {"Stone", "Ston", "Sto"}},
{ BL_MASK_SLIME, {"Slime", "Slim", "Slm"}}, { BL_MASK_SLIME, {"Slime", "Slim", "Slm"}},
@@ -3538,7 +3539,7 @@ static enum statusfields fieldorder[2][15] = { /* 2: two status lines */
static boolean windowdata_init = FALSE; static boolean windowdata_init = FALSE;
static int cond_shrinklvl = 0, cond_width_at_shrink = 0; static int cond_shrinklvl = 0, cond_width_at_shrink = 0;
static int enclev = 0, enc_shrinklvl = 0; static int enclev = 0, enc_shrinklvl = 0;
static int dl_shrinklvl = 0; /* static int dl_shrinklvl = 0; */
static boolean truncation_expected = FALSE; static boolean truncation_expected = FALSE;
/* This controls whether to skip fields that aren't /* This controls whether to skip fields that aren't
@@ -3663,87 +3664,85 @@ unsigned long *colormasks;
return; return;
switch (fldidx) { switch (fldidx) {
case BL_FLUSH: case BL_FLUSH:
force_update = TRUE; force_update = TRUE;
break; break;
case BL_CONDITION: case BL_CONDITION:
tty_status[NOW][fldidx].idx = fldidx; tty_status[NOW][fldidx].idx = fldidx;
tty_condition_bits = *condptr; tty_condition_bits = *condptr;
tty_colormasks = colormasks; tty_colormasks = colormasks;
tty_status[NOW][fldidx].valid = TRUE; tty_status[NOW][fldidx].valid = TRUE;
tty_status[NOW][fldidx].dirty = TRUE; tty_status[NOW][fldidx].dirty = TRUE;
truncation_expected = FALSE; truncation_expected = FALSE;
break; break;
default: default:
tty_status[NOW][fldidx].idx = fldidx; tty_status[NOW][fldidx].idx = fldidx;
Sprintf(status_vals[fldidx], Sprintf(status_vals[fldidx],
status_fieldfmt[fldidx] ? status_fieldfmt[fldidx] ? status_fieldfmt[fldidx] : "%s",
status_fieldfmt[fldidx] : "%s", text); text);
tty_status[NOW][fldidx].color = do_color ? (color & 0x00FF) tty_status[NOW][fldidx].color = do_color ? (color & 0x00FF) : NO_COLOR;
: NO_COLOR; tty_status[NOW][fldidx].attr = (color & 0xFF00) >> 8;
tty_status[NOW][fldidx].attr = (color & 0xFF00) >> 8; tty_status[NOW][fldidx].lth = strlen(status_vals[fldidx]);
tty_status[NOW][fldidx].lth = strlen(status_vals[fldidx]); tty_status[NOW][fldidx].valid = TRUE;
tty_status[NOW][fldidx].valid = TRUE; tty_status[NOW][fldidx].dirty = TRUE;
tty_status[NOW][fldidx].dirty = TRUE; break;
break;
} }
/* The core botl engine sends a single blank to the window port /* The core botl engine sends a single blank to the window port
for carrying-capacity when its unused. Let's suppress that */ for carrying-capacity when its unused. Let's suppress that */
if (tty_status[NOW][fldidx].lth == 1 if (tty_status[NOW][fldidx].lth == 1
&& status_vals[fldidx][0] == ' ') { && status_vals[fldidx][0] == ' ') {
status_vals[fldidx][0] = '\0'; status_vals[fldidx][0] = '\0';
tty_status[NOW][fldidx].lth = 0; tty_status[NOW][fldidx].lth = 0;
} }
/* default processing above was required before these */ /* default processing above was required before these */
switch (fldidx) { switch (fldidx) {
case BL_HP: case BL_HP:
if (iflags.wc2_hitpointbar) { if (iflags.wc2_hitpointbar) {
/* Special additional processing for hitpointbar */ /* Special additional processing for hitpointbar */
hpbar_percent = percent; hpbar_percent = percent;
hpbar_color = do_color ? (color & 0x00FF) : NO_COLOR; hpbar_color = do_color ? (color & 0x00FF) : NO_COLOR;
}
break;
case BL_LEVELDESC:
case BL_HUNGER:
/* The core sends trailing blanks for some fields.
Let's suppress the trailing blanks */
lastchar = eos(status_vals[fldidx]);
lastchar--;
while (*lastchar == ' ' && lastchar >= status_vals[fldidx]) {
*lastchar-- = '\0';
tty_status[NOW][fldidx].lth--;
}
break;
case BL_TITLE:
if (iflags.wc2_hitpointbar)
tty_status[NOW][fldidx].lth += 2; /* '[' and ']' */
break;
case BL_GOLD:
tty_status[NOW][fldidx].lth -= 9; /* \GXXXXNNNN counts as 1 */
break;
case BL_CAP:
fval = status_vals[fldidx];
if (fval) {
if (*fval == ' ')
fval++;
for (i = 0; i < SIZE(encvals); ++i) {
if (!strcmp(encvals[enc_shrinklvl][i], fval)) {
enclev = i;
break; /* for */
} }
break; }
case BL_LEVELDESC: }
case BL_HUNGER: break;
/* The core sends trailing blanks for some fields
Let's suppress the trailing blanks */
lastchar = eos(status_vals[fldidx]);
lastchar--;
while (lastchar && *lastchar == ' '
&& lastchar >= status_vals[fldidx]) {
*lastchar-- = '\0';
tty_status[NOW][fldidx].lth--;
}
break;
case BL_TITLE:
if (iflags.wc2_hitpointbar)
tty_status[NOW][fldidx].lth += 2; /* '[' and ']' */
break;
case BL_GOLD:
tty_status[NOW][fldidx].lth -= 9; /* \GXXXXNNNN counts as 1 */
break;
case BL_CAP:
fval = status_vals[fldidx];
if (fval) {
if (*fval == ' ')
fval++;
for (i = 0; i < SIZE(encvals); ++i) {
if (!strcmp(encvals[enc_shrinklvl][i], fval)) {
enclev = i;
break; /* for */
}
}
}
break;
} }
if (make_things_fit(force_update) || truncation_expected) if (make_things_fit(force_update) || truncation_expected)
render_status(); render_status();
return; return;
} }
int STATIC_OVL int
make_things_fit(force_update) make_things_fit(force_update)
boolean force_update; boolean force_update;
{ {
@@ -3754,7 +3753,8 @@ boolean force_update;
condsz = condition_size(); condsz = condition_size();
for (trycnt = 0; trycnt < 6 && !fitting; ++trycnt) { for (trycnt = 0; trycnt < 6 && !fitting; ++trycnt) {
check = check_fields(force_update, &rowsz[0], &rowsz[1]); check = check_fields(force_update, &rowsz[0], &rowsz[1]);
if (!check) return 0; if (!check)
return 0;
requirement = rowsz[1]; requirement = rowsz[1];
if (requirement < wins[WIN_STATUS]->cols - 1) { if (requirement < wins[WIN_STATUS]->cols - 1) {
@@ -3833,8 +3833,8 @@ int *topsz, *bottomsz;
matchprev = FALSE; matchprev = FALSE;
if (do_field_opt && tty_status[NOW][idx].dirty) { if (do_field_opt && tty_status[NOW][idx].dirty) {
/* compare values */ /* compare values */
const char *ob, *nb; /* old byte, new byte */ const char *ob, *nb; /* old byte, new byte */
c = col - 1; c = col - 1;
ob = &wins[WIN_STATUS]->data[row][c]; ob = &wins[WIN_STATUS]->data[row][c];
nb = status_vals[idx]; nb = status_vals[idx];
@@ -3848,7 +3848,7 @@ int *topsz, *bottomsz;
if (!*nb && c > col - 1) if (!*nb && c > col - 1)
matchprev = TRUE; matchprev = TRUE;
} }
} }
/* /*
* With STATUS_HILITES, it is possible that the color * With STATUS_HILITES, it is possible that the color
* needs to change even if the text is the same, so * needs to change even if the text is the same, so
@@ -3861,7 +3861,7 @@ int *topsz, *bottomsz;
if (forcefields || update_right || !matchprev if (forcefields || update_right || !matchprev
|| tty_status[NOW][idx].color != tty_status[BEFORE][idx].color || tty_status[NOW][idx].color != tty_status[BEFORE][idx].color
|| tty_status[NOW][idx].attr != tty_status[BEFORE][idx].attr) || tty_status[NOW][idx].attr != tty_status[BEFORE][idx].attr)
tty_status[NOW][idx].redraw = TRUE; tty_status[NOW][idx].redraw = TRUE;
col += tty_status[NOW][idx].lth; col += tty_status[NOW][idx].lth;
} }
if (row && bottomsz) if (row && bottomsz)
@@ -3877,11 +3877,11 @@ int *topsz, *bottomsz;
* If val isn't null, it will be used rather than * If val isn't null, it will be used rather than
* fld (it takes precedence). * fld (it takes precedence).
*/ */
void STATIC_OVL void
tty_putstatusfield(fld, val, x, y) tty_putstatusfield(fld, val, x, y)
struct tty_status_fields *fld; struct tty_status_fields *fld;
const char *val; const char *val;
int x,y; int x, y;
{ {
int i, n, ncols, lth; int i, n, ncols, lth;
struct WinDesc *cw = 0; struct WinDesc *cw = 0;
@@ -3898,7 +3898,8 @@ int x,y;
text = status_vals[fld->idx]; text = status_vals[fld->idx];
lth = fld->lth; lth = fld->lth;
} }
if (!text) return; if (!text)
return;
print_vt_code2(AVTC_SELECT_WINDOW, NHW_STATUS); print_vt_code2(AVTC_SELECT_WINDOW, NHW_STATUS);
@@ -3917,23 +3918,22 @@ int x,y;
} else { } else {
/* Now we're truncating */ /* Now we're truncating */
if (truncation_expected) if (truncation_expected)
; /* but we new in advance */ ; /* but we knew in advance */
} }
} }
int STATIC_OVL int
condition_size() condition_size()
{ {
long mask = 0L; long mask = 0L;
int c, x; int c, x;
boolean fitting = FALSE;
x = 0; x = 0;
for (c = 0; c < SIZE(conditions); ++c) { for (c = 0; c < SIZE(conditions); ++c) {
mask = conditions[c].mask; mask = conditions[c].mask;
if ((tty_condition_bits & mask) == mask) { if ((tty_condition_bits & mask) == mask) {
x++; /* for spacer */ x++; /* for spacer */
x += (int) strlen(conditions[c].text[cond_shrinklvl]); x += (int) strlen(conditions[c].text[cond_shrinklvl]);
} }
} }
tty_status[NOW][BL_CONDITION].lth = x; tty_status[NOW][BL_CONDITION].lth = x;
@@ -3941,7 +3941,7 @@ condition_size()
return x; return x;
} }
void STATIC_OVL void
shrink_enc(lvl) shrink_enc(lvl)
int lvl; int lvl;
{ {
@@ -3953,24 +3953,19 @@ int lvl;
tty_status[NOW][BL_CAP].lth = strlen(status_vals[BL_CAP]); tty_status[NOW][BL_CAP].lth = strlen(status_vals[BL_CAP]);
} }
void STATIC_OVL void
shrink_dlvl(lvl) shrink_dlvl(lvl)
int lvl; int lvl;
{ {
/* try changing Dlvl: to Dl: */ /* try changing Dlvl: to Dl: */
char buf[BUFSZ]; char buf[BUFSZ];
char *levval =index(status_vals[BL_LEVELDESC], ':'); char *levval = index(status_vals[BL_LEVELDESC], ':');
if (levval) { if (levval) {
if (lvl == 0) Strcpy(buf, (lvl == 0) ? "Dlvl" : "Dl");
Strcpy(buf, "Dlvl");
else
Strcpy(buf, "Dl");
Strcat(buf, levval); Strcat(buf, levval);
Strcpy(status_vals[BL_LEVELDESC], buf); Strcpy(status_vals[BL_LEVELDESC], buf);
tty_status[NOW][BL_LEVELDESC].lth = tty_status[NOW][BL_LEVELDESC].lth = strlen(status_vals[BL_LEVELDESC]);
strlen(status_vals[BL_LEVELDESC]);
} }
} }
@@ -3978,12 +3973,12 @@ int lvl;
* Ensure the underlying status window data start out * Ensure the underlying status window data start out
* blank and null-terminated. * blank and null-terminated.
*/ */
boolean STATIC_OVL boolean
check_windowdata(VOID_ARGS) check_windowdata(VOID_ARGS)
{ {
if (WIN_STATUS == WIN_ERR || wins[WIN_STATUS] == (struct WinDesc *) 0) { if (WIN_STATUS == WIN_ERR || wins[WIN_STATUS] == (struct WinDesc *) 0) {
paniclog("check_windowdata", " null status window."); paniclog("check_windowdata", " null status window.");
return FALSE; return FALSE;
} else if (!windowdata_init) { } else if (!windowdata_init) {
int i, n = wins[WIN_STATUS]->cols; int i, n = wins[WIN_STATUS]->cols;
@@ -3997,13 +3992,14 @@ check_windowdata(VOID_ARGS)
} }
return TRUE; return TRUE;
} }
#ifdef TEXTCOLOR #ifdef TEXTCOLOR
/* /*
* Return what color this condition should * Return what color this condition should
* be displayed in based on user settings. * be displayed in based on user settings.
*/ */
int condcolor(bm, bmarray) STATIC_OVL int
condcolor(bm, bmarray)
long bm; long bm;
unsigned long *bmarray; unsigned long *bmarray;
{ {
@@ -4018,7 +4014,8 @@ unsigned long *bmarray;
} }
#endif /* TEXTCOLOR */ #endif /* TEXTCOLOR */
int condattr(bm, bmarray) STATIC_OVL int
condattr(bm, bmarray)
long bm; long bm;
unsigned long *bmarray; unsigned long *bmarray;
{ {
@@ -4029,21 +4026,21 @@ unsigned long *bmarray;
for (i = HL_ATTCLR_DIM; i < BL_ATTCLR_MAX; ++i) { for (i = HL_ATTCLR_DIM; i < BL_ATTCLR_MAX; ++i) {
if (bmarray[i] && (bm & bmarray[i])) { if (bmarray[i] && (bm & bmarray[i])) {
switch(i) { switch(i) {
case HL_ATTCLR_DIM: case HL_ATTCLR_DIM:
attr |= HL_DIM; attr |= HL_DIM;
break; break;
case HL_ATTCLR_BLINK: case HL_ATTCLR_BLINK:
attr |= HL_BLINK; attr |= HL_BLINK;
break; break;
case HL_ATTCLR_ULINE: case HL_ATTCLR_ULINE:
attr |= HL_ULINE; attr |= HL_ULINE;
break; break;
case HL_ATTCLR_INVERSE: case HL_ATTCLR_INVERSE:
attr |= HL_INVERSE; attr |= HL_INVERSE;
break; break;
case HL_ATTCLR_BOLD: case HL_ATTCLR_BOLD:
attr |= HL_BOLD; attr |= HL_BOLD;
break; break;
} }
} }
} }
@@ -4052,50 +4049,56 @@ unsigned long *bmarray;
} }
#define Begin_Attr(m) \ #define Begin_Attr(m) \
if (m) { \ do { \
if ((m) & HL_BOLD) \ if (m) { \
term_start_attr(ATR_BOLD); \ if ((m) & HL_BOLD) \
if ((m) & HL_INVERSE) \ term_start_attr(ATR_BOLD); \
term_start_attr(ATR_INVERSE); \ if ((m) & HL_INVERSE) \
if ((m) & HL_ULINE) \ term_start_attr(ATR_INVERSE); \
term_start_attr(ATR_ULINE); \ if ((m) & HL_ULINE) \
if ((m) & HL_BLINK) \ term_start_attr(ATR_ULINE); \
term_start_attr(ATR_BLINK); \ if ((m) & HL_BLINK) \
if ((m) & HL_DIM) \ term_start_attr(ATR_BLINK); \
term_start_attr(ATR_DIM); \ if ((m) & HL_DIM) \
} term_start_attr(ATR_DIM); \
} \
} while (0)
#define End_Attr(m) \ #define End_Attr(m) \
if (m) { \ do { \
if ((m) & HL_DIM) \ if (m) { \
term_end_attr(ATR_DIM); \ if ((m) & HL_DIM) \
if ((m) & HL_BLINK) \ term_end_attr(ATR_DIM); \
term_end_attr(ATR_BLINK); \ if ((m) & HL_BLINK) \
if ((m) & HL_ULINE) \ term_end_attr(ATR_BLINK); \
term_end_attr(ATR_ULINE); \ if ((m) & HL_ULINE) \
if ((m) & HL_INVERSE) \ term_end_attr(ATR_ULINE); \
term_end_attr(ATR_INVERSE); \ if ((m) & HL_INVERSE) \
if ((m) & HL_BOLD) \ term_end_attr(ATR_INVERSE); \
term_end_attr(ATR_BOLD); \ if ((m) & HL_BOLD) \
} term_end_attr(ATR_BOLD); \
} \
} while (0)
void STATIC_OVL void
render_status(VOID_ARGS) render_status(VOID_ARGS)
{ {
long mask = 0L; long mask = 0L;
int i, c, row, attrmask = 0; int i, c, row, attrmask = 0;
struct WinDesc *cw = 0; struct WinDesc *cw = 0;
boolean do_color = FALSE, fit = FALSE; boolean do_color =
struct tty_status_fields *nullfield = (struct tty_status_fields *)0;
#ifdef TEXTCOLOR #ifdef TEXTCOLOR
do_color = TRUE; TRUE
#else
FALSE
#endif #endif
;
struct tty_status_fields *nullfield = (struct tty_status_fields *) 0;
if (WIN_STATUS == WIN_ERR if (WIN_STATUS == WIN_ERR
|| (cw = wins[WIN_STATUS]) == (struct WinDesc *) 0) { || (cw = wins[WIN_STATUS]) == (struct WinDesc *) 0) {
paniclog("render_status", "WIN_ERR on status window."); paniclog("render_status", "WIN_ERR on status window.");
return; return;
} }
for (row = 0; row < 2; ++row) { for (row = 0; row < 2; ++row) {
@@ -4103,23 +4106,23 @@ render_status(VOID_ARGS)
for (i = 0; fieldorder[row][i] != BL_FLUSH; ++i) { for (i = 0; fieldorder[row][i] != BL_FLUSH; ++i) {
int fldidx = fieldorder[row][i]; int fldidx = fieldorder[row][i];
if (do_field_opt && !tty_status[NOW][fldidx].redraw)
continue;
/*
* Ignore zero length fields. check_fields() didn't count
* them in either.
*/
if (!tty_status[NOW][fldidx].lth && fldidx != BL_CONDITION)
continue;
if (status_activefields[fldidx]) { if (status_activefields[fldidx]) {
int coloridx = tty_status[NOW][fldidx].color; int coloridx = tty_status[NOW][fldidx].color;
int attridx = tty_status[NOW][fldidx].attr; int attridx = tty_status[NOW][fldidx].attr;
int x = tty_status[NOW][fldidx].x; int x = tty_status[NOW][fldidx].x;
int y = row; int y = row;
char *text = status_vals[fldidx]; char *text = status_vals[fldidx];
boolean hitpointbar = (fldidx == BL_TITLE && iflags.wc2_hitpointbar); boolean hitpointbar = (fldidx == BL_TITLE
&& iflags.wc2_hitpointbar);
if (do_field_opt && !tty_status[NOW][fldidx].redraw)
continue;
/*
* Ignore zero length fields. check_fields() didn't count
* them in either.
*/
if (!tty_status[NOW][fldidx].lth && fldidx != BL_CONDITION)
continue;
if (fldidx == BL_CONDITION) { if (fldidx == BL_CONDITION) {
/* /*
@@ -4130,6 +4133,8 @@ render_status(VOID_ARGS)
for (c = 0; c < SIZE(conditions); ++c) { for (c = 0; c < SIZE(conditions); ++c) {
mask = conditions[c].mask; mask = conditions[c].mask;
if ((tty_condition_bits & mask) == mask) { if ((tty_condition_bits & mask) == mask) {
const char *condtext;
tty_putstatusfield(nullfield, " ", x++, y); tty_putstatusfield(nullfield, " ", x++, y);
if (iflags.hilite_delta) { if (iflags.hilite_delta) {
attrmask = condattr(mask, tty_colormasks); attrmask = condattr(mask, tty_colormasks);
@@ -4141,10 +4146,11 @@ render_status(VOID_ARGS)
} }
} }
if (x >= cw->cols && !truncation_expected) if (x >= cw->cols && !truncation_expected)
impossible("Unexpected condition placement overflow"); impossible(
tty_putstatusfield(nullfield, "Unexpected condition placement overflow");
conditions[c].text[cond_shrinklvl], x, y); condtext = conditions[c].text[cond_shrinklvl];
x += (int) strlen(conditions[c].text[cond_shrinklvl]); tty_putstatusfield(nullfield, condtext, x, y);
x += (int) strlen(condtext);
if (iflags.hilite_delta) { if (iflags.hilite_delta) {
if (do_color && coloridx != NO_COLOR) if (do_color && coloridx != NO_COLOR)
term_end_color(); term_end_color();
@@ -4152,6 +4158,11 @@ render_status(VOID_ARGS)
} }
} }
} }
if (x >= cw->cols) {
if (!truncation_expected)
paniclog("render_status()", " unexpected truncation.");
x = cw->cols - 1;
}
tty_curs(WIN_STATUS, x, y); tty_curs(WIN_STATUS, x, y);
cl_end(); cl_end();
} else if (fldidx == BL_GOLD) { } else if (fldidx == BL_GOLD) {
@@ -4161,9 +4172,21 @@ render_status(VOID_ARGS)
* | Gold | * | Gold |
* +-----------+ * +-----------+
*/ */
if (iflags.hilite_delta) {
/* multiple attributes can be in effect concurrently */
Begin_Attr(attridx);
if (do_color && coloridx != NO_COLOR
&& coloridx != CLR_MAX)
term_start_color(coloridx);
}
/* decode_mixed() due to GOLD glyph */ /* decode_mixed() due to GOLD glyph */
tty_putstatusfield(nullfield, tty_putstatusfield(nullfield,
decode_mixed(buf, text), x, y); decode_mixed(buf, text), x, y);
if (iflags.hilite_delta) {
if (do_color && coloridx != NO_COLOR)
term_end_color();
End_Attr(attridx);
}
} else if (hitpointbar) { } else if (hitpointbar) {
/* /*
* +-------------------------+ * +-------------------------+
@@ -4210,8 +4233,8 @@ render_status(VOID_ARGS)
tty_putstatusfield(nullfield, "]", x++, y); tty_putstatusfield(nullfield, "]", x++, y);
} else { } else {
tty_putstatusfield(&tty_status[NOW][fldidx], tty_putstatusfield(&tty_status[NOW][fldidx],
(char *)0, x, y); (char *) 0, x, y);
} }
} else { } else {
/* /*
* +-----------------------------+ * +-----------------------------+
@@ -4228,15 +4251,15 @@ render_status(VOID_ARGS)
Begin_Attr(attridx); Begin_Attr(attridx);
if (do_color && coloridx != NO_COLOR if (do_color && coloridx != NO_COLOR
&& coloridx != CLR_MAX) && coloridx != CLR_MAX)
term_start_color(coloridx); term_start_color(coloridx);
} }
tty_putstatusfield(&tty_status[NOW][fldidx], tty_putstatusfield(&tty_status[NOW][fldidx],
text, x, y); text, x, y);
if (iflags.hilite_delta) { if (iflags.hilite_delta) {
if (do_color && coloridx != NO_COLOR) if (do_color && coloridx != NO_COLOR)
term_end_color(); term_end_color();
End_Attr(attridx); End_Attr(attridx);
} }
} }
/* reset .redraw and .dirty now that they've been rendered */ /* reset .redraw and .dirty now that they've been rendered */
tty_status[NOW][fldidx].dirty = FALSE; tty_status[NOW][fldidx].dirty = FALSE;
@@ -4245,9 +4268,9 @@ render_status(VOID_ARGS)
* Make a copy of the entire tty_status struct for comparison * Make a copy of the entire tty_status struct for comparison
* of current and previous. * of current and previous.
*/ */
tty_status[BEFORE][fldidx] = tty_status[NOW][fldidx]; /* copy struct */ tty_status[BEFORE][fldidx] = tty_status[NOW][fldidx];
} }
} }
} }
if (cond_disp_width[NOW] < cond_width_at_shrink) { if (cond_disp_width[NOW] < cond_width_at_shrink) {
cond_shrinklvl = 0; /* reset */ cond_shrinklvl = 0; /* reset */