]> granicus.if.org Git - nethack/commitdiff
leash use vs perm_invent
authorPatR <rankin@nethack.org>
Mon, 10 Aug 2020 20:20:24 +0000 (13:20 -0700)
committerPatR <rankin@nethack.org>
Mon, 10 Aug 2020 20:20:24 +0000 (13:20 -0700)
Noticed while working on Qt's version of persistent inventory
window (paper doll-style display of equipment in use), leashing
or unleashing a pet wasn't updating persistent inventory.  Leash
descriptions format differently when in use so immediate update
is warranted.

doc/fixes37.0
src/apply.c

index ec0cd9f91631abd515a59c9476c5740c8de3866c..92522330cb132aed52d762e809fa7eaf3917e96d 100644 (file)
@@ -1,4 +1,4 @@
-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.280 $ $NHDT-Date: 1597069374 2020/08/10 14:22:54 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.281 $ $NHDT-Date: 1597090815 2020/08/10 20:20:15 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -243,6 +243,7 @@ wizard mode #wizintrinsic: setting Levitation wouldn't block Flying as
 chatting to the quest leader in wizard mode with sufficient experience level
        and insufficient piety, player is asked whether alignment should be
        boosted; answering 'n' resulted in being prompted a second time
+leashing or unleashing pets wasn't updating persistent inventory window
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index 849d110046f5b3676e60a587a1dd9895ca61c305..faef080bf34bc1df0826919c0ab26bb447e48d6a 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 apply.c $NHDT-Date: 1596498148 2020/08/03 23:42:28 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.326 $ */
+/* NetHack 3.7 apply.c $NHDT-Date: 1597090815 2020/08/10 20:20:15 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.327 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -548,20 +548,23 @@ number_leashed()
 /* otmp is about to be destroyed or stolen */
 void
 o_unleash(otmp)
-register struct obj *otmp;
+struct obj *otmp;
 {
     register struct monst *mtmp;
 
     for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
-        if (mtmp->m_id == (unsigned) otmp->leashmon)
+        if (mtmp->m_id == (unsigned) otmp->leashmon) {
             mtmp->mleashed = 0;
-    otmp->leashmon = 0;
+            otmp->leashmon = 0;
+            update_inventory();
+            break;
+        }
 }
 
 /* mtmp is about to die, or become untame */
 void
 m_unleash(mtmp, feedback)
-register struct monst *mtmp;
+struct monst *mtmp;
 boolean feedback;
 {
     register struct obj *otmp;
@@ -573,8 +576,11 @@ boolean feedback;
             Your("leash falls slack.");
     }
     for (otmp = g.invent; otmp; otmp = otmp->nobj)
-        if (otmp->otyp == LEASH && otmp->leashmon == (int) mtmp->m_id)
+        if (otmp->otyp == LEASH && (unsigned) otmp->leashmon == mtmp->m_id) {
             otmp->leashmon = 0;
+            update_inventory();
+            break;
+        }
     mtmp->mleashed = 0;
 }
 
@@ -686,6 +692,7 @@ struct obj *obj;
             mtmp->mleashed = 1;
             obj->leashmon = (int) mtmp->m_id;
             mtmp->msleeping = 0;
+            update_inventory();
         }
     } else {
         /* applying a leash which is currently in use */
@@ -697,6 +704,7 @@ struct obj *obj;
         } else {
             mtmp->mleashed = 0;
             obj->leashmon = 0;
+            update_inventory();
             You("remove the leash from %s%s.",
                 spotmon ? "your " : "", l_monnam(mtmp));
         }
@@ -711,13 +719,10 @@ struct monst *mtmp;
 {
     struct obj *otmp;
 
-    otmp = g.invent;
-    while (otmp) {
-        if (otmp->otyp == LEASH && otmp->leashmon == (int) mtmp->m_id)
-            return otmp;
-        otmp = otmp->nobj;
-    }
-    return (struct obj *) 0;
+    for (otmp = g.invent; otmp; otmp = otmp->nobj)
+        if (otmp->otyp == LEASH && (unsigned) otmp->leashmon == mtmp->m_id)
+            break;
+    return otmp;
 }
 
 boolean
@@ -735,13 +740,14 @@ next_to_u()
             if (distu(mtmp->mx, mtmp->my) > 2) {
                 for (otmp = g.invent; otmp; otmp = otmp->nobj)
                     if (otmp->otyp == LEASH
-                        && otmp->leashmon == (int) mtmp->m_id) {
+                        && (unsigned) otmp->leashmon == mtmp->m_id) {
                         if (otmp->cursed)
                             return FALSE;
-                        You_feel("%s leash go slack.",
-                                 (number_leashed() > 1) ? "a" : "the");
                         mtmp->mleashed = 0;
                         otmp->leashmon = 0;
+                        update_inventory();
+                        You_feel("%s leash go slack.",
+                                 (number_leashed() > 1) ? "a" : "the");
                     }
             }
         }