mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-15 04:54:05 +09:00
new save format wip (no branching on this commit)
This commit is contained in:
@@ -23,7 +23,7 @@ class DiskSkimmer(
|
||||
val diskFile: File,
|
||||
val charset: Charset = Charset.defaultCharset(),
|
||||
noInit: Boolean = false
|
||||
) {
|
||||
): SimpleFileSystem {
|
||||
|
||||
/*
|
||||
|
||||
@@ -250,6 +250,8 @@ removefile:
|
||||
}
|
||||
}
|
||||
|
||||
override fun getFile(id: EntryID) = requestFile(id)?.contents as? EntryFile
|
||||
|
||||
/**
|
||||
* Try to find a file with given path (which uses '/' as a separator). Is search is failed for whatever reason,
|
||||
* `null` is returned.
|
||||
|
||||
8
src/net/torvald/terrarum/tvda/SimpleFileSystem.kt
Normal file
8
src/net/torvald/terrarum/tvda/SimpleFileSystem.kt
Normal file
@@ -0,0 +1,8 @@
|
||||
package net.torvald.terrarum.tvda
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2021-10-07.
|
||||
*/
|
||||
interface SimpleFileSystem {
|
||||
fun getFile(id: EntryID): EntryFile?
|
||||
}
|
||||
@@ -124,7 +124,7 @@ class VirtualDisk(
|
||||
/** capacity of 0 makes the disk read-only */
|
||||
var capacity: Long,
|
||||
var diskName: ByteArray = ByteArray(NAME_LENGTH)
|
||||
) {
|
||||
): SimpleFileSystem {
|
||||
var extraInfoBytes = ByteArray(16)
|
||||
val entries = HashMap<EntryID, DiskEntry>()
|
||||
var isReadOnly: Boolean
|
||||
@@ -143,6 +143,8 @@ class VirtualDisk(
|
||||
extraInfoBytes = footer.toByteArray()
|
||||
}
|
||||
|
||||
override fun getFile(id: EntryID) = try { VDUtil.getAsNormalFile(this, id) } catch (e: NullPointerException) { null }
|
||||
|
||||
private fun serializeEntriesOnly(): ByteArray64 {
|
||||
val buffer = ByteArray64()
|
||||
entries.forEach {
|
||||
|
||||
Reference in New Issue
Block a user