v3.0.0: reverted a retreating code optimization that caused rare errors
This commit is contained in:
@@ -1079,24 +1079,22 @@ public class Dungeon {
|
||||
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 ) {
|
||||
boolean[] passable = findPassable(ch, pass, visible, false, 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
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user