v3.0.0: reverted a retreating code optimization that caused rare errors

This commit is contained in:
Evan Debenham
2025-01-22 13:25:39 -05:00
parent 8c8d3916b5
commit d2d58f8751

View File

@@ -1079,24 +1079,22 @@ public class Dungeon {
return PathFinder.getStep( ch.pos, to, findPassable(ch, pass, visible, chars) ); return PathFinder.getStep( ch.pos, to, findPassable(ch, pass, visible, chars) );
} }
public static int flee( Char ch, int from, boolean[] pass, boolean[] visible, boolean chars ) { public static int flee( Char ch, int from, boolean[] pass, boolean[] visible, boolean chars ) {
boolean[] passable = findPassable(ch, pass, visible, false, true); boolean[] passable = findPassable(ch, pass, visible, false, true);
passable[ch.pos] = true; passable[ch.pos] = true;
//only consider other chars impassable if our retreat step may collide with them
if (chars) {
for (Char c : Actor.chars()) {
if (c.pos == from || Dungeon.level.adjacent(c.pos, ch.pos)) {
passable[c.pos] = false;
}
}
}
//chars affected by terror have a shorter lookahead and can't approach the fear source //chars affected by terror have a shorter lookahead and can't approach the fear source
boolean canApproachFromPos = ch.buff(Terror.class) == null && ch.buff(Dread.class) == null; boolean canApproachFromPos = ch.buff(Terror.class) == null && ch.buff(Dread.class) == null;
return PathFinder.getStepBack( ch.pos, from, canApproachFromPos ? 8 : 4, passable, canApproachFromPos ); int step = PathFinder.getStepBack( ch.pos, from, canApproachFromPos ? 8 : 4, passable, canApproachFromPos );
//only consider chars impassable if our retreat step runs into them
while (step != -1 && Actor.findChar(step) != null && chars){
passable[step] = false;
step = PathFinder.getStepBack( ch.pos, from, canApproachFromPos ? 8 : 4, passable, canApproachFromPos );
}
return step;
} }
} }