Fix saving time mode state, delete save after loading
This commit is contained in:
parent
8a103f9533
commit
6ab176cbc3
3 changed files with 8 additions and 5 deletions
Binary file not shown.
|
@ -123,17 +123,18 @@ public class TimeScorer extends BaseScorer implements BinSerializable {
|
|||
|
||||
@Override
|
||||
public void write(DataOutputStream out) throws IOException {
|
||||
// startTime, highScoreTime, deadTime
|
||||
out.writeLong(startTime);
|
||||
// current/dead offset ("how long until we die"), highScoreTime
|
||||
out.writeLong(TimeUtils.nanoTime() - startTime);
|
||||
out.writeInt(highScoreTime);
|
||||
out.writeLong(deadTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInputStream in) throws IOException {
|
||||
startTime = in.readLong();
|
||||
// We need to use the offset, since the start time
|
||||
// is different and we couldn't save absolute values
|
||||
long deadOffset = in.readLong();
|
||||
deadTime = startTime + deadOffset;
|
||||
highScoreTime = in.readInt();
|
||||
deadTime = in.readLong();
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
|
|
@ -278,6 +278,8 @@ class GameScreen implements Screen, InputProcessor, BinSerializable {
|
|||
if (handle.exists()) {
|
||||
try {
|
||||
BinSerializer.deserialize(this, handle.read());
|
||||
// After it's been loaded, delete the save file
|
||||
deleteSave();
|
||||
return true;
|
||||
} catch (IOException ignored) { }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue