adjattrib() feedback (trunk only)

Fix a bug described in the slash'em bugs page at Sourceforge.  When
attributes are undergoing adjustment (from drinking a potion of gain
ability, for instance), don't display "you feel wise" or "you feel weak"
messages if worn equipment is keeping the relevant attribute at some point
below max or above min and the current value doesn't actually change.
The old logic just checked whether you were at max or min and assumed that
when not, the value would be changing.  Now it checks whether the value
actually did change.  But it doesn't intercept attempts to go over max or
under min at the same point any more; I hope it hasn't introduced any new
bugs in the process.
This commit is contained in:
nethack.rankin
2006-05-21 05:32:16 +00:00
parent 1c66428a26
commit bb8ec3e1d5
2 changed files with 24 additions and 23 deletions

View File

@@ -138,6 +138,8 @@ thrown silver weapon hitting silver-hating poly'd hero got double silver damage
wielded silver weapon hitting silver-hating poly'd hero lacked silver message
don't welcome the hero to Delphi if the Oracle was angered before first entry
shopkeeper polymorphed into animal form can no longer speak
don't give attribute adjustment messages ("you feel wise") unless the current
value actually changes
Platform- and/or Interface-Specific Fixes

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)attrib.c 3.5 2005/09/19 */
/* SCCS Id: @(#)attrib.c 3.5 2006/05/20 */
/* Copyright 1988, 1989, 1990, 1992, M. Stephenson */
/* NetHack may be freely redistributed. See license for details. */
@@ -106,6 +106,10 @@ adjattrib(ndx, incr, msgflg)
int ndx, incr;
int msgflg; /* positive => no message, zero => message, and */
{ /* negative => conditional (msg if change made) */
int old_acurr;
boolean abonflg;
const char *attrstr;
if (Fixed_abil || !incr) return FALSE;
if ((ndx == A_INT || ndx == A_WIS)
@@ -115,45 +119,40 @@ adjattrib(ndx, incr, msgflg)
return FALSE;
}
old_acurr = ACURR(ndx);
if (incr > 0) {
if ((AMAX(ndx) >= ATTRMAX(ndx)) && (ACURR(ndx) >= AMAX(ndx))) {
if (msgflg == 0 && flags.verbose)
pline("You're already as %s as you can get.",
plusattr[ndx]);
ABASE(ndx) = AMAX(ndx) = ATTRMAX(ndx); /* just in case */
return FALSE;
}
ABASE(ndx) += incr;
if(ABASE(ndx) > AMAX(ndx)) {
if (ABASE(ndx) > AMAX(ndx)) {
incr = ABASE(ndx) - AMAX(ndx);
AMAX(ndx) += incr;
if(AMAX(ndx) > ATTRMAX(ndx))
if (AMAX(ndx) > ATTRMAX(ndx))
AMAX(ndx) = ATTRMAX(ndx);
ABASE(ndx) = AMAX(ndx);
}
attrstr = plusattr[ndx];
abonflg = (ABON(ndx) < 0);
} else {
if (ABASE(ndx) <= ATTRMIN(ndx)) {
if (msgflg == 0 && flags.verbose)
pline("You're already as %s as you can get.",
minusattr[ndx]);
ABASE(ndx) = ATTRMIN(ndx); /* just in case */
return FALSE;
}
ABASE(ndx) += incr;
if(ABASE(ndx) < ATTRMIN(ndx)) {
if (ABASE(ndx) < ATTRMIN(ndx)) {
incr = ABASE(ndx) - ATTRMIN(ndx);
ABASE(ndx) = ATTRMIN(ndx);
AMAX(ndx) += incr;
if(AMAX(ndx) < ATTRMIN(ndx))
if (AMAX(ndx) < ATTRMIN(ndx))
AMAX(ndx) = ATTRMIN(ndx);
}
attrstr = minusattr[ndx];
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);
return FALSE;
}
if (msgflg <= 0)
You_feel("%s%s!",
(incr > 1 || incr < -1) ? "very ": "",
(incr > 0) ? plusattr[ndx] : minusattr[ndx]);
(incr > 1 || incr < -1) ? "very ": "", attrstr);
context.botl = 1;
if (moves > 1 && (ndx == A_STR || ndx == A_CON))
(void)encumber_msg();