From a08b3a94a87d0e7f662285ccc86e2ce6e967c0c9 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 12 Oct 2020 19:50:17 -0400 Subject: [PATCH] v0.9.0b: added safety checks to beacon of returning --- .../java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java | 2 +- .../shatteredpixeldungeon/items/spells/BeaconOfReturning.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java index 9612bf184..5092edbca 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java @@ -355,7 +355,7 @@ public class Dungeon { if (pos == -2){ pos = level.exit; - } else if (pos < 0 || pos >= level.length()){ + } else if (pos < 0 || pos >= level.length() || (!level.passable[pos] && !level.avoid[pos])){ pos = level.entrance; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/BeaconOfReturning.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/BeaconOfReturning.java index 19fb0fec2..25c943b76 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/BeaconOfReturning.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/BeaconOfReturning.java @@ -120,6 +120,9 @@ public class BeaconOfReturning extends Spell { } if (returnDepth == Dungeon.depth) { + if (!Dungeon.level.passable[returnPos] && !Dungeon.level.avoid[returnPos]){ + returnPos = Dungeon.level.entrance; + } ScrollOfTeleportation.appear( hero, returnPos ); for(Mob m : Dungeon.level.mobs){ if (m.pos == hero.pos){