From 0ecd573152ebf2c5377c3084c2ce043458830e48 Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 3 Apr 2025 15:26:05 -0700 Subject: [PATCH] escape_from_sticky_mon() Reorganized a 'switch' statement in order to eliminate a 'goto'. There should be no changed in behavior. --- src/hack.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/hack.c b/src/hack.c index af9d392c5..d7e6f6b1f 100644 --- a/src/hack.c +++ b/src/hack.c @@ -2636,14 +2636,6 @@ escape_from_sticky_mon(coordxy x, coordxy y) * guaranteed escape. */ switch (rn2(!u.ustuck->mcanmove ? 8 : 40)) { - case 0: - case 1: - case 2: - pull_free: - mtmp = u.ustuck; - set_ustuck((struct monst *) 0); - You("pull free from %s.", y_monnam(mtmp)); - break; case 3: if (!u.ustuck->mcanmove) { /* it's free to move on next turn */ @@ -2653,11 +2645,20 @@ escape_from_sticky_mon(coordxy x, coordxy y) FALLTHROUGH; /*FALLTHRU*/ default: - if (u.ustuck->mtame && !Conflict && !u.ustuck->mconf) - goto pull_free; - You("cannot escape from %s!", y_monnam(u.ustuck)); - nomul(0); - return TRUE; + if (Conflict || u.ustuck->mconf || !u.ustuck->mtame) { + You("cannot escape from %s!", y_monnam(u.ustuck)); + nomul(0); + return TRUE; + } + FALLTHROUGH; + /*FALLTHRU*/ + case 0: + case 1: + case 2: + mtmp = u.ustuck; + set_ustuck((struct monst *) 0); + You("pull free from %s.", y_monnam(mtmp)); + break; } } }