diff --git a/Dungeoneer/src/com/interrupt/dungeoneer/game/Level.java b/Dungeoneer/src/com/interrupt/dungeoneer/game/Level.java index 56844068..7351a763 100644 --- a/Dungeoneer/src/com/interrupt/dungeoneer/game/Level.java +++ b/Dungeoneer/src/com/interrupt/dungeoneer/game/Level.java @@ -62,9 +62,6 @@ public enum DungeonTheme { public enum Source { LEVEL_START, LEVEL_LOAD, EDITOR, SPAWNED } private enum Direction { NORTH, SOUTH, EAST, WEST } - - public static int CURRENT_VERSION = 2; - public int version = -1; public int width, height; public Tile[] tiles; @@ -236,9 +233,6 @@ public Level(int width, int height) { // make a blank level for the editor this.width = width; this.height = height; - - // Set a version for serialization purposes - version = CURRENT_VERSION; tiles = new Tile[width * height]; tileMaterials = new TileMaterials[width * height]; @@ -524,9 +518,11 @@ public void postLoad() { // Make sure the tile materials array matches the size of the tiles, and is filled if(tileMaterials == null || tileMaterials.length != tiles.length) { tileMaterials = new TileMaterials[tiles.length]; - for(int i = 0; i < tiles.length; i++) { + } + + for(int i = 0; i < tiles.length; i++) { + if(tileMaterials[i] == null) tileMaterials[i] = new TileMaterials(); - } } } diff --git a/Dungeoneer/src/com/interrupt/dungeoneer/tiles/Tile.java b/Dungeoneer/src/com/interrupt/dungeoneer/tiles/Tile.java index 6ef6e57a..05632c40 100644 --- a/Dungeoneer/src/com/interrupt/dungeoneer/tiles/Tile.java +++ b/Dungeoneer/src/com/interrupt/dungeoneer/tiles/Tile.java @@ -475,7 +475,7 @@ public void rotate90() { if(materials != null) { materials.rotate90(); - } + } } public static Tile copy(Tile tocopy) { @@ -1050,9 +1050,8 @@ public float getWallYOffset(TileEdges dir) { } public void setWallYOffset(TileEdges dir, float val) { - if(materials == null) { - materials = new TileMaterials(); - } + if(materials == null) + return; TileSurface s = materials.getTopSurface(dir); if(s == null) { @@ -1081,9 +1080,8 @@ public float getBottomWallYOffset(TileEdges dir) { } public void setBottomWallYOffset(TileEdges dir, float val) { - if(materials == null) { - materials = new TileMaterials(); - } + if(materials == null) + return; TileSurface s = materials.getTopSurface(dir); if(s == null) { @@ -1095,6 +1093,9 @@ public void setBottomWallYOffset(TileEdges dir, float val) { } public void offsetTopWallSurfaces(float amount) { + if(materials == null) + return; + for(int i = 0; i < TileEdges.values().length; i++) { TileEdges edge = TileEdges.values()[i]; TileSurface surface = materials.getTopSurface(edge); @@ -1107,6 +1108,9 @@ public void offsetTopWallSurfaces(float amount) { } public void offsetBottomWallSurfaces(float amount) { + if(materials == null) + return; + for(int i = 0; i < TileEdges.values().length; i++) { TileEdges edge = TileEdges.values()[i]; TileSurface surface = materials.getBottomSurface(edge);