Merge branch 'NetHack-3.6.2'

This commit is contained in:
nhmall
2019-03-25 22:56:11 -04:00
2 changed files with 46 additions and 18 deletions
+5 -6
View File
@@ -284,7 +284,7 @@ curses_teardown_messages(void)
void void
curses_prev_mesg() curses_prev_mesg()
{ {
int count, fifo_count; int count;
winid wid; winid wid;
long turn = 0; long turn = 0;
anything Id; anything Id;
@@ -296,9 +296,8 @@ curses_prev_mesg()
curses_create_nhmenu(wid); curses_create_nhmenu(wid);
Id = cg.zeroany; Id = cg.zeroany;
for (count = 0, fifo_count = num_messages - 1; count < num_messages; for (count = 0; count < num_messages; ++count) {
++count, --fifo_count) { mesg = get_msg_line(do_lifo, count);
mesg = get_msg_line(TRUE, do_lifo ? count : fifo_count);
if (turn != mesg->turn && count != 0) { if (turn != mesg->turn && count != 0) {
curses_add_menu(wid, NO_GLYPH, &Id, 0, 0, A_NORMAL, "---", FALSE); curses_add_menu(wid, NO_GLYPH, &Id, 0, 0, A_NORMAL, "---", FALSE);
} }
@@ -323,13 +322,13 @@ curses_prev_mesg()
void void
curses_count_window(const char *count_text) curses_count_window(const char *count_text)
{ {
static WINDOW *countwin = NULL;
int startx, starty, winx, winy; int startx, starty, winx, winy;
int messageh, messagew; int messageh, messagew;
static WINDOW *countwin = NULL;
if (!count_text) { if (!count_text) {
if (countwin) if (countwin)
delwin(countwin), countwin = NULL; delwin(countwin), countwin = NULL;
counting = FALSE; counting = FALSE;
return; return;
} }
+41 -12
View File
@@ -301,14 +301,14 @@ unsigned long *colormasks;
const enum statusfields (*fieldorder)[3][15]; const enum statusfields (*fieldorder)[3][15];
xchar spacing[MAXBLSTATS], valline[MAXBLSTATS]; xchar spacing[MAXBLSTATS], valline[MAXBLSTATS];
enum statusfields fld, prev_fld; enum statusfields fld, prev_fld;
char *text, *p, cbuf[BUFSZ]; char *text, *p, cbuf[BUFSZ], ebuf[STATVAL_WIDTH];
#ifdef SCORE_ON_BOTL #ifdef SCORE_ON_BOTL
char *colon; char *colon;
char sbuf[STATVAL_WIDTH]; char sbuf[STATVAL_WIDTH];
#endif #endif
int i, j, number_of_lines, int i, j, number_of_lines,
cap_and_hunger, exp_points, sho_score, cap_and_hunger, exp_points, sho_score,
height, width, w, xtra, clen, x, y, t, height, width, w, xtra, clen, x, y, t, ex, ey,
condstart = 0, conddummy = 0; condstart = 0, conddummy = 0;
int coloridx = NO_COLOR, attrmask = 0; int coloridx = NO_COLOR, attrmask = 0;
boolean asis = FALSE; boolean asis = FALSE;
@@ -367,7 +367,7 @@ unsigned long *colormasks;
startover: startover:
/* first pass for line #j -- figure out spacing */ /* first pass for line #j -- figure out spacing */
(void) memset((genericptr_t) spacing, 0, sizeof spacing); (void) memset((genericptr_t) spacing, 0, sizeof spacing);
w = xtra = 0; w = xtra = 0; /* w: width so far; xtra: number of extra spaces */
prev_fld = BL_FLUSH; prev_fld = BL_FLUSH;
for (i = 0; (fld = (*fieldorder)[j][i]) != BL_FLUSH; ++i) { for (i = 0; (fld = (*fieldorder)[j][i]) != BL_FLUSH; ++i) {
text = status_vals[fld]; text = status_vals[fld];
@@ -403,7 +403,7 @@ unsigned long *colormasks;
/*FALLTHRU*/ /*FALLTHRU*/
case BL_ALIGN: case BL_ALIGN:
case BL_LEVELDESC: case BL_LEVELDESC:
spacing[fld] = (i > 0 ? 1 : 0); spacing[fld] = (i > 0 ? 1 : 0); /* extra space unless first */
break; break;
case BL_HUNGER: case BL_HUNGER:
spacing[fld] = (cap_and_hunger & 1); spacing[fld] = (cap_and_hunger & 1);
@@ -525,6 +525,19 @@ unsigned long *colormasks;
/* always enabled but might be empty */ /* always enabled but might be empty */
if (!(cap_and_hunger & 2)) if (!(cap_and_hunger & 2))
continue; continue;
/* check whether encumbrance is going to go past right edge
and wrap; if so, truncate it; (won't wrap on last line
of borderless window, but will when there's a border);
could only do that after all extra spaces are gone */
if (!xtra) {
getyx(win, ey, ex);
t = (int) strlen(text);
if (ex + t > width - (border ? 0 : 1)) {
text = strcpy(ebuf, text);
t = (width - (border ? 0 : 1)) - (ex - 1);
ebuf[max(t, 2)] = '\0'; /* might still wrap... */
}
}
break; break;
case BL_SCORE: case BL_SCORE:
#ifdef SCORE_ON_BOTL #ifdef SCORE_ON_BOTL
@@ -545,7 +558,7 @@ unsigned long *colormasks;
if (fld == BL_TITLE && iflags.wc2_hitpointbar) { if (fld == BL_TITLE && iflags.wc2_hitpointbar) {
/* hitpointbar using hp percent calculation; title width /* hitpointbar using hp percent calculation; title width
is padded to 30 if shorter, truncated at 30 if longer; is padded to 30 if shorter, truncated at 30 if longer;
otherall width is 32 because of the enclosing brackets */ overall width is 32 because of the enclosing brackets */
curs_HPbar(text, 0); curs_HPbar(text, 0);
} else if (fld != BL_CONDITION) { } else if (fld != BL_CONDITION) {
@@ -584,6 +597,12 @@ unsigned long *colormasks;
/* status conditions */ /* status conditions */
if (curses_condition_bits) { if (curses_condition_bits) {
getyx(win, y, x); getyx(win, y, x);
/* encumbrance is truncated if too wide, but other fields
aren't; if window is narrower than normal, last field
written might have wrapped to the next line */
if (y > j + (border ? 1 : 0))
x = width - (border ? -1 : 0), /* (width-=2 above) */
y = j + (border ? 1 : 0);
/* cbuf[] was populated above; clen is its length */ /* cbuf[] was populated above; clen is its length */
if (number_of_lines == 3) { if (number_of_lines == 3) {
/* /*
@@ -610,7 +629,7 @@ unsigned long *colormasks;
condition string as-is if it will overflow; we condition string as-is if it will overflow; we
want curs_stat_conds() to write '+' in last column want curs_stat_conds() to write '+' in last column
if any conditions are all the way off the edge */ if any conditions are all the way off the edge */
if (x + clen <= width - (border ? 1 : 0)) if (x + clen > width - (border ? 1 : 0))
asis = FALSE; asis = FALSE;
if (asis) if (asis)
@@ -967,8 +986,8 @@ curs_stat_conds(int vert_cond, /* 0 => horizontal, 1 => vertical */
for (i = 0; i < BL_MASK_BITS; ++i) { for (i = 0; i < BL_MASK_BITS; ++i) {
bitmsk = valid_conditions[i].bitmask; bitmsk = valid_conditions[i].bitmask;
if (curses_condition_bits & bitmsk) { if (curses_condition_bits & bitmsk) {
Strcat(strcat(condbuf, " "), Strcpy(condnam, valid_conditions[i].id);
upstart(strcpy(condnam, valid_conditions[i].id))); Strcat(strcat(condbuf, " "), upstart(condnam));
if (nohilite && *nohilite if (nohilite && *nohilite
&& (condcolor(bitmsk, colormasks) != NO_COLOR && (condcolor(bitmsk, colormasks) != NO_COLOR
|| condattr(bitmsk, colormasks) != 0)) || condattr(bitmsk, colormasks) != 0))
@@ -977,7 +996,8 @@ curs_stat_conds(int vert_cond, /* 0 => horizontal, 1 => vertical */
} }
} else if (curses_condition_bits) { } else if (curses_condition_bits) {
unsigned long cond_bits; unsigned long cond_bits;
int height = 0, width, cx, cy, cy0, attrmask = 0, color = NO_COLOR; int height = 0, width, cx, cy, cy0, cndlen,
attrmask = 0, color = NO_COLOR;
boolean border, do_vert = (vert_cond != 0); boolean border, do_vert = (vert_cond != 0);
WINDOW *win = curses_get_nhwin(STATUS_WIN); WINDOW *win = curses_get_nhwin(STATUS_WIN);
@@ -990,10 +1010,19 @@ curs_stat_conds(int vert_cond, /* 0 => horizontal, 1 => vertical */
for (i = 0; i < BL_MASK_BITS; ++i) { for (i = 0; i < BL_MASK_BITS; ++i) {
bitmsk = valid_conditions[i].bitmask; bitmsk = valid_conditions[i].bitmask;
if (cond_bits & bitmsk) { if (cond_bits & bitmsk) {
Strcpy(condnam, valid_conditions[i].id);
cndlen = 1 + (int) strlen(condnam); /* count leading space */
if (!do_vert) { if (!do_vert) {
getyx(win, cy, cx); getyx(win, cy, cx);
if (cx >= width - (border ? 2 : 1) || (border && cy > cy0)) if (cy > cy0) /* wrap to next line shouldn't happen */
break; /* skip rest if not enough room for any more */ cx = width, cy = cy0;
if (cx + cndlen > width - (border ? 2 : 1)) {
/* not enough room for current condition */
if (cx + 1 > width - (border ? 2 : 1))
break; /* no room at all; skip it and the rest */
/* room for part; truncate it to avoid wrapping */
condnam[width - (border ? 2 : 1) - cx] = '\0';
}
} }
cond_bits &= ~bitmsk; /* nonzero if another cond after this */ cond_bits &= ~bitmsk; /* nonzero if another cond after this */
/* output unhighlighted leading space unless at #1 of 3 */ /* output unhighlighted leading space unless at #1 of 3 */
@@ -1011,7 +1040,7 @@ curs_stat_conds(int vert_cond, /* 0 => horizontal, 1 => vertical */
} }
/* output the condition name */ /* output the condition name */
waddstr(win, upstart(strcpy(condnam, valid_conditions[i].id))); waddstr(win, upstart(condnam));
if (iflags.hilite_delta) { if (iflags.hilite_delta) {
#ifdef TEXTCOLOR #ifdef TEXTCOLOR