v0.6.2: fixed exploits involving tapping outside the tilemap

This commit is contained in:
Evan Debenham 2017-09-19 02:13:21 -04:00
parent 925d737d93
commit b214ea58cf

View File

@ -26,6 +26,7 @@ import com.watabou.noosa.Image;
import com.watabou.noosa.TextureFilm; import com.watabou.noosa.TextureFilm;
import com.watabou.noosa.Tilemap; import com.watabou.noosa.Tilemap;
import com.watabou.noosa.tweeners.AlphaTweener; import com.watabou.noosa.tweeners.AlphaTweener;
import com.watabou.utils.GameMath;
import com.watabou.utils.PathFinder; import com.watabou.utils.PathFinder;
import com.watabou.utils.PointF; import com.watabou.utils.PointF;
@ -83,10 +84,10 @@ public abstract class DungeonTilemap extends Tilemap {
PointF p = camera().screenToCamera( x, y ). PointF p = camera().screenToCamera( x, y ).
offset( this.point().negate() ). offset( this.point().negate() ).
invScale( SIZE ); invScale( SIZE );
if (p.x < 0 || p.x >= Dungeon.level.width()
|| p.y < 0 //snap to the edges of the tilemap
|| p.y >= Dungeon.level.height()) p.x = GameMath.gate(0, p.x, Dungeon.level.width()-0.001f);
return -1; p.y = GameMath.gate(0, p.y, Dungeon.level.height()-0.001f);
int cell = (int)p.x + (int)p.y * Dungeon.level.width(); int cell = (int)p.x + (int)p.y * Dungeon.level.width();