From 9104c7a46f85d81973c14e5bd240367f23b96467 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 4 May 2024 10:38:32 +0700 Subject: [PATCH] Floating Dungeon Worlds now can finally unload its chunks --- .../dbotthepony/kstarbound/server/StarboundServer.kt | 4 ++-- .../kstarbound/server/world/ServerChunk.kt | 2 +- .../ru/dbotthepony/kstarbound/util/CarriedExecutor.kt | 2 +- .../kstarbound/world/entities/tile/WorldObject.kt | 11 +++++++---- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/server/StarboundServer.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/server/StarboundServer.kt index 023097fa..1812ba2d 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/server/StarboundServer.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/server/StarboundServer.kt @@ -224,7 +224,7 @@ sealed class StarboundServer(val root: File) : BlockableEventLoop("Server thread LOGGER.fatal("Exception loading celestial world at $location, recreating!") 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) } @@ -270,7 +270,7 @@ sealed class StarboundServer(val root: File) : BlockableEventLoop("Server thread visitable.disableDeathDrops = config.disableDeathDrops 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 { world.setProperty("ephemeral", JsonPrimitive(!config.persistent)) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/server/world/ServerChunk.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/server/world/ServerChunk.kt index a0552085..91b4be8f 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/server/world/ServerChunk.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/server/world/ServerChunk.kt @@ -501,7 +501,7 @@ class ServerChunk(world: ServerWorld, pos: ChunkPos) : Chunk) : TileEntit var soundEffectEnabled by networkedBoolean(true).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 chatMessage by networkedString().also { networkGroup.upstream.add(it) } - val chatPortrait by networkedString().also { networkGroup.upstream.add(it) } - val chatConfig by networkedJsonElement().also { networkGroup.upstream.add(it) } + var chatMessage by networkedString().also { networkGroup.upstream.add(it) } + var chatPortrait by networkedString().also { networkGroup.upstream.add(it) } + var chatConfig by networkedJsonElement().also { networkGroup.upstream.add(it) } @Suppress("deprecation") inner class WireNode(val position: Vector2i, val isInput: Boolean) { @@ -556,7 +556,10 @@ open class WorldObject(val config: Registry.Entry) : TileEntit } fun addChatMessage(message: String, config: JsonElement, portrait: String? = null) { - + chatMessage = message + chatPortrait = portrait ?: "" + chatConfig = config + newChatMessageEvent.trigger() } override fun tick(delta: Double) {