btex serialisation

This commit is contained in:
minjaesong
2024-04-29 01:11:48 +09:00
parent fa8054adac
commit cd51276c16
12 changed files with 871 additions and 8 deletions

View File

@@ -19,7 +19,6 @@ import net.torvald.terrarum.savegame.ByteArray64InputStream
import net.torvald.terrarum.savegame.ByteArray64Reader
import net.torvald.terrarum.utils.*
import net.torvald.terrarum.weather.*
import net.torvald.terrarum.weather.WeatherMixer
import org.apache.commons.codec.digest.DigestUtils
import java.io.File
import java.io.InputStream
@@ -470,7 +469,7 @@ object Common {
fun bytesToZipdStr(byteIterator: Iterator<Byte>): String = enasciiToString(zip(byteIterator))
fun zip(ba: ByteArray64) = Common.zip(ba.iterator())
fun zip(ba: ByteArray64, format: String = App.getConfigString("savegamecomp")) = Common.zip(ba.iterator(), format)
@Deprecated("New savegame standard should use Zstd")
private fun zipG(byteIterator: Iterator<Byte>): ByteArray64 {
@@ -518,8 +517,8 @@ object Common {
return bo.toByteArray64()
}*/
fun zip(byteIterator: Iterator<Byte>): ByteArray64 {
return when (App.getConfigString("savegamecomp")) {
fun zip(byteIterator: Iterator<Byte>, format: String = App.getConfigString("savegamecomp")): ByteArray64 {
return when (format) {
"snappy" -> zipS(byteIterator)
// "null" -> zipNull(byteIterator)
else -> zipZ(byteIterator)

View File

@@ -16,6 +16,7 @@ import net.torvald.terrarum.btex.BTeXDocument
import net.torvald.terrarum.ceilToInt
import net.torvald.terrarum.gdxClearAndEnableBlend
import net.torvald.terrarum.inUse
import java.io.File
import kotlin.system.measureTimeMillis
@@ -24,8 +25,8 @@ import kotlin.system.measureTimeMillis
*/
class BTeXTest : ApplicationAdapter() {
// val filePath = "btex.xml"
val filePath = "literature/en/daniel_defoe_robinson_crusoe.xml"
val filePath = "btex.xml"
// val filePath = "literature/en/daniel_defoe_robinson_crusoe.xml"
// val filePath = "literature/ruRU/anton_chekhov_palata_no_6.xml"
// val filePath = "literature/koKR/yisang_nalgae.xml"
@@ -60,6 +61,12 @@ class BTeXTest : ApplicationAdapter() {
}.also {
println("Time spent on finalising [ms]: $it")
}
measureTimeMillis {
document.serialise(File("./assets/mods/basegame/books/${filePath.replace(".xml", ".book")}"))
}.also {
println("Time spent on serialisation [ms]: $it")
}
}
private var scroll = 0