diff --git a/lib/TerrarumSansBitmap.jar b/lib/TerrarumSansBitmap.jar index 593e459c8..76a649bce 100644 Binary files a/lib/TerrarumSansBitmap.jar and b/lib/TerrarumSansBitmap.jar differ diff --git a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Terragen.kt b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Terragen.kt index 7c70b30f8..f0f045dcf 100644 --- a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Terragen.kt +++ b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Terragen.kt @@ -18,13 +18,16 @@ import kotlin.math.sin */ class Terragen(world: GameWorld, seed: Long, params: Any) : Gen(world, seed, params) { - private val genSlices = world.width / 8 + private val genSlices = maxOf(world.width, ThreadExecutor.threadCount, world.width / 8) private var genFutures: Array?> = arrayOfNulls(genSlices) override var generationStarted: Boolean = false override val generationDone: Boolean get() = generationStarted && genFutures.fold(true) { acc, f -> acc and (f?.isDone ?: true) } + private val YHEIGHT_MAGIC = 2800.0 / 3.0 + private val YHEIGHT_DIVISOR = 2.0 / 7.0 + override fun run() { generationStarted = true @@ -38,7 +41,8 @@ class Terragen(world: GameWorld, seed: Long, params: Any) : Gen(world, seed, par val sampleOffset = world.width / 8.0 val sampleX = sin(sampleTheta) * sampleOffset + sampleOffset // plus sampleOffset to make only val sampleZ = cos(sampleTheta) * sampleOffset + sampleOffset // positive points are to be sampled - val sampleY = y.toDouble() + val sampleY = y - (world.height - YHEIGHT_MAGIC) * YHEIGHT_DIVISOR // Q&D offsetting to make ratio of sky:ground to be constant + // DEBUG NOTE: it is the OFFSET FROM THE IDEAL VALUE (observed land height - (HEIGHT * DIVISOR)) that must be constant val noise = localJoise.map { it.get(sampleX, sampleY, sampleZ) } draw(x, y, noise, world) @@ -50,7 +54,6 @@ class Terragen(world: GameWorld, seed: Long, params: Any) : Gen(world, seed, par ThreadExecutor.join() printdbg(this, "Waking up Worldgen") - //Worldgen.wake() } diff --git a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Worldgen.kt b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Worldgen.kt index e7710deb1..a1c0bc976 100644 --- a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Worldgen.kt +++ b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Worldgen.kt @@ -28,31 +28,19 @@ object Worldgen { ) - for (i in 0 until jobs.size) { + for (i in jobs.indices) { printdbg(this, "Worldgen: job #$i") val it = jobs[i] AppLoader.getLoadScreen().addMessage(it.loadingScreenName) it.theWork.run() - - // wait - //while (!it.theWork.generationDone) { } // busy wait - //synchronized(threadLock) { - // threadLock.wait() - //} } printdbg(this, "Generation job finished") } - fun wake() { - synchronized(threadLock) { - threadLock.notifyAll() - } - } - private data class Work(val loadingScreenName: String, val theWork: Gen) } @@ -60,12 +48,7 @@ object Worldgen { abstract class Gen(val world: GameWorld, val seed: Long, val params: Any) { abstract var generationStarted: Boolean abstract val generationDone: Boolean - open fun run() { - /*if (generationDone) { - // worldgen.wake() - Worldgen.threadLock.notifyAll() - }*/ - } + open fun run() { } } data class WorldgenParams(