completely abolishing GSON; new save format impl wip

This commit is contained in:
minjaesong
2021-08-23 16:55:51 +09:00
parent df1ebdf93d
commit e15d5c9b05
58 changed files with 421 additions and 2101 deletions

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.tests
import com.badlogic.gdx.utils.JsonValue
import net.torvald.terrarum.utils.JsonFetcher
import net.torvald.terrarum.utils.JsonWriter
import java.io.File
@@ -63,7 +64,7 @@ fun main() {
val key = record[0]
val value = record[index + 2]
if (value.isNotBlank()) {
jsonObject.addProperty(key, value)
jsonObject.addChild(key, JsonValue(value))
}
}

View File

@@ -1,7 +1,6 @@
package net.torvald.terrarum.tests
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.ByteArray64GrowableOutputStream
import net.torvald.terrarum.serialise.WriteLayerDataZip
import net.torvald.terrarum.serialise.toLittle
import net.torvald.terrarum.serialise.toULittle48
import java.util.zip.Deflater
@@ -33,7 +32,7 @@ Ooh, black and yellow! Let's shake it up a little.""".trimIndent().toByteArray()
wb(WriteLayerDataZip.MAGIC); wb(WriteLayerDataZip.VERSION_NUMBER); wb(WriteLayerDataZip.NUMBER_OF_LAYERS); wb(WriteLayerDataZip.NUMBER_OF_PAYLOADS); wb(WriteLayerDataZip.COMPRESSION_ALGORITHM); wb(WriteLayerDataZip.GENERATOR_VERSION)
//wb(WriteLayerDataZip.MAGIC); wb(WriteLayerDataZip.VERSION_NUMBER); wb(WriteLayerDataZip.NUMBER_OF_LAYERS); wb(WriteLayerDataZip.NUMBER_OF_PAYLOADS); wb(WriteLayerDataZip.COMPRESSION_ALGORITHM); wb(WriteLayerDataZip.GENERATOR_VERSION)
val deflater = DeflaterOutputStream(outputStream, Deflater(Deflater.BEST_COMPRESSION), true)
repeat(20001) {
deflater.write(Math.random().times(256).toInt().and(255))

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.tests
import com.badlogic.gdx.utils.Json
import net.torvald.terrarum.utils.JsonWriter
import org.dyn4j.geometry.Vector2
@@ -22,13 +23,12 @@ object GsonTest {
operator fun invoke() {
val gson = JsonWriter.getJsonBuilder()
val jsonString = gson.toJson(testClass)
val jsonString = Json(com.badlogic.gdx.utils.JsonWriter.OutputType.json).toJson(testClass)
println(jsonString)
val deserialised = Json().fromJson(GsonTestSuper::class.java, jsonString)
val deserialised = gson.fromJson(jsonString, GsonTestSuper::class.java)
println(deserialised)
println(deserialised as GsonTestClass) // ClassCastException
}