From 24e43edafbbe3a5a273b8eaa4506fd7283a8862b Mon Sep 17 00:00:00 2001 From: minjaesong Date: Thu, 11 Jul 2024 16:17:38 +0900 Subject: [PATCH] not-generated marker works as intended, reducing number of chunks for initial worldgen --- .../modulebasegame/worldgenerator/Worldgen.kt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Worldgen.kt b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Worldgen.kt index 0286e05d2..cdc7b6ebf 100644 --- a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Worldgen.kt +++ b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Worldgen.kt @@ -146,7 +146,7 @@ object Worldgen { val start = (0.00342f * world.height - 3.22f).floorToInt().coerceAtLeast(1) // this value has to extend up, otherwise the player may spawn into the chopped-off mountaintop // this value has to extend down into the rock layer, otherwise, if the bottom of the bottom chunk is dirt, they will turn into grasses - return start - 1 to start + 7 + return start to start + 5 } private val rockScoreMin = 40 @@ -157,31 +157,38 @@ object Worldgen { val tallies = ArrayList>() // xypos, score (0..1+) var tries = 0 var found = false + val ySearchRadius = 30 while (tries < 99) { val posX = (Math.random() * world.width).toInt() var posY = yInit * CHUNK_H // go up? if (BlockCodex[world.getTileFromTerrain(posX, posY)].isSolid) { // go up! - while (BlockCodex[world.getTileFromTerrain(posX, posY)].isSolid) { + while (posY > ySearchRadius && BlockCodex[world.getTileFromTerrain(posX, posY)].isSolid) { posY -= 1 } } else { // go down! - while (!BlockCodex[world.getTileFromTerrain(posX, posY)].isSolid) { + while (posY < world.height - ySearchRadius && !BlockCodex[world.getTileFromTerrain(posX, posY)].isSolid) { posY += 1 } } printdbg(this, "Trying spawn point #${tries + 1} at ($posX, $posY)") + if (posY !in ySearchRadius+1 until world.height - ySearchRadius) { + printdbg(this, "...Survey says: X=$posX has no floor") + tries += 1 + continue + } + var rocks = 0 var trees = 0 var flatness = 0 // make survey for (sx in -80..80) { - for (sy in -30..30) { + for (sy in -ySearchRadius..ySearchRadius) { val x = posX + sx val y = posY + sy val tile = BlockCodex[world.getTileFromTerrain(x, y)]