mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-08 12:51:51 +09:00
the manual saving will unset the quicksave and autosave flags; save.1 won't overwrite save.2 if the target is .2 is cleansave and .1 is dirty
This commit is contained in:
@@ -19,11 +19,10 @@ import net.torvald.terrarum.ui.ConsoleWindow
|
||||
import net.torvald.util.SortedArrayList
|
||||
import org.khelekore.prtree.*
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
import java.util.concurrent.locks.Lock
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
/**
|
||||
* Although the game (as product) can have infinitely many stages/planets/etc., those stages must be manually managed by YOU;
|
||||
@@ -367,11 +366,18 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
|
||||
*/
|
||||
fun makeSavegameBackupCopy() {
|
||||
try {
|
||||
File(App.defaultSaveDir, INGAME.savegameNickname+".1").copyTo(
|
||||
File(App.defaultSaveDir, INGAME.savegameNickname+".2"), // don't use .bak as it's used by the savecracker
|
||||
true
|
||||
)
|
||||
} catch (e: NoSuchFileException) {}
|
||||
// do not overwrite clean .2 with dirty .1
|
||||
val file2 = File(App.defaultSaveDir, INGAME.savegameNickname+".2")
|
||||
val file1 = File(App.defaultSaveDir, INGAME.savegameNickname+".1")
|
||||
|
||||
val flags2 = FileInputStream(file2).let { it.skip(49L); val r = it.read(); it.close(); r }
|
||||
val flags1 = FileInputStream(file1).let { it.skip(49L); val r = it.read(); it.close(); r }
|
||||
|
||||
if (!(flags2 == 0 && flags1 != 0)) {
|
||||
file1.copyTo(file2, true)
|
||||
}
|
||||
} catch (e: NoSuchFileException) {
|
||||
} catch (e: FileNotFoundException) {}
|
||||
try {
|
||||
File(App.defaultSaveDir, INGAME.savegameNickname).copyTo(
|
||||
File(App.defaultSaveDir, INGAME.savegameNickname+".1"), // don't use .bak as it's used by the savecracker
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
package net.torvald.terrarum.modulebasegame.console
|
||||
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.ReferencingRanges
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.console.ConsoleCommand
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.gameactors.BlockMarkerActor
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.tvda.DiskEntry
|
||||
import net.torvald.terrarum.tvda.VDUtil
|
||||
import net.torvald.terrarum.tvda.VirtualDisk
|
||||
import net.torvald.terrarum.serialise.Common
|
||||
import net.torvald.terrarum.serialise.WriteSavegame
|
||||
import net.torvald.terrarum.tvda.VDUtil
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
@@ -28,7 +22,7 @@ object Save : ConsoleCommand {
|
||||
val ingame = Terrarum.ingame!! as TerrarumIngame
|
||||
val savename = args[1].trim()
|
||||
val disk = VDUtil.createNewDisk(1L shl 60, savename, Common.CHARSET)
|
||||
val file = File(App.defaultDir + "/Exports/${args[1]}")
|
||||
val file = File(App.defaultSaveDir + "/${args[1]}")
|
||||
|
||||
WriteSavegame(disk, file, ingame)
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.torvald.terrarum.serialise
|
||||
|
||||
import com.badlogic.gdx.graphics.Pixmap
|
||||
import net.torvald.gdx.graphics.PixmapIO2
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.console.Echo
|
||||
@@ -30,6 +29,8 @@ class GameSavingThread(val disk: VirtualDisk, val outFile: File, val ingame: Ter
|
||||
private val actorProgressMultiplier = 1f
|
||||
|
||||
override fun run() {
|
||||
disk.saveMode = 0 // no quick, no auto
|
||||
|
||||
if (hasThumbnail) {
|
||||
while (!IngameRenderer.fboRGBexportedLatch) {
|
||||
Thread.sleep(1L)
|
||||
|
||||
@@ -35,8 +35,8 @@ object WriteWorld {
|
||||
world.totalPlayTime += currentPlayTime_t
|
||||
|
||||
val actorIDbuf = ArrayList<ActorID>()
|
||||
ingame.actorContainerActive.filter { actorAcceptable(it) }.forEach { actorIDbuf.add(it.referenceID) }
|
||||
ingame.actorContainerInactive.filter { actorAcceptable(it) }.forEach { actorIDbuf.add(it.referenceID) }
|
||||
ingame.actorContainerActive.cloneToList().filter { actorAcceptable(it) }.forEach { actorIDbuf.add(it.referenceID) }
|
||||
ingame.actorContainerInactive.cloneToList().filter { actorAcceptable(it) }.forEach { actorIDbuf.add(it.referenceID) }
|
||||
|
||||
world.actors.clear()
|
||||
world.actors.addAll(actorIDbuf.sorted().distinct())
|
||||
|
||||
Reference in New Issue
Block a user