mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
tevd update
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -148,7 +148,7 @@ class SavegameCracker(
|
|||||||
fun ls(args: List<String>) {
|
fun ls(args: List<String>) {
|
||||||
letdisk {
|
letdisk {
|
||||||
it.entries.forEach { i, entry ->
|
it.entries.forEach { i, entry ->
|
||||||
if (i != 0)
|
if (i != 0L)
|
||||||
println(
|
println(
|
||||||
ccNoun + i.toString(10).padStart(11, ' ') + " " +
|
ccNoun + i.toString(10).padStart(11, ' ') + " " +
|
||||||
ccNoun2 + (entry.filename.toCanonicalString(charset) + cc0).padEnd(18) { if (it == 0) ' ' else '.' } +
|
ccNoun2 + (entry.filename.toCanonicalString(charset) + cc0).padEnd(18) { if (it == 0) ' ' else '.' } +
|
||||||
@@ -175,7 +175,7 @@ class SavegameCracker(
|
|||||||
@Command("Exports contents of the entry into a real file", "entry-id output-file")
|
@Command("Exports contents of the entry into a real file", "entry-id output-file")
|
||||||
fun export(args: List<String>) {
|
fun export(args: List<String>) {
|
||||||
letdisk {
|
letdisk {
|
||||||
val entryID = args[1].toInt(10)
|
val entryID = args[1].toLong(10)
|
||||||
val outfile = File(args[2])
|
val outfile = File(args[2])
|
||||||
VDUtil.exportFile(it.entries[entryID]?.contents as? EntryFile ?: throw NullPointerException("No entry with ID $entryID"), outfile)
|
VDUtil.exportFile(it.entries[entryID]?.contents as? EntryFile ?: throw NullPointerException("No entry with ID $entryID"), outfile)
|
||||||
}
|
}
|
||||||
@@ -184,8 +184,8 @@ class SavegameCracker(
|
|||||||
@Command("Changes one entry-ID into another", "change-from change-to")
|
@Command("Changes one entry-ID into another", "change-from change-to")
|
||||||
fun renum(args: List<String>) {
|
fun renum(args: List<String>) {
|
||||||
letdisk {
|
letdisk {
|
||||||
val id0 = args[1].toInt(10)
|
val id0 = args[1].toLong(10)
|
||||||
val id1 = args[2].toInt(10)
|
val id1 = args[2].toLong(10)
|
||||||
|
|
||||||
val entry = it.entries.remove(id0)!!
|
val entry = it.entries.remove(id0)!!
|
||||||
entry.entryID = id1
|
entry.entryID = id1
|
||||||
@@ -198,7 +198,7 @@ class SavegameCracker(
|
|||||||
@Command("Renames one file into another", "entry-id new-name")
|
@Command("Renames one file into another", "entry-id new-name")
|
||||||
fun mv(args: List<String>) {
|
fun mv(args: List<String>) {
|
||||||
letdisk {
|
letdisk {
|
||||||
val id = args[1].toInt(10)
|
val id = args[1].toLong(10)
|
||||||
val newname = args[2]
|
val newname = args[2]
|
||||||
it.entries[id]!!.filename = newname.toByteArray(charset)
|
it.entries[id]!!.filename = newname.toByteArray(charset)
|
||||||
return@letdisk null
|
return@letdisk null
|
||||||
@@ -209,7 +209,7 @@ class SavegameCracker(
|
|||||||
fun import(args: List<String>) {
|
fun import(args: List<String>) {
|
||||||
letdisk {
|
letdisk {
|
||||||
val file = File(args[1])
|
val file = File(args[1])
|
||||||
val id = args[2].toInt(10)
|
val id = args[2].toLong(10)
|
||||||
val entry = VDUtil.importFile(file, id, charset)
|
val entry = VDUtil.importFile(file, id, charset)
|
||||||
|
|
||||||
it.entries[id] = entry
|
it.entries[id] = entry
|
||||||
@@ -221,7 +221,7 @@ class SavegameCracker(
|
|||||||
@Command("Removes a file within the savefile", "entry-id")
|
@Command("Removes a file within the savefile", "entry-id")
|
||||||
fun rm(args: List<String>) {
|
fun rm(args: List<String>) {
|
||||||
letdisk {
|
letdisk {
|
||||||
val id = args[1].toInt(10)
|
val id = args[1].toLong(10)
|
||||||
it.entries.remove(id)
|
it.entries.remove(id)
|
||||||
VDUtil.getAsDirectory(it, 0).remove(id)
|
VDUtil.getAsDirectory(it, 0).remove(id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ object WriteSavegame {
|
|||||||
// Write World //
|
// Write World //
|
||||||
val worldNum = ingame.world.worldIndex
|
val worldNum = ingame.world.worldIndex
|
||||||
val worldContent = EntryFile(WriteWorld.encodeToByteArray64(ingame))
|
val worldContent = EntryFile(WriteWorld.encodeToByteArray64(ingame))
|
||||||
val world = DiskEntry(worldNum, 0, "world${worldNum}".toByteArray(Common.CHARSET), creation_t, time_t, worldContent)
|
val world = DiskEntry(worldNum.toLong(), 0, "world${worldNum}".toByteArray(Common.CHARSET), creation_t, time_t, worldContent)
|
||||||
addFile(disk, world)
|
addFile(disk, world)
|
||||||
|
|
||||||
// Write Actors //
|
// Write Actors //
|
||||||
@@ -105,7 +105,7 @@ object WriteSavegame {
|
|||||||
actors.forEach {
|
actors.forEach {
|
||||||
if (actorAcceptable(it)) {
|
if (actorAcceptable(it)) {
|
||||||
val actorContent = EntryFile(WriteActor.encodeToByteArray64(it))
|
val actorContent = EntryFile(WriteActor.encodeToByteArray64(it))
|
||||||
val actor = DiskEntry(it.referenceID, 0, "actor${it.referenceID}".toByteArray(Common.CHARSET), creation_t, time_t, actorContent)
|
val actor = DiskEntry(it.referenceID.toLong(), 0, "actor${it.referenceID}".toByteArray(Common.CHARSET), creation_t, time_t, actorContent)
|
||||||
addFile(disk, actor)
|
addFile(disk, actor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,8 +133,8 @@ object WriteSavegame {
|
|||||||
*/
|
*/
|
||||||
object LoadSavegame {
|
object LoadSavegame {
|
||||||
|
|
||||||
private fun getFileBytes(disk: VirtualDisk, id: Int): ByteArray64 = VDUtil.getAsNormalFile(disk, id).getContent()
|
private fun getFileBytes(disk: VirtualDisk, id: Long): ByteArray64 = VDUtil.getAsNormalFile(disk, id).getContent()
|
||||||
private fun getFileReader(disk: VirtualDisk, id: Int): Reader = ByteArray64Reader(getFileBytes(disk, id), Common.CHARSET)
|
private fun getFileReader(disk: VirtualDisk, id: Long): Reader = ByteArray64Reader(getFileBytes(disk, id), Common.CHARSET)
|
||||||
|
|
||||||
operator fun invoke(disk: VirtualDisk) {
|
operator fun invoke(disk: VirtualDisk) {
|
||||||
val newIngame = TerrarumIngame(App.batch)
|
val newIngame = TerrarumIngame(App.batch)
|
||||||
@@ -142,9 +142,9 @@ object LoadSavegame {
|
|||||||
// NOTE: do NOT set ingame.actorNowPlaying as one read directly from the disk;
|
// NOTE: do NOT set ingame.actorNowPlaying as one read directly from the disk;
|
||||||
// you'll inevitably read the player actor twice, and they're separate instances of the player!
|
// you'll inevitably read the player actor twice, and they're separate instances of the player!
|
||||||
val meta = ReadMeta(disk)
|
val meta = ReadMeta(disk)
|
||||||
val currentWorld = (ReadActor(getFileReader(disk, Terrarum.PLAYER_REF_ID)) as IngamePlayer).worldCurrentlyPlaying
|
val currentWorld = (ReadActor(getFileReader(disk, Terrarum.PLAYER_REF_ID.toLong())) as IngamePlayer).worldCurrentlyPlaying
|
||||||
val world = ReadWorld(getFileReader(disk, currentWorld))
|
val world = ReadWorld(getFileReader(disk, currentWorld.toLong()))
|
||||||
val actors = world.actors.distinct().map { ReadActor(getFileReader(disk, it)) }
|
val actors = world.actors.distinct().map { ReadActor(getFileReader(disk, it.toLong())) }
|
||||||
// val block = Common.jsoner.fromJson(BlockCodex.javaClass, getUnzipInputStream(getFileBytes(disk, -16)))
|
// val block = Common.jsoner.fromJson(BlockCodex.javaClass, getUnzipInputStream(getFileBytes(disk, -16)))
|
||||||
val item = Common.jsoner.fromJson(ItemCodex.javaClass, getUnzipInputStream(getFileBytes(disk, -17)))
|
val item = Common.jsoner.fromJson(ItemCodex.javaClass, getUnzipInputStream(getFileBytes(disk, -17)))
|
||||||
// val wire = Common.jsoner.fromJson(WireCodex.javaClass, getUnzipInputStream(getFileBytes(disk, -18)))
|
// val wire = Common.jsoner.fromJson(WireCodex.javaClass, getUnzipInputStream(getFileBytes(disk, -18)))
|
||||||
|
|||||||
Reference in New Issue
Block a user