Merge branch 'NetHack-3.6.2-beta01' into NetHack-3.6.2

This commit is contained in:
nhmall
2018-09-30 00:11:30 -04:00
3 changed files with 44 additions and 36 deletions
+3 -2
View File
@@ -168,8 +168,9 @@ tty: turn off an optimization that is the suspected cause of Windows reported
tty: ensure that current status fields are always copied to prior status tty: ensure that current status fields are always copied to prior status
values so that comparisons are correct values so that comparisons are correct
tty: fix an out of bounds error in tty_status_update() for BL_HUNGER case tty: fix an out of bounds error in tty_status_update() for BL_HUNGER case
tty: fix leftover display artifact when last field on the row got smaller tty: fix leftover display artifact when the last field on the row got placed
and optimize so only the right-most field requires the cleanup code to the left of where it was previously due to it, or one of the fields
to its left, getting shorter
X11: its use of genl_status_update exposed a negative index use that could X11: its use of genl_status_update exposed a negative index use that could
lead to a segfault lead to a segfault
+1 -1
View File
@@ -79,7 +79,7 @@ struct tty_status_fields {
boolean valid; boolean valid;
boolean dirty; boolean dirty;
boolean redraw; boolean redraw;
boolean padright; boolean last_on_row;
}; };
#endif #endif
+40 -33
View File
@@ -3541,7 +3541,8 @@ static enum statusfields fieldorder[2][MAX_PER_ROW] = { /* 2: two status lines *
BL_CAP, BL_CONDITION, BL_FLUSH } BL_CAP, BL_CONDITION, BL_FLUSH }
}; };
static int last_on_row[2]; static int last_on_row[2]; /* [rows] */
static int finalx[2][2]; /* [rows][NOW or BEFORE] */
static boolean setlast = FALSE; static boolean setlast = FALSE;
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;
@@ -3588,7 +3589,7 @@ tty_status_init()
tty_status[NOW][i].valid = FALSE; tty_status[NOW][i].valid = FALSE;
tty_status[NOW][i].dirty = FALSE; tty_status[NOW][i].dirty = FALSE;
tty_status[NOW][i].redraw = FALSE; tty_status[NOW][i].redraw = FALSE;
tty_status[NOW][i].padright = FALSE; tty_status[NOW][i].last_on_row = FALSE;
tty_status[BEFORE][i] = tty_status[NOW][i]; tty_status[BEFORE][i] = tty_status[NOW][i];
} }
tty_condition_bits = 0L; tty_condition_bits = 0L;
@@ -3883,12 +3884,11 @@ int *topsz, *bottomsz;
/* On a change to the field length, everything /* On a change to the field length, everything
further to the right must be updated as well */ further to the right must be updated as well */
if (tty_status[NOW][idx].lth != tty_status[BEFORE][idx].lth) { if (tty_status[NOW][idx].lth != tty_status[BEFORE][idx].lth)
update_right = TRUE; update_right = TRUE;
if ((tty_status[NOW][idx].lth < tty_status[BEFORE][idx].lth) &&
idx == last_on_row[row]) if (idx == last_on_row[row])
tty_status[NOW][idx].padright = TRUE; tty_status[NOW][idx].last_on_row = TRUE;
}
if (!update_right && !forcefields) { if (!update_right && !forcefields) {
/* /*
@@ -4176,22 +4176,22 @@ render_status(VOID_ARGS)
for (row = 0; row < 2; ++row) { for (row = 0; row < 2; ++row) {
curs(WIN_STATUS, 1, row); curs(WIN_STATUS, 1, row);
for (i = 0; fieldorder[row][i] != BL_FLUSH; ++i) { for (i = 0; fieldorder[row][i] != BL_FLUSH; ++i) {
int fldidx = fieldorder[row][i]; int idx = fieldorder[row][i];
if (!status_activefields[fldidx]) if (!status_activefields[idx])
continue; continue;
if ((tty_status[NOW][fldidx].lth || fldidx == BL_CONDITION) if ((tty_status[NOW][idx].lth || idx == BL_CONDITION)
&& (tty_status[NOW][fldidx].redraw || !do_field_opt)) { && (tty_status[NOW][idx].redraw || !do_field_opt)) {
int coloridx = tty_status[NOW][fldidx].color; int coloridx = tty_status[NOW][idx].color;
int attridx = tty_status[NOW][fldidx].attr; int attridx = tty_status[NOW][idx].attr;
int x = tty_status[NOW][fldidx].x; int x = tty_status[NOW][idx].x;
int y = row; int y = row;
char *text = status_vals[fldidx]; char *text = status_vals[idx];
boolean hitpointbar = (fldidx == BL_TITLE boolean hitpointbar = (idx == BL_TITLE
&& iflags.wc2_hitpointbar); && iflags.wc2_hitpointbar);
if (fldidx == BL_CONDITION) { if (idx == BL_CONDITION) {
/* /*
* +-----------------+ * +-----------------+
* | Condition Codes | * | Condition Codes |
@@ -4235,7 +4235,7 @@ render_status(VOID_ARGS)
} }
tty_curs(WIN_STATUS, x, y); tty_curs(WIN_STATUS, x, y);
cl_end(); cl_end();
} else if (fldidx == BL_GOLD) { } else if (idx == BL_GOLD) {
char buf[BUFSZ]; char buf[BUFSZ];
/* /*
* +-----------+ * +-----------+
@@ -4312,7 +4312,7 @@ 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][idx],
(char *) 0, x, y); (char *) 0, x, y);
} }
} else { } else {
@@ -4332,34 +4332,41 @@ render_status(VOID_ARGS)
if (coloridx != NO_COLOR && coloridx != CLR_MAX) if (coloridx != NO_COLOR && coloridx != CLR_MAX)
term_start_color(coloridx); term_start_color(coloridx);
} }
tty_putstatusfield(&tty_status[NOW][fldidx], tty_putstatusfield(&tty_status[NOW][idx],
text, x, y); text, x, y);
if (iflags.hilite_delta) { if (iflags.hilite_delta) {
if (coloridx != NO_COLOR && coloridx != CLR_MAX) if (coloridx != NO_COLOR && coloridx != CLR_MAX)
term_end_color(); term_end_color();
End_Attr(attridx); End_Attr(attridx);
} }
if (tty_status[NOW][fldidx].padright) { }
int cnt = tty_status[BEFORE][fldidx].lth if (tty_status[NOW][idx].last_on_row) {
- tty_status[NOW][fldidx].lth; int padright = 0;
x += (tty_status[NOW][fldidx].lth - 1); x = tty_status[NOW][idx].x + tty_status[NOW][idx].lth;
while (cnt-- > 0) finalx[row][NOW] = x - 1;
tty_putstatusfield(nullfield, " ", x++, y); if (finalx[row][NOW] < finalx[row][BEFORE])
} padright = finalx[row][BEFORE] - finalx[row][NOW];
while (padright-- > 0)
tty_putstatusfield(nullfield, " ", x++, y);
} }
} }
/* reset .redraw, .dirty, .padright now that they've been rendered */ /* reset .redraw, .dirty, .padright now that they've been rendered */
tty_status[NOW][fldidx].dirty = FALSE; tty_status[NOW][idx].dirty = FALSE;
tty_status[NOW][fldidx].redraw = FALSE; tty_status[NOW][idx].redraw = FALSE;
tty_status[NOW][fldidx].padright = FALSE; tty_status[NOW][idx].last_on_row = FALSE;
/* /*
* Make a copy of the entire tty_status struct for comparison * For comparison of current and previous:
* of current and previous. * - Copy the entire tty_status struct.
*/ */
tty_status[BEFORE][fldidx] = tty_status[NOW][fldidx]; tty_status[BEFORE][idx] = tty_status[NOW][idx];
} }
/*
* For comparison of current and previous:
* - Copy the last written column number on the row.
*/
finalx[row][BEFORE] = finalx[row][NOW];
} }
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 */