]> granicus.if.org Git - nethack/commitdiff
fix #2382 - temp Dex loss becomes permanent when dismounting
authornethack.rankin <nethack.rankin>
Sat, 16 Jul 2011 03:41:46 +0000 (03:41 +0000)
committernethack.rankin <nethack.rankin>
Sat, 16 Jul 2011 03:41:46 +0000 (03:41 +0000)
     From a bug report, if you dismount
from a steed whose legs are wounded, you won't recover the point of
dexterity which was removed when they becme injured.  He noticed the
case where the steed had just died, but it happens for voluntary
dismount too (actually any dismount except one which wounds the hero's
legs in the process:  DISMOUNT_THROWN or DISMOUNT_FELL).

     It seems rather odd that the hero temporarily loses Dex when the
steed becomes injured, but I haven't changed that.

doc/fixes34.4
src/do.c
src/steed.c

index 8ff8100326bcb1813f558c6f1b9a1624fbde593d..f836dfd8e04b492e9fe0a439cc8b133d27546b41 100644 (file)
@@ -407,6 +407,8 @@ for number_pad:2 (MSDOS compatibility), M-5 (Alt+5, or Shift+keypad5 using
 objects inside the Wizard's Tower can't be teleport to outside and vica versa
 unlit candelabrum would become unlightable if its candles had exactly 1 turn
        of fuel left and it was applied anywhere other than the invocation spot
+temporary loss of Dex from wounded legs will become permanent if it occurs
+       while mounted and hero dismounts before steed's legs have healed
 
 
 Platform- and/or Interface-Specific Fixes
index 5bfcfe29d7ab05f427bd28b1b1832364db49e468..93b08b5fd5a16bc1af0edaa533c21d30eda148ac 100644 (file)
--- a/src/do.c
+++ b/src/do.c
@@ -1,5 +1,4 @@
 /* NetHack 3.5 do.c    $Date$  $Revision$ */
-/*     SCCS Id: @(#)do.c       3.5     2008/01/22      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1678,7 +1677,7 @@ register int timex;
 void
 heal_legs()
 {
-       if(Wounded_legs) {
+       if (Wounded_legs) {
                if (ATEMP(A_DEX) < 0) {
                        ATEMP(A_DEX)++;
                        context.botl = 1;
@@ -1688,18 +1687,29 @@ heal_legs()
                if (!u.usteed)
 #endif
                {
-                       /* KMH, intrinsics patch */
-                       if((EWounded_legs & BOTH_SIDES) == BOTH_SIDES) {
-                       Your("%s feel somewhat better.",
-                               makeplural(body_part(LEG)));
-               } else {
-                       Your("%s feels somewhat better.",
-                               body_part(LEG));
-               }
+                   const char *legs = body_part(LEG);
+
+                   if ((EWounded_legs & BOTH_SIDES) == BOTH_SIDES)
+                       legs = makeplural(legs);
+                   /* this used to say "somewhat better" but that was
+                      misleading since legs are being fully healed */
+                   Your("%s %s better.", legs, vtense(legs, "feel"));
                }
+
                HWounded_legs = EWounded_legs = 0;
+
+               /* Wounded_legs reduces carrying capacity, so we want
+                  an encumbrance check when they're healed.  However,
+                  while dismounting, first steed's legs get healed,
+                  then hero is dropped to floor and a new encumbrance
+                  check is made [in dismount_steed()].  So don't give
+                  encumbrance feedback during the dismount stage
+                  because it could seem to be shown out of order and
+                  it might be immediately contradicted [able to carry
+                  more when steed becomes healthy, then possible floor
+                  feedback, then able to carry less when back on foot]. */
+               if (!in_steed_dismounting) (void)encumber_msg();
        }
-       (void)encumber_msg();
 }
 
 /*do.c*/
index ef62febe5b838450e61592104563ffdf1bab74b8..ef9490b6a2e97eb46d5d381c73e6fb6fd18b6596 100644 (file)
@@ -1,5 +1,4 @@
 /* NetHack 3.5 steed.c $Date$  $Revision$ */
-/*     SCCS Id: @(#)steed.c    3.5     2006/12/13      */
 /* Copyright (c) Kevin Hugo, 1998-1999. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -221,7 +220,10 @@ mount_steed(mtmp, force)
         * healed upon dismount (Wounded_legs context switch).
         * By preventing a hero with Wounded_legs from
         * mounting a steed, the potential for abuse is
-        * minimized, if not eliminated altogether.
+        * reduced.  However, dismounting still immediately
+        * heals the steed's wounded legs.  [In 3.4.3 and
+        * earlier, that unintentionally made the hero's
+        * temporary 1 point Dex loss become permanent.]
         */
        if (Wounded_legs) {
            Your("%s are in no shape for riding.", makeplural(body_part(LEG)));
@@ -472,7 +474,7 @@ dismount_steed(reason)
        struct obj *otmp;
        coord cc;
        const char *verb = "fall";
-       boolean repair_leg_damage = TRUE;
+       boolean repair_leg_damage = (Wounded_legs != 0L);
        unsigned save_utrap = u.utrap;
        boolean have_spot = landing_spot(&cc,reason,0);
        
@@ -526,11 +528,14 @@ dismount_steed(reason)
                } else
                        You("dismount %s.", mon_nam(mtmp));
        }
-       /* While riding these refer to the steed's legs
-        * so after dismounting they refer to the player's
-        * legs once again.
-        */
-       if (repair_leg_damage) HWounded_legs = EWounded_legs = 0;
+       /* While riding, Wounded_legs refers to the steed's legs;
+          after dismounting, it reverts to the hero's legs. */
+       if (repair_leg_damage) {
+               /* [TODO: make heal_legs() take a parameter to handle this] */
+               in_steed_dismounting = TRUE;
+               heal_legs();
+               in_steed_dismounting = FALSE;
+       }
 
        /* Release the steed and saddle */
        u.usteed = 0;
@@ -546,7 +551,7 @@ dismount_steed(reason)
                (void) rloc(mtmp, FALSE);
            return;
        }
-       if (!DEADMONSTER(mtmp)) {
+       if (mtmp->mhp > 0) {
            place_monster(mtmp, u.ux, u.uy);
            if (!u.uswallow && !u.ustuck && have_spot) {
                struct permonst *mdat = mtmp->data;
@@ -587,7 +592,7 @@ dismount_steed(reason)
             * falling into the hole).
             */
                /* [ALI] No need to move the player if the steed died. */
-               if (!DEADMONSTER(mtmp)) {
+               if (mtmp->mhp > 0) {
                    /* Keep steed here, move the player to cc;
                     * teleds() clears u.utrap
                     */