diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/dungeon/DungeonWorld.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/dungeon/DungeonWorld.kt index 6068af6c..c9de055d 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/dungeon/DungeonWorld.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/dungeon/DungeonWorld.kt @@ -473,6 +473,17 @@ class DungeonWorld(val parent: ServerWorld, val random: RandomGenerator, val mar }, parent.eventLoop)) } + val placedObjects = placedObjects.entries + .map { (pos, data) -> + try { + WorldObject.create(data.prototype, pos, data.parameters).also { it?.randomize(random) } to data.direction + } catch (err: Throwable) { + LOGGER.error("Exception while creating dungeon object ${data.prototype} at $pos", err) + null to data.direction + } + } + .filter { it.first != null } + // wait for all chunks to be loaded (and cell changes to be applied) // if any of cell change operation fails, entire generation fails... leaving world in inconsistent state, // but also limiting damage by exiting early. @@ -482,12 +493,6 @@ class DungeonWorld(val parent: ServerWorld, val random: RandomGenerator, val mar if (playerStart != null) parent.setPlayerSpawn(playerStart!!, false) - val placedObjects = placedObjects.entries - .map { (pos, data) -> - WorldObject.create(data.prototype, pos, data.parameters).also { it?.randomize(random) } to data.direction - } - .filter { it.first != null } - parent.eventLoop.supplyAsync { for ((obj, direction) in placedObjects) { try {