X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavecraft%2Fgame%2FGameSaver.java;h=c4e13a640a737ec58b8bf1a1a9bb6c425a42c2c5;hb=feb58daa2c3e8126871e9d4f26e978d2fc1fb01c;hp=fccc7bc8a889378d7e1ef89fb9a6cfef53b7d68a;hpb=0d7e23d2bdd65c0f7510b2db6ee7f4159dd25da6;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java b/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java index fccc7bc..c4e13a6 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java @@ -3,134 +3,110 @@ package ru.deadsoftware.cavecraft.game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import ru.deadsoftware.cavecraft.CaveGame; -import ru.deadsoftware.cavecraft.Items; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; +import java.io.*; import java.nio.ByteBuffer; public class GameSaver { private static final int VERSION = 0; - private static int[][] fMap, bMap; - private static int readIndex; - - private static int bytesInt(byte[] bytes) { - ByteBuffer wrapped = ByteBuffer.wrap(bytes); - int res = wrapped.getInt(readIndex); - readIndex+=4; - return res; - } - - private static void writeInt(FileHandle file, int i, boolean append) { - byte[] bytes = ByteBuffer.allocate(4).putInt(i).array(); - file.writeBytes(bytes, append); + private static byte[] intToBytes(int i) { + return ByteBuffer.allocate(4).putInt(i).array(); } - private static void saveMap(FileHandle file, int[][] map) { - 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; - writeInt(file, VERSION, false); - writeInt(file, width, true); - writeInt(file, height, true); - for (int y=0; y