From 44b80b24a915de9b308e0f58cbdd9a8d6f4e03d8 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 21 Feb 2021 16:56:43 -0500 Subject: [PATCH] v0.9.2: fixed rare cases where retreating character would fail to run --- .../shatteredpixeldungeon/Dungeon.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java index ab2c8fad3..6142f25ea 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java @@ -857,16 +857,15 @@ public class Dungeon { BArray.and( passable, Dungeon.level.openSpace, passable ); } - if (chars) { - for (Char c : Actor.chars()) { - if (visible[c.pos]) { - passable[c.pos] = false; - } - } - } passable[ch.pos] = true; - - return PathFinder.getStepBack( ch.pos, from, passable ); + + //only consider chars impassable if our retreat path runs into them + int step = PathFinder.getStepBack( ch.pos, from, passable ); + while (step != -1 && Actor.findChar(step) != null){ + passable[step] = false; + step = PathFinder.getStepBack( ch.pos, from, passable ); + } + return step; }