X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavecraft%2Fgame%2FGameSaver.java;h=5f8743dc8710a3f054b597fea29a9be5a19e6538;hb=22eccb137bf9642700f762dd39cf02ea144bdca3;hp=a4e314b465273705b1cc404d44918080ef0b7f26;hpb=bea2a3c5b967bcd90ccd83e08e833d58449e963a;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java b/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java index a4e314b..5f8743d 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java @@ -23,10 +23,10 @@ public class GameSaver { out.write(intToBytes(VERSION)); out.write(intToBytes(width)); out.write(intToBytes(height)); - for (int y = 0; y < map[0].length; y++) { + for (int y = 0; y < height; y++) { bl = map[0][y]; rl = 0; - for (int x = 0; x < map.length; x++) { + for (int x = 0; x < width; x++) { if (map[x][y] != bl) { out.write(intToBytes(rl)); out.write(intToBytes(bl)); @@ -78,7 +78,7 @@ public class GameSaver { 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); + gameProc.physics = new GamePhysics(); gameProc.resetRenderer(); } catch (Exception e) { Gdx.app.error("GameSaver", e.getMessage(), e); @@ -87,17 +87,17 @@ public class GameSaver { return gameProc; } - public static void save(GameProc gameProc) { + public static void save(GameProc gp) { FileHandle file = Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/"); file.mkdirs(); file = Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/game.sav"); try { ObjectOutputStream out = new ObjectOutputStream(file.write(false)); out.writeInt(VERSION); - out.writeObject(gameProc); + out.writeObject(gp); out.close(); - saveMap(Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/foremap.sav"), gameProc.world.getFullForeMap()); - saveMap(Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/backmap.sav"), gameProc.world.getFullBackMap()); + saveMap(Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/foremap.sav"), gp.world.getFullForeMap()); + saveMap(Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/backmap.sav"), gp.world.getFullBackMap()); } catch (Exception e) { e.printStackTrace(); }