X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavecraft%2Fgame%2FGameSaver.java;h=a4e314b465273705b1cc404d44918080ef0b7f26;hb=bea2a3c5b967bcd90ccd83e08e833d58449e963a;hp=2b5b906d877a3dadcd77baca27e1e346d8eeeff1;hpb=e14d8af238926a5cbfc067cfc9a9b032e51f1cac;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java b/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java index 2b5b906..a4e314b 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java @@ -2,7 +2,6 @@ package ru.deadsoftware.cavecraft.game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; -import com.badlogic.gdx.utils.ArrayMap; import ru.deadsoftware.cavecraft.CaveGame; import java.io.*; @@ -16,23 +15,23 @@ public class GameSaver { return ByteBuffer.allocate(4).putInt(i).array(); } - private static void saveMap(FileHandle file, int[][] map) throws IOException{ - int rl,bl; + private static void saveMap(FileHandle file, int[][] map) throws IOException { + int rl, bl; int width = map.length; int height = map[0].length; BufferedOutputStream out = new BufferedOutputStream(file.write(false)); out.write(intToBytes(VERSION)); out.write(intToBytes(width)); out.write(intToBytes(height)); - for (int y=0; y(); gameProc.physics = new GamePhysics(gameProc); gameProc.resetRenderer(); } catch (Exception e) { - Gdx.app.error("GameSaver",e.getMessage(),e); + Gdx.app.error("GameSaver", e.getMessage(), e); Gdx.app.exit(); } return gameProc; } public static void save(GameProc gameProc) { - FileHandle file = Gdx.files.absolute(CaveGame.GAME_FOLDER+"/saves/"); + FileHandle file = Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/"); file.mkdirs(); - file = Gdx.files.absolute(CaveGame.GAME_FOLDER+"/saves/game.sav"); + 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.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"), gameProc.world.getFullForeMap()); + saveMap(Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/backmap.sav"), gameProc.world.getFullBackMap()); } catch (Exception e) { e.printStackTrace(); } } public static boolean exists() { - return (Gdx.files.absolute(CaveGame.GAME_FOLDER+"/saves/game.sav").exists() && - Gdx.files.absolute(CaveGame.GAME_FOLDER+"/saves/foremap.sav").exists() && - Gdx.files.absolute(CaveGame.GAME_FOLDER+"/saves/backmap.sav").exists()); + return (Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/game.sav").exists() && + Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/foremap.sav").exists() && + Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/backmap.sav").exists()); } }