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

This commit is contained in:
nhmall
2019-04-06 09:13:11 -04:00
3 changed files with 102 additions and 60 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 extern.h $NHDT-Date: 1554538087 2019/04/06 08:08:07 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.698 $ */ /* NetHack 3.6 extern.h $NHDT-Date: 1554554180 2019/04/06 12:36:20 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.699 $ */
/* Copyright (c) Steve Creps, 1988. */ /* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -162,6 +162,8 @@ E int FDECL(describe_level, (char *));
E void NDECL(status_eval_next_unhilite); E void NDECL(status_eval_next_unhilite);
E void FDECL(status_initialize, (BOOLEAN_P)); E void FDECL(status_initialize, (BOOLEAN_P));
E void NDECL(status_finish); E void NDECL(status_finish);
E int NDECL(stat_cap_indx);
E int NDECL(stat_hunger_indx);
E const char *FDECL(bl_idx_to_fldname, (int)); E const char *FDECL(bl_idx_to_fldname, (int));
#ifdef STATUS_HILITES #ifdef STATUS_HILITES
E void NDECL(reset_status_hilites); E void NDECL(reset_status_hilites);

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 botl.c $NHDT-Date: 1554538091 2019/04/06 08:08:11 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.141 $ */ /* NetHack 3.6 botl.c $NHDT-Date: 1554554180 2019/04/06 12:36:20 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.142 $ */
/* 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. */
@@ -1302,6 +1302,37 @@ struct istat_s *bl, *maxbl;
return result; return result;
} }
/* callback so that interface can get capacity index rather than trying
to reconstruct that from the encumbrance string or asking the general
core what the value is */
int
stat_cap_indx()
{
int cap;
#ifdef STATUS_HILITES
cap = blstats[now_or_before_idx][BL_CAP].a.a_int;
#else
cap = near_capacity();
#endif
return cap;
}
/* callback so that interface can get hunger index rather than trying to
reconstruct that from the hunger string or dipping into core internals */
int
stat_hunger_indx()
{
int uhs;
#ifdef STATUS_HILITES
uhs = blstats[now_or_before_idx][BL_HUNGER].a.a_int;
#else
uhs = (int) u.uhs;
#endif
return uhs;
}
/* used by X11 for "tty status" even when STATUS_HILITES is disabled */ /* used by X11 for "tty status" even when STATUS_HILITES is disabled */
const char * const char *
bl_idx_to_fldname(idx) bl_idx_to_fldname(idx)

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 wintty.c $NHDT-Date: 1553895321 2019/03/29 21:35:21 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.200 $ */ /* NetHack 3.6 wintty.c $NHDT-Date: 1554554181 2019/04/06 12:36:21 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.201 $ */
/* 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. */
@@ -3704,7 +3704,7 @@ static int finalx[3][2]; /* [rows][NOW or BEFORE] */
static boolean windowdata_init = FALSE; static boolean windowdata_init = FALSE;
static int cond_shrinklvl = 0; static int cond_shrinklvl = 0;
static int enclev = 0, enc_shrinklvl = 0; static int enclev = 0, enc_shrinklvl = 0;
/* static int dl_shrinklvl = 0; */ static int dlvl_shrinklvl = 0;
static boolean truncation_expected = FALSE; static boolean truncation_expected = FALSE;
#define FORCE_RESET TRUE #define FORCE_RESET TRUE
#define NO_RESET FALSE #define NO_RESET FALSE
@@ -3833,10 +3833,10 @@ int fldidx, chg UNUSED, percent, color;
genericptr_t ptr; genericptr_t ptr;
unsigned long *colormasks; unsigned long *colormasks;
{ {
int i, attrmask; int attrmask;
long *condptr = (long *) ptr; long *condptr = (long *) ptr;
char *text = (char *) ptr; char *text = (char *) ptr;
char goldbuf[40], *fval, *lastchar, *p; char goldbuf[40], *lastchar, *p;
const char *fmt; const char *fmt;
boolean reset_state = NO_RESET; boolean reset_state = NO_RESET;
@@ -3911,6 +3911,8 @@ unsigned long *colormasks;
} }
break; break;
case BL_LEVELDESC: case BL_LEVELDESC:
dlvl_shrinklvl = 0; /* caller is passing full length string */
/*FALLTHRU*/
case BL_HUNGER: case BL_HUNGER:
/* The core sends trailing blanks for some fields. /* The core sends trailing blanks for some fields.
Let's suppress the trailing blanks */ Let's suppress the trailing blanks */
@@ -3934,20 +3936,8 @@ unsigned long *colormasks;
tty_status[NOW][fldidx].lth -= (10 - 1); tty_status[NOW][fldidx].lth -= (10 - 1);
break; break;
case BL_CAP: case BL_CAP:
fval = status_vals[fldidx]; enc_shrinklvl = 0; /* caller is passing full length string */
enclev = 0; enclev = stat_cap_indx();
if (*fval) {
/* TODO: replace this with a callback to the core to
retrieve the cap index directly */
if (*fval == ' ')
fval++;
for (i = 0; i < SIZE(encvals[0]); ++i) {
if (!strcmp(encvals[0][i], fval)) {
enclev = i;
break; /* for */
}
}
}
break; break;
} }
/* 3.6.2 we only render on BL_FLUSH (or BL_RESET) */ /* 3.6.2 we only render on BL_FLUSH (or BL_RESET) */
@@ -3962,15 +3952,21 @@ boolean force_update;
int rowsz[3], num_rows, condrow, otheroptions = 0; int rowsz[3], num_rows, condrow, otheroptions = 0;
num_rows = (iflags.wc2_statuslines < 3) ? 2 : 3; num_rows = (iflags.wc2_statuslines < 3) ? 2 : 3;
condrow = num_rows - 1; condrow = num_rows - 1; /* always last row, 1 for 0..1 or 2 for 0..2 */
cond_shrinklvl = 0; cond_shrinklvl = 0;
if (enc_shrinklvl > 0 && num_rows == 2)
shrink_enc(0);
if (dlvl_shrinklvl > 0)
shrink_dlvl(0);
condsz = condition_size(); condsz = condition_size();
for (trycnt = 0; trycnt < 6 && !fitting; ++trycnt) { for (trycnt = 0; trycnt < 6 && !fitting; ++trycnt) {
/* FIXME: this remeasures each line every time even though it /* FIXME: this remeasures each line every time even though it
is only attempting to shrink one of them and the other one is only attempting to shrink one of them and the other one
(or two) remains the same */ (or two) remains the same */
if (!check_fields(force_update, rowsz)) if (!check_fields(force_update, rowsz)) {
return 0; fitting = 0;
break;
}
requirement = rowsz[condrow] - 1; requirement = rowsz[condrow] - 1;
if (requirement <= wins[WIN_STATUS]->cols - 1) { if (requirement <= wins[WIN_STATUS]->cols - 1) {
@@ -3986,22 +3982,21 @@ boolean force_update;
} }
if (cond_shrinklvl >= 2) { if (cond_shrinklvl >= 2) {
/* We've exhausted the condition identifiers shrinkage, /* We've exhausted the condition identifiers shrinkage,
* so let's try something other things... * so let's try shrinking other things...
*/ */
if (otheroptions < 2) { if (otheroptions < 2) {
/* try shrinking the encumbrance word, but /* try shrinking the encumbrance word, but
only when it's on the same line as conditions */ only when it's on the same line as conditions */
if (num_rows == 2) if (num_rows == 2)
shrink_enc(otheroptions + 1); shrink_enc(otheroptions + 1);
otheroptions++;
} else if (otheroptions == 2) { } else if (otheroptions == 2) {
shrink_dlvl(1); shrink_dlvl(1);
otheroptions++;
} else { } else {
/* Last resort - turn on trunction */ /* Last resort - turn on trunction */
truncation_expected = TRUE; truncation_expected = TRUE;
otheroptions++; break;
} }
++otheroptions;
} }
} }
return fitting; return fitting;
@@ -4035,24 +4030,37 @@ int sz[3];
continue; continue;
if (!tty_status[NOW][idx].valid) if (!tty_status[NOW][idx].valid)
valid = FALSE; valid = FALSE;
/* might be called more than once for shrink tests, so need
to reset these (redraw and x at any rate) each time */
tty_status[NOW][idx].redraw = FALSE;
tty_status[NOW][idx].y = row; tty_status[NOW][idx].y = row;
tty_status[NOW][idx].x = col; tty_status[NOW][idx].x = col;
/* On a change to the field length, everything /* On a change to the field location, everything further
further to the right must be updated as well */ to the right must be updated as well. (Not necessarily
if (tty_status[NOW][idx].lth != tty_status[BEFORE][idx].lth everything; it's possible for complementary changes to
|| (idx == BL_CONDITION multiple fields to put stuff further right back in sync.) */
&& tty_status[NOW][idx].x != tty_status[BEFORE][idx].x)) if (tty_status[NOW][idx].x + tty_status[NOW][idx].lth
!= tty_status[BEFORE][idx].x + tty_status[BEFORE][idx].lth)
update_right = TRUE; update_right = TRUE;
else if (tty_status[NOW][idx].lth != tty_status[BEFORE][idx].lth
|| tty_status[NOW][idx].x != tty_status[BEFORE][idx].x)
tty_status[NOW][idx].redraw = TRUE;
else /* in case update_right is set, we're back in sync now */
update_right = FALSE;
matchprev = FALSE; /* assume failure */ matchprev = FALSE; /* assume failure */
if (valid && !update_right && !forcefields) { if (valid && !update_right && !forcefields
&& !tty_status[NOW][idx].redraw) {
/* /*
* Check values against those already on the display. * Check values against those already on the display.
* - Is the additional processing time for this worth it? * - Is the additional processing time for this worth it?
*/ */
if (do_field_opt if (do_field_opt
/* These color/attr checks aren't right for
'condition'; is it safe to assume that same text
means same highlighting for that field? If not,
we'd end up redrawing conditions every time. */
&& (tty_status[NOW][idx].color && (tty_status[NOW][idx].color
== tty_status[BEFORE][idx].color) == tty_status[BEFORE][idx].color)
&& (tty_status[NOW][idx].attr && (tty_status[NOW][idx].attr
@@ -4183,6 +4191,7 @@ int lvl;
char *levval = index(status_vals[BL_LEVELDESC], ':'); char *levval = index(status_vals[BL_LEVELDESC], ':');
if (levval) { if (levval) {
dlvl_shrinklvl = lvl;
Strcpy(buf, (lvl == 0) ? "Dlvl" : "Dl"); Strcpy(buf, (lvl == 0) ? "Dlvl" : "Dl");
Strcat(buf, levval); Strcat(buf, levval);
Strcpy(status_vals[BL_LEVELDESC], buf); Strcpy(status_vals[BL_LEVELDESC], buf);
@@ -4269,35 +4278,35 @@ unsigned long *bmarray;
} }
#define Begin_Attr(m) \ #define Begin_Attr(m) \
do { \ do { \
if (m) { \ if (m) { \
if ((m) & HL_BOLD) \ if ((m) & HL_BOLD) \
term_start_attr(ATR_BOLD); \ term_start_attr(ATR_BOLD); \
if ((m) & HL_INVERSE) \ if ((m) & HL_INVERSE) \
term_start_attr(ATR_INVERSE); \ term_start_attr(ATR_INVERSE); \
if ((m) & HL_ULINE) \ if ((m) & HL_ULINE) \
term_start_attr(ATR_ULINE); \ term_start_attr(ATR_ULINE); \
if ((m) & HL_BLINK) \ if ((m) & HL_BLINK) \
term_start_attr(ATR_BLINK); \ term_start_attr(ATR_BLINK); \
if ((m) & HL_DIM) \ if ((m) & HL_DIM) \
term_start_attr(ATR_DIM); \ term_start_attr(ATR_DIM); \
} \ } \
} while (0) } while (0)
#define End_Attr(m) \ #define End_Attr(m) \
do { \ do { \
if (m) { \ if (m) { \
if ((m) & HL_DIM) \ if ((m) & HL_DIM) \
term_end_attr(ATR_DIM); \ term_end_attr(ATR_DIM); \
if ((m) & HL_BLINK) \ if ((m) & HL_BLINK) \
term_end_attr(ATR_BLINK); \ term_end_attr(ATR_BLINK); \
if ((m) & HL_ULINE) \ if ((m) & HL_ULINE) \
term_end_attr(ATR_ULINE); \ term_end_attr(ATR_ULINE); \
if ((m) & HL_INVERSE) \ if ((m) & HL_INVERSE) \
term_end_attr(ATR_INVERSE); \ term_end_attr(ATR_INVERSE); \
if ((m) & HL_BOLD) \ if ((m) & HL_BOLD) \
term_end_attr(ATR_BOLD); \ term_end_attr(ATR_BOLD); \
} \ } \
} while (0) } while (0)
STATIC_OVL void STATIC_OVL void