mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 11:04:05 +09:00
save/load ore layer
This commit is contained in:
@@ -201,6 +201,7 @@ open class GameWorld(
|
|||||||
|
|
||||||
layerTerrain = BlockLayerI16(width, height)
|
layerTerrain = BlockLayerI16(width, height)
|
||||||
layerWall = BlockLayerI16(width, height)
|
layerWall = BlockLayerI16(width, height)
|
||||||
|
layerOres = BlockLayerI16I8(width, height)
|
||||||
|
|
||||||
// temperature layer: 2x2 is one cell
|
// temperature layer: 2x2 is one cell
|
||||||
//layerThermal = MapLayerHalfFloat(width, height, averageTemperature)
|
//layerThermal = MapLayerHalfFloat(width, height, averageTemperature)
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ class QuickSingleplayerWorldSavingThread(
|
|||||||
ingame.world.getLayer(layerNum)?.let { layer ->
|
ingame.world.getLayer(layerNum)?.let { layer ->
|
||||||
chunks.forEach { chunkNumber ->
|
chunks.forEach { chunkNumber ->
|
||||||
|
|
||||||
printdbg(this, "Writing chunks... $chunksWrote/$chunkCount")
|
printdbg(this, "Writing chunks... $chunksWrote/$chunkCount (chunk# $chunkNumber at layer# $layerNum)")
|
||||||
|
|
||||||
val chunkXY = LandUtil.chunkNumToChunkXY(ingame.world, chunkNumber)
|
val chunkXY = LandUtil.chunkNumToChunkXY(ingame.world, chunkNumber)
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class WorldSavingThread(
|
|||||||
|
|
||||||
val playersList: List<IngamePlayer> = allTheActors.filterIsInstance<IngamePlayer>()
|
val playersList: List<IngamePlayer> = allTheActors.filterIsInstance<IngamePlayer>()
|
||||||
val actorsList = allTheActors.filter { WriteWorld.actorAcceptable(it) }
|
val actorsList = allTheActors.filter { WriteWorld.actorAcceptable(it) }
|
||||||
val layers = intArrayOf(0,1).map { ingame.world.getLayer(it) }
|
val layers = intArrayOf(0,1,2).map { ingame.world.getLayer(it) }
|
||||||
val cw = ingame.world.width / LandUtil.CHUNK_W
|
val cw = ingame.world.width / LandUtil.CHUNK_W
|
||||||
val ch = ingame.world.height / LandUtil.CHUNK_H
|
val ch = ingame.world.height / LandUtil.CHUNK_H
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import net.torvald.terrarum.*
|
|||||||
import net.torvald.terrarum.App.printdbg
|
import net.torvald.terrarum.App.printdbg
|
||||||
import net.torvald.terrarum.console.Echo
|
import net.torvald.terrarum.console.Echo
|
||||||
import net.torvald.terrarum.gameworld.BlockLayerI16
|
import net.torvald.terrarum.gameworld.BlockLayerI16
|
||||||
|
import net.torvald.terrarum.gameworld.BlockLayerI16I8
|
||||||
import net.torvald.terrarum.gameworld.GameWorld
|
import net.torvald.terrarum.gameworld.GameWorld
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.modulebasegame.ChunkLoadingLoadScreen
|
import net.torvald.terrarum.modulebasegame.ChunkLoadingLoadScreen
|
||||||
@@ -145,6 +146,7 @@ object LoadSavegame {
|
|||||||
|
|
||||||
world.layerTerrain = BlockLayerI16(world.width, world.height)
|
world.layerTerrain = BlockLayerI16(world.width, world.height)
|
||||||
world.layerWall = BlockLayerI16(world.width, world.height)
|
world.layerWall = BlockLayerI16(world.width, world.height)
|
||||||
|
world.layerOres = BlockLayerI16I8(world.width, world.height)
|
||||||
|
|
||||||
newIngame.world = world // must be set before the loadscreen, otherwise the loadscreen will try to read from the NullWorld which is already destroyed
|
newIngame.world = world // must be set before the loadscreen, otherwise the loadscreen will try to read from the NullWorld which is already destroyed
|
||||||
newIngame.worldDisk = VDUtil.readDiskArchive(worldDisk.diskFile, Level.INFO)
|
newIngame.worldDisk = VDUtil.readDiskArchive(worldDisk.diskFile, Level.INFO)
|
||||||
@@ -184,10 +186,12 @@ object LoadSavegame {
|
|||||||
val cw = LandUtil.CHUNK_W
|
val cw = LandUtil.CHUNK_W
|
||||||
val ch = LandUtil.CHUNK_H
|
val ch = LandUtil.CHUNK_H
|
||||||
val chunkCount = world.width * world.height / (cw * ch)
|
val chunkCount = world.width * world.height / (cw * ch)
|
||||||
val worldLayer = arrayOf(world.getLayer(0), world.getLayer(1))
|
val hasOreLayer = (newIngame.worldDisk.getFile(0x1_0000_0000L or 2L.shl(24)) != null)
|
||||||
|
val worldLayer = (if (hasOreLayer) intArrayOf(0,1,2) else intArrayOf(0,1)).map { world.getLayer(it) }
|
||||||
|
val layerCount = worldLayer.size
|
||||||
for (chunk in 0L until (world.width * world.height) / (cw * ch)) {
|
for (chunk in 0L until (world.width * world.height) / (cw * ch)) {
|
||||||
for (layer in worldLayer.indices) {
|
for (layer in worldLayer.indices) {
|
||||||
loadscreen.addMessage("${Lang["MENU_IO_LOADING"]} ${chunk*worldLayer.size+layer+1}/${chunkCount*2}")
|
loadscreen.addMessage("${Lang["MENU_IO_LOADING"]} ${chunk*layerCount+layer+1}/${chunkCount*layerCount}")
|
||||||
|
|
||||||
val chunkFile = newIngame.worldDisk.getFile(0x1_0000_0000L or layer.toLong().shl(24) or chunk)!!
|
val chunkFile = newIngame.worldDisk.getFile(0x1_0000_0000L or layer.toLong().shl(24) or chunk)!!
|
||||||
val chunkXY = LandUtil.chunkNumToChunkXY(world, chunk.toInt())
|
val chunkXY = LandUtil.chunkNumToChunkXY(world, chunk.toInt())
|
||||||
|
|||||||
Reference in New Issue
Block a user