]> granicus.if.org Git - nethack/commitdiff
Return early from mon_has_friends
authorPasi Kallinen <paxed@alt.org>
Tue, 16 Aug 2022 11:49:25 +0000 (14:49 +0300)
committerPasi Kallinen <paxed@alt.org>
Tue, 16 Aug 2022 11:49:25 +0000 (14:49 +0300)
src/muse.c

index 358da80aeecf36699e50553cafc6d0003aeb5dc7..46f36d33e80c6b83586baed7f98ac9651f12eee4 100644 (file)
@@ -1222,12 +1222,11 @@ hero_behind_chokepoint(struct monst *mtmp)
     return FALSE;
 }
 
-/* hostile monster has other hostiles next to it */
+/* hostile monster has another hostile next to it */
 static boolean
 mon_has_friends(struct monst *mtmp)
 {
     coordxy dx, dy;
-    int n = 0;
     struct monst *mon2;
 
     if (mtmp->mtame || mtmp->mpeaceful)
@@ -1239,11 +1238,12 @@ mon_has_friends(struct monst *mtmp)
             coordxy y = mtmp->my + dy;
 
             if (isok(x, y) && (mon2 = m_at(x, y)) != 0
+                && mon2 != mtmp
                 && !mon2->mtame && !mon2->mpeaceful)
-                n++;
+                return TRUE;
         }
 
-    return (n > 1) ? TRUE : FALSE;
+    return FALSE;
 }
 
 /* Select an offensive item/action for a monster.  Returns TRUE iff one is