]> granicus.if.org Git - nethack/commitdiff
fix #K3496 - leash description when pet changes
authorPatR <rankin@nethack.org>
Sun, 19 Dec 2021 17:30:07 +0000 (09:30 -0800)
committerPatR <rankin@nethack.org>
Sun, 19 Dec 2021 17:30:07 +0000 (09:30 -0800)
If persistent inventory is displayed and contains an entry for a leash
attached to a pet and the pet's type or name changes, the perm_invent
window didn't get updated to reflect the new leash information:
 x - leash (attached to <mon>)
Report was for polymorph but applied to growing into bigger form and
to being (re-/un-)christened as well.

doc/fixes37.0
src/do_name.c
src/makemon.c
src/mon.c

index 7557dd1ff850c9e286f8cd3237e047335781b4b2..72535099eb5b9177e6a821c23c54276666cacd47 100644 (file)
@@ -714,6 +714,9 @@ for accessibility reasons, give a message when monster teleports
 if a gremlin stole intrinsic 'see invisible' the map wasn't updated properly
 mark some messages as urgent ("You die*.", having equipment stolen, being
        caught in a magical explosion)
+if a leashed pet changed name (#name m) or an unnamed pet changed type
+       (polymorph or grow-up) and perm_invent was On, persistent inventory
+       display didn't get updated to show the leash's changed information
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index 4e71d5eafc7df113d4e6daab3b0b49c0fbd879c3..7a3cf73106396f5a0d16cacd82f261a05fd320de 100644 (file)
@@ -1107,6 +1107,9 @@ christen_monst(struct monst *mtmp, const char *name)
     new_mgivenname(mtmp, lth); /* removes old name if one is present */
     if (lth)
         Strcpy(MGIVENNAME(mtmp), name);
+    /* if 'mtmp' is leashed, persistent inventory window needs updating */
+    if (mtmp->mleashed)
+        update_inventory(); /* x - leash (attached to Fido) */
     return mtmp;
 }
 
index e2968c65d9dcf221d839108124b16c76f1528c3f..d9769521e342206be4391c355eb039bcb86719e0 100644 (file)
@@ -1914,6 +1914,9 @@ grow_up(struct monst *mtmp, struct monst *victim)
         lev_limit = (int) mtmp->m_lev; /* never undo increment */
 
         mtmp->female = fem; /* gender might be changing */
+        /* if 'mtmp' is leashed, persistent inventory window needs updating */
+        if (mtmp->mleashed)
+            update_inventory(); /* x - leash (attached to a <mon> */
     }
 
     /* sanity checks */
index 998fac1a90c5838ba11a58046c9878b09c93f9ef..5088005ed112ba0b976dac1756d7a78e15462f8a 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -4345,8 +4345,15 @@ newcham(
     /* take on the new form... */
     set_mon_data(mtmp, mdat);
 
-    if (mtmp->mleashed && !leashable(mtmp))
-        m_unleash(mtmp, TRUE);
+    if (mtmp->mleashed) {
+        if (!leashable(mtmp))
+            m_unleash(mtmp, TRUE);
+        else
+            /* if leashed, persistent inventory window needs updating
+               (really only when mon_nam() is going to yield "a frog"
+               rather than "Kermit" but no need to micromanage here) */
+            update_inventory(); /* x - leash (attached to a <mon>) */
+    }
 
     if (emits_light(olddata) != emits_light(mtmp->data)) {
         /* used to give light, now doesn't, or vice versa,