From e9df79d108184331473fbb7dc7b77eed3d925d73 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 23 Aug 2017 04:34:40 -0400 Subject: [PATCH] v0.6.1b: fixed rare crashes when tengu's arena was very full --- .../shatteredpixeldungeon/actors/mobs/Tengu.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Tengu.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Tengu.java index 181989041..8532a1d5c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Tengu.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Tengu.java @@ -184,13 +184,12 @@ public class Tengu extends Mob { int newPos; //if we're in phase 1, want to warp around within the room if (HP > HT/2) { + int tries = 50; do { - newPos = Random.Int(Dungeon.level.length()); - } while ( - !(Dungeon.level.map[newPos] == Terrain.INACTIVE_TRAP || Dungeon.level.map[newPos] == Terrain.TRAP)|| - Level.solid[newPos] || - Dungeon.level.adjacent(newPos, enemy.pos) || - Actor.findChar(newPos) != null); + newPos = Random.IntRange(3, 7) + 32*Random.IntRange(26, 30); + } while ( (Dungeon.level.adjacent(newPos, enemy.pos) || Actor.findChar(newPos) != null) + && --tries > 0); + if (tries <= 0) return; //otherwise go wherever, as long as it's a little bit away } else {