mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 02:54:04 +09:00
fixing random terragen crash? (was it block change event too big?)
This commit is contained in:
@@ -84,19 +84,19 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
println("[BuildingMaker] Generating builder world...")
|
||||
|
||||
for (y in 0 until gameWorld.height) {
|
||||
gameWorld.setTileWall(0, y, Block.ILLUMINATOR_RED)
|
||||
gameWorld.setTileWall(gameWorld.width - 1, y, Block.ILLUMINATOR_RED)
|
||||
gameWorld.setTileTerrain(0, y, Block.ILLUMINATOR_RED_OFF)
|
||||
gameWorld.setTileTerrain(gameWorld.width - 1, y, Block.ILLUMINATOR_RED_OFF)
|
||||
gameWorld.setTileWall(0, y, Block.ILLUMINATOR_RED, true)
|
||||
gameWorld.setTileWall(gameWorld.width - 1, y, Block.ILLUMINATOR_RED, true)
|
||||
gameWorld.setTileTerrain(0, y, Block.ILLUMINATOR_RED_OFF, true)
|
||||
gameWorld.setTileTerrain(gameWorld.width - 1, y, Block.ILLUMINATOR_RED_OFF, true)
|
||||
}
|
||||
|
||||
for (y in 150 until gameWorld.height) {
|
||||
for (x in 1 until gameWorld.width - 1) {
|
||||
// wall layer
|
||||
gameWorld.setTileWall(x, y, Block.DIRT)
|
||||
gameWorld.setTileWall(x, y, Block.DIRT, true)
|
||||
|
||||
// terrain layer
|
||||
gameWorld.setTileTerrain(x, y, if (y == 150) Block.GRASS else Block.DIRT)
|
||||
gameWorld.setTileTerrain(x, y, if (y == 150) Block.GRASS else Block.DIRT, true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,15 +425,15 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
// test paint terrain layer
|
||||
PENMODE_PENCIL -> {
|
||||
if (palSelection.startsWith("wall@"))
|
||||
world.setTileWall(x, y, palSelection.substring(5))
|
||||
world.setTileWall(x, y, palSelection.substring(5), true)
|
||||
else
|
||||
world.setTileTerrain(x, y, palSelection)
|
||||
world.setTileTerrain(x, y, palSelection, true)
|
||||
}
|
||||
PENMODE_PENCIL_ERASE -> {
|
||||
if (currentPenTarget and PENTARGET_WALL != 0)
|
||||
world.setTileWall(x, y, Block.AIR)
|
||||
world.setTileWall(x, y, Block.AIR, true)
|
||||
else
|
||||
world.setTileTerrain(x, y, Block.AIR)
|
||||
world.setTileTerrain(x, y, Block.AIR, true)
|
||||
}
|
||||
PENMODE_EYEDROPPER -> {
|
||||
uiPaletteSelector.fore = if (world.getTileFromTerrain(x, y) == Block.AIR)
|
||||
|
||||
@@ -78,10 +78,10 @@ open class FixtureBase(
|
||||
// if the collision type is allow_move_down, only the top surface tile should be "the platform"
|
||||
// lower part must not have such property (think of the table!)
|
||||
// TODO does this ACTUALLY work ?!
|
||||
world.setTileTerrain(x, y, if (y == posY) BlockBox.ALLOW_MOVE_DOWN else BlockBox.NO_COLLISION)
|
||||
world.setTileTerrain(x, y, if (y == posY) BlockBox.ALLOW_MOVE_DOWN else BlockBox.NO_COLLISION, false)
|
||||
}
|
||||
else
|
||||
world.setTileTerrain(x, y, blockBox.collisionType)
|
||||
world.setTileTerrain(x, y, blockBox.collisionType, false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ open class FixtureBase(
|
||||
// remove filler block
|
||||
for (x in posX until posX + blockBox.width) {
|
||||
for (y in posY until posY + blockBox.height) {
|
||||
world.setTileTerrain(x, y, Block.AIR)
|
||||
world.setTileTerrain(x, y, Block.AIR, false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ open class FixtureBase(
|
||||
for (x in posX until posX + blockBox.width) {
|
||||
for (y in posY until posY + blockBox.height) {
|
||||
if (world.getTileFromTerrain(x, y) == blockBox.collisionType) {
|
||||
world.setTileTerrain(x, y, Block.AIR)
|
||||
world.setTileTerrain(x, y, Block.AIR, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,9 @@ object PlayerBuilderSigrid {
|
||||
try {
|
||||
inventory.add("wall@"+t, 9995)
|
||||
}
|
||||
catch (e: Throwable) {}
|
||||
catch (e: Throwable) {
|
||||
System.err.println("[PlayerBuilder] $e")
|
||||
}
|
||||
}
|
||||
|
||||
// item ids are defined in <module>/items/itemid.csv
|
||||
|
||||
@@ -56,14 +56,16 @@ object BlockBase {
|
||||
ingame.world.setTileWall(
|
||||
mouseTile.x,
|
||||
mouseTile.y,
|
||||
itemID.substring(5)
|
||||
itemID.substring(5),
|
||||
false
|
||||
)
|
||||
}
|
||||
else {
|
||||
ingame.world.setTileTerrain(
|
||||
mouseTile.x,
|
||||
mouseTile.y,
|
||||
itemID
|
||||
itemID,
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -208,8 +208,8 @@ object WorldSimulator {
|
||||
// process the gradual falling of the selected "stack"
|
||||
if (!fallableStackProcessed && fallDownCounter != 0 && isFallable) {
|
||||
// replace blocks
|
||||
world.setTileTerrain(x, y, Block.AIR)
|
||||
world.setTileTerrain(x, y + fallDownCounter, currentTile)
|
||||
world.setTileTerrain(x, y, Block.AIR, true)
|
||||
world.setTileTerrain(x, y + fallDownCounter, currentTile, true)
|
||||
|
||||
fallableStackProcessed = true
|
||||
}
|
||||
|
||||
@@ -86,17 +86,17 @@ class Biomegen(world: GameWorld, seed: Long, params: Any) : Gen(world, seed, par
|
||||
when (control) {
|
||||
0 -> { // woodlands
|
||||
if (tileThis == Block.DIRT && nearbyTerr.any { it == Block.AIR } && nearbyWall.any { it == Block.AIR }) {
|
||||
world.setTileTerrain(x, y, Block.GRASS)
|
||||
world.setTileTerrain(x, y, Block.GRASS, true)
|
||||
}
|
||||
}
|
||||
1 -> { // shrublands
|
||||
if (tileThis == Block.DIRT && nearbyTerr.any { it == Block.AIR } && nearbyWall.any { it == Block.AIR }) {
|
||||
world.setTileTerrain(x, y, Block.GRASS)
|
||||
world.setTileTerrain(x, y, Block.GRASS, true)
|
||||
}
|
||||
}
|
||||
2, 3 -> { // plains
|
||||
if (tileThis == Block.DIRT && nearbyTerr.any { it == Block.AIR } && nearbyWall.any { it == Block.AIR }) {
|
||||
world.setTileTerrain(x, y, Block.GRASS)
|
||||
world.setTileTerrain(x, y, Block.GRASS, true)
|
||||
}
|
||||
}
|
||||
/*3 -> { // sands
|
||||
@@ -109,8 +109,8 @@ class Biomegen(world: GameWorld, seed: Long, params: Any) : Gen(world, seed, par
|
||||
}*/
|
||||
4 -> { // rockylands
|
||||
if (tileThis == Block.DIRT) {
|
||||
world.setTileTerrain(x, y, Block.STONE)
|
||||
world.setTileWall(x, y, Block.STONE)
|
||||
world.setTileTerrain(x, y, Block.STONE, true)
|
||||
world.setTileWall(x, y, Block.STONE, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ class Terragen(world: GameWorld, seed: Long, params: Any) : Gen(world, seed, par
|
||||
(0 until world.width).sliceEvenly(genSlices).mapIndexed { i, xs ->
|
||||
ThreadExecutor.submit {
|
||||
val localJoise = getGenerator(seed, params as TerragenParams)
|
||||
val localLock = java.lang.Object() // in an attempt to fix the "premature exit" issue of a thread run
|
||||
synchronized(localLock) { // also see: https://stackoverflow.com/questions/28818494/threads-stopping-prematurely-for-certain-values
|
||||
//val localLock = java.lang.Object() // in an attempt to fix the "premature exit" issue of a thread run
|
||||
//synchronized(localLock) { // also see: https://stackoverflow.com/questions/28818494/threads-stopping-prematurely-for-certain-values
|
||||
for (x in xs) {
|
||||
for (y in 0 until world.height) {
|
||||
val sampleTheta = (x.toDouble() / world.width) * TWO_PI
|
||||
@@ -43,7 +43,7 @@ class Terragen(world: GameWorld, seed: Long, params: Any) : Gen(world, seed, par
|
||||
draw(x, y, noise, world)
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@ class Terragen(world: GameWorld, seed: Long, params: Any) : Gen(world, seed, par
|
||||
val wallBlock = groundDepthBlock[terr]
|
||||
val terrBlock = if (cave == 0) Block.AIR else wallBlock //wallBlock * cave // AIR is always zero, this is the standard
|
||||
|
||||
world.setTileTerrain(x, y, terrBlock)
|
||||
world.setTileWall(x, y, wallBlock)
|
||||
world.setTileTerrain(x, y, terrBlock, true)
|
||||
world.setTileWall(x, y, wallBlock, true)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user