X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavecraft%2Fgame%2FGameSaver.java;h=5f8743dc8710a3f054b597fea29a9be5a19e6538;hb=22eccb137bf9642700f762dd39cf02ea144bdca3;hp=1bf6684682e6e6af212e4d158cb5699e36118a7b;hpb=08def9aa287e5309c12c6a4110f6b8486afd3a6c;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java b/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java index 1bf6684..5f8743d 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java @@ -4,47 +4,34 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import ru.deadsoftware.cavecraft.CaveGame; -import java.io.BufferedOutputStream; -import java.io.IOException; -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 bytesToInt(byte[] bytes) { - ByteBuffer wrapped = ByteBuffer.wrap(bytes); - int res = wrapped.getInt(readIndex); - readIndex+=4; - return res; - } - private static byte[] intToBytes(int i) { 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