]> granicus.if.org Git - nethack/commitdiff
adjattrib() feedback (trunk only)
authornethack.rankin <nethack.rankin>
Sun, 21 May 2006 05:32:16 +0000 (05:32 +0000)
committernethack.rankin <nethack.rankin>
Sun, 21 May 2006 05:32:16 +0000 (05:32 +0000)
     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.

doc/fixes35.0
src/attrib.c

index 8cf8785f5de8ad2712e56eacac5a04a22d9405fa..c4419dfc7ae87d098a52e669d83c6d8bf71d36ab 100644 (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
index 283c08315de9d638edb4dd72a011409778f51149..2f6c0cc7f12eacc7d46bf1b523f6276345f39907 100644 (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();