diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index 9d4c1b551..2f533bce3 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -32,6 +32,7 @@ import org.lwjgl.input.Controllers import java.io.File import java.io.IOException import net.torvald.getcpuname.GetCpuName +import net.torvald.terrarum.modulebasegame.Ingame @@ -420,16 +421,17 @@ object Terrarum : Screen { // jump right into the ingame - /*ingame = Ingame(batch) - ingame!!.gameLoadInfoPayload = Ingame.NewWorldParameters(2400, 800, HQRNG().nextLong()) - ingame!!.gameLoadMode = Ingame.GameLoadMode.CREATE_NEW - LoadScreen.screenToLoad = ingame!! - super.setScreen(LoadScreen)*/ + val ingame = Ingame(batch) + ingame.gameLoadInfoPayload = Ingame.NewWorldParameters(2400, 800, HQRNG().nextLong()) + ingame.gameLoadMode = Ingame.GameLoadMode.CREATE_NEW + LoadScreen.screenToLoad = ingame + this.ingame = ingame + setScreen(LoadScreen) // title screen - AppLoader.getINSTANCE().setScreen(TitleScreen(batch)) + //AppLoader.getINSTANCE().setScreen(TitleScreen(batch)) } fun setScreen(screen: Screen) { diff --git a/src/net/torvald/terrarum/gameworld/GameWorld.kt b/src/net/torvald/terrarum/gameworld/GameWorld.kt index 0678b2a49..99486f9a3 100644 --- a/src/net/torvald/terrarum/gameworld/GameWorld.kt +++ b/src/net/torvald/terrarum/gameworld/GameWorld.kt @@ -35,7 +35,7 @@ open class GameWorld { val layerTerrainLowBits: PairedMapLayer //val layerThermal: MapLayerHalfFloat // in Kelvins - //val layerAirPressure: MapLayerHalfFloat // (milibar - 1000) + //val layerFluidPressure: MapLayerHalfFloat // (milibar - 1000) /** Tilewise spawn point */ var spawnX: Int @@ -59,6 +59,8 @@ open class GameWorld { constructor(worldIndex: Int, width: Int, height: Int, creationTIME_T: Long, lastPlayTIME_T: Long, totalPlayTime: Int) { + if (width <= 0 || height <= 0) throw IllegalArgumentException("Non-positive width/height: ($width, $height)") + this.worldIndex = worldIndex this.width = width this.height = height @@ -76,10 +78,10 @@ open class GameWorld { terrainDamages = HashMap() // temperature layer: 2x2 is one cell - //layerThermal = MapLayerHalfFloat(width / 2, height / 2, averageTemperature) + //layerThermal = MapLayerHalfFloat(width, height, averageTemperature) - // air pressure layer: 4 * 8 is one cell - //layerAirPressure = MapLayerHalfFloat(width / 4, height / 8, 13f) // 1013 mBar + // fluid pressure layer: 4 * 8 is one cell + //layerFluidPressure = MapLayerHalfFloat(width, height, 13f) // 1013 mBar creationTime = creationTIME_T @@ -337,13 +339,12 @@ open class GameWorld { fun getAirPressure(worldTileX: Int, worldTileY: Int): Float? { return null - //return layerAirPressure.getValue((worldTileX fmod width) / 4, worldTileY / 8) + //return layerFluidPressure.getValue((worldTileX fmod width) / 4, worldTileY / 8) } companion object { - @Transient val WALL = 0 @Transient val TERRAIN = 1 @Transient val WIRE = 2 @@ -351,6 +352,8 @@ open class GameWorld { @Transient val TILES_SUPPORTED = MapLayer.RANGE * PairedMapLayer.RANGE @Transient val SIZEOF: Byte = MapLayer.SIZEOF @Transient val LAYERS: Byte = 4 // terrain, wall (layerTerrainLowBits + layerWallLowBits), wire + + fun makeNullWorld() = GameWorld(-1, 1, 1, 0, 0, 0) } } diff --git a/src/net/torvald/terrarum/gameworld/MapLayerHalfFloat.kt b/src/net/torvald/terrarum/gameworld/MapLayerHalfFloat.kt index c7955f0c5..a1e6aae3b 100644 --- a/src/net/torvald/terrarum/gameworld/MapLayerHalfFloat.kt +++ b/src/net/torvald/terrarum/gameworld/MapLayerHalfFloat.kt @@ -11,13 +11,13 @@ import net.torvald.dataclass.Float16Bits open class MapLayerHalfFloat(val width: Int, val height: Int) : Iterable { constructor(width: Int, height: Int, init: Float) : this(width, height) { - data = Array(height) { Array(width, { Float16.fromFloat(init) }) } + data = Array(height) { Array(width) { Float16.fromFloat(init) } } } internal @Volatile var data: Array> // in parallel programming: do not trust your register; always read freshly from RAM! init { - data = Array(height) { Array(width, { 0.toShort() }) } + data = Array(height) { Array(width) { 0.toShort() } } } /** diff --git a/src/net/torvald/terrarum/modulebasegame/Ingame.kt b/src/net/torvald/terrarum/modulebasegame/Ingame.kt index 31b716ab0..b926c2ee6 100644 --- a/src/net/torvald/terrarum/modulebasegame/Ingame.kt +++ b/src/net/torvald/terrarum/modulebasegame/Ingame.kt @@ -47,7 +47,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) { private val ACTOR_UPDATE_RANGE = 4096 - lateinit var historicalFigureIDBucket: ArrayList + var historicalFigureIDBucket: ArrayList = ArrayList() /** diff --git a/src/net/torvald/terrarum/worlddrawer/BlocksDrawerNew.kt b/src/net/torvald/terrarum/worlddrawer/BlocksDrawerNew.kt index 0751f0bb2..9fe4ce8de 100644 --- a/src/net/torvald/terrarum/worlddrawer/BlocksDrawerNew.kt +++ b/src/net/torvald/terrarum/worlddrawer/BlocksDrawerNew.kt @@ -2,7 +2,6 @@ package net.torvald.terrarum.worlddrawer import com.badlogic.gdx.Gdx import com.badlogic.gdx.graphics.* -import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.glutils.ShaderProgram import com.badlogic.gdx.math.Matrix4 import net.torvald.terrarum.gameworld.GameWorld @@ -31,8 +30,8 @@ import java.util.zip.GZIPInputStream * Created by minjaesong on 2016-01-19. */ internal object BlocksDrawer { - lateinit var world: GameWorld + var world: GameWorld = GameWorld.makeNullWorld() private val TILE_SIZE = FeaturesDrawer.TILE_SIZE private val TILE_SIZEF = FeaturesDrawer.TILE_SIZE.toFloat() diff --git a/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt b/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt index 7e63a3f69..cc9ee9baa 100644 --- a/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt +++ b/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt @@ -10,7 +10,6 @@ import net.torvald.terrarum.blockproperties.BlockCodex import com.jme3.math.FastMath import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.Terrarum -import net.torvald.terrarum.blendNormal import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.blockproperties.Block import net.torvald.terrarum.gameactors.* @@ -40,7 +39,7 @@ object LightmapRenderer { // FIXME lightmap shifts to left, ONLY AT x=33.5-34.5 - private lateinit var world: GameWorld + private var world: GameWorld = GameWorld.makeNullWorld() /** do not call this yourself! Let your game renderer handle this! */ fun setWorld(world: GameWorld) { @@ -486,7 +485,7 @@ object LightmapRenderer { const val DRAW_FOR_RGB = 0xFFF0 const val DRAW_FOR_ALPHA = 0x000F - lateinit var lightBuffer: Pixmap + var lightBuffer: Pixmap = Pixmap(1, 1, Pixmap.Format.RGBA8888) private val colourNull = Color(0)