mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-09 13:21:51 +09:00
ba64 outputting functions
This commit is contained in:
@@ -4,6 +4,7 @@ import com.badlogic.gdx.utils.Json
|
||||
import com.badlogic.gdx.utils.JsonValue
|
||||
import com.badlogic.gdx.utils.JsonWriter
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.ByteArray64
|
||||
import java.math.BigInteger
|
||||
|
||||
/**
|
||||
@@ -30,4 +31,10 @@ object WriteActor {
|
||||
return jsoner.toJson(actor)
|
||||
}
|
||||
|
||||
fun encodeToByteArray64(actor: Actor): ByteArray64 {
|
||||
val ba = ByteArray64()
|
||||
this.invoke(actor).toByteArray().forEach { ba.add(it) }
|
||||
return ba
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,8 +2,10 @@ package net.torvald.terrarum.serialise
|
||||
|
||||
import com.badlogic.gdx.utils.compression.Lzma
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulebasegame.worldgenerator.RoguelikeRandomiser
|
||||
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.ByteArray64
|
||||
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.ByteArray64GrowableOutputStream
|
||||
import net.torvald.terrarum.weather.WeatherMixer
|
||||
import java.io.ByteArrayInputStream
|
||||
@@ -63,6 +65,12 @@ open class WriteMeta(val ingame: TerrarumIngame) {
|
||||
|
||||
return json
|
||||
}
|
||||
|
||||
fun encodeToByteArray64(): ByteArray64 {
|
||||
val ba = ByteArray64()
|
||||
this.invoke().toByteArray().forEach { ba.add(it) }
|
||||
return ba
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.torvald.terrarum.serialise
|
||||
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.ByteArray64
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2021-08-23.
|
||||
@@ -12,5 +13,18 @@ class WriteWorld(val ingame: TerrarumIngame) {
|
||||
return "{${world.getJsonFields().joinToString(",\n")}}"
|
||||
}
|
||||
|
||||
|
||||
fun encodeToByteArray64(): ByteArray64 {
|
||||
val world = ingame.world
|
||||
val ba = ByteArray64()
|
||||
ba.add('{'.code.toByte())
|
||||
world.getJsonFields().forEachIndexed { index, str ->
|
||||
if (index > 0) {
|
||||
ba.add(','.code.toByte())
|
||||
ba.add('\n'.code.toByte())
|
||||
}
|
||||
str.toByteArray().forEach { ba.add(it) }
|
||||
}
|
||||
ba.add('}'.code.toByte())
|
||||
return ba
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user