From b214ea58cf8484a25dca18c4511cc5a25628d552 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 19 Sep 2017 02:13:21 -0400 Subject: [PATCH] v0.6.2: fixed exploits involving tapping outside the tilemap --- .../shatteredpixeldungeon/tiles/DungeonTilemap.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/DungeonTilemap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/DungeonTilemap.java index 4b94755d6..8ab225cfb 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/DungeonTilemap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/DungeonTilemap.java @@ -26,6 +26,7 @@ import com.watabou.noosa.Image; import com.watabou.noosa.TextureFilm; import com.watabou.noosa.Tilemap; import com.watabou.noosa.tweeners.AlphaTweener; +import com.watabou.utils.GameMath; import com.watabou.utils.PathFinder; import com.watabou.utils.PointF; @@ -83,10 +84,10 @@ public abstract class DungeonTilemap extends Tilemap { PointF p = camera().screenToCamera( x, y ). offset( this.point().negate() ). invScale( SIZE ); - if (p.x < 0 || p.x >= Dungeon.level.width() - || p.y < 0 - || p.y >= Dungeon.level.height()) - return -1; + + //snap to the edges of the tilemap + p.x = GameMath.gate(0, p.x, Dungeon.level.width()-0.001f); + p.y = GameMath.gate(0, p.y, Dungeon.level.height()-0.001f); int cell = (int)p.x + (int)p.y * Dungeon.level.width();