From 4d6fdad4eaac22b8559b45afd83d86a8066c4f1a Mon Sep 17 00:00:00 2001
From: Evan Debenham <Evan.SHPX@gmail.com>
Date: Mon, 8 Jan 2018 18:30:06 -0500
Subject: [PATCH] v0.6.3: fixed crash bugs caused by tile discovery

---
 .../shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java | 1 +
 .../shatteredpixeldungeon/tiles/DungeonTilemap.java            | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java
index f82c4313f..3fe138e21 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java
@@ -786,6 +786,7 @@ public class GameScene extends PixelScene {
 		}
 	}
 	
+	//todo this doesn't account for walls right now
 	public static void discoverTile( int pos, int oldValue ) {
 		if (scene != null) {
 			scene.tiles.discover( pos, oldValue );
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 8ab225cfb..1b74666e4 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/DungeonTilemap.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/DungeonTilemap.java
@@ -113,6 +113,9 @@ public abstract class DungeonTilemap extends Tilemap {
 	
 	public void discover( int pos, int oldValue ) {
 		
+		int visual = getTileVisual( pos, oldValue, false);
+		if (visual < 0) return;
+		
 		final Image tile = new Image( texture );
 		tile.frame( tileset.get( getTileVisual( pos, oldValue, false)));
 		tile.point( tileToWorld( pos ) );