mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 12:04:06 +09:00
writing savemode to the savegame binary
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user