mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
world: ZIP compression is the reference now
This commit is contained in:
@@ -4,7 +4,7 @@ import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.console.ConsoleCommand
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
import net.torvald.terrarum.serialise.ReadLayerDataLzma
|
||||
import net.torvald.terrarum.serialise.ReadLayerDataZip
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import java.io.File
|
||||
|
||||
@@ -19,7 +19,7 @@ object ImportLayerData : ConsoleCommand {
|
||||
}
|
||||
|
||||
val file = File(args[1])
|
||||
val layerData = ReadLayerDataLzma(file)
|
||||
val layerData = ReadLayerDataZip(file)
|
||||
|
||||
|
||||
Terrarum.ingame!!.world = GameWorldExtension(1, layerData, 0, 0, 0) // FIXME null TIME_T for the (partial) test to pass
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameworld
|
||||
|
||||
import net.torvald.terrarum.gameworld.*
|
||||
import net.torvald.terrarum.serialise.ReadLayerDataLzma
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.serialise.ReadLayerDataZip
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2018-07-03.
|
||||
@@ -9,7 +9,7 @@ import net.torvald.terrarum.serialise.ReadLayerDataLzma
|
||||
class GameWorldExtension: GameWorld {
|
||||
|
||||
constructor(worldIndex: Int, width: Int, height: Int, creationTIME_T: Long, lastPlayTIME_T: Long, totalPlayTime: Int) : super(worldIndex, width, height, creationTIME_T, lastPlayTIME_T, totalPlayTime)
|
||||
internal constructor(worldIndex: Int, layerData: ReadLayerDataLzma.LayerData, creationTIME_T: Long, lastPlayTIME_T: Long, totalPlayTime: Int) : super(worldIndex, layerData, creationTIME_T, lastPlayTIME_T, totalPlayTime)
|
||||
internal constructor(worldIndex: Int, layerData: ReadLayerDataZip.LayerData, creationTIME_T: Long, lastPlayTIME_T: Long, totalPlayTime: Int) : super(worldIndex, layerData, creationTIME_T, lastPlayTIME_T, totalPlayTime)
|
||||
|
||||
|
||||
val time: WorldTime
|
||||
|
||||
@@ -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