mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
some autosave stuffs; bootloader to actually use bundled runtime
This commit is contained in:
@@ -410,14 +410,14 @@ open class IngameInstance(val batch: FlippingSpriteBatch, val isMultiplayer: Boo
|
||||
/**
|
||||
* Copies most recent `save` to `save.1`, leaving `save` for overwriting, previous `save.1` will be copied to `save.2`
|
||||
*/
|
||||
fun makeSavegameBackupCopy(file: File) {
|
||||
fun makeSavegameBackupCopy(file: File, isAuto: Boolean) {
|
||||
if (!file.exists()) {
|
||||
return
|
||||
}
|
||||
|
||||
val file1 = File("${file.absolutePath}.1")
|
||||
val file2 = File("${file.absolutePath}.2")
|
||||
val file3 = File("${file.absolutePath}.3")
|
||||
val file1 = File("${file.absolutePath}.${if (isAuto) "a" else "1"}")
|
||||
val file2 = File("${file.absolutePath}.${if (isAuto) "b" else "1"}")
|
||||
val file3 = File("${file.absolutePath}.${if (isAuto) "c" else "1"}")
|
||||
|
||||
try {
|
||||
// do not overwrite clean .2 with dirty .1
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.torvald.terrarum;
|
||||
import com.badlogic.gdx.utils.JsonValue;
|
||||
import net.torvald.terrarum.utils.JsonFetcher;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -83,8 +84,12 @@ public class Principii {
|
||||
|
||||
int xmx = getConfigInt("jvm_xmx");
|
||||
|
||||
String runtime = new File("./out/runtime-osx-x86/bin/java").getAbsolutePath();
|
||||
|
||||
System.out.println("Runtime path: "+runtime);
|
||||
|
||||
try {
|
||||
Process proc = Runtime.getRuntime().exec("java"+extracmd+" -Xms1G -Xmx"+xmx+"G -cp ./out/TerrarumBuild.jar net.torvald.terrarum.App");
|
||||
Process proc = Runtime.getRuntime().exec(runtime+extracmd+" -Xms1G -Xmx"+xmx+"G -cp ./out/TerrarumBuild.jar net.torvald.terrarum.App");
|
||||
|
||||
Thread tp = new Thread(() -> {
|
||||
String p = null;
|
||||
|
||||
@@ -420,10 +420,10 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
uiAutosaveNotifier.setAsOpen()
|
||||
val saveTime_t = App.getTIME_T()
|
||||
WriteSavegame.immediate(saveTime_t, WriteSavegame.SaveMode.PLAYER, playerDisk, getPlayerSaveFiledesc(playerSavefileName), this, true, autosaveOnErrorAction) {
|
||||
makeSavegameBackupCopy(getPlayerSaveFiledesc(playerSavefileName))
|
||||
makeSavegameBackupCopy(getPlayerSaveFiledesc(playerSavefileName), true)
|
||||
|
||||
WriteSavegame.immediate(saveTime_t, WriteSavegame.SaveMode.WORLD, worldDisk, getWorldSaveFiledesc(worldSavefileName), this, true, autosaveOnErrorAction) {
|
||||
makeSavegameBackupCopy(getWorldSaveFiledesc(worldSavefileName)) // don't put it on the postInit() or render(); must be called using callback
|
||||
makeSavegameBackupCopy(getWorldSaveFiledesc(worldSavefileName), true) // don't put it on the postInit() or render(); must be called using callback
|
||||
uiAutosaveNotifier.setAsClose()
|
||||
}
|
||||
}
|
||||
@@ -1111,10 +1111,10 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
val playerSavefile = getPlayerSaveFiledesc(INGAME.playerSavefileName)
|
||||
val worldSavefile = getWorldSaveFiledesc(INGAME.worldSavefileName)
|
||||
|
||||
INGAME.makeSavegameBackupCopy(playerSavefile)
|
||||
INGAME.makeSavegameBackupCopy(playerSavefile, true)
|
||||
WriteSavegame(saveTime_t, WriteSavegame.SaveMode.PLAYER, INGAME.playerDisk, playerSavefile, INGAME as TerrarumIngame, true, autosaveOnErrorAction) {
|
||||
|
||||
INGAME.makeSavegameBackupCopy(worldSavefile)
|
||||
INGAME.makeSavegameBackupCopy(worldSavefile, true)
|
||||
WriteSavegame(saveTime_t, WriteSavegame.SaveMode.QUICK_WORLD, INGAME.worldDisk, worldSavefile, INGAME as TerrarumIngame, true, autosaveOnErrorAction) {
|
||||
// callback:
|
||||
// rebuild the disk skimmers
|
||||
|
||||
@@ -110,10 +110,10 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
||||
val worldSavefile = getWorldSaveFiledesc(INGAME.worldSavefileName)
|
||||
|
||||
|
||||
INGAME.makeSavegameBackupCopy(playerSavefile)
|
||||
INGAME.makeSavegameBackupCopy(playerSavefile, false)
|
||||
WriteSavegame(saveTime_t, WriteSavegame.SaveMode.PLAYER, INGAME.playerDisk, playerSavefile, INGAME as TerrarumIngame, false, onError) {
|
||||
|
||||
INGAME.makeSavegameBackupCopy(worldSavefile)
|
||||
INGAME.makeSavegameBackupCopy(worldSavefile, false)
|
||||
WriteSavegame(saveTime_t, WriteSavegame.SaveMode.WORLD, INGAME.worldDisk, worldSavefile, INGAME as TerrarumIngame, false, onError) {
|
||||
// callback:
|
||||
// rebuild the disk skimmers
|
||||
|
||||
Reference in New Issue
Block a user