From a8e9e1b488bb02485da3e5a4fea7e68b9c1a93e0 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 11 Jan 2022 11:25:04 -0800 Subject: [PATCH] suppress obsolete restore_attrib() moveloop() has been calling restore_attrib() every turn, and restore_attrib() loops through all six characteristics every time to check for ones that have temporary adjustments timing out. But ATIME(characteristic) is never set anywhere and no time outs would occur. So delete the call to restore_attrib() from moveloop(). This leaves that no-longer-called routine in place and updates it to handle Wounded_legs properly in case it ever does get used. Also, add a comment about "restore ability" not fixing temporarily lost characteristics due to hunger or wounded legs. And update unfixable_trouble_count() to check for those so that restore ability won't say "you feel great" when it fails to fix them. --- src/allmain.c | 1 - src/apply.c | 4 +++- src/attrib.c | 15 +++++++++++---- src/potion.c | 12 ++++++++---- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/allmain.c b/src/allmain.c index 66a0dd69c..3bcc63249 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -322,7 +322,6 @@ moveloop_core(void) u.udg_cnt = rn1(200, 50); } } - restore_attrib(); /* XXX This should be recoded to use something like regions - a list of * things that are active and need to be handled that is dynamically * maintained and not a list of special cases. */ diff --git a/src/apply.c b/src/apply.c index 568a73cb2..62cc4e785 100644 --- a/src/apply.c +++ b/src/apply.c @@ -3982,7 +3982,9 @@ unfixable_trouble_count(boolean is_horn) unfixable_trbl++; if (Strangled) unfixable_trbl++; - if (Wounded_legs && !u.usteed) + if (ATEMP(A_DEX) < 0 && Wounded_legs) + unfixable_trbl++; + if (ATEMP(A_STR) < 0 && u.uhs >= WEAK) unfixable_trbl++; /* lycanthropy is undesirable, but it doesn't actually make you feel bad so don't count it as a trouble which can't be fixed */ diff --git a/src/attrib.c b/src/attrib.c index 46398f662..7d74cc21a 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -377,19 +377,26 @@ set_moreluck(void) u.moreluck = -LUCKADD; } +/* (not used) */ void restore_attrib(void) { int i, equilibrium;; /* - * Note: this gets called on every turn but ATIME() is never set - * to non-zero anywhere, and ATEMP() is only used for strength loss - * from hunger, so it doesn't actually do anything. + * Note: this used to get called by moveloop() on every turn but + * ATIME() is never set to non-zero anywhere so didn't do anything. + * Presumably it once supported something like potion of heroism + * which conferred temporary characteristics boost(s). + * + * ATEMP() is used for strength loss from hunger, which doesn't + * time out, and for dexterity loss from wounded legs, which has + * its own timeout routine. */ for (i = 0; i < A_MAX; i++) { /* all temporary losses/gains */ - equilibrium = (i == A_STR && u.uhs >= WEAK) ? -1 : 0; + equilibrium = ((i == A_STR && u.uhs >= WEAK) + || (i == A_DEX && Wounded_legs)) ? -1 : 0; if (ATEMP(i) != equilibrium && ATIME(i) != 0) { if (!(--(ATIME(i)))) { /* countdown for change */ ATEMP(i) += (ATEMP(i) > 0) ? -1 : 1; diff --git a/src/potion.c b/src/potion.c index 72d69f8ab..686e83ecc 100644 --- a/src/potion.c +++ b/src/potion.c @@ -598,6 +598,8 @@ dopotion(struct obj *otmp) return ECMD_TIME; } +/* potion or spell of restore ability; for spell, otmp is a temporary + spellbook object that will be blessed if hero is skilled in healing */ static void peffect_restore_ability(struct obj *otmp) { @@ -608,11 +610,13 @@ peffect_restore_ability(struct obj *otmp) } else { int i, ii; - /* unlike unicorn horn, overrides Fixed_abil */ + /* unlike unicorn horn, overrides Fixed_abil; + does not recover temporary strength loss due to hunger + or temporary dexterity loss due to wounded legs */ pline("Wow! This makes you feel %s!", - (otmp->blessed) - ? (unfixable_trouble_count(FALSE) ? "better" : "great") - : "good"); + (!otmp->blessed) ? "good" + : unfixable_trouble_count(FALSE) ? "better" + : "great"); i = rn2(A_MAX); /* start at a random point */ for (ii = 0; ii < A_MAX; ii++) { int lim = AMAX(i);