From 17ac29b190d393e5960e1da7ee93c22bc1599398 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 26 Aug 2020 19:12:38 -0400 Subject: [PATCH] v0.8.2c: added crash safety checks to tengu and WndBlacksmith --- .../actors/mobs/NewTengu.java | 14 +++++++++----- .../windows/WndBlacksmith.java | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/NewTengu.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/NewTengu.java index f188f8272..ab2ea13ba 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/NewTengu.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/NewTengu.java @@ -265,19 +265,23 @@ public class NewTengu extends Mob { //otherwise, jump in a larger possible area, as the room is bigger } else { - + + int tries = 100; do { newPos = Random.Int(level.length()); - } while ( - level.solid[newPos] || + tries--; + } while ( tries > 0 && + (level.solid[newPos] || level.distance(newPos, enemy.pos) < 5 || level.distance(newPos, enemy.pos) > 7 || level.distance(newPos, Dungeon.hero.pos) < 5 || level.distance(newPos, Dungeon.hero.pos) > 7 || level.distance(newPos, pos) < 5 || Actor.findChar(newPos) != null || - Dungeon.level.heaps.get(newPos) != null); - + Dungeon.level.heaps.get(newPos) != null)); + + if (tries <= 0) newPos = pos; + if (level.heroFOV[pos]) CellEmitter.get( pos ).burst( Speck.factory( Speck.WOOL ), 6 ); sprite.move( pos, newPos ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBlacksmith.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBlacksmith.java index 1ee57f7a7..e94d93c8d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBlacksmith.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBlacksmith.java @@ -103,7 +103,7 @@ public class WndBlacksmith extends Window { protected WndBag.Listener itemSelector = new WndBag.Listener() { @Override public void onSelect( Item item ) { - if (item != null) { + if (item != null && btnPressed.parent != null) { btnPressed.item( item ); if (btnItem1.item != null && btnItem2.item != null) {