Floating Dungeon Worlds now can finally unload its chunks

This commit is contained in:
DBotThePony 2024-05-04 10:38:32 +07:00
parent a23493fa83
commit 9104c7a46f
Signed by: DBot
GPG Key ID: DCC23B5715498507
4 changed files with 11 additions and 8 deletions

View File

@ -224,7 +224,7 @@ sealed class StarboundServer(val root: File) : BlockableEventLoop("Server thread
LOGGER.fatal("Exception loading celestial world at $location, recreating!") LOGGER.fatal("Exception loading celestial world at $location, recreating!")
var i = 0 var i = 0
while (!file.renameTo(File(universeFolder, "$fileName-fail$i")) && ++i < 1000) {} while (!file.renameTo(File(universeFolder, "$fileName-fail$i")) && ++i < 10000) {}
ServerWorld.create(this, WorldTemplate.create(location.pos, universe), NativeLocalWorldStorage(file), location) ServerWorld.create(this, WorldTemplate.create(location.pos, universe), NativeLocalWorldStorage(file), location)
} }
@ -270,7 +270,7 @@ sealed class StarboundServer(val root: File) : BlockableEventLoop("Server thread
visitable.disableDeathDrops = config.disableDeathDrops visitable.disableDeathDrops = config.disableDeathDrops
val template = WorldTemplate(visitable, config.skyParameters, random) val template = WorldTemplate(visitable, config.skyParameters, random)
val world = ServerWorld.create(this, template, LegacyWorldStorage.memory(), location) val world = ServerWorld.create(this, template, NativeLocalWorldStorage(null), location)
try { try {
world.setProperty("ephemeral", JsonPrimitive(!config.persistent)) world.setProperty("ephemeral", JsonPrimitive(!config.persistent))

View File

@ -501,7 +501,7 @@ class ServerChunk(world: ServerWorld, pos: ChunkPos) : Chunk<ServerWorld, Server
} }
} }
var shouldUnload = !isBusy && temporary.isEmpty() && permanent.isEmpty() && world.template.worldParameters !is FloatingDungeonWorldParameters var shouldUnload = !isBusy && temporary.isEmpty() && permanent.isEmpty() //&& world.template.worldParameters !is FloatingDungeonWorldParameters
if (shouldUnload) { if (shouldUnload) {
idleTicks++ idleTicks++

View File

@ -70,7 +70,7 @@ class CarriedExecutor(private val parent: Executor, private val allowExecutionIn
if (queue.isNotEmpty() && isCarried.compareAndSet(false, true)) { if (queue.isNotEmpty() && isCarried.compareAndSet(false, true)) {
// bugger! queue updated while we have finished // bugger! queue updated while we have finished
// and no other thread has picked up // and no other thread has picked it up
} else { } else {
break break
} }

View File

@ -248,9 +248,9 @@ open class WorldObject(val config: Registry.Entry<ObjectDefinition>) : TileEntit
var soundEffectEnabled by networkedBoolean(true).also { networkGroup.upstream.add(it) } var soundEffectEnabled by networkedBoolean(true).also { networkGroup.upstream.add(it) }
var lightSourceColor by networkedData(RGBAColor.TRANSPARENT_BLACK, RGBACodec).also { networkGroup.upstream.add(it) } var lightSourceColor by networkedData(RGBAColor.TRANSPARENT_BLACK, RGBACodec).also { networkGroup.upstream.add(it) }
val newChatMessageEvent = networkedEventCounter().also { networkGroup.upstream.add(it) } val newChatMessageEvent = networkedEventCounter().also { networkGroup.upstream.add(it) }
val chatMessage by networkedString().also { networkGroup.upstream.add(it) } var chatMessage by networkedString().also { networkGroup.upstream.add(it) }
val chatPortrait by networkedString().also { networkGroup.upstream.add(it) } var chatPortrait by networkedString().also { networkGroup.upstream.add(it) }
val chatConfig by networkedJsonElement().also { networkGroup.upstream.add(it) } var chatConfig by networkedJsonElement().also { networkGroup.upstream.add(it) }
@Suppress("deprecation") @Suppress("deprecation")
inner class WireNode(val position: Vector2i, val isInput: Boolean) { inner class WireNode(val position: Vector2i, val isInput: Boolean) {
@ -556,7 +556,10 @@ open class WorldObject(val config: Registry.Entry<ObjectDefinition>) : TileEntit
} }
fun addChatMessage(message: String, config: JsonElement, portrait: String? = null) { fun addChatMessage(message: String, config: JsonElement, portrait: String? = null) {
chatMessage = message
chatPortrait = portrait ?: ""
chatConfig = config
newChatMessageEvent.trigger()
} }
override fun tick(delta: Double) { override fun tick(delta: Double) {