From 74679f153e63e5257fdb015e16752eaf281a2528 Mon Sep 17 00:00:00 2001 From: Evan Debenham <Evan@ShatteredPixel.com> Date: Wed, 2 Dec 2020 18:11:55 -0500 Subject: [PATCH] v0.9.1: fixed crashes with rockfall traps --- .../shatteredpixeldungeon/levels/traps/RockfallTrap.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/RockfallTrap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/RockfallTrap.java index fa5478473..ff52fabe4 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/RockfallTrap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/RockfallTrap.java @@ -58,9 +58,12 @@ public class RockfallTrap extends Trap { //determines if the trap is actually in the world, or if it is being spawned for its effect boolean onGround = Dungeon.level.traps.get(pos) == this; + Room r = null; + if (Dungeon.level instanceof RegularLevel){ + r = ((RegularLevel) Dungeon.level).room(pos); + } - if (onGround && Dungeon.level instanceof RegularLevel){ - Room r = ((RegularLevel) Dungeon.level).room(pos); + if (onGround && r != null){ int cell; for (Point p : r.getPoints()){ cell = Dungeon.level.pointToCell(p); @@ -69,7 +72,7 @@ public class RockfallTrap extends Trap { } } - //if we don't have rooms, then just do 5x5 + //if we don't have a room, then just do 5x5 } else { PathFinder.buildDistanceMap( pos, BArray.not( Dungeon.level.solid, null ), 2 ); for (int i = 0; i < PathFinder.distance.length; i++) {