status updating: a*.c

I went through the places that set context.botl/botlx in src/a*.c to
see whether I could find any unnecessary status updates.  I didn't
find anything interesting, mostly some minor sequencing issues plus
a couple of redundant sets (call foo() which includes setting botl,
then explicitly set botl after it returns).  If you issue pline first
and then set context.botl, bottom lines won't be updated until the
next message or next pass through moveloop.  If you order those the
other way around, status will be updated as the message describing
the reason for the update is being delivered.
This commit is contained in:
PatR
2019-03-23 10:50:26 -07:00
parent 02bf042ab4
commit c57b32f5fe
4 changed files with 30 additions and 29 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 allmain.c $NHDT-Date: 1539804859 2018/10/17 19:34:19 $ $NHDT-Branch: keni-makedefsm $:$NHDT-Revision: 1.89 $ */
/* 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 $ */
/* 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 = 1;
context.botl = TRUE;
/* One possible result of prayer is healing. Whether or
* not you get healed depends on your current hit points.
@@ -226,7 +226,7 @@ boolean resuming;
(int) (ACURR(A_WIS) + ACURR(A_INT)) / 15 + 1, 1);
if (u.uen > u.uenmax)
u.uen = u.uenmax;
context.botl = 1;
context.botl = TRUE;
if (u.uen == u.uenmax)
interrupt_multi("You feel full of energy.");
}
@@ -405,7 +405,7 @@ boolean resuming;
/* lookaround may clear multi */
context.move = 0;
if (flags.time)
context.botl = 1;
context.botl = TRUE;
continue;
}
if (context.mv) {
@@ -427,7 +427,7 @@ boolean resuming;
deferred_goto(); /* after rhack() */
/* !context.move here: multiple movement command stopped */
else if (flags.time && (!context.move || !context.mv))
context.botl = 1;
context.botl = TRUE;
if (vision_full_recalc)
vision_recalc(0); /* vision! */
@@ -435,7 +435,8 @@ boolean resuming;
if ((!context.run || flags.runmode == RUN_TPORT)
&& (multi && (!context.travel ? !(multi % 7) : !(moves % 7L)))) {
if (flags.time && context.run)
context.botl = 1;
context.botl = TRUE;
/* [should this be flush_screen() instead?] */
display_nhwindow(WIN_MAP, FALSE);
}
}
@@ -465,7 +466,7 @@ int wtcap;
heal = 1;
}
if (heal) {
context.botl = 1;
context.botl = TRUE;
u.mh += heal;
reached_full = (u.mh == u.mhmax);
}
@@ -497,7 +498,7 @@ int wtcap;
heal = 1;
if (heal) {
context.botl = 1;
context.botl = TRUE;
u.uhp += heal;
if (u.uhp > u.uhpmax)
u.uhp = u.uhpmax;
@@ -518,7 +519,7 @@ stop_occupation()
if (!maybe_finished_meal(TRUE))
You("stop %s.", occtxt);
occupation = 0;
context.botl = 1; /* in case u.uhs changed */
context.botl = TRUE; /* in case u.uhs changed */
nomul(0);
pushch(0);
} else if (multi >= 0) {
@@ -571,7 +572,7 @@ newgame()
gameDiskPrompt();
#endif
context.botlx = 1;
context.botlx = TRUE;
context.ident = 1;
context.stethoscope_move = -1L;
context.warnlevel = 1;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 apply.c $NHDT-Date: 1544442708 2018/12/10 11:51:48 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.269 $ */
/* NetHack 3.6 apply.c $NHDT-Date: 1553363415 2019/03/23 17:50:15 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.272 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1922,7 +1922,6 @@ struct obj *obj;
if (Deaf) /* make_deaf() won't give feedback when already deaf */
pline("Nothing seems to happen.");
make_deaf((HDeaf & TIMEOUT) + lcount, TRUE);
context.botl = TRUE;
break;
}
return;
@@ -2049,6 +2048,8 @@ struct obj *obj;
}
}
if (did_attr || did_prop)
context.botl = TRUE;
if (did_attr)
pline("This makes you feel %s!",
(did_prop + did_attr) == (trouble_count + unfixable_trbl)
@@ -2057,7 +2058,6 @@ struct obj *obj;
else if (!did_prop)
pline("Nothing seems to happen.");
context.botl = (did_attr || did_prop);
#undef PROP_COUNT
#undef ATTR_COUNT
#undef prop2trbl
@@ -2687,7 +2687,6 @@ struct obj *obj;
You("hit your %s with your bullwhip.", body_part(FOOT));
Sprintf(buf, "killed %sself with %s bullwhip", uhim(), uhis());
losehp(Maybe_Half_Phys(dam), buf, NO_KILLER_PREFIX);
context.botl = 1;
return 1;
} else if ((Fumbling || Glib) && !rn2(5)) {

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 artifact.c $NHDT-Date: 1545597414 2018/12/23 20:36:54 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.128 $ */
/* NetHack 3.6 artifact.c $NHDT-Date: 1553363416 2019/03/23 17:50:16 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.129 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1039,20 +1039,20 @@ char *hittee; /* target's name: "you" or mon_nam(mdef) */
if (youmonst.data != old_uasmon)
*dmgptr = 0; /* rehumanized, so no more damage */
if (u.uenmax > 0) {
You("lose magical energy!");
u.uenmax--;
if (u.uen > 0)
u.uen--;
context.botl = 1;
context.botl = TRUE;
You("lose magical energy!");
}
} else {
if (mdef->data == &mons[PM_CLAY_GOLEM])
mdef->mhp = 1; /* cancelled clay golems will die */
if (youattack && attacktype(mdef->data, AT_MAGC)) {
You("absorb magical energy!");
u.uenmax++;
u.uen++;
context.botl = 1;
context.botl = TRUE;
You("absorb magical energy!");
}
}
}
@@ -1474,7 +1474,7 @@ struct obj *obj;
make_slimed(0L, (char *) 0);
if (Blinded > creamed)
make_blinded(creamed, FALSE);
context.botl = 1;
context.botl = TRUE;
break;
}
case ENERGY_BOOST: {
@@ -1485,9 +1485,9 @@ struct obj *obj;
else if (epboost < 12)
epboost = u.uenmax - u.uen;
if (epboost) {
You_feel("re-energized.");
u.uen += epboost;
context.botl = 1;
context.botl = TRUE;
You_feel("re-energized.");
} else
goto nothing_special;
break;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 attrib.c $NHDT-Date: 1547086687 2019/01/10 02:18:07 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.64 $ */
/* NetHack 3.6 attrib.c $NHDT-Date: 1553363417 2019/03/23 17:50:17 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.65 $ */
/* Copyright 1988, 1989, 1990, 1992, M. Stephenson */
/* NetHack may be freely redistributed. See license for details. */
@@ -185,8 +185,8 @@ int msgflg; /* positive => no message, zero => message, and */
if (msgflg <= 0)
You_feel("%s%s!", (incr > 1 || incr < -1) ? "very " : "", attrstr);
context.botl = 1;
if (moves > 1 && (ndx == A_STR || ndx == A_CON))
context.botl = TRUE;
if (program_state.in_moveloop && (ndx == A_STR || ndx == A_CON))
(void) encumber_msg();
return TRUE;
}
@@ -397,7 +397,7 @@ restore_attrib()
if (ATEMP(i) != equilibrium && ATIME(i) != 0) {
if (!(--(ATIME(i)))) { /* countdown for change */
ATEMP(i) += (ATEMP(i) > 0) ? -1 : 1;
context.botl = 1;
context.botl = TRUE;
if (ATEMP(i)) /* reset timer */
ATIME(i) = 100 / ACURR(A_CON);
}
@@ -1141,8 +1141,10 @@ int reason; /* 0==conversion, 1==helm-of-OA on, 2==helm-of-OA off */
{
aligntyp oldalign = u.ualign.type;
u.ublessed = 0; /* lose divine protection */
context.botl = 1; /* status line needs updating */
u.ublessed = 0; /* lose divine protection */
/* You/Your/pline message with call flush_screen(), triggering bot(),
so the actual data change needs to come before the message */
context.botl = TRUE; /* status line needs updating */
if (reason == 0) {
/* conversion via altar */
u.ualignbase[A_CURRENT] = (aligntyp) newalign;
@@ -1161,7 +1163,6 @@ int reason; /* 0==conversion, 1==helm-of-OA on, 2==helm-of-OA off */
? "much of a muchness"
: "back in sync with your body");
}
if (u.ualign.type != oldalign) {
u.ualign.record = 0; /* slate is wiped clean */
retouch_equipment(0);