diff --git a/src/micropolisj/engine/Micropolis.java b/src/micropolisj/engine/Micropolis.java index be427d8..2227e8d 100644 --- a/src/micropolisj/engine/Micropolis.java +++ b/src/micropolisj/engine/Micropolis.java @@ -1964,7 +1964,9 @@ public class Micropolis { for (int y = 0; y < DEFAULT_HEIGHT; y++) { - map[y][x] = (char) dis.readShort(); + int z = dis.readShort(); + z &= ~(2048); // clear ANIMBIT on import + map[y][x] = (char) z; } } } @@ -1976,7 +1978,11 @@ public class Micropolis { for (int y = 0; y < DEFAULT_HEIGHT; y++) { - out.writeShort(map[y][x]); + int z = map[y][x]; + if (isAnimated(z)) { + z |= 2048; //synthesize ANIMBIT on export + } + out.writeShort(z); } } } diff --git a/src/micropolisj/engine/TileConstants.java b/src/micropolisj/engine/TileConstants.java index e09a194..1fa16a4 100644 --- a/src/micropolisj/engine/TileConstants.java +++ b/src/micropolisj/engine/TileConstants.java @@ -283,7 +283,7 @@ public class TileConstants public static boolean isAnimated(int tile) { TileSpec spec = Tiles.get(tile & LOMASK); - return spec.animNext != null; + return spec != null && spec.animNext != null; } //used by setFire() diff --git a/src/micropolisj/engine/Tiles.java b/src/micropolisj/engine/Tiles.java index e76d0ce..c7e4aa9 100644 --- a/src/micropolisj/engine/Tiles.java +++ b/src/micropolisj/engine/Tiles.java @@ -50,6 +50,11 @@ public class Tiles public static TileSpec get(int tileNumber) { - return tiles[tileNumber]; + if (tileNumber >= 0 && tileNumber < tiles.length) { + return tiles[tileNumber]; + } + else { + return null; + } } }