X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavedroid%2Fgame%2FGameSaver.java;h=0788561d8edf39e8a4151278b41abd7a5398c8e3;hb=59d48c1b28c570755327a8fb0827fa57e7fd3914;hp=0d796b8b3a22583ed5e7e540bcb3b0ebe5bfe6a0;hpb=2948fcd9c40ebf588ef7d0e7cd8dd34ecaa1f9b2;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameSaver.java b/core/src/ru/deadsoftware/cavedroid/game/GameSaver.java index 0d796b8..0788561 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GameSaver.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GameSaver.java @@ -2,7 +2,6 @@ package ru.deadsoftware.cavedroid.game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; -import org.jetbrains.annotations.NotNull; import ru.deadsoftware.cavedroid.CaveGame; import java.io.*; @@ -12,12 +11,12 @@ public class GameSaver { private static final int VERSION = 0; - @NotNull + private static byte[] intToBytes(int i) { return ByteBuffer.allocate(4).putInt(i).array(); } - private static void saveMap(@NotNull FileHandle file, @NotNull int[][] map) throws IOException { + private static void saveMap(FileHandle file, int[][] map) throws IOException { int rl, bl; int width = map.length; int height = map[0].length; @@ -44,8 +43,8 @@ public class GameSaver { out.close(); } - @NotNull - private static int[][] loadMap(@NotNull FileHandle file) throws Exception { + + private static int[][] loadMap(FileHandle file) throws Exception { int[][] map; int ver, width, height; int rl, bl; @@ -59,11 +58,15 @@ public class GameSaver { for (int x = 0; x < width; x += rl) { rl = in.readInt(); bl = in.readInt(); - for (int i = x; i < x + rl; i++) map[i][y] = bl; + for (int i = x; i < x + rl; i++) { + map[i][y] = bl; + } } } in.close(); - } else throw new Exception("version mismatch"); + } else { + throw new Exception("version mismatch"); + } return map; } @@ -73,15 +76,18 @@ public class GameSaver { try { ObjectInputStream in = new ObjectInputStream(file.read()); int ver = in.readInt(); - if (VERSION == ver) gameProc = (GameProc) in.readObject(); - else throw new Exception("version mismatch"); + if (VERSION == ver) { + gameProc = (GameProc) in.readObject(); + } else { + throw new Exception("version mismatch"); + } in.close(); 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();