mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 12:04:06 +09:00
yep, it works when unzipped, except for the wires dammit
This commit is contained in:
@@ -4,6 +4,7 @@ import com.badlogic.gdx.utils.Json
|
|||||||
import com.badlogic.gdx.utils.JsonReader
|
import com.badlogic.gdx.utils.JsonReader
|
||||||
import com.badlogic.gdx.utils.JsonValue
|
import com.badlogic.gdx.utils.JsonValue
|
||||||
import com.badlogic.gdx.utils.JsonWriter
|
import com.badlogic.gdx.utils.JsonWriter
|
||||||
|
import net.torvald.terrarum.AppLoader.printdbg
|
||||||
import net.torvald.terrarum.console.EchoError
|
import net.torvald.terrarum.console.EchoError
|
||||||
import net.torvald.terrarum.gameworld.BlockLayer
|
import net.torvald.terrarum.gameworld.BlockLayer
|
||||||
import net.torvald.terrarum.gameworld.WorldTime
|
import net.torvald.terrarum.gameworld.WorldTime
|
||||||
@@ -11,6 +12,7 @@ import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
|||||||
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.ByteArray64
|
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.ByteArray64
|
||||||
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.ByteArray64GrowableOutputStream
|
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.ByteArray64GrowableOutputStream
|
||||||
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.ByteArray64InputStream
|
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.ByteArray64InputStream
|
||||||
|
import net.torvald.terrarum.serialise.WriteWorld.Companion.tostr
|
||||||
import org.apache.commons.codec.digest.DigestUtils
|
import org.apache.commons.codec.digest.DigestUtils
|
||||||
import java.math.BigInteger
|
import java.math.BigInteger
|
||||||
import java.util.zip.GZIPInputStream
|
import java.util.zip.GZIPInputStream
|
||||||
@@ -73,6 +75,10 @@ open class WriteWorld(val ingame: TerrarumIngame) {
|
|||||||
val hash = StringBuilder().let { sb -> digester.digest().forEach { sb.append(it.tostr()) }; sb.toString() }
|
val hash = StringBuilder().let { sb -> digester.digest().forEach { sb.append(it.tostr()) }; sb.toString() }
|
||||||
|
|
||||||
val layer = LayerInfo(hash, blockLayerToStr(obj), obj.width, obj.height)
|
val layer = LayerInfo(hash, blockLayerToStr(obj), obj.width, obj.height)
|
||||||
|
|
||||||
|
printdbg(this, "pre: ${(0L..1023L).map { obj.ptr[it].tostr() }.joinToString(" ")}")
|
||||||
|
|
||||||
|
|
||||||
json.writeValue(layer)
|
json.writeValue(layer)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,15 +129,13 @@ open class WriteWorld(val ingame: TerrarumIngame) {
|
|||||||
zo.write(it.toInt())
|
zo.write(it.toInt())
|
||||||
}
|
}
|
||||||
zo.flush(); zo.close()*/
|
zo.flush(); zo.close()*/
|
||||||
b.bytesIterator().forEachRemaining {
|
|
||||||
bo.write(it.toInt())
|
|
||||||
}
|
|
||||||
|
|
||||||
// enascii
|
// enascii
|
||||||
val ba = bo.toByteArray64()
|
val ba = bo.toByteArray64()
|
||||||
var bai = 0
|
var bai = 0
|
||||||
val buf = IntArray(4) { Ascii85.PAD_BYTE }
|
val buf = IntArray(4) { Ascii85.PAD_BYTE }
|
||||||
ba.forEach {
|
// ba.forEach {
|
||||||
|
b.bytesIterator().forEachRemaining {
|
||||||
if (bai > 0 && bai % 4 == 0) {
|
if (bai > 0 && bai % 4 == 0) {
|
||||||
sb.append(Ascii85.encode(buf[0], buf[1], buf[2], buf[3]))
|
sb.append(Ascii85.encode(buf[0], buf[1], buf[2], buf[3]))
|
||||||
buf.fill(Ascii85.PAD_BYTE)
|
buf.fill(Ascii85.PAD_BYTE)
|
||||||
@@ -176,15 +180,26 @@ open class WriteWorld(val ingame: TerrarumIngame) {
|
|||||||
// write to blocklayer and the digester
|
// write to blocklayer and the digester
|
||||||
digester.reset()
|
digester.reset()
|
||||||
var writeCursor = 0L
|
var writeCursor = 0L
|
||||||
|
val sb = StringBuilder()
|
||||||
// unzipdBytes.forEach {
|
// unzipdBytes.forEach {
|
||||||
unasciidBytes.forEach {
|
unasciidBytes.forEach {
|
||||||
if (writeCursor < layer.ptr.size) {
|
if (writeCursor < layer.ptr.size) {
|
||||||
|
|
||||||
|
if (writeCursor < 1024) {
|
||||||
|
sb.append("${it.tostr()} ")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
layer.ptr[writeCursor] = it
|
layer.ptr[writeCursor] = it
|
||||||
digester.update(it)
|
digester.update(it)
|
||||||
writeCursor += 1
|
writeCursor += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
printdbg(this, "post: $sb")
|
||||||
|
|
||||||
|
|
||||||
// check hash
|
// check hash
|
||||||
val hash = StringBuilder().let { sb -> digester.digest().forEach { sb.append(it.tostr()) }; sb.toString() }
|
val hash = StringBuilder().let { sb -> digester.digest().forEach { sb.append(it.tostr()) }; sb.toString() }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user