mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 20:44:05 +09:00
world: ZIP compression is the reference now
This commit is contained in:
@@ -20,7 +20,7 @@ internal object ReadLayerDataLzma {
|
||||
|
||||
// FIXME TERRAIN DAMAGE UNTESTED
|
||||
|
||||
internal operator fun invoke(file: File): LayerData {
|
||||
internal operator fun invoke(file: File): ReadLayerDataZip.LayerData {
|
||||
val inputStream = MarkableFileInputStream(FileInputStream(file))
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ internal object ReadLayerDataLzma {
|
||||
// TODO parse fluid(Types|Fills)
|
||||
|
||||
|
||||
return LayerData(
|
||||
return ReadLayerDataZip.LayerData(
|
||||
MapLayer(width, height, payloadBytes["WALL_MSB"]!!),
|
||||
MapLayer(width, height, payloadBytes["TERR_MSB"]!!),
|
||||
MapLayer(width, height, payloadBytes["WIRE"]!!),
|
||||
@@ -198,26 +198,6 @@ internal object ReadLayerDataLzma {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Immediately deployable, a part of the gameworld
|
||||
*/
|
||||
internal data class LayerData(
|
||||
val layerWall: MapLayer,
|
||||
val layerTerrain: MapLayer,
|
||||
val layerWire: MapLayer,
|
||||
val layerWallLowBits: PairedMapLayer,
|
||||
val layerTerrainLowBits: PairedMapLayer,
|
||||
//val layerThermal: MapLayerHalfFloat, // in Kelvins
|
||||
//val layerAirPressure: MapLayerHalfFloat, // (milibar - 1000)
|
||||
|
||||
val spawnX: Int,
|
||||
val spawnY: Int,
|
||||
val wallDamages: HashMap<BlockAddress, Float>,
|
||||
val terrainDamages: HashMap<BlockAddress, Float>,
|
||||
val fluidTypes: HashMap<BlockAddress, FluidType>,
|
||||
val fluidFills: HashMap<BlockAddress, Float>
|
||||
)
|
||||
|
||||
internal fun InputStream.readRelative(b: ByteArray, off: Int, len: Int): Int {
|
||||
if (b == null) {
|
||||
throw NullPointerException()
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.serialise
|
||||
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.gameworld.BlockAddress
|
||||
import net.torvald.terrarum.gameworld.FluidType
|
||||
import net.torvald.terrarum.gameworld.MapLayer
|
||||
import net.torvald.terrarum.gameworld.PairedMapLayer
|
||||
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.DiskSkimmer.Companion.read
|
||||
@@ -157,6 +158,8 @@ internal object ReadLayerDataZip {
|
||||
|
||||
val terrainDamages = HashMap<BlockAddress, Float>()
|
||||
val wallDamages = HashMap<BlockAddress, Float>()
|
||||
val fluidTypes = HashMap<BlockAddress, FluidType>()
|
||||
val fluidFills = HashMap<BlockAddress, Float>()
|
||||
|
||||
// parse terrain damages
|
||||
for (c in 0 until payloadBytes["TdMG"]!!.size step 10) {
|
||||
@@ -179,6 +182,9 @@ internal object ReadLayerDataZip {
|
||||
wallDamages[tileAddr.toLittleInt48()] = value.toLittleFloat()
|
||||
}
|
||||
|
||||
|
||||
// TODO parse fluid(Types|Fills)
|
||||
|
||||
|
||||
return LayerData(
|
||||
MapLayer(width, height, payloadBytes["WALL_MSB"]!!),
|
||||
@@ -189,7 +195,7 @@ internal object ReadLayerDataZip {
|
||||
|
||||
spawnPoint.first, spawnPoint.second,
|
||||
|
||||
wallDamages, terrainDamages
|
||||
wallDamages, terrainDamages, fluidTypes, fluidFills
|
||||
)
|
||||
}
|
||||
|
||||
@@ -208,7 +214,9 @@ internal object ReadLayerDataZip {
|
||||
val spawnX: Int,
|
||||
val spawnY: Int,
|
||||
val wallDamages: HashMap<BlockAddress, Float>,
|
||||
val terrainDamages: HashMap<BlockAddress, Float>
|
||||
val terrainDamages: HashMap<BlockAddress, Float>,
|
||||
val fluidTypes: HashMap<BlockAddress, FluidType>,
|
||||
val fluidFills: HashMap<BlockAddress, Float>
|
||||
)
|
||||
|
||||
internal fun InputStream.readRelative(b: ByteArray, off: Int, len: Int): Int {
|
||||
|
||||
Reference in New Issue
Block a user