diff --git a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Aquagen.kt b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Aquagen.kt index d100f4bc7..7653a8cc2 100644 --- a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Aquagen.kt +++ b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Aquagen.kt @@ -2,7 +2,6 @@ package net.torvald.terrarum.modulebasegame.worldgenerator import com.sudoplay.joise.Joise import com.sudoplay.joise.module.* -import net.torvald.terrarum.BlockCodex import net.torvald.terrarum.INGAME import net.torvald.terrarum.LoadScreenBase import net.torvald.terrarum.blockproperties.Block @@ -19,7 +18,7 @@ import kotlin.math.sin */ class Aquagen(world: GameWorld, isFinal: Boolean, val groundScalingCached: ModuleCache, seed: Long, params: Any) : Gen(world, isFinal, seed, params) { - private val isAlpha2 = ((params as TerragenParams).version >= 0x0000_000004_000004) + private val isAlpha2 = ((params as TerragenParams).versionSince >= 0x0000_000004_000004) private val FLUID_FILL = 1.2f diff --git a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Cavegen.kt b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Cavegen.kt index e49e60166..e447194a2 100644 --- a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Cavegen.kt +++ b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Cavegen.kt @@ -16,7 +16,7 @@ import kotlin.math.sin */ class Cavegen(world: GameWorld, isFinal: Boolean, val highlandLowlandSelectCache: ModuleCache, seed: Long, params: Any) : Gen(world, isFinal, seed, params) { - private val isAlpha2 = ((params as TerragenParams).version >= 0x0000_000004_000004) + private val isAlpha2 = ((params as TerragenParams).versionSince >= 0x0000_000004_000004) override fun getDone(loadscreen: LoadScreenBase?) { loadscreen?.let { diff --git a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Oregen.kt b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Oregen.kt index 7f5843cd7..4e3da8dc5 100644 --- a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Oregen.kt +++ b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Oregen.kt @@ -13,9 +13,9 @@ import kotlin.math.sqrt /** * Created by minjaesong on 2023-10-25. */ -class Oregen(world: GameWorld, isFinal: Boolean, private val caveAttenuateBiasScaledCache: ModuleCache, seed: Long, private val ores: List) : Gen(world, isFinal, seed) { +class Oregen(world: GameWorld, isFinal: Boolean, private val caveAttenuateBiasScaledCache: ModuleCache, seed: Long, private val ores: List, terragenParams: TerragenParams) : Gen(world, isFinal, seed, terragenParams) { - private val isAlpha2 = ((params as TerragenParams).version >= 0x0000_000004_000004) + private val isAlpha2 = (terragenParams.versionSince >= 0x0000_000004_000004) override fun getDone(loadscreen: LoadScreenBase?) { loadscreen?.let { diff --git a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Terragen.kt b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Terragen.kt index bd266e20e..c1fcfd56a 100644 --- a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Terragen.kt +++ b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Terragen.kt @@ -18,7 +18,7 @@ import kotlin.math.sin */ class Terragen(world: GameWorld, isFinal: Boolean, val groundScalingCached: ModuleCache, seed: Long, params: Any) : Gen(world, isFinal, seed, params) { - private val isAlpha2 = ((params as TerragenParams).version >= 0x0000_000004_000004) + private val isAlpha2 = ((params as TerragenParams).versionSince >= 0x0000_000004_000004) override fun getDone(loadscreen: LoadScreenBase?) { loadscreen?.let { @@ -223,7 +223,7 @@ class Terragen(world: GameWorld, isFinal: Boolean, val groundScalingCached: Modu abstract class TerragenParams { val LANDBLOCK_VAR_COUNTS = 16 - abstract val version: Long + abstract val versionSince: Long abstract val strata: List abstract val featureSize: Double abstract val lowlandScaleOffset: Double // linearly alters the height @@ -297,12 +297,15 @@ abstract class TerragenParams { * @param h: STARTING height of the strata relative to the ground select gradient * @param v: linear ± to the `h` */ -data class Hv(val h: Double, val v: Double) +data class Hv(val h: Double, val v: Double) { init { + if (h.isNaN() || h.isInfinite() || h < 0.0) throw IllegalArgumentException("h-value must be zero or positive (got $h)") + if (v.isNaN() || v.isInfinite() || v < 0.0) throw IllegalArgumentException("v-value must be zero or positive (got $v)") +} } class Stratum(val yheight: Hv, vararg val tiles: ItemID) class StratumObj(val yheight: Double, val tiles: ItemID) data class TerragenParamsAlpha1( - override val version: Long = 0L, + override val versionSince: Long = 0L, // 0. randomiser gets two-element buffer // 1. randomiser consults the buffer and removes matching elements from the random pool @@ -340,7 +343,7 @@ data class TerragenParamsAlpha1( ) : TerragenParams() data class TerragenParamsAlpha2( - override val version: Long = 0x0000_000004_000004, + override val versionSince: Long = 0x0000_000004_000004, override val strata: List = listOf( Stratum(Hv(.0, .0), Block.AIR), @@ -396,4 +399,4 @@ data class TerragenParamsAlpha2( override val landBlockScale: Double = 0.5, -) : TerragenParams() \ No newline at end of file + ) : TerragenParams() \ No newline at end of file diff --git a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Worldgen.kt b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Worldgen.kt index 371d53dbf..cae35b139 100644 --- a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Worldgen.kt +++ b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Worldgen.kt @@ -98,7 +98,7 @@ object Worldgen { Work(Lang["MENU_IO_WORLDGEN_RETICULATING_SPLINES"], Terragen(world, false, groundScalingCached, params.seed, params.terragenParams), listOf("TERRAIN")), // also generates marble veins Work(Lang["MENU_IO_WORLDGEN_CARVING_EARTH"], Cavegen(world, false, highlandLowlandSelectCache, params.seed, params.terragenParams), listOf("TERRAIN", "CAVE")), Work(Lang["MENU_IO_WORLDGEN_FLOODING_UNDERGROUND"], Aquagen(world, false, groundScalingCached, params.seed, params.terragenParams), listOf("WATER")), - Work(Lang["MENU_IO_WORLDGEN_GROWING_MINERALS"], Oregen(world, false, caveAttenuateBiasScaledForOresCache, params.seed, oreRegistry), listOf("ORES")), + Work(Lang["MENU_IO_WORLDGEN_GROWING_MINERALS"], Oregen(world, false, caveAttenuateBiasScaledForOresCache, params.seed, oreRegistry, params.terragenParams), listOf("ORES")), Work(Lang["MENU_IO_WORLDGEN_POSITIONING_ROCKS"], OregenAutotiling(world, false, params.seed, oreTilingModes), listOf("ORES")), // TODO generate gemstones Work(Lang["MENU_IO_WORLDGEN_PAINTING_GREEN"], Biomegen(world, false, params.seed, params.biomegenParams, biomeMap), listOf("BIOME")),