DEADSOFTWARE

Nonnull by default
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / GameSaver.java
index edc29e3f01c2ff97b16c60fade7ab31b1fb5921f..38e295931f27b864ed98fa94ecad05698e323e94 100644 (file)
@@ -11,6 +11,7 @@ public class GameSaver {
 
     private static final int VERSION = 0;
 
+
     private static byte[] intToBytes(int i) {
         return ByteBuffer.allocate(4).putInt(i).array();
     }
@@ -26,12 +27,12 @@ public class GameSaver {
         for (int y = 0; y < height; y++) {
             bl = map[0][y];
             rl = 0;
-            for (int x = 0; x < width; x++) {
-                if (map[x][y] != bl) {
+            for (int[] ints : map) {
+                if (ints[y] != bl) {
                     out.write(intToBytes(rl));
                     out.write(intToBytes(bl));
                     rl = 0;
-                    bl = map[x][y];
+                    bl = ints[y];
                 }
                 rl++;
             }
@@ -42,6 +43,7 @@ public class GameSaver {
         out.close();
     }
 
+
     private static int[][] loadMap(FileHandle file) throws Exception {
         int[][] map;
         int ver, width, height;
@@ -73,13 +75,12 @@ public class GameSaver {
             if (VERSION == ver) gameProc = (GameProc) in.readObject();
             else throw new Exception("version mismatch");
             in.close();
-            gameProc.world = new GameWorld();
-            gameProc.world.setMaps(
+            gameProc.world = new GameWorld(
                     loadMap(Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/foremap.sav")),
                     loadMap(Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/backmap.sav"))
             );
             gameProc.physics = new GamePhysics();
-            gameProc.resetRenderer();
+            gameProc.input = new GameInput();
         } catch (Exception e) {
             Gdx.app.error("GameSaver", e.getMessage(), e);
             Gdx.app.exit();