writing savemode to the savegame binary

This commit is contained in:
minjaesong
2021-09-29 17:34:26 +09:00
parent 60a8382f93
commit 7ddde8e4f0
7 changed files with 24 additions and 9 deletions

View File

@@ -8,6 +8,7 @@ import net.torvald.terrarum.console.Echo
import net.torvald.terrarum.modulebasegame.IngameRenderer
import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.realestate.LandUtil
import net.torvald.terrarum.toInt
import net.torvald.terrarum.tvda.*
import java.io.File
import java.util.zip.GZIPOutputStream
@@ -15,7 +16,7 @@ import java.util.zip.GZIPOutputStream
/**
* Created by minjaesong on 2021-09-29.
*/
class QuickSaveThread(val disk: VirtualDisk, val file: File, val ingame: TerrarumIngame, val hasThumbnail: Boolean, val callback: () -> Unit) : Runnable {
class QuickSaveThread(val disk: VirtualDisk, val file: File, val ingame: TerrarumIngame, val hasThumbnail: Boolean, val isAuto: Boolean, val callback: () -> Unit) : Runnable {
/**
* Will happily overwrite existing entry
@@ -130,14 +131,14 @@ class QuickSaveThread(val disk: VirtualDisk, val file: File, val ingame: Terraru
skimmer.rewriteDirectories()
skimmer.injectDiskCRC(disk.hashCode())
skimmer.setSaveMode(1 + 2 * isAuto.toInt())
Echo ("${ccW}Game saved with size of $ccG${file.length()}$ccW bytes")
if (hasThumbnail) IngameRenderer.fboRGBexportedLatch = false
WriteSavegame.savingStatus = 255
ingame.modifiedChunks.forEach { it.clear() }
ingame.clearModifiedChunks()
callback()
}

View File

@@ -68,7 +68,7 @@ object WriteSavegame {
// use field 'savingStatus' to know when the saving is done
}
fun quick(disk: VirtualDisk, file: File, ingame: TerrarumIngame, callback: () -> Unit = {}) {
fun quick(disk: VirtualDisk, file: File, ingame: TerrarumIngame, isAuto: Boolean, callback: () -> Unit = {}) {
savingStatus = 0
Echo("Quicksave queued")
@@ -88,7 +88,7 @@ object WriteSavegame {
}
IngameRenderer.fboRGBexportRequested = true
val savingThread = Thread(QuickSaveThread(disk, file, ingame, true, callback), "TerrarumBasegameGameSaveThread")
val savingThread = Thread(QuickSaveThread(disk, file, ingame, true, isAuto, callback), "TerrarumBasegameGameSaveThread")
savingThread.start()
// it is caller's job to keep the game paused or keep a "save in progress" ui up