diff --git a/engine/src/tools/jme3tools/savegame/SaveGame.java b/engine/src/tools/jme3tools/savegame/SaveGame.java index 189934606..5f3477f51 100644 --- a/engine/src/tools/jme3tools/savegame/SaveGame.java +++ b/engine/src/tools/jme3tools/savegame/SaveGame.java @@ -11,12 +11,12 @@ import com.jme3.export.binary.BinaryImporter; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.InputStream; import java.util.logging.Level; import java.util.logging.Logger; import java.util.prefs.Preferences; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; import sun.misc.UUDecoder; import sun.misc.UUEncoder; @@ -36,12 +36,9 @@ public class SaveGame { Preferences prefs = Preferences.userRoot().node(gamePath); BinaryExporter ex = BinaryExporter.getInstance(); ByteArrayOutputStream out = new ByteArrayOutputStream(); - ZipOutputStream zos = new ZipOutputStream(out); - zos.setLevel(9); try { - zos.putNextEntry(new ZipEntry(dataName)); + GZIPOutputStream zos = new GZIPOutputStream(out); ex.save(data, zos); - zos.closeEntry(); zos.close(); } catch (IOException ex1) { Logger.getLogger(SaveGame.class.getName()).log(Level.SEVERE, "Error saving data: {0}", ex1); @@ -49,6 +46,7 @@ public class SaveGame { } UUEncoder enc = new UUEncoder(); String dataString = enc.encodeBuffer(out.toByteArray()); + System.out.println(dataString); if (dataString.length() > Preferences.MAX_VALUE_LENGTH) { throw new IllegalStateException("SaveGame dataset too large"); } @@ -75,12 +73,11 @@ public class SaveGame { public static Savable loadGame(String gamePath, String dataName, AssetManager manager) { Preferences prefs = Preferences.userRoot().node(gamePath); String data = prefs.get(dataName, ""); - ZipInputStream is = null; + InputStream is = null; Savable sav = null; UUDecoder dec = new UUDecoder(); try { - is = new ZipInputStream(new ByteArrayInputStream(dec.decodeBuffer(data))); - is.getNextEntry(); + is = new GZIPInputStream(new ByteArrayInputStream(dec.decodeBuffer(data))); BinaryImporter imp = BinaryImporter.getInstance(); if (manager != null) { imp.setAssetManager(manager);