Implemented save time recording
This commit is contained in:
@@ -15,12 +15,13 @@ public abstract class SaveFileVersion{
|
||||
|
||||
public SaveMeta getData(DataInputStream stream) throws IOException{
|
||||
long time = stream.readLong(); //read last saved time
|
||||
long playtime = stream.readLong();
|
||||
int build = stream.readInt();
|
||||
byte mode = stream.readByte(); //read the gamemode
|
||||
String map = stream.readUTF(); //read the map
|
||||
int wave = stream.readInt(); //read the wave
|
||||
byte difficulty = stream.readByte(); //read the difficulty
|
||||
return new SaveMeta(version, time, build, mode, map, wave, Difficulty.values()[difficulty]);
|
||||
return new SaveMeta(version, time, playtime, build, mode, map, wave, Difficulty.values()[difficulty]);
|
||||
}
|
||||
|
||||
public abstract void read(DataInputStream stream) throws IOException;
|
||||
|
||||
@@ -13,15 +13,17 @@ public class SaveMeta{
|
||||
public int version;
|
||||
public int build;
|
||||
public String date;
|
||||
public long timePlayed;
|
||||
public GameMode mode;
|
||||
public Map map;
|
||||
public int wave;
|
||||
public Difficulty difficulty;
|
||||
|
||||
public SaveMeta(int version, long date, int build, int mode, String map, int wave, Difficulty difficulty){
|
||||
public SaveMeta(int version, long date, long timePlayed, int build, int mode, String map, int wave, Difficulty difficulty){
|
||||
this.version = version;
|
||||
this.build = build;
|
||||
this.date = Platform.instance.format(new Date(date));
|
||||
this.timePlayed = timePlayed;
|
||||
this.mode = GameMode.values()[mode];
|
||||
this.map = world.maps().getByName(map);
|
||||
this.wave = wave;
|
||||
|
||||
@@ -25,8 +25,7 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Save16 extends SaveFileVersion{
|
||||
|
||||
@@ -37,6 +36,7 @@ public class Save16 extends SaveFileVersion{
|
||||
@Override
|
||||
public void read(DataInputStream stream) throws IOException{
|
||||
stream.readLong(); //time
|
||||
stream.readLong(); //total playtime
|
||||
stream.readInt(); //build
|
||||
|
||||
//general state
|
||||
@@ -154,6 +154,7 @@ public class Save16 extends SaveFileVersion{
|
||||
//--META--
|
||||
stream.writeInt(version); //version id
|
||||
stream.writeLong(TimeUtils.millis()); //last saved
|
||||
stream.writeLong(headless ? 0 : control.getSaves().getTotalPlaytime()); //playtime
|
||||
stream.writeInt(Version.build); //build
|
||||
|
||||
//--GENERAL STATE--
|
||||
|
||||
Reference in New Issue
Block a user