streamlined status update for 'time'
When the 'time' option is on and context.botl isn't already set, call a simpler status update routine that ignores all other fields. When that flag is already set, full status update takes care of time along with the other fields. Expected to reduce bottom lines processing time but not screen I/O. Only lightly tested.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 allmain.c $NHDT-Date: 1553363414 2019/03/23 17:50:14 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.95 $ */
|
||||
/* NetHack 3.6 allmain.c $NHDT-Date: 1554045808 2019/03/31 15:23:28 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.96 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -181,7 +181,7 @@ boolean resuming;
|
||||
if (u.ublesscnt)
|
||||
u.ublesscnt--;
|
||||
if (flags.time && !context.run)
|
||||
context.botl = TRUE;
|
||||
iflags.time_botl = TRUE;
|
||||
|
||||
/* One possible result of prayer is healing. Whether or
|
||||
* not you get healed depends on your current hit points.
|
||||
@@ -207,8 +207,10 @@ boolean resuming;
|
||||
: moves % 10)) {
|
||||
if (Upolyd && u.mh > 1) {
|
||||
u.mh--;
|
||||
context.botl = TRUE;
|
||||
} else if (!Upolyd && u.uhp > 1) {
|
||||
u.uhp--;
|
||||
context.botl = TRUE;
|
||||
} else {
|
||||
You("pass out from exertion!");
|
||||
exercise(A_CON, FALSE);
|
||||
@@ -234,6 +236,7 @@ boolean resuming;
|
||||
if (!u.uinvulnerable) {
|
||||
if (Teleportation && !rn2(85)) {
|
||||
xchar old_ux = u.ux, old_uy = u.uy;
|
||||
|
||||
tele();
|
||||
if (u.ux != old_ux || u.uy != old_uy) {
|
||||
if (!next_to_u()) {
|
||||
@@ -356,6 +359,9 @@ boolean resuming;
|
||||
if (context.botl || context.botlx) {
|
||||
bot();
|
||||
curs_on_u();
|
||||
} else if (iflags.time_botl) {
|
||||
timebot();
|
||||
curs_on_u();
|
||||
}
|
||||
|
||||
context.move = 1;
|
||||
|
||||
46
src/botl.c
46
src/botl.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 botl.c $NHDT-Date: 1554017610 2019/03/31 07:33:30 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.139 $ */
|
||||
/* NetHack 3.6 botl.c $NHDT-Date: 1554045809 2019/03/31 15:23:29 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.140 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Michael Allison, 2006. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -17,6 +17,7 @@ STATIC_OVL NEARDATA int mrank_sz = 0; /* loaded by max_rank_sz (from u_init) */
|
||||
STATIC_DCL const char *NDECL(rank);
|
||||
#ifdef STATUS_HILITES
|
||||
STATIC_DCL void NDECL(bot_via_windowport);
|
||||
STATIC_DCL void NDECL(stat_update_time);
|
||||
#endif
|
||||
|
||||
static char *
|
||||
@@ -244,7 +245,21 @@ bot()
|
||||
putmixed(WIN_STATUS, 0, do_statusline2());
|
||||
#endif
|
||||
}
|
||||
context.botl = context.botlx = 0;
|
||||
context.botl = context.botlx = iflags.time_botl = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
timebot()
|
||||
{
|
||||
if (flags.time) {
|
||||
#ifdef STATUS_HILITES
|
||||
stat_update_time();
|
||||
#else
|
||||
/* old status display updates everything */
|
||||
bot();
|
||||
#endif
|
||||
}
|
||||
iflags.time_botl = FALSE;
|
||||
}
|
||||
|
||||
/* convert experience level (1..30) to rank index (0..8) */
|
||||
@@ -528,22 +543,23 @@ static long bl_hilite_moves = 0L;
|
||||
* without STATUS_HILITES.
|
||||
*/
|
||||
static unsigned long cond_hilites[BL_ATTCLR_MAX];
|
||||
static int now_or_before_idx = 0; /* 0..1 for array[2][] first index */
|
||||
|
||||
void
|
||||
bot_via_windowport()
|
||||
{
|
||||
static int idx = 0;
|
||||
char buf[BUFSZ];
|
||||
const char *titl;
|
||||
register char *nb;
|
||||
int i, cap;
|
||||
int i, idx, cap;
|
||||
long money;
|
||||
|
||||
if (!blinit)
|
||||
panic("bot before init.");
|
||||
|
||||
/* toggle from previous iteration */
|
||||
idx = 1 - idx; /* 0 -> 1, 1 -> 0 */
|
||||
idx = 1 - now_or_before_idx; /* 0 -> 1, 1 -> 0 */
|
||||
now_or_before_idx = idx;
|
||||
|
||||
/* clear the "value set" indicators */
|
||||
(void) memset((genericptr_t) valset, 0, MAXBLSTATS * sizeof (boolean));
|
||||
@@ -710,6 +726,24 @@ bot_via_windowport()
|
||||
evaluate_and_notify_windowport(valset, idx);
|
||||
}
|
||||
|
||||
/* update just the status lines' 'time' field */
|
||||
STATIC_OVL void
|
||||
stat_update_time()
|
||||
{
|
||||
int idx = now_or_before_idx; /* no 0/1 toggle */
|
||||
int fld = BL_TIME;
|
||||
|
||||
/* Time (moves) */
|
||||
blstats[idx][fld].a.a_long = moves;
|
||||
valset[fld] = FALSE;
|
||||
|
||||
eval_notify_windowport_field(fld, valset, idx);
|
||||
if ((windowprocs.wincap2 & WC2_FLUSH_STATUS) != 0L)
|
||||
status_update(BL_FLUSH, (genericptr_t) 0, 0, 0,
|
||||
NO_COLOR, (unsigned long *) 0);
|
||||
return;
|
||||
}
|
||||
|
||||
STATIC_OVL boolean
|
||||
eval_notify_windowport_field(fld, valsetlist, idx)
|
||||
int fld, idx;
|
||||
@@ -854,7 +888,7 @@ boolean *valsetlist;
|
||||
status_update(BL_FLUSH, (genericptr_t) 0, 0, 0,
|
||||
NO_COLOR, (unsigned long *) 0);
|
||||
|
||||
context.botl = context.botlx = FALSE;
|
||||
context.botl = context.botlx = iflags.time_botl = FALSE;
|
||||
update_all = FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 display.c $NHDT-Date: 1553895319 2019/03/29 21:35:19 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.98 $ */
|
||||
/* NetHack 3.6 display.c $NHDT-Date: 1554045810 2019/03/31 15:23:30 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.99 $ */
|
||||
/* Copyright (c) Dean Luick, with acknowledgements to Kevin Darcy */
|
||||
/* and Dave Cohrs, 1990. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -1625,6 +1625,8 @@ int cursor_on_u;
|
||||
flushing = 0;
|
||||
if (context.botl || context.botlx)
|
||||
bot();
|
||||
else if (iflags.time_botl)
|
||||
timebot();
|
||||
}
|
||||
|
||||
/* ======================================================================== */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 end.c $NHDT-Date: 1553652951 2019/03/27 02:15:51 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.166 $ */
|
||||
/* NetHack 3.6 end.c $NHDT-Date: 1554045810 2019/03/31 15:23:30 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.167 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -1048,7 +1048,7 @@ int how;
|
||||
#endif
|
||||
) {
|
||||
/* skip status update if panicking or disconnected */
|
||||
context.botl = context.botlx = FALSE;
|
||||
context.botl = context.botlx = iflags.time_botl = FALSE;
|
||||
} else {
|
||||
/* otherwise force full status update */
|
||||
context.botlx = TRUE;
|
||||
|
||||
Reference in New Issue
Block a user