mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 20:14:05 +09:00
adding 'kind flag' to the savegame format so the file can be determined if it contains player or world data
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package net.torvald.terrarum.savegame
|
||||
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.savegame.VDSaveKind.PLAYER_DATA
|
||||
import net.torvald.terrarum.savegame.VDSaveKind.WORLD_DATA
|
||||
import net.torvald.terrarum.serialise.Common
|
||||
import net.torvald.terrarum.serialise.toUint
|
||||
import java.io.File
|
||||
@@ -66,12 +68,18 @@ Version 254 is a customised version of TEVD tailored to be used as a savegame fo
|
||||
4. for elems on list: update crc with the elem (crc = calculateCRC(crc, elem))
|
||||
Int8 Version
|
||||
Int8 0xFE
|
||||
< BEGIN extraInfoBytes >
|
||||
Int8 Disk properties flag 1
|
||||
0th bit: readonly
|
||||
Int8 Save type
|
||||
0th bit: unset - full save; set - quick save
|
||||
1st bit: set - generated by autosave
|
||||
Int8[14] Extra info bytes
|
||||
0th bit: unset - full save; set - quick save
|
||||
1st bit: set - generated by autosave
|
||||
Int8 Kind of the Save file
|
||||
0: Undefined (old version of the game?)
|
||||
1: Player Data
|
||||
2: World Data
|
||||
Int8[13] Extra info bytes
|
||||
< END extraInfoBytes >
|
||||
Unit8[236] Rest of the long disk name (268 bytes total)
|
||||
|
||||
(Header size: 300 bytes)
|
||||
@@ -141,6 +149,9 @@ class VirtualDisk(
|
||||
var saveMode: Int
|
||||
set(value) { extraInfoBytes[1] = value.toByte() }
|
||||
get() = extraInfoBytes[1].toUint()
|
||||
var saveKind: Int
|
||||
set(value) { extraInfoBytes[2] = value.toByte() }
|
||||
get() = extraInfoBytes[2].toUint()
|
||||
override fun getDiskName(charset: Charset) = diskName.toCanonicalString(charset)
|
||||
val root: DiskEntry
|
||||
get() = entries[0]!!
|
||||
@@ -234,6 +245,12 @@ class VirtualDisk(
|
||||
}
|
||||
}
|
||||
|
||||
object VDSaveKind {
|
||||
const val UNDEFINED = 0
|
||||
const val PLAYER_DATA = 1
|
||||
const val WORLD_DATA = 2
|
||||
}
|
||||
|
||||
object VDFileID {
|
||||
const val ROOT = 0L
|
||||
const val SAVEGAMEINFO = -1L
|
||||
@@ -245,11 +262,21 @@ object VDFileID {
|
||||
const val BODYPARTGLOW_TO_ENTRY_MAP = -1026L
|
||||
}
|
||||
|
||||
fun diskIDtoReadableFilename(id: EntryID): String = when (id) {
|
||||
fun diskIDtoReadableFilename(id: EntryID, saveKind: Int?): String = when (id) {
|
||||
VDFileID.ROOT -> "root"
|
||||
VDFileID.SAVEGAMEINFO -> "savegameinfo.json"
|
||||
VDFileID.THUMBNAIL, VDFileID.SPRITEDEF -> "thumbnail.tga.gz (world)/spritedef (player)"
|
||||
VDFileID.SPRITEDEF_GLOW -> "spritedef-glow (player)"
|
||||
VDFileID.THUMBNAIL, VDFileID.SPRITEDEF ->
|
||||
if (saveKind == PLAYER_DATA)
|
||||
"spritedef"
|
||||
else if (saveKind == WORLD_DATA)
|
||||
"thumbnail.tga.gz"
|
||||
else
|
||||
"thumbnail.tga.gz (world)/spritedef (player)"
|
||||
VDFileID.SPRITEDEF_GLOW ->
|
||||
if (saveKind == PLAYER_DATA)
|
||||
"spritedef-glow"
|
||||
else
|
||||
"file #$id"
|
||||
VDFileID.LOADORDER -> "loadOrder.txt"
|
||||
// -16L -> "blockcodex.json.gz"
|
||||
// -17L -> "itemcodex.json.gz"
|
||||
@@ -259,7 +286,11 @@ fun diskIDtoReadableFilename(id: EntryID): String = when (id) {
|
||||
// -1024L -> "apocryphas.json.gz"
|
||||
VDFileID.BODYPART_TO_ENTRY_MAP -> "bodypart-to-entry.map"
|
||||
VDFileID.BODYPARTGLOW_TO_ENTRY_MAP -> "bodypartglow-to-entry.map"
|
||||
in 1..65535 -> "bodypart #$id.tga.gz (player)"
|
||||
in 1..65535 ->
|
||||
if (saveKind == PLAYER_DATA)
|
||||
"bodypart #$id.tga.gz"
|
||||
else
|
||||
"file #$id"
|
||||
in 1048576..2147483647 -> "actor #$id.json"
|
||||
in 0x0000_0001_0000_0000L..0x0000_FFFF_FFFF_FFFFL ->
|
||||
"World${id.ushr(32)}-L${id.and(0xFF00_0000).ushr(24)}-C${id.and(0xFFFFFF)}.gz"
|
||||
@@ -324,7 +355,7 @@ class DiskEntry(
|
||||
|
||||
override fun equals(other: Any?) = if (other == null) false else this.hashCode() == other.hashCode()
|
||||
|
||||
override fun toString() = "DiskEntry(name: ${diskIDtoReadableFilename(entryID)}, ID: $entryID, parent: $parentEntryID, type: ${contents.getTypeFlag()}, contents size: ${contents.getSizeEntry()}, crc: ${hashCode().toHex()})"
|
||||
override fun toString() = "DiskEntry(name: ${diskIDtoReadableFilename(entryID, null)}, ID: $entryID, parent: $parentEntryID, type: ${contents.getTypeFlag()}, contents size: ${contents.getSizeEntry()}, crc: ${hashCode().toHex()})"
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user