From dfd6e0739ffaddff0c21565abd41a94e075672d7 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 12 Jun 2026 01:11:43 -0700 Subject: [PATCH] fix issue #1580 - item action for leash in use Issue reported by JodiJodington: the item action for a leash didn't distringuish a leash that is already in use from one that isn't. Fixes 1580 --- doc/fixes5-0-1.txt | 1 + src/iactions.c | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/fixes5-0-1.txt b/doc/fixes5-0-1.txt index ffa76e493..3fa4b761d 100644 --- a/doc/fixes5-0-1.txt +++ b/doc/fixes5-0-1.txt @@ -60,6 +60,7 @@ monsters (including pets) aren't scared of the Sokoban rolling boulder traps fix a bug in which steeds would continuously gain movement points while being ridden when hero's behavior makes erinyes stronger, cap level at 49 rather than 50 +with inventory item action for leash, distingluish leash-in-use from empty one Platform- and/or Interface-Specific Fixes diff --git a/src/iactions.c b/src/iactions.c index 164bf2f5b..62566569c 100644 --- a/src/iactions.c +++ b/src/iactions.c @@ -331,9 +331,17 @@ itemactions(struct obj *otmp) ia_addmenu(win, IA_APPLY_OBJ, 'a', "Use this tool to pick a lock"); else if (otmp->otyp == TINNING_KIT) ia_addmenu(win, IA_APPLY_OBJ, 'a', "Use this kit to tin a corpse"); - else if (otmp->otyp == LEASH) - ia_addmenu(win, IA_APPLY_OBJ, 'a', "Tie a pet to this leash"); - else if (otmp->otyp == SADDLE) + else if (otmp->otyp == LEASH) { + if (!otmp->leashmon) { + Strcpy(buf, "Attach this leash to a pet"); + } else { + mtmp = find_mid(otmp->leashmon, FM_FMON); + if (!mtmp) /* assume this won't happen */ + panic("Can't find leash's monster"); + Sprintf(buf, "Detach this leash from %s", some_mon_nam(mtmp)); + } + ia_addmenu(win, IA_APPLY_OBJ, 'a', buf); + } else if (otmp->otyp == SADDLE) ia_addmenu(win, IA_APPLY_OBJ, 'a', "Place this saddle on a pet"); else if (otmp->otyp == MAGIC_WHISTLE || otmp->otyp == TIN_WHISTLE)