From 35d9cd3fd02937a54c8f44086fe3e9bbaf6c3d63 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 5 May 2017 18:32:40 -0700 Subject: [PATCH] fix #H5416 - misleading attribute message Report was for losing strength when sitting on a throne, but the message issue was more general than that. Character was wearing gauntlets of power, so no visible change in strength took place, but player was told "you're already as weak as you can get" (because the attempt to reduce strength didn't change current strength; however, it did change the hero's underlying strength, observable once the gloves were removed). There was a beta report last January that was related: in that case the player thought that gauntlets of power were preventing blessed potion of gain ability from raising strength, but it was actually giving a misleading message claiming that strength was already as high as it could get. Fix: vary the message when something prevents an attribute change from being noticeable. --- doc/fixes36.1 | 2 ++ src/attrib.c | 46 +++++++++++++++++++++++++++++++++++----------- src/cmd.c | 13 ++++--------- 3 files changed, 41 insertions(+), 20 deletions(-) diff --git a/doc/fixes36.1 b/doc/fixes36.1 index 3db597f9f..e25a866ae 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -372,6 +372,8 @@ Bell of Opening could trigger segfault attempting to open some types of traps if hero was mounted automatic #overview annotation for quest summons wasn't shown if the quest entry portal was on same level as bigroom or rogue level +gaining or losing strength while wearing gauntlets of power could give + misleading message about already being as strong or weak as possible Fixes to Post-3.6.0 Problems that Were Exposed Via git Repository diff --git a/src/attrib.c b/src/attrib.c index c87afb683..e0021632f 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 attrib.c $NHDT-Date: 1455357587 2016/02/13 09:59:47 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.55 $ */ +/* NetHack 3.6 attrib.c $NHDT-Date: 1494034337 2017/05/06 01:32:17 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.62 $ */ /* Copyright 1988, 1989, 1990, 1992, M. Stephenson */ /* NetHack may be freely redistributed. See license for details. */ @@ -14,6 +14,10 @@ static const char *const minusattr[] = { "weak", "stupid", "foolish", "clumsy", "fragile", "repulsive" }; +/* also used by enlightenment for non-abbreviated status info */ +const char + *const attrname[] = { "strength", "intelligence", "wisdom", + "dexterity", "constitution", "charisma" }; static const struct innate { schar ulevel; @@ -111,7 +115,7 @@ adjattrib(ndx, incr, msgflg) int ndx, incr; int msgflg; /* positive => no message, zero => message, and */ { /* negative => conditional (msg if change made) */ - int old_acurr; + int old_acurr, old_abase; boolean abonflg; const char *attrstr; @@ -125,6 +129,7 @@ int msgflg; /* positive => no message, zero => message, and */ } old_acurr = ACURR(ndx); + old_abase = ABASE(ndx); if (incr > 0) { ABASE(ndx) += incr; if (ABASE(ndx) > AMAX(ndx)) { @@ -149,9 +154,14 @@ int msgflg; /* positive => no message, zero => message, and */ abonflg = (ABON(ndx) > 0); } if (ACURR(ndx) == old_acurr) { - if (msgflg == 0 && flags.verbose) - pline("You're %s as %s as you can get.", - abonflg ? "currently" : "already", attrstr); + if (msgflg == 0 && flags.verbose) { + if (ABASE(ndx) == old_abase) + pline("You're %s as %s as you can get.", + abonflg ? "currently" : "already", attrstr); + else /* current stayed the same but base value changed */ + Your("innate %s has %s.", attrname[ndx], + (incr > 0) ? "improved" : "declined"); + } return FALSE; } @@ -223,16 +233,28 @@ int typ; /* which attribute */ boolean exclaim; /* emphasis */ { void VDECL((*func), (const char *, ...)) = poiseff[typ].delivery_func; + const char *msg_txt = poiseff[typ].effect_msg; - (*func)("%s%c", poiseff[typ].effect_msg, exclaim ? '!' : '.'); + /* + * "You feel weaker" or "you feel very sick" aren't appropriate when + * wearing or wielding something (gauntlets of power, Ogresmasher) + * which forces the attribute to maintain its maximum value. + * Phrasing for other attributes which might have fixed values + * (dunce cap) is such that we don't need message fixups for them. + */ + if (typ == A_STR && ACURR(A_STR) == STR19(25)) + msg_txt = "innately weaker"; + else if (typ == A_CON && ACURR(A_CON) == 25) + msg_txt = "sick inside"; + + (*func)("%s%c", msg_txt, exclaim ? '!' : '.'); } -/* called when an attack or trap has poisoned the hero (used to be in mon.c) - */ +/* called when an attack or trap has poisoned hero (used to be in mon.c) */ void poisoned(reason, typ, pkiller, fatal, thrown_weapon) const char *reason, /* controls what messages we display */ - *pkiller; /* for score+log file if fatal */ + *pkiller; /* for score+log file if fatal */ int typ, fatal; /* if fatal is 0, limit damage to adjattrib */ boolean thrown_weapon; /* thrown weapons are less deadly */ { @@ -671,7 +693,9 @@ int r; { 0, 0 } }; int i; - for (i = 0; roleabils[i].abil && roleabils[i].role != r; i++); + + for (i = 0; roleabils[i].abil && roleabils[i].role != r; i++) + continue; return roleabils[i].abil; } @@ -996,7 +1020,7 @@ int x; #ifdef WIN32_BUG return (x = ((tmp <= 3) ? 3 : tmp)); #else - return (schar) ((tmp <= 3) ? 3 : tmp); + return (schar) ((tmp <= 3) ? 3 : tmp); #endif } else if (x == A_CHA) { if (tmp < 18 diff --git a/src/cmd.c b/src/cmd.c index d88664664..048fc5bbd 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 cmd.c $NHDT-Date: 1493946186 2017/05/05 01:03:06 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.255 $ */ +/* NetHack 3.6 cmd.c $NHDT-Date: 1494034344 2017/05/06 01:32:24 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.256 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1664,9 +1664,10 @@ STATIC_OVL void one_characteristic(mode, final, attrindx) int mode, final, attrindx; { + extern const char *const attrname[]; /* attrib.c */ boolean hide_innate_value = FALSE, interesting_alimit; int acurrent, abase, apeak, alimit; - const char *attrname, *paren_pfx; + const char *paren_pfx; char subjbuf[BUFSZ], valubuf[BUFSZ], valstring[32]; /* being polymorphed or wearing certain cursed items prevents @@ -1684,30 +1685,24 @@ int mode, final, attrindx; } switch (attrindx) { case A_STR: - attrname = "strength"; if (uarmg && uarmg->otyp == GAUNTLETS_OF_POWER && uarmg->cursed) hide_innate_value = TRUE; break; case A_DEX: - attrname = "dexterity"; break; case A_CON: - attrname = "constitution"; if (uwep && uwep->oartifact == ART_OGRESMASHER && uwep->cursed) hide_innate_value = TRUE; break; case A_INT: - attrname = "intelligence"; if (uarmh && uarmh->otyp == DUNCE_CAP && uarmh->cursed) hide_innate_value = TRUE; break; case A_WIS: - attrname = "wisdom"; if (uarmh && uarmh->otyp == DUNCE_CAP && uarmh->cursed) hide_innate_value = TRUE; break; case A_CHA: - attrname = "charisma"; break; default: return; /* impossible */ @@ -1718,7 +1713,7 @@ int mode, final, attrindx; acurrent = ACURR(attrindx); (void) attrval(attrindx, acurrent, valubuf); /* Sprintf(valubuf,"%d",) */ - Sprintf(subjbuf, "Your %s ", attrname); + Sprintf(subjbuf, "Your %s ", attrname[attrindx]); if (!hide_innate_value) { /* show abase, amax, and/or attrmax if acurr doesn't match abase