Further decreased save time and filesize 3x
This commit is contained in:
@@ -218,7 +218,7 @@ public class UI extends SceneModule{
|
|||||||
|
|
||||||
public void loadAnd(String text, Callable call){
|
public void loadAnd(String text, Callable call){
|
||||||
loadfrag.show(text);
|
loadfrag.show(text);
|
||||||
Timers.run(6f, () -> {
|
Timers.runTask(6f, () -> {
|
||||||
call.run();
|
call.run();
|
||||||
loadfrag.hide();
|
loadfrag.hide();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import io.anuke.mindustry.io.versions.Save16;
|
|||||||
import io.anuke.ucore.core.Settings;
|
import io.anuke.ucore.core.Settings;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.zip.DeflaterOutputStream;
|
||||||
|
import java.util.zip.InflaterInputStream;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
@@ -59,7 +61,7 @@ public class SaveIO{
|
|||||||
byte[] bytes = Base64Coder.decode(string);
|
byte[] bytes = Base64Coder.decode(string);
|
||||||
return new DataInputStream(new ByteArrayInputStream(bytes));
|
return new DataInputStream(new ByteArrayInputStream(bytes));
|
||||||
}else{
|
}else{
|
||||||
return new DataInputStream(fileFor(slot).read());
|
return new DataInputStream(new InflaterInputStream(fileFor(slot).read()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,11 +114,10 @@ public class SaveIO{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void write(OutputStream os){
|
public static void write(OutputStream os){
|
||||||
|
|
||||||
DataOutputStream stream;
|
DataOutputStream stream;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
stream = new DataOutputStream(os);
|
stream = new DataOutputStream(new DeflaterOutputStream(os));
|
||||||
getVersion().write(stream);
|
getVersion().write(stream);
|
||||||
stream.close();
|
stream.close();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
@@ -142,7 +143,7 @@ public class SaveIO{
|
|||||||
DataInputStream stream;
|
DataInputStream stream;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
stream = new DataInputStream(is);
|
stream = new DataInputStream(new InflaterInputStream(is));
|
||||||
int version = stream.readInt();
|
int version = stream.readInt();
|
||||||
SaveFileVersion ver = versions.get(version);
|
SaveFileVersion ver = versions.get(version);
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import io.anuke.ucore.entities.Entities;
|
|||||||
import io.anuke.ucore.entities.EntityGroup;
|
import io.anuke.ucore.entities.EntityGroup;
|
||||||
import io.anuke.ucore.entities.trait.Entity;
|
import io.anuke.ucore.entities.trait.Entity;
|
||||||
import io.anuke.ucore.util.Bits;
|
import io.anuke.ucore.util.Bits;
|
||||||
|
import io.anuke.ucore.util.Log;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@@ -240,32 +241,5 @@ public class Save16 extends SaveFileVersion {
|
|||||||
i += consecutives;
|
i += consecutives;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
//now write all blocks
|
|
||||||
for(int x = 0; x < world.width(); x ++){
|
|
||||||
for(int y = 0; y < world.height(); y ++){
|
|
||||||
Tile tile = world.tile(x, y);
|
|
||||||
|
|
||||||
stream.writeByte(tile.floor().id);
|
|
||||||
stream.writeByte(tile.block().id);
|
|
||||||
stream.writeByte(tile.elevation);
|
|
||||||
|
|
||||||
if(tile.block() instanceof BlockPart){
|
|
||||||
stream.writeByte(tile.link);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(tile.entity != null){
|
|
||||||
stream.writeByte(Bits.packByte((byte)tile.getTeam().ordinal(), tile.getRotation())); //team + rotation
|
|
||||||
stream.writeShort((short)tile.entity.health); //health
|
|
||||||
|
|
||||||
if(tile.entity.items != null) tile.entity.items.write(stream);
|
|
||||||
if(tile.entity.power != null) tile.entity.power.write(stream);
|
|
||||||
if(tile.entity.liquids != null) tile.entity.liquids.write(stream);
|
|
||||||
|
|
||||||
tile.entity.write(stream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public class SaveDialog extends LoadDialog{
|
|||||||
try{
|
try{
|
||||||
slot.save();
|
slot.save();
|
||||||
}catch(Throwable e){
|
}catch(Throwable e){
|
||||||
|
e.printStackTrace();
|
||||||
e = (e.getCause() == null ? e : e.getCause());
|
e = (e.getCause() == null ? e : e.getCause());
|
||||||
|
|
||||||
ui.showError("[orange]"+Bundles.get("text.savefail")+"\n[white]" + ClassReflection.getSimpleName(e.getClass()) + ": " + e.getMessage() + "\n" + "at " + e.getStackTrace()[0].getFileName() + ":" + e.getStackTrace()[0].getLineNumber());
|
ui.showError("[orange]"+Bundles.get("text.savefail")+"\n[white]" + ClassReflection.getSimpleName(e.getClass()) + ": " + e.getMessage() + "\n" + "at " + e.getStackTrace()[0].getFileName() + ":" + e.getStackTrace()[0].getLineNumber());
|
||||||
|
|||||||
Reference in New Issue
Block a user