]> granicus.if.org Git - nethack/commitdiff
Use get_mleash to find the leash attached to monster
authorPasi Kallinen <paxed@alt.org>
Tue, 26 Apr 2022 05:46:55 +0000 (08:46 +0300)
committerPasi Kallinen <paxed@alt.org>
Tue, 26 Apr 2022 05:46:55 +0000 (08:46 +0300)
src/apply.c

index e52c101337eed05ac9b3ea7990664133085b11ef..fd8399ed1c6f5ddfd56cb843c7dd449cb1a23439 100644 (file)
@@ -565,12 +565,10 @@ m_unleash(struct monst *mtmp, boolean feedback)
         else
             Your("leash falls slack.");
     }
-    for (otmp = g.invent; otmp; otmp = otmp->nobj)
-        if (otmp->otyp == LEASH && (unsigned) otmp->leashmon == mtmp->m_id) {
-            otmp->leashmon = 0;
-            update_inventory();
-            break;
-        }
+    if ((otmp = get_mleash(mtmp)) != 0) {
+        otmp->leashmon = 0;
+        update_inventory();
+    }
     mtmp->mleashed = 0;
 }