From ff273394ab000d82e214517c49b342475d91969a Mon Sep 17 00:00:00 2001 From: GregHib Date: Thu, 9 Jan 2025 14:44:28 +0000 Subject: [PATCH 01/25] Fix xp rate modifier --- .../main/kotlin/world/gregs/voidps/engine/EngineModules.kt | 4 ++-- .../world/gregs/voidps/engine/client/PlayerAccountLoader.kt | 5 +++-- .../kotlin/world/gregs/voidps/engine/data/AccountManager.kt | 6 ++++-- .../kotlin/world/gregs/voidps/engine/data/PlayerSave.kt | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt index 1eadb7cda..ed35eb1fa 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt @@ -48,7 +48,7 @@ val engineModule = module { y = getIntProperty("homeY", 0), level = getIntProperty("homeLevel", 0) ) - AccountManager(get(), get(), get(), get(), get(), get(), homeTile, get(), get(), get(), get()) + AccountManager(get(), get(), get(), get(), get(), get(), homeTile, get(), get(), get(), get(), getProperty("experienceRate", "1.0").toDouble()) } // IO single { Yaml(YamlReaderConfiguration(2, 8, VERY_FAST_LOAD_FACTOR)) } @@ -69,7 +69,7 @@ val engineModule = module { } FileStorage(get(), saves, get(), getProperty("experienceRate", "1.0").toDouble()) } } - single { PlayerAccountLoader(get(), get(), get(), get(), get(), Contexts.Game) } + single { PlayerAccountLoader(get(), get(), get(), get(), get(), Contexts.Game, getProperty("experienceRate", "1.0").toDouble()) } // Map single { ZoneBatchUpdates() } single { DynamicZones(get(), get(), get()) } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoader.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoader.kt index a53549923..3b205e878 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoader.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoader.kt @@ -29,7 +29,8 @@ class PlayerAccountLoader( private val accounts: AccountManager, private val saveQueue: SaveQueue, private val accountDefinitions: AccountDefinitions, - private val gameContext: CoroutineDispatcher + private val gameContext: CoroutineDispatcher, + private val experienceRate: Double ) : AccountLoader { private val logger = InlineLogger() @@ -51,7 +52,7 @@ class PlayerAccountLoader( client.disconnect(Response.ACCOUNT_ONLINE) return null } - val player = storage.load(username)?.toPlayer() ?: accounts.create(username, passwordHash) + val player = storage.load(username)?.toPlayer(experienceRate) ?: accounts.create(username, passwordHash) logger.info { "Player $username loaded and queued for login." } connect(player, client, displayMode) return player.instructions diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/AccountManager.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/AccountManager.kt index df8bf33bf..7ac39d773 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/AccountManager.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/AccountManager.kt @@ -13,6 +13,7 @@ import world.gregs.voidps.engine.entity.character.mode.move.AreaEntered import world.gregs.voidps.engine.entity.character.mode.move.AreaExited import world.gregs.voidps.engine.entity.character.move.previousTile import world.gregs.voidps.engine.entity.character.player.* +import world.gregs.voidps.engine.entity.character.player.skill.exp.Experience import world.gregs.voidps.engine.entity.character.player.skill.level.PlayerLevels import world.gregs.voidps.engine.inv.equipment import world.gregs.voidps.engine.inv.restrict.ValidItemRestriction @@ -38,12 +39,13 @@ class AccountManager( private val saveQueue: SaveQueue, private val connectionQueue: ConnectionQueue, private val players: Players, - private val areaDefinitions: AreaDefinitions + private val areaDefinitions: AreaDefinitions, + private val experienceRate: Double ) { private val validItems = ValidItemRestriction(itemDefinitions) fun create(name: String, passwordHash: String): Player { - return Player(tile = homeTile, accountName = name, passwordHash = passwordHash).apply { + return Player(tile = homeTile, accountName = name, passwordHash = passwordHash, experience = Experience(rate = experienceRate)).apply { this["creation"] = System.currentTimeMillis() this["new_player"] = true } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/PlayerSave.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/PlayerSave.kt index 07d8c4325..db0469333 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/PlayerSave.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/PlayerSave.kt @@ -26,12 +26,12 @@ data class PlayerSave( val ignores: List ) { - fun toPlayer(): Player { + fun toPlayer(rate: Double): Player { return Player( accountName = name, passwordHash = password, tile = tile, - experience = Experience(experience, blocked.toMutableSet()), + experience = Experience(experience, blocked.toMutableSet(), rate = rate), levels = Levels(levels), body = BodyParts(male, looks, colours), variables = variables.toMutableMap(), From fa411d64596e1eed526e7e3e4b8358446ac271fe Mon Sep 17 00:00:00 2001 From: GregHib Date: Thu, 9 Jan 2025 15:12:09 +0000 Subject: [PATCH 02/25] Fix music unlock command --- .../world/interact/entity/player/music/MusicUnlock.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/music/MusicUnlock.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/music/MusicUnlock.kt index 504af8287..b233fbf59 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/music/MusicUnlock.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/music/MusicUnlock.kt @@ -1,16 +1,16 @@ package world.gregs.voidps.world.interact.entity.player.music import world.gregs.voidps.engine.client.ui.playTrack +import world.gregs.voidps.engine.client.variable.BitwiseValues import world.gregs.voidps.engine.data.definition.VariableDefinitions import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.get object MusicUnlock { - @Suppress("UNCHECKED_CAST") fun unlockTrack(player: Player, trackIndex: Int): Boolean { val name = "unlocked_music_${trackIndex / 32}" - val list = get().get(name)?.values as? List - val track = list?.get(trackIndex.rem(32)) as? String ?: return false + val list = get().get(name)?.values as? BitwiseValues + val track = list?.values?.get(trackIndex.rem(32)) as? String ?: return false return player.addVarbit("unlocked_music_${trackIndex / 32}", track) } } From 7487c619bc5b1228e9b27de5fa4fe3c3132833f4 Mon Sep 17 00:00:00 2001 From: GregHib Date: Thu, 9 Jan 2025 17:49:44 +0000 Subject: [PATCH 03/25] Fix tests for experience rate --- .../gregs/voidps/engine/client/PlayerAccountLoaderTest.kt | 2 +- .../world/gregs/voidps/engine/data/AccountManagerTest.kt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/engine/src/test/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoaderTest.kt b/engine/src/test/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoaderTest.kt index 33e7e2f9e..aec15cf48 100644 --- a/engine/src/test/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoaderTest.kt +++ b/engine/src/test/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoaderTest.kt @@ -60,7 +60,7 @@ internal class PlayerAccountLoaderTest : KoinMock() { saveQueue = SaveQueue(storage, scope = TestScope()) definitions = AccountDefinitions(mutableMapOf("name" to AccountDefinition("name", "oldName", "", "hash"))) accounts = mockk(relaxed = true) - loader = PlayerAccountLoader(queue, storage, accounts, saveQueue, definitions, UnconfinedTestDispatcher()) + loader = PlayerAccountLoader(queue, storage, accounts, saveQueue, definitions, UnconfinedTestDispatcher(), 1.0) } @Test diff --git a/engine/src/test/kotlin/world/gregs/voidps/engine/data/AccountManagerTest.kt b/engine/src/test/kotlin/world/gregs/voidps/engine/data/AccountManagerTest.kt index 044424ca1..503be9187 100644 --- a/engine/src/test/kotlin/world/gregs/voidps/engine/data/AccountManagerTest.kt +++ b/engine/src/test/kotlin/world/gregs/voidps/engine/data/AccountManagerTest.kt @@ -64,7 +64,8 @@ class AccountManagerTest : KoinMock() { saveQueue = SaveQueue(storage), connectionQueue = connectionQueue, areaDefinitions = get(), - players = Players() + players = Players(), + experienceRate = 1.0 ) } From 968599d4db2aa094e2daf9a04b2b56bd9a464c67 Mon Sep 17 00:00:00 2001 From: GregHib Date: Thu, 9 Jan 2025 17:53:54 +0000 Subject: [PATCH 04/25] Add Settings closes #576 --- .../gregs/voidps/engine/EngineModules.kt | 14 ++--- .../gregs/voidps/engine/data/Settings.kt | 38 +++++++++++ .../world/gregs/voidps/engine/entity/World.kt | 27 +++----- .../gregs/voidps/engine/data/SettingsTest.kt | 63 +++++++++++++++++++ .../main/kotlin/world/gregs/voidps/Main.kt | 30 +++++---- .../combat/magic/spell/CombinationRuneTest.kt | 7 ++- .../player/combat/magic/spell/SpellTest.kt | 2 +- .../gregs/voidps/world/script/WorldTest.kt | 6 +- 8 files changed, 139 insertions(+), 48 deletions(-) create mode 100644 engine/src/main/kotlin/world/gregs/voidps/engine/data/Settings.kt create mode 100644 engine/src/test/kotlin/world/gregs/voidps/engine/data/SettingsTest.kt diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt index ed35eb1fa..b8cb9795b 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt @@ -7,9 +7,7 @@ import org.rsmod.game.pathfinder.PathFinder import org.rsmod.game.pathfinder.StepValidator import world.gregs.voidps.engine.client.PlayerAccountLoader import world.gregs.voidps.engine.client.update.batch.ZoneBatchUpdates -import world.gregs.voidps.engine.data.AccountManager -import world.gregs.voidps.engine.data.SafeStorage -import world.gregs.voidps.engine.data.SaveQueue +import world.gregs.voidps.engine.data.* import world.gregs.voidps.engine.data.definition.* import world.gregs.voidps.engine.data.json.FileStorage import world.gregs.voidps.engine.data.sql.DatabaseStorage @@ -54,11 +52,11 @@ val engineModule = module { single { Yaml(YamlReaderConfiguration(2, 8, VERY_FAST_LOAD_FACTOR)) } single { if (getProperty("storage", "") == "database") { DatabaseStorage.connect( - getProperty("database_username"), - getProperty("database_password"), - getProperty("database_driver"), - getProperty("database_jdbc_url"), - getProperty("database_pool", "2").toInt(), + Settings["database_username"], + Settings["database_password"], + Settings["database_driver"], + Settings["database_jdbc_url"], + Settings["database_pool", 2], ) val definitions: ItemDefinitions = get() DatabaseStorage { definitions.get(it) } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/Settings.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/Settings.kt new file mode 100644 index 000000000..b2018fed7 --- /dev/null +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/Settings.kt @@ -0,0 +1,38 @@ +package world.gregs.voidps.engine.data + +import java.io.InputStream +import java.util.* + +/** + * Class to load and reload game settings from .property files + */ +open class Settings { + + protected val properties = Properties() + + fun load(stream: InputStream): Properties { + properties.load(stream) + return properties + } + + fun load(map: Map): Properties { + properties.putAll(map) + return properties + } + + operator fun get(name: String): String = properties.getProperty(name) + + operator fun get(name: String, default: String): String = properties.getProperty(name, default) + + operator fun get(name: String, default: Int): Int = (properties[name] as? String)?.toIntOrNull() ?: default + + operator fun get(name: String, default: Double): Double = (properties[name] as? String)?.toDoubleOrNull() ?: default + + operator fun get(name: String, default: Boolean): Boolean = (properties[name] as? String)?.toBooleanStrictOrNull() ?: default + + fun clear() { + properties.clear() + } + + companion object : Settings() +} \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt index 294511d0b..1fd0768ee 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt @@ -5,11 +5,11 @@ import org.koin.core.component.KoinComponent import world.gregs.voidps.engine.GameLoop import world.gregs.voidps.engine.client.variable.Variable import world.gregs.voidps.engine.client.variable.Variables +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.event.EventDispatcher import world.gregs.voidps.engine.timer.TimerQueue import world.gregs.voidps.engine.timer.Timers import world.gregs.voidps.type.Tile -import java.util.* import java.util.concurrent.ConcurrentHashMap const val MAX_PLAYERS = 0x800 // 2048 @@ -21,25 +21,14 @@ object World : Entity, Variable, EventDispatcher, Runnable, KoinComponent { override val variables = Variables(this) private val logger = InlineLogger() - var id = 0 - private set(value) { - field = value - name = "World $value" - } - var name: String = "World" - private set - var members: Boolean = false - private set - - fun start(properties: Properties) { - val members = properties.getProperty("members").toBoolean() - val id = properties.getProperty("world").toInt() - start(members, id) - } + val id: Int + get() = Settings["world", 16] + val name: String + get() = "World $id" + val members: Boolean + get() = Settings["members", false] - fun start(members: Boolean = true, id: Int = 16) { - this.members = members - this.id = id + fun start() { emit(Spawn) } diff --git a/engine/src/test/kotlin/world/gregs/voidps/engine/data/SettingsTest.kt b/engine/src/test/kotlin/world/gregs/voidps/engine/data/SettingsTest.kt new file mode 100644 index 000000000..b0a2665d8 --- /dev/null +++ b/engine/src/test/kotlin/world/gregs/voidps/engine/data/SettingsTest.kt @@ -0,0 +1,63 @@ +package world.gregs.voidps.engine.data + +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows + +class SettingsTest { + + private lateinit var settings: Settings + + @BeforeEach + fun setUp() { + settings = Settings() + } + + private val example = """ + name=Void + port=43594 + experienceRate=10.0 + active=true + """.trimIndent() + + @Test + fun `Load settings`() { + settings.load(example) + assertEquals("Void", settings["name"]) + assertEquals(43594, settings["port", -1]) + assertEquals(10.0, settings["experienceRate", -10.0]) + assertEquals(true, settings["active", false]) + } + + @Test + fun `Get missing setting throws exception settings`() { + settings.load(example) + assertThrows { + assertEquals("Nothing", settings["missing"]) + } + } + + @Test + fun `Get a missing setting returns default`() { + assertEquals("missing", settings["unknown", "missing"]) + } + + @Test + fun `Get an incorrect format setting returns default`() { + settings.load(example) + assertEquals(1234, settings["name", 1234]) + } + + @Test + fun `Override settings`() { + settings.load(example) + settings.load("name=Void 2") + + assertEquals("Void 2", settings["name"]) + assertEquals(43594, settings["port", -1]) + } + + private fun Settings.load(string: String) = load(string.byteInputStream(Charsets.UTF_8)) + +} \ No newline at end of file diff --git a/game/src/main/kotlin/world/gregs/voidps/Main.kt b/game/src/main/kotlin/world/gregs/voidps/Main.kt index 67baa7473..4fa47871a 100644 --- a/game/src/main/kotlin/world/gregs/voidps/Main.kt +++ b/game/src/main/kotlin/world/gregs/voidps/Main.kt @@ -15,6 +15,7 @@ import world.gregs.voidps.cache.definition.decoder.* import world.gregs.voidps.cache.secure.Huffman import world.gregs.voidps.engine.* import world.gregs.voidps.engine.client.PlayerAccountLoader +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.definition.* import world.gregs.voidps.engine.entity.World import world.gregs.voidps.engine.map.collision.CollisionDecoder @@ -41,17 +42,17 @@ object Main : CoroutineScope { @JvmStatic fun main(args: Array) { val startTime = System.currentTimeMillis() - val properties = properties() - name = properties.getProperty("name") + val properties = settings() + name = Settings["name"] // File server val cache = timed("cache") { Cache.load(properties) } val server = GameServer.load(cache, properties) - val job = server.start(properties.getProperty("port").toInt()) + val job = server.start(Settings["port"].toInt()) // Content try { - preload(cache, properties) + preload(cache) } catch (ex: Exception) { logger.error(ex) { "Error loading files." } server.stop() @@ -64,7 +65,7 @@ object Main : CoroutineScope { // Game world val stages = getTickStages() - World.start(properties) + World.start() val scope = CoroutineScope(Contexts.Game) val engine = GameLoop(stages).start(scope) server.loginServer = loginServer @@ -79,32 +80,29 @@ object Main : CoroutineScope { } } - private fun properties(): Properties = timed("properties") { - val properties = Properties() + private fun settings(): Properties = timed("properties") { val file = File("./$PROPERTY_FILE_NAME") - if (file.exists()) { - properties.load(file.inputStream()) + val properties = if (file.exists()) { + Settings.load(file.inputStream()) } else { logger.debug { "Property file not found; defaulting to internal." } - properties.load(Main::class.java.getResourceAsStream("/$PROPERTY_FILE_NAME")) + Settings.load(Main::class.java.getResourceAsStream("/$PROPERTY_FILE_NAME")!!) } properties.putAll(System.getenv()) return@timed properties } - @Suppress("UNCHECKED_CAST") - private fun preload(cache: Cache, properties: Properties) { - val module = cache(cache, properties) + private fun preload(cache: Cache) { + val module = cache(cache) startKoin { slf4jLogger(level = Level.ERROR) - properties(properties.toMap() as Map) modules(engineModule, gameModule, module) } loadScripts() } - private fun cache(cache: Cache, properties: Properties) = module { - val members = properties.getProperty("members").toBoolean() + private fun cache(cache: Cache) = module { + val members = Settings["members", false] single(createdAtStart = true) { MapDefinitions(CollisionDecoder(get()), get(), get(), cache).loadCache() } single(createdAtStart = true) { Huffman().load(cache.data(Index.HUFFMAN, 1)!!) } single(createdAtStart = true) { ObjectDefinitions(ObjectDecoder(members, lowDetail = false, get()).load(cache)).load() } diff --git a/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/CombinationRuneTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/CombinationRuneTest.kt index a123d4dbc..ee9103409 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/CombinationRuneTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/CombinationRuneTest.kt @@ -4,6 +4,7 @@ import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.DynamicTest.dynamicTest import org.junit.jupiter.api.TestFactory +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.World import world.gregs.voidps.engine.entity.item.Item import world.gregs.voidps.engine.inv.add @@ -21,7 +22,8 @@ class CombinationRuneTest : MagicSpellTest() { Triple("lava_rune", "earth_rune", "fire_rune") ).map { (combo, element1, element2) -> dynamicTest("Remove ${combo.replace("_", " ")}s") { - World.start(members = true) + Settings.load(mapOf("members" to "true")) + World.start() val player = player() setItems(Item(element1, 2), Item(element2, 1), Item("chaos_rune", 1)) @@ -50,7 +52,8 @@ class CombinationRuneTest : MagicSpellTest() { "lava_rune" to "fire_rune" ).map { (combo, element) -> dynamicTest("Use ${element.replace("_", " ")}s when out of ${combo.replace("_", " ")}s") { - World.start(members = true) + Settings.load(mapOf("members" to "true")) + World.start() val player = player() setItems(Item(element, 2)) diff --git a/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/SpellTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/SpellTest.kt index c2bd34cc6..02accba38 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/SpellTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/SpellTest.kt @@ -45,7 +45,7 @@ class SpellTest : MagicSpellTest() { @Test fun `Members spell`() { - World.start(members = false) + World.start() val player = player() setItems(Item("blood_rune", 1) to ItemDefinition(stringId = "blood_rune", members = true)) player.inventory.add("blood_rune", 10) diff --git a/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt index a6ae9268b..9b10eea00 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt @@ -25,6 +25,7 @@ import world.gregs.voidps.engine.client.instruction.InterfaceHandler import world.gregs.voidps.engine.client.update.batch.ZoneBatchUpdates import world.gregs.voidps.engine.client.update.view.Viewport import world.gregs.voidps.engine.data.AccountManager +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.definition.* import world.gregs.voidps.engine.entity.World import world.gregs.voidps.engine.entity.character.npc.NPC @@ -147,10 +148,10 @@ abstract class WorldTest : KoinTest { @BeforeAll fun beforeAll() { Main.name = "test" + Settings.load(WorldTest::class.java.getResourceAsStream("/test.properties")!!) stopKoin() startKoin { printLogger(Level.ERROR) - fileProperties("/test.properties") properties(extraProperties) allowOverride(true) modules(engineModule, gameModule, module { @@ -206,7 +207,8 @@ abstract class WorldTest : KoinTest { handler, sequential = true) engine = GameLoop(tickStages) - World.start(true) + + World.start() } players = get() npcs = get() From 50fd0176f2ebb4288ba054321bd3eb03b93dd5ad Mon Sep 17 00:00:00 2001 From: GregHib Date: Thu, 9 Jan 2025 18:05:22 +0000 Subject: [PATCH 05/25] Add settings reload event --- .../voidps/engine/data/SettingsReload.kt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 engine/src/main/kotlin/world/gregs/voidps/engine/data/SettingsReload.kt diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/SettingsReload.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/SettingsReload.kt new file mode 100644 index 000000000..65c266de9 --- /dev/null +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/SettingsReload.kt @@ -0,0 +1,22 @@ +package world.gregs.voidps.engine.data + +import world.gregs.voidps.engine.entity.character.player.Player +import world.gregs.voidps.engine.event.Event +import world.gregs.voidps.engine.event.EventDispatcher +import world.gregs.voidps.engine.event.Events + +object SettingsReload : Event { + + override val notification: Boolean = true + + override val size = 1 + + override fun parameter(dispatcher: EventDispatcher, index: Int) = when (index) { + 0 -> "settings_reload" + else -> null + } +} + +fun settingsReload(handler: suspend SettingsReload.(Player) -> Unit) { + Events.handle("settings_reload", handler = handler) +} From d64b63daf63c0d7932d8e1fdebfcbb05ffee03ba Mon Sep 17 00:00:00 2001 From: GregHib Date: Thu, 9 Jan 2025 18:37:40 +0000 Subject: [PATCH 06/25] Convert properties to load via Settings --- .../gregs/voidps/engine/EngineModules.kt | 8 ++++---- .../kotlin/world/gregs/voidps/engine/Koin.kt | 10 ---------- .../gregs/voidps/engine/data/Settings.kt | 19 ++++++++++++++++++- .../engine/data/definition/AmmoDefinitions.kt | 4 ++-- .../data/definition/AnimationDefinitions.kt | 4 ++-- .../engine/data/definition/AreaDefinitions.kt | 4 ++-- .../data/definition/CategoryDefinitions.kt | 4 ++-- .../definition/ClientScriptDefinitions.kt | 4 ++-- .../data/definition/DiangoCodeDefinitions.kt | 4 ++-- .../engine/data/definition/EnumDefinitions.kt | 4 ++-- .../engine/data/definition/FontDefinitions.kt | 4 ++-- .../engine/data/definition/GearDefinitions.kt | 4 ++-- .../data/definition/GraphicDefinitions.kt | 4 ++-- .../data/definition/HuntModeDefinitions.kt | 4 ++-- .../data/definition/InterfaceDefinitions.kt | 6 +++--- .../data/definition/InventoryDefinitions.kt | 4 ++-- .../engine/data/definition/ItemDefinitions.kt | 4 ++-- .../data/definition/ItemOnItemDefinitions.kt | 6 +++--- .../data/definition/JingleDefinitions.kt | 4 ++-- .../engine/data/definition/MidiDefinitions.kt | 4 ++-- .../engine/data/definition/NPCDefinitions.kt | 4 ++-- .../data/definition/ObjectDefinitions.kt | 4 ++-- .../data/definition/ParameterDefinitions.kt | 4 ++-- .../data/definition/PatrolDefinitions.kt | 4 ++-- .../data/definition/PrayerDefinitions.kt | 4 ++-- .../data/definition/QuestDefinitions.kt | 4 ++-- .../data/definition/RenderEmoteDefinitions.kt | 4 ++-- .../data/definition/SoundDefinitions.kt | 4 ++-- .../data/definition/SpellDefinitions.kt | 4 ++-- .../data/definition/StructDefinitions.kt | 4 ++-- .../data/definition/VariableDefinitions.kt | 4 ++-- .../definition/WeaponAnimationDefinitions.kt | 4 ++-- .../data/definition/WeaponStyleDefinitions.kt | 4 ++-- .../world/gregs/voidps/engine/entity/World.kt | 4 ++++ .../engine/entity/character/mode/Wander.kt | 4 ++-- .../engine/entity/character/npc/NPCs.kt | 5 ----- .../engine/entity/item/drop/DropTables.kt | 4 ++-- .../main/kotlin/world/gregs/voidps/Main.kt | 9 +-------- .../world/gregs/voidps/bot/BotSpawns.kts | 17 +++++++++++++++-- .../bot/navigation/graph/NavigationGraph.kt | 4 ++-- .../world/gregs/voidps/script/ScriptLoader.kt | 4 ++-- .../dnd/shootingstar/ShootingStar.kts | 16 ++++++++++++---- .../voidps/world/activity/quest/Books.kt | 4 ++-- .../skill/agility/course/BarbarianOutpost.kts | 14 +++++++------- .../skill/agility/course/GnomeAdvanced.kts | 6 +++--- .../world/command/admin/AdminCommands.kts | 12 ++++++++++-- .../gregs/voidps/world/community/Rights.kts | 6 ++---- .../voidps/world/interact/entity/Movement.kts | 13 ++++++------- .../entity/combat/hit/CombatHitsplats.kts | 9 +++------ .../interact/entity/death/PlayerDeath.kts | 9 ++++----- .../world/interact/entity/obj/Teleports.kt | 4 ++-- .../entity/player/music/MusicTracks.kt | 4 ++-- .../world/interact/world/spawn/ItemSpawns.kt | 4 ++-- .../world/interact/world/spawn/NPCSpawns.kt | 4 ++-- .../interact/world/spawn/ObjectSpawns.kt | 4 ++-- .../gregs/voidps/world/script/WorldTest.kt | 4 ++-- .../gregs/voidps/tools/EnumDefinitions.kt | 1 + .../world/gregs/voidps/tools/Properties.kt | 18 +++++++++--------- .../world/gregs/voidps/tools/cache/Xteas.kt | 9 ++++----- 59 files changed, 187 insertions(+), 166 deletions(-) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt index b8cb9795b..32fc4c9db 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt @@ -42,9 +42,9 @@ val engineModule = module { } single { val homeTile = Tile( - x = getIntProperty("homeX", 0), - y = getIntProperty("homeY", 0), - level = getIntProperty("homeLevel", 0) + x = Settings["homeX", 0], + y = Settings["homeY", 0], + level = Settings["homeLevel", 0] ) AccountManager(get(), get(), get(), get(), get(), get(), homeTile, get(), get(), get(), get(), getProperty("experienceRate", "1.0").toDouble()) } @@ -74,7 +74,7 @@ val engineModule = module { single(createdAtStart = true) { AreaDefinitions().load() } // Network single { - ConnectionQueue(getIntProperty("connectionPerTickCap", 1)) + ConnectionQueue(Settings["connectionPerTickCap", 1]) } single(createdAtStart = true) { GameObjectCollisionAdd(get()) } single(createdAtStart = true) { GameObjectCollisionRemove(get()) } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/Koin.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/Koin.kt index 98615f1e3..510a11b71 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/Koin.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/Koin.kt @@ -9,16 +9,6 @@ inline fun get( noinline parameters: ParametersDefinition? = null ): T = getKoin().get(qualifier, parameters) -fun getIntProperty(key: String): Int = getKoin().getProperty(key)!!.toInt() - -fun getProperty(key: String): String = getKoin().getProperty(key)!! - -fun getPropertyOrNull(key: String): String? = getKoin().getProperty(key) - -fun getFloatProperty(key: String): Float = getKoin().getProperty(key)!! - -fun getIntProperty(key: String, defaultValue: Int): Int = getKoin().getProperty(key)?.toIntOrNull() ?: defaultValue - inline fun inject( qualifier: Qualifier? = null, noinline parameters: ParametersDefinition? = null diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/Settings.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/Settings.kt index b2018fed7..37642d6f6 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/Settings.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/Settings.kt @@ -1,5 +1,7 @@ package world.gregs.voidps.engine.data +import com.github.michaelbull.logging.InlineLogger +import java.io.File import java.io.InputStream import java.util.* @@ -20,6 +22,8 @@ open class Settings { return properties } + fun getOrNull(name: String): String? = properties.getProperty(name) + operator fun get(name: String): String = properties.getProperty(name) operator fun get(name: String, default: String): String = properties.getProperty(name, default) @@ -34,5 +38,18 @@ open class Settings { properties.clear() } - companion object : Settings() + companion object : Settings() { + private const val PROPERTY_FILE_NAME = "game.properties" + private val logger = InlineLogger() + + fun load(): Properties { + val file = File("./$PROPERTY_FILE_NAME") + return if (file.exists()) { + Settings.load(file.inputStream()) + } else { + logger.debug { "Property file not found; defaulting to internal." } + Settings.load(Settings::class.java.getResourceAsStream("/$PROPERTY_FILE_NAME")!!) + } + } + } } \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AmmoDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AmmoDefinitions.kt index a8c8a4f59..f96a2c2bf 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AmmoDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AmmoDefinitions.kt @@ -1,10 +1,10 @@ package world.gregs.voidps.engine.data.definition import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.config.AmmoDefinition import world.gregs.voidps.engine.data.yaml.decode import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -18,7 +18,7 @@ class AmmoDefinitions : DefinitionsDecoder { override lateinit var ids: Map @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = getProperty("ammoDefinitionsPath")): AmmoDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["ammoDefinitionsPath"]): AmmoDefinitions { timedLoad("ammo definition") { decode(yaml, path) { id, key, extras -> val items = extras?.get("items") as? List diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AnimationDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AnimationDefinitions.kt index 4b7194809..72a6174d6 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AnimationDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AnimationDefinitions.kt @@ -1,8 +1,8 @@ package world.gregs.voidps.engine.data.definition import world.gregs.voidps.cache.definition.data.AnimationDefinition +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -14,7 +14,7 @@ class AnimationDefinitions( override fun empty() = AnimationDefinition.EMPTY - fun load(yaml: Yaml = get(), path: String = getProperty("animationDefinitionsPath")): AnimationDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["animationDefinitionsPath"]): AnimationDefinitions { timedLoad("animation extra") { decode(yaml, path) } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AreaDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AreaDefinitions.kt index fedd3e6a4..b82fbf50b 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AreaDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AreaDefinitions.kt @@ -3,8 +3,8 @@ package world.gregs.voidps.engine.data.definition import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.voidps.type.Area import world.gregs.voidps.type.Zone @@ -34,7 +34,7 @@ class AreaDefinitions( } @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = getProperty("areaPath")): AreaDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["areaPath"]): AreaDefinitions { timedLoad("map area") { val config = object : YamlReaderConfiguration(2, 2) { override fun set(map: MutableMap, key: String, value: Any, indent: Int, parentMap: String?) { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/CategoryDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/CategoryDefinitions.kt index 4c225a4e7..c318593ea 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/CategoryDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/CategoryDefinitions.kt @@ -1,9 +1,9 @@ package world.gregs.voidps.engine.data.definition +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.config.CategoryDefinition import world.gregs.voidps.engine.data.yaml.decode import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -15,7 +15,7 @@ class CategoryDefinitions : DefinitionsDecoder { override lateinit var definitions: Array override lateinit var ids: Map - fun load(yaml: Yaml = get(), path: String = getProperty("categoryDefinitionsPath")): CategoryDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["categoryDefinitionsPath"]): CategoryDefinitions { timedLoad("category definition") { decode(yaml, path) { id, key, _ -> CategoryDefinition(id = id, stringId = key) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ClientScriptDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ClientScriptDefinitions.kt index 99e836067..71daa80df 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ClientScriptDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ClientScriptDefinitions.kt @@ -1,9 +1,9 @@ package world.gregs.voidps.engine.data.definition import world.gregs.voidps.cache.definition.data.ClientScriptDefinition +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.yaml.decode import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -12,7 +12,7 @@ class ClientScriptDefinitions : DefinitionsDecoder { override lateinit var definitions: Array override lateinit var ids: Map - fun load(yaml: Yaml = get(), path: String = getProperty("clientScriptDefinitionsPath")): ClientScriptDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["clientScriptDefinitionsPath"]): ClientScriptDefinitions { timedLoad("client script definition") { decode(yaml, path) { id, key, _ -> ClientScriptDefinition(id = id, stringId = key) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/DiangoCodeDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/DiangoCodeDefinitions.kt index f45964df2..03d732fe4 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/DiangoCodeDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/DiangoCodeDefinitions.kt @@ -1,10 +1,10 @@ package world.gregs.voidps.engine.data.definition import com.github.michaelbull.logging.InlineLogger +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.config.DiangoCodeDefinition import world.gregs.voidps.engine.entity.item.Item import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml import world.gregs.yaml.read.YamlReaderConfiguration @@ -18,7 +18,7 @@ class DiangoCodeDefinitions { fun getOrNull(code: String) = definitions[code] @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = getProperty("diangoCodeDefinitionsPath"), itemDefinitions: ItemDefinitions? = null): DiangoCodeDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["diangoCodeDefinitionsPath"], itemDefinitions: ItemDefinitions? = null): DiangoCodeDefinitions { timedLoad("diango code definition") { val config = object : YamlReaderConfiguration(2, 2) { override fun add(list: MutableList, value: Any, parentMap: String?) { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/EnumDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/EnumDefinitions.kt index 1e3cd73de..77d58a21f 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/EnumDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/EnumDefinitions.kt @@ -1,8 +1,8 @@ package world.gregs.voidps.engine.data.definition import world.gregs.voidps.cache.definition.data.EnumDefinition +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -34,7 +34,7 @@ class EnumDefinitions( return structs.get(struct)[param, default] } - fun load(yaml: Yaml = get(), path: String = getProperty("enumDefinitionsPath")): EnumDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["enumDefinitionsPath"]): EnumDefinitions { timedLoad("enum extra") { decode(yaml, path) } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/FontDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/FontDefinitions.kt index 049053f32..fc35a19f7 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/FontDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/FontDefinitions.kt @@ -1,8 +1,8 @@ package world.gregs.voidps.engine.data.definition import world.gregs.voidps.cache.definition.data.FontDefinition +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -14,7 +14,7 @@ class FontDefinitions( override fun empty() = FontDefinition.EMPTY - fun load(yaml: Yaml = get(), path: String = getProperty("fontDefinitionsPath")): FontDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["fontDefinitionsPath"]): FontDefinitions { timedLoad("font extra") { decode(yaml, path) } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/GearDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/GearDefinitions.kt index c03d91b08..d1a2ed7a7 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/GearDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/GearDefinitions.kt @@ -3,10 +3,10 @@ package world.gregs.voidps.engine.data.definition import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import net.pearx.kasechange.toSentenceCase import world.gregs.voidps.engine.client.ui.chat.toIntRange +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.config.GearDefinition import world.gregs.voidps.engine.entity.item.Item import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.voidps.network.login.protocol.visual.update.player.EquipSlot import world.gregs.yaml.Yaml @@ -19,7 +19,7 @@ class GearDefinitions { fun get(style: String): List = definitions[style] ?: emptyList() @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = getProperty("gearDefinitionsPath"), itemDefinitions: ItemDefinitions = get()): GearDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["gearDefinitionsPath"]): GearDefinitions { timedLoad("gear definition") { var count = 0 val config = object : YamlReaderConfiguration() { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/GraphicDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/GraphicDefinitions.kt index 50afc1913..f13994ced 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/GraphicDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/GraphicDefinitions.kt @@ -1,8 +1,8 @@ package world.gregs.voidps.engine.data.definition import world.gregs.voidps.cache.definition.data.GraphicDefinition +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -14,7 +14,7 @@ class GraphicDefinitions( override fun empty() = GraphicDefinition.EMPTY - fun load(yaml: Yaml = get(), path: String = getProperty("graphicDefinitionsPath")): GraphicDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["graphicDefinitionsPath"]): GraphicDefinitions { timedLoad("graphic extra") { decode(yaml, path) } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/HuntModeDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/HuntModeDefinitions.kt index 58064db02..6db5650cc 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/HuntModeDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/HuntModeDefinitions.kt @@ -1,8 +1,8 @@ package world.gregs.voidps.engine.data.definition +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.config.HuntModeDefinition import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml import world.gregs.yaml.read.YamlReaderConfiguration @@ -16,7 +16,7 @@ class HuntModeDefinitions { } @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = getProperty("huntPath")): HuntModeDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["huntPath"]): HuntModeDefinitions { timedLoad("hunt mode") { val config = object : YamlReaderConfiguration(2, 2) { override fun set(map: MutableMap, key: String, value: Any, indent: Int, parentMap: String?) { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/InterfaceDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/InterfaceDefinitions.kt index 3bb80950e..347cee5da 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/InterfaceDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/InterfaceDefinitions.kt @@ -7,8 +7,8 @@ import world.gregs.voidps.cache.definition.data.InterfaceComponentDefinition import world.gregs.voidps.cache.definition.data.InterfaceDefinition import world.gregs.voidps.engine.client.ui.Interfaces import world.gregs.voidps.engine.client.ui.chat.toIntRange +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml import world.gregs.yaml.read.YamlReaderConfiguration @@ -40,8 +40,8 @@ class InterfaceDefinitions( fun load( yaml: Yaml = get(), - path: String = getProperty("interfacesPath"), - typePath: String = getProperty("interfaceTypesPath") + path: String = Settings["interfacesPath"], + typePath: String = Settings["interfaceTypesPath"] ): InterfaceDefinitions { timedLoad("interface extra") { val ids = Object2IntOpenHashMap() diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/InventoryDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/InventoryDefinitions.kt index 28b026757..967734755 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/InventoryDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/InventoryDefinitions.kt @@ -2,9 +2,9 @@ package world.gregs.voidps.engine.data.definition import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap import world.gregs.voidps.cache.config.data.InventoryDefinition +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.yaml.DefinitionConfig import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -17,7 +17,7 @@ class InventoryDefinitions( override fun empty() = InventoryDefinition.EMPTY @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = getProperty("inventoryDefinitionsPath"), itemDefs: ItemDefinitions = get()): InventoryDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["inventoryDefinitionsPath"], itemDefs: ItemDefinitions = get()): InventoryDefinitions { timedLoad("inventory extra") { val ids = Object2IntOpenHashMap() val config = object : DefinitionConfig(ids, definitions) { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ItemDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ItemDefinitions.kt index ea3444e9b..6698a6bb4 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ItemDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ItemDefinitions.kt @@ -5,13 +5,13 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet import net.pearx.kasechange.toSentenceCase import world.gregs.voidps.cache.definition.data.ItemDefinition +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.definition.data.* import world.gregs.voidps.engine.data.yaml.DefinitionConfig import world.gregs.voidps.engine.entity.character.player.equip.EquipType import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.entity.item.ItemKept import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.voidps.network.login.protocol.visual.update.player.EquipSlot import world.gregs.yaml.Yaml @@ -27,7 +27,7 @@ class ItemDefinitions( override fun empty() = ItemDefinition.EMPTY - fun load(yaml: Yaml = get(), path: String = getProperty("itemDefinitionsPath")): ItemDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["itemDefinitionsPath"]): ItemDefinitions { timedLoad("item extra") { val equipment = IntArray(definitions.size) { -1 } var index = 0 diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ItemOnItemDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ItemOnItemDefinitions.kt index 730187103..301696ee9 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ItemOnItemDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ItemOnItemDefinitions.kt @@ -5,12 +5,12 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ObjectArrayList import net.pearx.kasechange.toSentenceCase import world.gregs.voidps.engine.client.ui.chat.toIntRange +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.config.ItemOnItemDefinition import world.gregs.voidps.engine.data.yaml.DefinitionIdsConfig import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.entity.item.Item import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -25,7 +25,7 @@ class ItemOnItemDefinitions { fun contains(one: Item, two: Item) = definitions.containsKey(id(one, two)) || definitions.containsKey(id(two, one)) @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = getProperty("itemOnItemDefinitionsPath"), itemDefinitions: ItemDefinitions = get()): ItemOnItemDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["itemOnItemDefinitionsPath"], itemDefinitions: ItemDefinitions = get()): ItemOnItemDefinitions { timedLoad("item on item definition") { val definitions = Object2ObjectOpenHashMap>() var count = 0 @@ -33,7 +33,7 @@ class ItemOnItemDefinitions { override fun add(list: MutableList, value: Any, parentMap: String?) { super.add(list, if (value is Map<*, *>) { val id = value["item"] as String - if (itemDefinitions != null && !itemDefinitions.contains(id)) { + if (!itemDefinitions.contains(id)) { logger.warn { "Invalid item-on-item id: $id" } } Item(id, value["amount"] as? Int ?: 1) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/JingleDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/JingleDefinitions.kt index 5c0156551..3727ef63f 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/JingleDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/JingleDefinitions.kt @@ -1,9 +1,9 @@ package world.gregs.voidps.engine.data.definition +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.config.JingleDefinition import world.gregs.voidps.engine.data.yaml.decode import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -12,7 +12,7 @@ class JingleDefinitions : DefinitionsDecoder { override lateinit var definitions: Array override lateinit var ids: Map - fun load(yaml: Yaml = get(), path: String = getProperty("jingleDefinitionsPath")): JingleDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["jingleDefinitionsPath"]): JingleDefinitions { timedLoad("jingle definition") { decode(yaml, path) { id, key, _ -> JingleDefinition(id = id, stringId = key) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/MidiDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/MidiDefinitions.kt index a34dd5c85..3db1025ff 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/MidiDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/MidiDefinitions.kt @@ -1,9 +1,9 @@ package world.gregs.voidps.engine.data.definition +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.config.MidiDefinition import world.gregs.voidps.engine.data.yaml.decode import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -12,7 +12,7 @@ class MidiDefinitions : DefinitionsDecoder { override lateinit var definitions: Array override lateinit var ids: Map - fun load(yaml: Yaml = get(), path: String = getProperty("midiDefinitionsPath")): MidiDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["midiDefinitionsPath"]): MidiDefinitions { timedLoad("midi definition") { decode(yaml, path) { id, key, _ -> MidiDefinition(id = id, stringId = key) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/NPCDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/NPCDefinitions.kt index 58a54021e..3f440650a 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/NPCDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/NPCDefinitions.kt @@ -3,11 +3,11 @@ package world.gregs.voidps.engine.data.definition import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import world.gregs.voidps.cache.definition.data.NPCDefinition +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.definition.data.Pocket import world.gregs.voidps.engine.data.definition.data.Spot import world.gregs.voidps.engine.data.yaml.DefinitionConfig import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml import world.gregs.yaml.read.YamlReader @@ -21,7 +21,7 @@ class NPCDefinitions( override fun empty() = NPCDefinition.EMPTY @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = getProperty("npcDefinitionsPath")): NPCDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["npcDefinitionsPath"]): NPCDefinitions { timedLoad("npc extra") { val ids = Object2IntOpenHashMap() this.ids = ids diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ObjectDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ObjectDefinitions.kt index f855a084a..cee6cb092 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ObjectDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ObjectDefinitions.kt @@ -3,12 +3,12 @@ package world.gregs.voidps.engine.data.definition import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap import world.gregs.voidps.cache.definition.data.ObjectDefinition import world.gregs.voidps.engine.client.ui.chat.toIntRange +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.definition.data.Pickable import world.gregs.voidps.engine.data.definition.data.Rock import world.gregs.voidps.engine.data.definition.data.Tree import world.gregs.voidps.engine.data.yaml.DefinitionConfig import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -25,7 +25,7 @@ class ObjectDefinitions( override fun empty() = ObjectDefinition.EMPTY @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = getProperty("objectDefinitionsPath")): ObjectDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["objectDefinitionsPath"]): ObjectDefinitions { timedLoad("object extra") { val ids = Object2IntOpenHashMap() this.ids = ids diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ParameterDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ParameterDefinitions.kt index 183aff9ae..c73c2eba2 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ParameterDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ParameterDefinitions.kt @@ -4,11 +4,11 @@ import com.github.michaelbull.logging.InlineLogger import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap import world.gregs.voidps.cache.definition.Parameters +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.config.ParameterDefinition import world.gregs.voidps.engine.data.yaml.decode import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -25,7 +25,7 @@ class ParameterDefinitions( override lateinit var parameters: Map private val logger = InlineLogger() - fun load(yaml: Yaml = get(), path: String = getProperty("parameterDefinitionsPath")): ParameterDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["parameterDefinitionsPath"]): ParameterDefinitions { timedLoad("parameter definition") { val size = decode(yaml, path) { id, key, _ -> ParameterDefinition(id = id, stringId = key) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/PatrolDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/PatrolDefinitions.kt index f758f817f..c38c3ff4c 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/PatrolDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/PatrolDefinitions.kt @@ -1,9 +1,9 @@ package world.gregs.voidps.engine.data.definition import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.config.PatrolDefinition import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml import world.gregs.yaml.read.YamlReaderConfiguration @@ -15,7 +15,7 @@ class PatrolDefinitions { fun get(key: String) = definitions[key] ?: PatrolDefinition() @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = getProperty("patrolDefinitionsPath")): PatrolDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["patrolDefinitionsPath"]): PatrolDefinitions { timedLoad("patrol definition") { val definitions = Object2ObjectOpenHashMap() val config = object : YamlReaderConfiguration() { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/PrayerDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/PrayerDefinitions.kt index 5845671f2..6a8830197 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/PrayerDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/PrayerDefinitions.kt @@ -3,9 +3,9 @@ package world.gregs.voidps.engine.data.definition import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.config.PrayerDefinition import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml import world.gregs.yaml.read.YamlReaderConfiguration @@ -28,7 +28,7 @@ class PrayerDefinitions { fun getGroup(group: Int) = groups[group] @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = getProperty("prayerDefinitionsPath")): PrayerDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["prayerDefinitionsPath"]): PrayerDefinitions { timedLoad("prayer definition") { val definitions = Object2ObjectOpenHashMap() val prayers = Int2ObjectArrayMap() diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/QuestDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/QuestDefinitions.kt index a2854e038..c8d6e887f 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/QuestDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/QuestDefinitions.kt @@ -1,9 +1,9 @@ package world.gregs.voidps.engine.data.definition import world.gregs.voidps.cache.config.data.QuestDefinition +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.yaml.decode import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -12,7 +12,7 @@ class QuestDefinitions : DefinitionsDecoder { override lateinit var definitions: Array override lateinit var ids: Map - fun load(yaml: Yaml = get(), path: String = getProperty("questDefinitionsPath")): QuestDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["questDefinitionsPath"]): QuestDefinitions { timedLoad("quest definition") { decode(yaml, path) { id, key, extras -> QuestDefinition(id = id, stringId = key, extras = extras) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/RenderEmoteDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/RenderEmoteDefinitions.kt index 030b81e04..218513b5a 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/RenderEmoteDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/RenderEmoteDefinitions.kt @@ -1,9 +1,9 @@ package world.gregs.voidps.engine.data.definition +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.config.RenderEmoteDefinition import world.gregs.voidps.engine.data.yaml.decode import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -12,7 +12,7 @@ class RenderEmoteDefinitions : DefinitionsDecoder { override lateinit var definitions: Array override lateinit var ids: Map - fun load(yaml: Yaml = get(), path: String = getProperty("renderEmoteDefinitionsPath")): RenderEmoteDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["renderEmoteDefinitionsPath"]): RenderEmoteDefinitions { timedLoad("render emote definition") { decode(yaml, path) { id, key, _ -> RenderEmoteDefinition(id = id, stringId = key) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/SoundDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/SoundDefinitions.kt index 46a1755d0..966fec4b6 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/SoundDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/SoundDefinitions.kt @@ -1,9 +1,9 @@ package world.gregs.voidps.engine.data.definition +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.config.SoundDefinition import world.gregs.voidps.engine.data.yaml.decode import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -12,7 +12,7 @@ class SoundDefinitions : DefinitionsDecoder { override lateinit var definitions: Array override lateinit var ids: Map - fun load(yaml: Yaml = get(), path: String = getProperty("soundDefinitionsPath")): SoundDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["soundDefinitionsPath"]): SoundDefinitions { timedLoad("sound definition") { decode(yaml, path) { id, key, _ -> SoundDefinition(id = id, stringId = key) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/SpellDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/SpellDefinitions.kt index f938a1463..620408e02 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/SpellDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/SpellDefinitions.kt @@ -1,9 +1,9 @@ package world.gregs.voidps.engine.data.definition import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.config.SpellDefinition import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml import world.gregs.yaml.read.YamlReaderConfiguration @@ -15,7 +15,7 @@ class SpellDefinitions { fun get(key: String) = definitions[key] ?: SpellDefinition() @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = getProperty("spellDefinitionsPath")): SpellDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["spellDefinitionsPath"]): SpellDefinitions { timedLoad("spell definition") { val definitions = Object2ObjectOpenHashMap() val config = object : YamlReaderConfiguration() { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/StructDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/StructDefinitions.kt index 5692252b4..cc16a6b19 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/StructDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/StructDefinitions.kt @@ -1,8 +1,8 @@ package world.gregs.voidps.engine.data.definition import world.gregs.voidps.cache.config.data.StructDefinition +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -17,7 +17,7 @@ class StructDefinitions( override fun empty() = StructDefinition.EMPTY - fun load(yaml: Yaml = get(), path: String = getProperty("structDefinitionsPath")): StructDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["structDefinitionsPath"]): StructDefinitions { timedLoad("struct extra") { decode(yaml, path) } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/VariableDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/VariableDefinitions.kt index 074eec92c..c03102189 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/VariableDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/VariableDefinitions.kt @@ -2,10 +2,10 @@ package world.gregs.voidps.engine.data.definition import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.config.VariableDefinition import world.gregs.voidps.engine.data.yaml.DefinitionIdsConfig import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml import java.io.File @@ -24,7 +24,7 @@ class VariableDefinitions { fun getVarp(id: Int) = varpIds[id] @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = getProperty("definitionsPath")): VariableDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitionsPath"]): VariableDefinitions { timedLoad("variable definition") { val definitions = Object2ObjectOpenHashMap() val files = File(path).listFiles()?.filter { it.name.startsWith("variables-") } ?: emptyList() diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/WeaponAnimationDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/WeaponAnimationDefinitions.kt index 568c19125..d6b431fdd 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/WeaponAnimationDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/WeaponAnimationDefinitions.kt @@ -1,9 +1,9 @@ package world.gregs.voidps.engine.data.definition import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.config.WeaponAnimationDefinition import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml import world.gregs.yaml.read.YamlReaderConfiguration @@ -16,7 +16,7 @@ class WeaponAnimationDefinitions { fun getOrNull(key: String) = definitions[key] - fun load(yaml: Yaml = get(), path: String = getProperty("weaponAnimationDefinitionsPath")): WeaponAnimationDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["weaponAnimationDefinitionsPath"]): WeaponAnimationDefinitions { timedLoad("weapon animation definition") { val definitions = Object2ObjectOpenHashMap() val config = object : YamlReaderConfiguration() { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/WeaponStyleDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/WeaponStyleDefinitions.kt index 66155a327..797645004 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/WeaponStyleDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/WeaponStyleDefinitions.kt @@ -1,9 +1,9 @@ package world.gregs.voidps.engine.data.definition +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.config.WeaponStyleDefinition import world.gregs.voidps.engine.data.yaml.decode import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -12,7 +12,7 @@ class WeaponStyleDefinitions : DefinitionsDecoder { override lateinit var definitions: Array override lateinit var ids: Map - fun load(yaml: Yaml = get(), path: String = getProperty("weaponStyleDefinitionsPath")): WeaponStyleDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["weaponStyleDefinitionsPath"]): WeaponStyleDefinitions { timedLoad("weapon style definition") { decode(yaml, path) { id, key, extras -> WeaponStyleDefinition.fromMap(id, key, extras!!) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt index 1fd0768ee..449f33d14 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt @@ -58,6 +58,10 @@ object World : Entity, Variable, EventDispatcher, Runnable, KoinComponent { } } + fun clearQueue(name: String) { + actions.remove(name) + } + fun clear() { timers.clearAll() for ((_, block) in actions.values) { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/Wander.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/Wander.kt index 2f9477b2f..c15644406 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/Wander.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/Wander.kt @@ -1,5 +1,6 @@ package world.gregs.voidps.engine.entity.character.mode +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.mode.move.Movement import world.gregs.voidps.engine.entity.character.move.tele import world.gregs.voidps.engine.entity.character.npc.NPC @@ -45,7 +46,6 @@ class Wander( } companion object { - var active = false - fun wanders(npc: NPC) = active && npc.def.walkMask.toInt() and 0x1 != 0 && npc.def.walkMask.toInt() and 0x2 != 0 && npc.def.contains("wander_radius") + fun wanders(npc: NPC) = Settings["randomWalk", false] && npc.def.walkMask.toInt() and 0x1 != 0 && npc.def.walkMask.toInt() and 0x2 != 0 && npc.def.contains("wander_radius") } } \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/npc/NPCs.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/npc/NPCs.kt index c431b6ea1..fbdd7ba69 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/npc/NPCs.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/npc/NPCs.kt @@ -12,7 +12,6 @@ import world.gregs.voidps.engine.entity.character.face import world.gregs.voidps.engine.entity.character.mode.Wander import world.gregs.voidps.engine.entity.character.mode.move.AreaEntered import world.gregs.voidps.engine.entity.character.player.skill.Skill -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.map.collision.CollisionStrategyProvider import world.gregs.voidps.engine.map.collision.Collisions import world.gregs.voidps.type.Direction @@ -30,10 +29,6 @@ data class NPCs( private val logger = InlineLogger() private val map: CharacterMap = CharacterMap() - init { - Wander.active = getProperty("randomWalk") == "true" - } - override operator fun get(tile: Tile): List { return get(tile.regionLevel).filter { it.tile == tile } } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/item/drop/DropTables.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/item/drop/DropTables.kt index 61aff1b4d..9d52cd1d8 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/item/drop/DropTables.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/item/drop/DropTables.kt @@ -1,9 +1,9 @@ package world.gregs.voidps.engine.entity.item.drop import world.gregs.voidps.engine.client.ui.chat.toIntRange +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.definition.ItemDefinitions import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml import world.gregs.yaml.read.YamlReaderConfiguration @@ -17,7 +17,7 @@ class DropTables { fun getValue(key: String) = tables.getValue(key) - fun load(yaml: Yaml = get(), path: String = getProperty("dropsPath"), itemDefinitions: ItemDefinitions? = null): DropTables { + fun load(yaml: Yaml = get(), path: String = Settings["dropsPath"], itemDefinitions: ItemDefinitions? = null): DropTables { timedLoad("drop table") { val config = object : YamlReaderConfiguration() { override fun add(list: MutableList, value: Any, parentMap: String?) { diff --git a/game/src/main/kotlin/world/gregs/voidps/Main.kt b/game/src/main/kotlin/world/gregs/voidps/Main.kt index 4fa47871a..3439cec22 100644 --- a/game/src/main/kotlin/world/gregs/voidps/Main.kt +++ b/game/src/main/kotlin/world/gregs/voidps/Main.kt @@ -36,7 +36,6 @@ object Main : CoroutineScope { override val coroutineContext: CoroutineContext = Contexts.Game lateinit var name: String private val logger = InlineLogger() - private const val PROPERTY_FILE_NAME = "game.properties" @OptIn(ExperimentalUnsignedTypes::class) @JvmStatic @@ -81,13 +80,7 @@ object Main : CoroutineScope { } private fun settings(): Properties = timed("properties") { - val file = File("./$PROPERTY_FILE_NAME") - val properties = if (file.exists()) { - Settings.load(file.inputStream()) - } else { - logger.debug { "Property file not found; defaulting to internal." } - Settings.load(Main::class.java.getResourceAsStream("/$PROPERTY_FILE_NAME")!!) - } + val properties = Settings.load() properties.putAll(System.getenv()) return@timed properties } diff --git a/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts b/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts index 2255c8e9b..5cd3b6a79 100644 --- a/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts +++ b/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts @@ -4,9 +4,12 @@ import kotlinx.coroutines.* import world.gregs.voidps.engine.Contexts import world.gregs.voidps.engine.client.PlayerAccountLoader import world.gregs.voidps.engine.client.ui.event.adminCommand +import world.gregs.voidps.engine.data.AccountManager +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.definition.AreaDefinitions import world.gregs.voidps.engine.data.definition.EnumDefinitions import world.gregs.voidps.engine.data.definition.StructDefinitions +import world.gregs.voidps.engine.entity.MAX_PLAYERS import world.gregs.voidps.engine.entity.World import world.gregs.voidps.engine.entity.character.move.running import world.gregs.voidps.engine.entity.character.player.Player @@ -15,7 +18,7 @@ import world.gregs.voidps.engine.entity.character.player.sex import world.gregs.voidps.engine.entity.worldSpawn import world.gregs.voidps.engine.event.Event import world.gregs.voidps.engine.event.Events -import world.gregs.voidps.engine.getIntProperty +import world.gregs.voidps.engine.get import world.gregs.voidps.engine.inject import world.gregs.voidps.engine.inv.add import world.gregs.voidps.engine.inv.inventory @@ -32,7 +35,7 @@ import kotlin.reflect.KClass val areas: AreaDefinitions by inject() val lumbridge = areas["lumbridge_teleport"] -val botCount = getIntProperty("bots", 0) +val botCount = Settings["bots", 0] val bots = mutableListOf() val enums: EnumDefinitions by inject() @@ -77,6 +80,16 @@ adminCommand("bots") { } } +adminCommand("clear_bots") { + val count = content.toIntOrNull() ?: MAX_PLAYERS + World.queue("bot_${counter}") { + val manager = get() + for (bot in bots.take(count)) { + manager.logout(bot, false) + } + } +} + adminCommand("bot") { if (player.isBot) { player.clear("bot") diff --git a/game/src/main/kotlin/world/gregs/voidps/bot/navigation/graph/NavigationGraph.kt b/game/src/main/kotlin/world/gregs/voidps/bot/navigation/graph/NavigationGraph.kt index f1fcdb351..f1144803d 100644 --- a/game/src/main/kotlin/world/gregs/voidps/bot/navigation/graph/NavigationGraph.kt +++ b/game/src/main/kotlin/world/gregs/voidps/bot/navigation/graph/NavigationGraph.kt @@ -2,12 +2,12 @@ package world.gregs.voidps.bot.navigation.graph import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.definition.AreaDefinition import world.gregs.voidps.engine.data.definition.AreaDefinitions import world.gregs.voidps.engine.data.definition.ObjectDefinitions import world.gregs.voidps.engine.entity.obj.GameObject import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.voidps.network.client.Instruction import world.gregs.voidps.network.client.instruction.InteractObject @@ -47,7 +47,7 @@ class NavigationGraph( } @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = getProperty("navGraphPath")): NavigationGraph { + fun load(yaml: Yaml = get(), path: String = Settings["navGraphPath"]): NavigationGraph { timedLoad("ai nav graph edge") { val config = object : YamlReaderConfiguration(2, 2) { override fun add(list: MutableList, value: Any, parentMap: String?) { diff --git a/game/src/main/kotlin/world/gregs/voidps/script/ScriptLoader.kt b/game/src/main/kotlin/world/gregs/voidps/script/ScriptLoader.kt index 2b5c9c442..69b3239be 100644 --- a/game/src/main/kotlin/world/gregs/voidps/script/ScriptLoader.kt +++ b/game/src/main/kotlin/world/gregs/voidps/script/ScriptLoader.kt @@ -4,12 +4,12 @@ import com.github.michaelbull.logging.InlineLogger import io.github.classgraph.ClassGraph import world.gregs.voidps.Main import world.gregs.voidps.engine.client.ui.chat.plural -import world.gregs.voidps.engine.getProperty +import world.gregs.voidps.engine.data.Settings import kotlin.system.measureTimeMillis private val logger = InlineLogger("ScriptLoader") -fun loadScripts(scriptPackage: String = getProperty("scriptPackage"), botScriptPackage: String = getProperty("botScriptPackage")) { +fun loadScripts(scriptPackage: String = Settings["scriptPackage"], botScriptPackage: String = Settings["botScriptPackage"]) { var scriptCount = 0 val found = mutableSetOf() val isJar = Main::class.java.getResource("${Main::class.simpleName}.class")?.protocol == "jar" diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts index ce1e0cc2f..2adcb524b 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts @@ -4,7 +4,9 @@ import com.github.michaelbull.logging.InlineLogger import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.ui.chat.plural import world.gregs.voidps.engine.client.variable.start +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.definition.data.Rock +import world.gregs.voidps.engine.data.settingsReload import world.gregs.voidps.engine.entity.World import world.gregs.voidps.engine.entity.character.exactMove import world.gregs.voidps.engine.entity.character.mode.interact.Interact @@ -21,7 +23,6 @@ import world.gregs.voidps.engine.entity.obj.* import world.gregs.voidps.engine.entity.objectDespawn import world.gregs.voidps.engine.entity.playerSpawn import world.gregs.voidps.engine.entity.worldSpawn -import world.gregs.voidps.engine.getPropertyOrNull import world.gregs.voidps.engine.inject import world.gregs.voidps.engine.inv.add import world.gregs.voidps.engine.inv.inventory @@ -53,14 +54,21 @@ val objects: GameObjects by inject() val npcs: NPCs by inject() val players: Players by inject() val logger = InlineLogger() -val active = getPropertyOrNull("shootingStars") == "true" worldSpawn { - if (active) { + if (Settings["shootingStars", false]) { eventUpdate() } } +settingsReload { + if (Settings["shootingStars", false] && !World.contains("shooting_star_event_timer")) { + eventUpdate() + } else if (!Settings["shootingStars", false] && World.contains("shooting_star_event_timer")) { + World.clearQueue("shooting_star_event_timer") + } +} + fun eventUpdate() { World.queue("shooting_star_event_timer", startEvent) { if (currentStarTile != Tile.EMPTY) { @@ -224,7 +232,7 @@ npcOperate("Talk-to", "star_sprite") { messageBuilder.append(", $amount ${reward.replace("_", " ").replace("noted", "").plural(amount)}") } } - if(!ShootingStarHandler.rewardPlayerBonusOre(player)) { + if (!ShootingStarHandler.rewardPlayerBonusOre(player)) { npc("I have rewarded you by making it so you can mine extra ore for the next 15 minutes, ${messageBuilder}.") givePlayerBonusOreReward(player) } else { diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/Books.kt b/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/Books.kt index 1a0c38ec7..18481d971 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/Books.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/Books.kt @@ -1,9 +1,9 @@ package world.gregs.voidps.world.activity.quest import world.gregs.voidps.engine.client.ui.open +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml import world.gregs.yaml.read.YamlReaderConfiguration @@ -21,7 +21,7 @@ class Books { fun title(name: String) = titles.getOrDefault(name, "") @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = getProperty("bookPath")): Books { + fun load(yaml: Yaml = get(), path: String = Settings["bookPath"]): Books { timedLoad("book") { val config = object : YamlReaderConfiguration(2, 2) { override fun add(list: MutableList, value: Any, parentMap: String?) { diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/agility/course/BarbarianOutpost.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/agility/course/BarbarianOutpost.kts index 6cecc994b..83477cb80 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/agility/course/BarbarianOutpost.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/agility/course/BarbarianOutpost.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.activity.skill.agility.course import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.variable.start +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.exactMove import world.gregs.voidps.engine.entity.character.face import world.gregs.voidps.engine.entity.character.move.tele @@ -15,7 +16,6 @@ import world.gregs.voidps.engine.entity.character.player.skill.level.Level import world.gregs.voidps.engine.entity.character.player.skill.level.Level.has import world.gregs.voidps.engine.entity.character.setAnimation import world.gregs.voidps.engine.entity.obj.objectOperate -import world.gregs.voidps.engine.getPropertyOrNull import world.gregs.voidps.engine.queue.strongQueue import world.gregs.voidps.type.Direction import world.gregs.voidps.type.Tile @@ -48,7 +48,7 @@ objectOperate("Swing-on", "barbarian_outpost_rope_swing") { player.walkTo(player.tile.copy(y = 3554)) player.clear("face_entity") player.face(Direction.SOUTH) - val disable = getPropertyOrNull("disableAdvancedAgilityCourseFailure").toBoolean() + val disable = Settings["disableAdvancedAgilityCourseFailure", false] val success = disable || Level.success(player.levels.get(Skill.Agility), 70) // 50% success at 35 // player.message("The rope swing is being used at the moment.", ChatType.Filter) player.start("input_delay", if (success) 5 else 8) @@ -70,7 +70,7 @@ objectOperate("Swing-on", "barbarian_outpost_rope_swing") { player.walkTo(player.tile.copy(y = 9949), noCollision = true, noRun = true) // player.message("", ChatType.Filter) TODO } - if (success || getPropertyOrNull("disableAdvancedAgilityCourseFailLapSkip").toBoolean()) { + if (success || Settings["disableAdvancedAgilityCourseFailLapSkip", false]) { player.agilityStage(1) } } @@ -78,7 +78,7 @@ objectOperate("Swing-on", "barbarian_outpost_rope_swing") { objectOperate("Walk-across", "barbarian_outpost_log_balance") { player.start("input_delay", 12) - val disable = getPropertyOrNull("disableAdvancedAgilityCourseFailure").toBoolean() + val disable = Settings["disableAdvancedAgilityCourseFailure", false] val success = disable || Level.success(player.levels.get(Skill.Agility), 93) // 62.1% success rate at 35 player.strongQueue("agility_log_balance") { onCancel = { @@ -111,7 +111,7 @@ objectOperate("Walk-across", "barbarian_outpost_log_balance") { player.clearRenderEmote() player.damage(random.nextInt(30, 52)) } - if (success || getPropertyOrNull("disableAdvancedAgilityCourseFailLapSkip").toBoolean()) { + if (success || Settings["disableAdvancedAgilityCourseFailLapSkip", false]) { player.agilityStage(2) } } @@ -131,7 +131,7 @@ objectOperate("Climb-over", "barbarian_outpost_obstacle_net") { objectOperate("Walk-across", "barbarian_outpost_balancing_ledge") { player.start("input_delay", 6) player.setAnimation("ledge_stand_right") - val disable = getPropertyOrNull("disableAdvancedAgilityCourseFailure").toBoolean() + val disable = Settings["disableAdvancedAgilityCourseFailure", false] val success = disable || Level.success(player.levels.get(Skill.Agility), 93) // 62.1% success rate player.strongQueue("agility_ledge_balance", 1) { onCancel = { @@ -166,7 +166,7 @@ objectOperate("Walk-across", "barbarian_outpost_balancing_ledge") { // player.message("", ChatType.Filter) // TODO // Skip stage so lap doesn't count at end } - if (success || getPropertyOrNull("disableAdvancedAgilityCourseFailLapSkip").toBoolean()) { + if (success || Settings["disableAdvancedAgilityCourseFailLapSkip", false]) { player.agilityStage(4) } } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/agility/course/GnomeAdvanced.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/agility/course/GnomeAdvanced.kts index f34e5a242..4292acc3d 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/agility/course/GnomeAdvanced.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/agility/course/GnomeAdvanced.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.activity.skill.agility.course import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.variable.start +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.* import world.gregs.voidps.engine.entity.character.move.tele import world.gregs.voidps.engine.entity.character.npc.NPCs @@ -12,7 +13,6 @@ import world.gregs.voidps.engine.entity.character.player.skill.level.Level import world.gregs.voidps.engine.entity.character.player.skill.level.Level.has import world.gregs.voidps.engine.entity.obj.objectApproach import world.gregs.voidps.engine.entity.obj.objectOperate -import world.gregs.voidps.engine.getPropertyOrNull import world.gregs.voidps.engine.inject import world.gregs.voidps.engine.queue.strongQueue import world.gregs.voidps.engine.suspend.approachRange @@ -50,7 +50,7 @@ objectApproach("Run-across", "gnome_sign_post_advanced") { // Pausing for 2 ticks to ensure we're in the correct spot. // arriveDelay() wouldn't work as objectApproach is called before Movement.tick where "last_movement" is set pause(2) - val disable = getPropertyOrNull("disableAdvancedAgilityCourseFailure").toBoolean() + val disable = Settings["disableAdvancedAgilityCourseFailure", false] val success = disable || Level.success(player.levels.get(Skill.Agility), -8..286) // failure rate 4.68-1.17% from 85-88 player.face(Direction.EAST) player.setAnimation("gnome_wall_${if (success) "run" else "fail"}") @@ -74,7 +74,7 @@ objectApproach("Run-across", "gnome_sign_post_advanced") { player.damage((player.levels.get(Skill.Constitution) - 10).coerceAtMost(65)) } // Skip stage so lap doesn't count at end - if (success || getPropertyOrNull("disableAdvancedAgilityCourseFailLapSkip").toBoolean()) { + if (success || Settings["disableAdvancedAgilityCourseFailLapSkip", false]) { player.agilityStage(5) } player.clearAnimation() diff --git a/game/src/main/kotlin/world/gregs/voidps/world/command/admin/AdminCommands.kts b/game/src/main/kotlin/world/gregs/voidps/world/command/admin/AdminCommands.kts index 041247ddc..9f8fb5aec 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/command/admin/AdminCommands.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/command/admin/AdminCommands.kts @@ -23,6 +23,8 @@ import world.gregs.voidps.engine.client.ui.open import world.gregs.voidps.engine.client.ui.playTrack import world.gregs.voidps.engine.client.variable.start import world.gregs.voidps.engine.data.SaveQueue +import world.gregs.voidps.engine.data.Settings +import world.gregs.voidps.engine.data.SettingsReload import world.gregs.voidps.engine.data.definition.* import world.gregs.voidps.engine.entity.World import world.gregs.voidps.engine.entity.character.move.tele @@ -114,12 +116,14 @@ adminCommand("npc") { return@adminCommand } val npcs: NPCs = get() - println(""" + println( + """ - name: $content x: ${player.tile.x} y: ${player.tile.y} level: ${player.tile.level} - """.trimIndent()) + """.trimIndent() + ) val npc = npcs.add(definition.stringId, player.tile, Direction.NORTH) npc?.start("movement_delay", -1) } @@ -375,6 +379,10 @@ adminCommand("reload") { "prayers" -> get().load() "drops" -> get().load() "cs2", "cs2s", "client scripts" -> get().load() + "settings", "setting", "game setting", "game settings", "games settings", "properties", "props" -> { + Settings.load() + World.emit(SettingsReload) + } } } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/community/Rights.kts b/game/src/main/kotlin/world/gregs/voidps/world/community/Rights.kts index 3d45b0801..107c6e909 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/community/Rights.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/community/Rights.kts @@ -3,18 +3,16 @@ package world.gregs.voidps.world.community import net.pearx.kasechange.toSentenceCase import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.ui.event.adminCommand +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.player.PlayerRights import world.gregs.voidps.engine.entity.character.player.Players import world.gregs.voidps.engine.entity.character.player.name import world.gregs.voidps.engine.entity.character.player.rights import world.gregs.voidps.engine.entity.playerSpawn import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getPropertyOrNull - -val adminName = getPropertyOrNull("admin") playerSpawn { player -> - if (player.name == adminName && player.rights != PlayerRights.Admin) { + if (player.name == Settings.getOrNull("admin") && player.rights != PlayerRights.Admin) { player.rights = PlayerRights.Admin player.message("Rights set to Admin. Please re-log to activate.") } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/Movement.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/Movement.kts index ae605806f..9e4da4535 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/Movement.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/Movement.kts @@ -1,6 +1,7 @@ package world.gregs.voidps.world.interact.entity import org.rsmod.game.pathfinder.flag.CollisionFlag +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.Character import world.gregs.voidps.engine.entity.character.mode.move.move import world.gregs.voidps.engine.entity.character.mode.move.npcMove @@ -11,7 +12,6 @@ import world.gregs.voidps.engine.entity.character.size import world.gregs.voidps.engine.entity.characterDespawn import world.gregs.voidps.engine.entity.npcSpawn import world.gregs.voidps.engine.entity.playerSpawn -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.inject import world.gregs.voidps.engine.map.collision.Collisions import world.gregs.voidps.type.Tile @@ -21,16 +21,15 @@ import world.gregs.voidps.world.interact.entity.death.npcDeath val collisions: Collisions by inject() val npcs: NPCs by inject() val players: Players by inject() -val active = getProperty("characterCollision") == "true" playerSpawn { player -> - if (players.add(player) && active) { + if (players.add(player) && Settings["characterCollision", false]) { add(player) } } npcSpawn { npc -> - if (active) { + if (Settings["characterCollision", false]) { add(npc) } } @@ -40,19 +39,19 @@ npcDeath { npc -> } characterDespawn { character -> - if (active) { + if (Settings["characterCollision", false]) { remove(character) } } move { - if (active) { + if (Settings["characterCollision", false]) { move(character, from, to) } } npcMove { - if (active && !character.dead) { + if (Settings["characterCollision", false] && !character.dead) { move(character, from, to) } npcs.update(from, to, npc) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/combat/hit/CombatHitsplats.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/combat/hit/CombatHitsplats.kts index 57263ab61..f30311353 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/combat/hit/CombatHitsplats.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/combat/hit/CombatHitsplats.kts @@ -1,9 +1,9 @@ package world.gregs.voidps.world.interact.entity.combat.hit +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.definition.SpellDefinitions import world.gregs.voidps.engine.entity.character.hit import world.gregs.voidps.engine.entity.character.player.skill.Skill -import world.gregs.voidps.engine.getPropertyOrNull import world.gregs.voidps.engine.inject import world.gregs.voidps.network.login.protocol.visual.update.Hitsplat import world.gregs.voidps.world.interact.entity.combat.damageDealers @@ -12,21 +12,18 @@ import kotlin.math.floor val definitions: SpellDefinitions by inject() -val showSoak = getPropertyOrNull("showSoak") == "true" -val damageSoak = getPropertyOrNull("damageSoak") == "true" - characterCombatHit { character -> if (damage < 0 || type == "magic" && definitions.get(spell).maxHit == -1 || type == "healed") { return@characterCombatHit } var damage = damage var soak = 0 - if (damageSoak && damage > 200) { + if (Settings["damageSoak", true] && damage > 200) { val percent = character["absorb_$type", 10] / 100.0 soak = floor((damage - 200) * percent).toInt() damage -= soak } - if (showSoak || soak <= 0) { + if (Settings["showSoak", true] || soak <= 0) { soak = -1 } val dealers = character.damageDealers diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/PlayerDeath.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/PlayerDeath.kts index 853f96ef2..d18006b06 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/PlayerDeath.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/PlayerDeath.kts @@ -3,6 +3,7 @@ package world.gregs.voidps.world.interact.entity.death import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap import it.unimi.dsi.fastutil.objects.ObjectArrayList import world.gregs.voidps.engine.client.message +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.definition.EnumDefinitions import world.gregs.voidps.engine.entity.character.* import world.gregs.voidps.engine.entity.character.move.tele @@ -14,7 +15,7 @@ import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.entity.characterSpawn import world.gregs.voidps.engine.entity.item.Item import world.gregs.voidps.engine.entity.item.floor.FloorItems -import world.gregs.voidps.engine.getIntProperty +import world.gregs.voidps.engine.get import world.gregs.voidps.engine.inject import world.gregs.voidps.engine.inv.* import world.gregs.voidps.engine.map.Spiral @@ -44,10 +45,8 @@ characterSpawn { character -> val Character.damageDealers: MutableMap get() = getOrPut("damage_dealers") { mutableMapOf() } -val x = getIntProperty("homeX", 0) -val y = getIntProperty("homeY", 0) -val level = getIntProperty("homeLevel", 0) -val respawnTile = Tile(x, y, level) +val respawnTile: Tile + get() = Tile(Settings["homeX", 0], Settings["homeY", 0], Settings["homeLevel", 0]) playerDeath { player -> player.dead = true diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/obj/Teleports.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/obj/Teleports.kt index 7369b9b08..091f74ed9 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/obj/Teleports.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/obj/Teleports.kt @@ -3,12 +3,12 @@ package world.gregs.voidps.world.interact.entity.obj import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import world.gregs.voidps.cache.definition.data.ObjectDefinition +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.move.tele import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.obj.ObjectOption import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.suspend.delay import world.gregs.voidps.engine.timedLoad import world.gregs.voidps.type.Delta @@ -71,7 +71,7 @@ class Teleports { } @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = getProperty("teleportsPath")): Teleports { + fun load(yaml: Yaml = get(), path: String = Settings["teleportsPath"]): Teleports { timedLoad("object teleport") { val config = object : YamlReaderConfiguration() { override fun add(list: MutableList, value: Any, parentMap: String?) { diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/music/MusicTracks.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/music/MusicTracks.kt index 5426a13b6..75059d57d 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/music/MusicTracks.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/music/MusicTracks.kt @@ -3,8 +3,8 @@ package world.gregs.voidps.world.interact.entity.player.music import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap import it.unimi.dsi.fastutil.objects.ObjectArrayList +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.engine.timedLoad import world.gregs.voidps.type.Area import world.gregs.voidps.type.Region @@ -24,7 +24,7 @@ class MusicTracks { } @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = getProperty("musicPath")): MusicTracks { + fun load(yaml: Yaml = get(), path: String = Settings["musicPath"]): MusicTracks { timedLoad("music track") { var count = 0 val tracks = Int2ObjectOpenHashMap>() diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/ItemSpawns.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/ItemSpawns.kt index 92ddb75be..2e4386e43 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/ItemSpawns.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/ItemSpawns.kt @@ -1,10 +1,10 @@ package world.gregs.voidps.world.interact.world.spawn import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.World import world.gregs.voidps.engine.entity.item.floor.FloorItems import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.type.Tile import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -32,7 +32,7 @@ fun loadItemSpawns( items: FloorItems, spawns: ItemSpawns, yaml: Yaml = get(), - path: String = getProperty("itemSpawnsPath") + path: String = Settings["itemSpawnsPath"] ) { timedLoad("item spawn") { spawns.clear() diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/NPCSpawns.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/NPCSpawns.kt index 7a15063bf..8f843394b 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/NPCSpawns.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/NPCSpawns.kt @@ -1,10 +1,10 @@ package world.gregs.voidps.world.interact.world.spawn +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.type.Direction import world.gregs.voidps.engine.entity.World import world.gregs.voidps.engine.entity.character.npc.NPCs import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.type.Tile import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -14,7 +14,7 @@ import world.gregs.yaml.read.YamlReaderConfiguration fun loadNpcSpawns( npcs: NPCs, yaml: Yaml = get(), - path: String = getProperty("npcSpawnsPath") + path: String = Settings["npcSpawnsPath"] ) { timedLoad("npc spawn") { npcs.clear() diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/ObjectSpawns.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/ObjectSpawns.kt index c170681fe..a219cf175 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/ObjectSpawns.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/ObjectSpawns.kt @@ -1,11 +1,11 @@ package world.gregs.voidps.world.interact.world.spawn +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.definition.ObjectDefinitions import world.gregs.voidps.engine.entity.World import world.gregs.voidps.engine.entity.obj.GameObject import world.gregs.voidps.engine.entity.obj.GameObjects import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.getProperty import world.gregs.voidps.type.Tile import world.gregs.voidps.engine.timedLoad import world.gregs.yaml.Yaml @@ -15,7 +15,7 @@ import world.gregs.yaml.read.YamlReaderConfiguration fun loadObjectSpawns( objects: GameObjects, yaml: Yaml = get(), - path: String = getProperty("objectsPath"), + path: String = Settings["objectsPath"], definitions: ObjectDefinitions = get(), ) = timedLoad("object spawn") { objects.reset() diff --git a/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt index 9b10eea00..dc750fc6a 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt @@ -187,7 +187,7 @@ abstract class WorldTest : KoinTest { } loadScripts() MapDefinitions(CollisionDecoder(get()), get(), get(), cache).loadCache() - saves = File(getProperty("savePath")) + saves = File(Settings["savePath"]) saves?.mkdirs() val millis = measureTimeMillis { val handler = InterfaceHandler(get(), get(), get()) @@ -252,7 +252,7 @@ abstract class WorldTest : KoinTest { } companion object { - private val cache: Cache by lazy { MemoryCache(getProperty("cachePath")) } + private val cache: Cache by lazy { MemoryCache(Settings["cachePath"]) } private val huffman: Huffman by lazy { Huffman().load(cache.data(Index.HUFFMAN, 1)!!) } private val ammoDefinitions: AmmoDefinitions by lazy { AmmoDefinitions().load() } private val parameterDefinitions: ParameterDefinitions by lazy { ParameterDefinitions(CategoryDefinitions().load(), ammoDefinitions).load() } diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/EnumDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/EnumDefinitions.kt index 31f5d507c..c6517c29a 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/EnumDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/EnumDefinitions.kt @@ -3,6 +3,7 @@ package world.gregs.voidps.tools import world.gregs.voidps.cache.Cache import world.gregs.voidps.cache.CacheDelegate import world.gregs.voidps.cache.definition.decoder.EnumDecoder +import world.gregs.voidps.engine.data.Settings object EnumDefinitions { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/Properties.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/Properties.kt index ce6d1b06e..5b70e35a0 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/Properties.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/Properties.kt @@ -1,18 +1,18 @@ package world.gregs.voidps.tools -import java.io.File +import java.io.FileInputStream +import java.util.Properties +private val properties: Properties by lazy { + Properties().apply { + load(FileInputStream("./game/src/test/resources/test.properties")) + } +} fun property(name: String): String { - return File("./game/src/test/resources/test.properties") - .readLines() - .first { it.startsWith(name) } - .split("=")[1].replace("../", "./") + return properties.getProperty(name).replace("../", "./") } fun propertyOrNull(name: String): String? { - return (File("./game/src/test/resources/test.properties") - .readLines() - .firstOrNull { it.startsWith(name) } ?: return null) - .split("=")[1].replace("../", "./") + return properties.getProperty(name)?.replace("../", "./") } diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/Xteas.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/Xteas.kt index 322c9cb83..e9fd8a3d9 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/Xteas.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/Xteas.kt @@ -2,8 +2,7 @@ package world.gregs.voidps.tools.cache import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import world.gregs.voidps.buffer.read.BufferReader -import world.gregs.voidps.engine.getProperty -import world.gregs.voidps.engine.getPropertyOrNull +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.timedLoad import world.gregs.voidps.type.Region import world.gregs.yaml.Yaml @@ -18,9 +17,9 @@ data class Xteas( } fun load( - path: String = getProperty("xteaPath"), - key: String = getPropertyOrNull("xteaJsonKey") ?: DEFAULT_KEY, - value: String = getPropertyOrNull("xteaJsonValue") ?: DEFAULT_VALUE + path: String = Settings["xteaPath"], + key: String = Settings["xteaJsonKey", DEFAULT_KEY], + value: String = Settings["xteaJsonValue", DEFAULT_VALUE] ): Xteas { timedLoad("xtea") { val file = File(path) From fbef3d100a7bb77de394db84e302a8180d4c2968 Mon Sep 17 00:00:00 2001 From: GregHib Date: Thu, 9 Jan 2025 21:40:19 +0000 Subject: [PATCH 07/25] Fix incorrect inject() usages --- .../voidps/world/interact/entity/gfx/SpawnGraphic.kt | 5 ++--- .../world/interact/entity/npc/shop/GeneralStores.kt | 9 +++------ .../gregs/voidps/world/interact/entity/npc/shop/Price.kt | 9 ++++----- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/gfx/SpawnGraphic.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/gfx/SpawnGraphic.kt index b00be0ff2..ac7cff528 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/gfx/SpawnGraphic.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/gfx/SpawnGraphic.kt @@ -2,6 +2,7 @@ package world.gregs.voidps.world.interact.entity.gfx import world.gregs.voidps.engine.client.update.batch.ZoneBatchUpdates import world.gregs.voidps.engine.data.definition.GraphicDefinitions +import world.gregs.voidps.engine.get import world.gregs.voidps.engine.inject import world.gregs.voidps.network.login.protocol.encode.zone.GraphicAddition import world.gregs.voidps.type.Direction @@ -14,7 +15,5 @@ fun areaGraphic( height: Int = 0, rotation: Direction = Direction.SOUTH ) { - val batches: ZoneBatchUpdates by inject() - val definitions: GraphicDefinitions by inject() - batches.add(tile.zone, GraphicAddition(tile.id, definitions.get(id).id, height, delay, rotation.ordinal)) + get().add(tile.zone, GraphicAddition(tile.id, get().get(id).id, height, delay, rotation.ordinal)) } \ No newline at end of file diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/shop/GeneralStores.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/shop/GeneralStores.kt index e535bdcdc..4895ff10e 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/shop/GeneralStores.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/shop/GeneralStores.kt @@ -4,7 +4,7 @@ import world.gregs.voidps.engine.data.definition.InventoryDefinitions import world.gregs.voidps.engine.data.definition.ItemDefinitions import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.item.Item -import world.gregs.voidps.engine.inject +import world.gregs.voidps.engine.get import world.gregs.voidps.engine.inv.Inventory import world.gregs.voidps.engine.inv.remove.ItemIndexAmountBounds import world.gregs.voidps.engine.inv.sendInventory @@ -12,13 +12,10 @@ import world.gregs.voidps.engine.inv.stack.AlwaysStack object GeneralStores { - private val inventoryDefinitions: InventoryDefinitions by inject() - private val itemDefs: ItemDefinitions by inject() - val stores: MutableMap = mutableMapOf() fun get(key: String) = stores.getOrPut(key) { - val definition = inventoryDefinitions.get(key) + val definition = get().get(key) val minimumQuantities = IntArray(definition.length) { if (definition.getOrNull>>("defaults")?.getOrNull(it) != null) -1 else 0 } @@ -32,7 +29,7 @@ object GeneralStores { ) }, id = key, - itemRule = GeneralStoreRestrictions(itemDefs), + itemRule = GeneralStoreRestrictions(get()), stackRule = AlwaysStack, amountBounds = checker ) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/shop/Price.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/shop/Price.kt index 2f2030a9b..abcd8c5aa 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/shop/Price.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/shop/Price.kt @@ -3,16 +3,14 @@ package world.gregs.voidps.world.interact.entity.npc.shop import world.gregs.voidps.engine.data.definition.EnumDefinitions import world.gregs.voidps.engine.data.definition.ItemDefinitions import world.gregs.voidps.engine.entity.character.player.Player +import world.gregs.voidps.engine.get import world.gregs.voidps.engine.inject import kotlin.math.max import kotlin.math.min object Price { - private val itemDefs: ItemDefinitions by inject() - private val enums: EnumDefinitions by inject() - private fun getRealItem(item: String): Int { - val def = itemDefs.get(item) + val def = get().get(item) if (def.noted) { return def.noteId } @@ -21,6 +19,7 @@ object Price { fun getPrice(player: Player, item: String, index: Int, amount: Int): Int { val itemId = getRealItem(item) + val enums = get() var price = enums.get("price_runes").getInt(itemId) if (player["shop_currency", "coins"] == "tokkul" && price != -1 && price > 0) { return price @@ -29,7 +28,7 @@ object Price { if (price != -1 && price > 0) { return price } - val def = itemDefs.get(itemId) + val def = get().get(itemId) if (def.contains("skill_cape") || def.contains("skill_cape_t")) { return 99000 } From 7e4486f96fe8bb600b2e2134b46cac8e59aa690c Mon Sep 17 00:00:00 2001 From: GregHib Date: Thu, 9 Jan 2025 21:42:10 +0000 Subject: [PATCH 08/25] Convert properties to Settings --- .../world/gregs/voidps/engine/EngineModules.kt | 6 +++--- .../world/gregs/voidps/engine/data/Settings.kt | 5 +++++ .../kotlin/world/gregs/voidps/engine/entity/World.kt | 2 +- .../player/combat/magic/spell/CombinationRuneTest.kt | 2 -- .../entity/player/combat/magic/spell/SpellTest.kt | 4 ++++ .../world/gregs/voidps/world/script/WorldTest.kt | 12 ++++++++---- .../world/gregs/voidps/tools/DropTableDefinitions.kt | 3 ++- .../gregs/voidps/tools/map/render/WorldMapDumper.kt | 5 +++-- 8 files changed, 26 insertions(+), 13 deletions(-) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt index 32fc4c9db..fde908a0f 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt @@ -33,12 +33,12 @@ val engineModule = module { // Entities single { NPCs(get(), get(), get(), get()) } single { Players() } - single { GameObjects(get(), get(), get(), get(), getProperty("loadUnusedObjects") == "true").apply { get().register(this) } } + single { GameObjects(get(), get(), get(), get(), Settings["loadUnusedObjects", false]).apply { get().register(this) } } single { FloorItems(get(), get()).apply { get().register(this) } } single { FloorItemTracking(get(), get(), get()) } single { Hunting(get(), get(), get(), get(), get(), get()) } single { - SaveQueue(get(), SafeStorage(File(getProperty("storageFailDirectory")))) + SaveQueue(get(), SafeStorage(File(Settings["storageFailDirectory"]))) } single { val homeTile = Tile( @@ -61,7 +61,7 @@ val engineModule = module { val definitions: ItemDefinitions = get() DatabaseStorage { definitions.get(it) } } else { - val saves = File(getProperty("savePath")) + val saves = File(Settings["savePath"]) if (!saves.exists()) { saves.mkdir() } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/Settings.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/Settings.kt index 37642d6f6..92972ce8e 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/Settings.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/Settings.kt @@ -22,6 +22,11 @@ open class Settings { return properties } + fun load(properties: Properties): Properties { + this.properties.putAll(properties) + return this.properties + } + fun getOrNull(name: String): String? = properties.getProperty(name) operator fun get(name: String): String = properties.getProperty(name) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt index 449f33d14..fa7e3d898 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt @@ -26,7 +26,7 @@ object World : Entity, Variable, EventDispatcher, Runnable, KoinComponent { val name: String get() = "World $id" val members: Boolean - get() = Settings["members", false] + get() = Settings["members", true] fun start() { emit(Spawn) diff --git a/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/CombinationRuneTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/CombinationRuneTest.kt index ee9103409..33b4d5b6e 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/CombinationRuneTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/CombinationRuneTest.kt @@ -22,7 +22,6 @@ class CombinationRuneTest : MagicSpellTest() { Triple("lava_rune", "earth_rune", "fire_rune") ).map { (combo, element1, element2) -> dynamicTest("Remove ${combo.replace("_", " ")}s") { - Settings.load(mapOf("members" to "true")) World.start() val player = player() setItems(Item(element1, 2), Item(element2, 1), Item("chaos_rune", 1)) @@ -52,7 +51,6 @@ class CombinationRuneTest : MagicSpellTest() { "lava_rune" to "fire_rune" ).map { (combo, element) -> dynamicTest("Use ${element.replace("_", " ")}s when out of ${combo.replace("_", " ")}s") { - Settings.load(mapOf("members" to "true")) World.start() val player = player() setItems(Item(element, 2)) diff --git a/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/SpellTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/SpellTest.kt index 02accba38..7a4abac3f 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/SpellTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/SpellTest.kt @@ -5,6 +5,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ValueSource import world.gregs.voidps.cache.definition.data.ItemDefinition +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.World import world.gregs.voidps.engine.entity.character.player.equip.equipped import world.gregs.voidps.engine.entity.character.player.skill.Skill @@ -45,13 +46,16 @@ class SpellTest : MagicSpellTest() { @Test fun `Members spell`() { + Settings.load(mapOf("members" to "false")) World.start() + val player = player() setItems(Item("blood_rune", 1) to ItemDefinition(stringId = "blood_rune", members = true)) player.inventory.add("blood_rune", 10) assertFalse(player.hasSpellItems("spell", message = false)) assertFalse(player.removeSpellItems("spell")) + Settings.clear() } @Test diff --git a/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt index dc750fc6a..5b3adb121 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt @@ -56,6 +56,7 @@ import world.gregs.voidps.world.interact.world.spawn.loadItemSpawns import world.gregs.voidps.world.interact.world.spawn.loadNpcSpawns import world.gregs.voidps.world.interact.world.spawn.loadObjectSpawns import java.io.File +import java.util.Properties import kotlin.system.measureTimeMillis /** @@ -74,8 +75,8 @@ abstract class WorldTest : KoinTest { private lateinit var accountDefs: AccountDefinitions private lateinit var accounts: AccountManager private var saves: File? = null - - val extraProperties: MutableMap = mutableMapOf() + private lateinit var properties: Properties + lateinit var settings: Properties open var loadNpcs: Boolean = false @@ -148,11 +149,12 @@ abstract class WorldTest : KoinTest { @BeforeAll fun beforeAll() { Main.name = "test" - Settings.load(WorldTest::class.java.getResourceAsStream("/test.properties")!!) + properties = Properties() + properties.load(WorldTest::class.java.getResourceAsStream("/test.properties")!!) + Settings.load(properties) stopKoin() startKoin { printLogger(Level.ERROR) - properties(extraProperties) allowOverride(true) modules(engineModule, gameModule, module { single(createdAtStart = true) { cache } @@ -226,6 +228,7 @@ abstract class WorldTest : KoinTest { @BeforeEach fun beforeEach() { + settings = Settings.load(properties) loadItemSpawns(floorItems, get()) if (loadNpcs) { loadNpcSpawns(npcs) @@ -241,6 +244,7 @@ abstract class WorldTest : KoinTest { floorItems.clear() objects.reset() World.clear() + Settings.clear() } @AfterAll diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/DropTableDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/DropTableDefinitions.kt index 13bd933ad..f3118c909 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/DropTableDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/DropTableDefinitions.kt @@ -6,6 +6,7 @@ import org.koin.fileProperties import world.gregs.voidps.cache.Cache import world.gregs.voidps.cache.CacheDelegate import world.gregs.voidps.cache.definition.decoder.ItemDecoder +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.definition.ItemDefinitions import world.gregs.voidps.engine.entity.item.drop.DropTables import world.gregs.voidps.engine.entity.item.drop.ItemDrop @@ -20,7 +21,7 @@ object DropTableDefinitions { fileProperties("/tool.properties") modules(module { @Suppress("USELESS_CAST") - single { CacheDelegate(getProperty("cachePath")) as Cache } + single { CacheDelegate(Settings["cachePath"]) as Cache } single { ItemDefinitions(ItemDecoder().load(get())).load(Yaml()) } }) } diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/WorldMapDumper.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/WorldMapDumper.kt index 7e6ec87b2..24deb9cac 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/WorldMapDumper.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/WorldMapDumper.kt @@ -10,6 +10,7 @@ import world.gregs.voidps.cache.config.decoder.OverlayDecoder import world.gregs.voidps.cache.config.decoder.UnderlayDecoder import world.gregs.voidps.cache.config.decoder.WorldMapInfoDecoder import world.gregs.voidps.cache.definition.decoder.* +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.tools.Pipeline import world.gregs.voidps.tools.cache.Xteas import world.gregs.voidps.tools.map.render.draw.MinimapIconPainter @@ -33,10 +34,10 @@ object WorldMapDumper { fileProperties("/tool.properties") modules( module { - single { MemoryCache(getProperty("cachePath")) as Cache } + single { MemoryCache(Settings["cachePath"]) as Cache } single { MapDecoder(get()) } single(createdAtStart = true) { - Xteas()//.load(getProperty("xteaPath"), getPropertyOrNull("xteaJsonKey") ?: Xteas.DEFAULT_KEY, getPropertyOrNull("xteaJsonValue") ?: Xteas.DEFAULT_VALUE) + Xteas()//.load(Settings["xteaPath"], Settings["xteaJsonKey", Xteas.DEFAULT_KEY], Settings["xteaJsonValue", Xteas.DEFAULT_VALUE]) } }) }.koin From 549843d997ef27c89702be360e5bb2064c834ea6 Mon Sep 17 00:00:00 2001 From: GregHib Date: Thu, 9 Jan 2025 22:29:15 +0000 Subject: [PATCH 09/25] Fix left-over state effecting other tests --- .../world/gregs/voidps/engine/EngineModules.kt | 3 +-- .../world/gregs/voidps/engine/data/Settings.kt | 12 ++++++------ .../voidps/engine/data/sql/DatabaseStorage.kt | 5 +---- .../world/gregs/voidps/engine/entity/World.kt | 2 +- .../engine/client/PlayerAccountLoaderTest.kt | 6 +----- .../entity/character/mode/interact/InteractTest.kt | 1 + .../voidps/engine/entity/obj/GameObjectsTest.kt | 14 ++++++++++---- .../voidps/world/interact/entity/npc/NPCTest.kt | 5 +---- .../combat/magic/spell/CombinationRuneTest.kt | 6 ++++-- .../world/gregs/voidps/world/script/WorldTest.kt | 2 +- 10 files changed, 27 insertions(+), 29 deletions(-) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt index fde908a0f..f3b4f8506 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt @@ -58,8 +58,7 @@ val engineModule = module { Settings["database_jdbc_url"], Settings["database_pool", 2], ) - val definitions: ItemDefinitions = get() - DatabaseStorage { definitions.get(it) } + DatabaseStorage() } else { val saves = File(Settings["savePath"]) if (!saves.exists()) { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/Settings.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/Settings.kt index 92972ce8e..d1b97d22d 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/Settings.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/Settings.kt @@ -33,11 +33,11 @@ open class Settings { operator fun get(name: String, default: String): String = properties.getProperty(name, default) - operator fun get(name: String, default: Int): Int = (properties[name] as? String)?.toIntOrNull() ?: default + operator fun get(name: String, default: Int): Int = getOrNull(name)?.toIntOrNull() ?: default - operator fun get(name: String, default: Double): Double = (properties[name] as? String)?.toDoubleOrNull() ?: default + operator fun get(name: String, default: Double): Double = getOrNull(name)?.toDoubleOrNull() ?: default - operator fun get(name: String, default: Boolean): Boolean = (properties[name] as? String)?.toBooleanStrictOrNull() ?: default + operator fun get(name: String, default: Boolean): Boolean = getOrNull(name)?.toBooleanStrictOrNull() ?: default fun clear() { properties.clear() @@ -47,13 +47,13 @@ open class Settings { private const val PROPERTY_FILE_NAME = "game.properties" private val logger = InlineLogger() - fun load(): Properties { - val file = File("./$PROPERTY_FILE_NAME") + fun load(fileName: String = PROPERTY_FILE_NAME): Properties { + val file = File("./$fileName") return if (file.exists()) { Settings.load(file.inputStream()) } else { logger.debug { "Property file not found; defaulting to internal." } - Settings.load(Settings::class.java.getResourceAsStream("/$PROPERTY_FILE_NAME")!!) + Settings.load(Settings::class.java.getResourceAsStream("/$fileName")!!) } } } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/sql/DatabaseStorage.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/sql/DatabaseStorage.kt index e6ab20ad4..d5d48863e 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/sql/DatabaseStorage.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/sql/DatabaseStorage.kt @@ -5,7 +5,6 @@ import com.zaxxer.hikari.HikariDataSource import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.SqlExpressionBuilder.inList import org.jetbrains.exposed.sql.transactions.transaction -import world.gregs.voidps.cache.definition.data.ItemDefinition import world.gregs.voidps.engine.data.AccountStorage import world.gregs.voidps.engine.data.PlayerSave import world.gregs.voidps.engine.data.config.AccountDefinition @@ -15,9 +14,7 @@ import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.entity.item.Item import world.gregs.voidps.type.Tile -class DatabaseStorage( - private val definitions: (String) -> ItemDefinition = { ItemDefinition.EMPTY } -) : AccountStorage { +class DatabaseStorage : AccountStorage { override fun names(): Map = transaction { val display = VariablesTable.alias("display_name") diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt index fa7e3d898..449f33d14 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt @@ -26,7 +26,7 @@ object World : Entity, Variable, EventDispatcher, Runnable, KoinComponent { val name: String get() = "World $id" val members: Boolean - get() = Settings["members", true] + get() = Settings["members", false] fun start() { emit(Spawn) diff --git a/engine/src/test/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoaderTest.kt b/engine/src/test/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoaderTest.kt index aec15cf48..dbb52f8a8 100644 --- a/engine/src/test/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoaderTest.kt +++ b/engine/src/test/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoaderTest.kt @@ -2,16 +2,12 @@ package world.gregs.voidps.engine.client import io.mockk.* import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test -import world.gregs.voidps.engine.data.AccountManager -import world.gregs.voidps.engine.data.AccountStorage -import world.gregs.voidps.engine.data.PlayerSave -import world.gregs.voidps.engine.data.SaveQueue +import world.gregs.voidps.engine.data.* import world.gregs.voidps.engine.data.config.AccountDefinition import world.gregs.voidps.engine.data.definition.AccountDefinitions import world.gregs.voidps.engine.entity.character.player.Player diff --git a/engine/src/test/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/InteractTest.kt b/engine/src/test/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/InteractTest.kt index bc4141a4b..3080c8861 100644 --- a/engine/src/test/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/InteractTest.kt +++ b/engine/src/test/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/InteractTest.kt @@ -66,6 +66,7 @@ internal class InteractTest : KoinMock() { @BeforeEach fun setup() { + Events.setEvents(Events()) mockkStatic("world.gregs.voidps.engine.client.ui.InterfacesKt") mockkStatic("world.gregs.voidps.engine.client.EncodeExtensionsKt") approached = false diff --git a/engine/src/test/kotlin/world/gregs/voidps/engine/entity/obj/GameObjectsTest.kt b/engine/src/test/kotlin/world/gregs/voidps/engine/entity/obj/GameObjectsTest.kt index 49515f425..0f9c0308d 100644 --- a/engine/src/test/kotlin/world/gregs/voidps/engine/entity/obj/GameObjectsTest.kt +++ b/engine/src/test/kotlin/world/gregs/voidps/engine/entity/obj/GameObjectsTest.kt @@ -1,8 +1,7 @@ package world.gregs.voidps.engine.entity.obj import io.mockk.* -import kotlinx.coroutines.test.TestScope -import kotlinx.coroutines.test.runTest +import org.junit.jupiter.api.AfterAll import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import world.gregs.voidps.cache.definition.data.ObjectDefinition @@ -14,7 +13,6 @@ import world.gregs.voidps.engine.event.Events import world.gregs.voidps.network.login.protocol.encode.zone.ObjectAddition import world.gregs.voidps.network.login.protocol.encode.zone.ObjectRemoval import world.gregs.voidps.type.Tile -import kotlin.coroutines.EmptyCoroutineContext import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertNull @@ -34,7 +32,7 @@ class GameObjectsTest { every { definitions.get("test2") } returns ObjectDefinition(456) updates = mockk(relaxed = true) objects = GameObjects(mockk(relaxed = true), mockk(relaxed = true), updates, definitions, storeUnused = true) - events = spyk(Events(TestScope())) + events = spyk(Events()) Events.setEvents(events) } @@ -241,4 +239,12 @@ class GameObjectsTest { events.emit(replacement, Despawn) } } + + companion object { + @JvmStatic + @AfterAll + fun tearDown() { + Events.setEvents(Events()) + } + } } \ No newline at end of file diff --git a/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/npc/NPCTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/npc/NPCTest.kt index 07b2fae40..cf0a2bca5 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/npc/NPCTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/npc/NPCTest.kt @@ -7,12 +7,9 @@ import world.gregs.voidps.world.script.WorldTest internal class NPCTest : WorldTest() { - init { - extraProperties["randomWalk"] = "true" - } - @Test fun `Man randomly walks around`() { + settings["randomWalk"] = "true" val spawn = emptyTile val npc = createNPC("chicken", spawn) { npc -> npc["area"] = Rectangle(spawn.minus(25, 25), 50, 50) diff --git a/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/CombinationRuneTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/CombinationRuneTest.kt index 33b4d5b6e..16ce9461d 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/CombinationRuneTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/CombinationRuneTest.kt @@ -22,7 +22,7 @@ class CombinationRuneTest : MagicSpellTest() { Triple("lava_rune", "earth_rune", "fire_rune") ).map { (combo, element1, element2) -> dynamicTest("Remove ${combo.replace("_", " ")}s") { - World.start() + Settings.load(mapOf("members" to "true")) val player = player() setItems(Item(element1, 2), Item(element2, 1), Item("chaos_rune", 1)) @@ -32,6 +32,7 @@ class CombinationRuneTest : MagicSpellTest() { assertTrue(player.removeSpellItems("spell")) assertEquals(8, player.inventory.count(combo)) assertEquals(9, player.inventory.count("chaos_rune")) + Settings.clear() } } @@ -51,7 +52,7 @@ class CombinationRuneTest : MagicSpellTest() { "lava_rune" to "fire_rune" ).map { (combo, element) -> dynamicTest("Use ${element.replace("_", " ")}s when out of ${combo.replace("_", " ")}s") { - World.start() + Settings.load(mapOf("members" to "true")) val player = player() setItems(Item(element, 2)) @@ -63,6 +64,7 @@ class CombinationRuneTest : MagicSpellTest() { assertEquals(0, player.inventory.count(combo)) assertTrue(player.hasSpellItems("spell")) + Settings.clear() } } } \ No newline at end of file diff --git a/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt index 5b3adb121..c050eb555 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt @@ -151,7 +151,7 @@ abstract class WorldTest : KoinTest { Main.name = "test" properties = Properties() properties.load(WorldTest::class.java.getResourceAsStream("/test.properties")!!) - Settings.load(properties) + settings = Settings.load(properties) stopKoin() startKoin { printLogger(Level.ERROR) From 039dcf53752daa69d0819ebb17ccde15eaf120d1 Mon Sep 17 00:00:00 2001 From: GregHib Date: Thu, 9 Jan 2025 22:41:30 +0000 Subject: [PATCH 10/25] Convert World variables to Settings --- .../world/gregs/voidps/engine/entity/World.kt | 4 --- .../voidps/world/community/clan/ClanChat.kts | 8 +++-- .../voidps/world/community/clan/ClanSetup.kts | 6 ++-- .../voidps/world/community/friend/Friends.kt | 9 +++++- .../world/community/friend/FriendsList.kts | 10 +++--- .../world/community/friend/NameChange.kts | 4 +-- .../world/community/friend/FriendTest.kt | 4 +-- .../world/community/friend/IgnoreTest.kt | 2 +- .../community/friend/PrivateChatStatusTest.kt | 32 +++++++++---------- 9 files changed, 43 insertions(+), 36 deletions(-) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt index 449f33d14..5412cea96 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt @@ -21,10 +21,6 @@ object World : Entity, Variable, EventDispatcher, Runnable, KoinComponent { override val variables = Variables(this) private val logger = InlineLogger() - val id: Int - get() = Settings["world", 16] - val name: String - get() = "World $id" val members: Boolean get() = Settings["members", false] diff --git a/game/src/main/kotlin/world/gregs/voidps/world/community/clan/ClanChat.kts b/game/src/main/kotlin/world/gregs/voidps/world/community/clan/ClanChat.kts index 82ef44def..89975d23a 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/community/clan/ClanChat.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/community/clan/ClanChat.kts @@ -4,8 +4,8 @@ import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.variable.hasClock import world.gregs.voidps.engine.client.variable.remaining import world.gregs.voidps.engine.client.variable.start +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.definition.AccountDefinitions -import world.gregs.voidps.engine.entity.World import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.Players import world.gregs.voidps.engine.entity.character.player.chat.ChatType @@ -24,6 +24,8 @@ import world.gregs.voidps.network.login.protocol.encode.Member import world.gregs.voidps.network.login.protocol.encode.appendClanChat import world.gregs.voidps.network.login.protocol.encode.leaveClanChat import world.gregs.voidps.network.login.protocol.encode.updateClanChat +import world.gregs.voidps.world.community.friend.world +import world.gregs.voidps.world.community.friend.worldName import java.util.concurrent.TimeUnit val accounts: AccountDefinitions by inject() @@ -179,9 +181,9 @@ fun updateMembers(player: Player, clan: Clan, rank: ClanRank = clan.getRank(play fun toMember(player: Player, rank: ClanRank) = Member( player.name, - World.id, + Settings.world, rank.value, - World.name + Settings.worldName ) val list = listOf(ClanRank.None, ClanRank.Recruit, ClanRank.Corporeal, ClanRank.Sergeant, ClanRank.Lieutenant, ClanRank.Captain, ClanRank.General) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/community/clan/ClanSetup.kts b/game/src/main/kotlin/world/gregs/voidps/world/community/clan/ClanSetup.kts index 1e1da14ad..5b0f313cf 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/community/clan/ClanSetup.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/community/clan/ClanSetup.kts @@ -7,7 +7,7 @@ import world.gregs.voidps.engine.client.ui.event.interfaceOpen import world.gregs.voidps.engine.client.ui.hasMenuOpen import world.gregs.voidps.engine.client.ui.interfaceOption import world.gregs.voidps.engine.client.ui.open -import world.gregs.voidps.engine.entity.World +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.player.chat.ChatType import world.gregs.voidps.engine.entity.character.player.chat.clan.Clan import world.gregs.voidps.engine.entity.character.player.chat.clan.ClanRank @@ -16,6 +16,8 @@ import world.gregs.voidps.engine.entity.character.player.name import world.gregs.voidps.network.login.protocol.encode.Member import world.gregs.voidps.network.login.protocol.encode.leaveClanChat import world.gregs.voidps.network.login.protocol.encode.updateClanChat +import world.gregs.voidps.world.community.friend.world +import world.gregs.voidps.world.community.friend.worldName import world.gregs.voidps.world.interact.dialogue.type.stringEntry interfaceOption("Clan Setup", "settings", "clan_chat") { @@ -161,7 +163,7 @@ interfaceOption("Disable", "name", "clan_chat_setup") { } fun updateUI(clan: Clan) { - val membersList = clan.members.map { Member(it.name, World.id, clan.getRank(it).value, World.name) } + val membersList = clan.members.map { Member(it.name, Settings.world, clan.getRank(it).value, Settings.worldName) } for (member in clan.members) { member.client?.updateClanChat(clan.ownerDisplayName, clan.name, clan.kickRank.value, membersList) } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/community/friend/Friends.kt b/game/src/main/kotlin/world/gregs/voidps/world/community/friend/Friends.kt index 8999de036..4d412fcd2 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/community/friend/Friends.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/community/friend/Friends.kt @@ -1,5 +1,12 @@ package world.gregs.voidps.world.community.friend +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.player.Player -fun Player.friend(other: Player) = this != other && friends.contains(other.accountName) \ No newline at end of file +fun Player.friend(other: Player) = this != other && friends.contains(other.accountName) + +val Settings.world: Int + get() = this["world", 16] + +val Settings.worldName: String + get() = this["worldName", "World 16"] \ No newline at end of file diff --git a/game/src/main/kotlin/world/gregs/voidps/world/community/friend/FriendsList.kts b/game/src/main/kotlin/world/gregs/voidps/world/community/friend/FriendsList.kts index 173f9bb1b..05060b149 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/community/friend/FriendsList.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/community/friend/FriendsList.kts @@ -3,9 +3,9 @@ package world.gregs.voidps.world.community.friend import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.ui.interfaceOption import world.gregs.voidps.engine.client.updateFriend +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.config.AccountDefinition import world.gregs.voidps.engine.data.definition.AccountDefinitions -import world.gregs.voidps.engine.entity.World import world.gregs.voidps.engine.entity.character.player.* import world.gregs.voidps.engine.entity.character.player.chat.clan.Clan import world.gregs.voidps.engine.entity.character.player.chat.clan.ClanRank @@ -103,7 +103,7 @@ ignoresDelete { player -> } val other = players.get(name) if (other != null && (other.friend(player) || other.isAdmin())) { - other.updateFriend(Friend(player.name, player.previousName, world = World.id, worldName = World.name)) + other.updateFriend(Friend(player.name, player.previousName, world = Settings.world, worldName = Settings.worldName)) } } @@ -167,7 +167,7 @@ fun toFriend(player: Player, account: AccountDefinition): Friend { val friend = players.get(account.displayName) val rank = 0 val online = friend != null && (player.isAdmin() || friend.visibleOnline(player)) - return Friend(account.displayName, account.previousName, rank, world = if (online) World.id else 0, worldName = World.name) + return Friend(account.displayName, account.previousName, rank, world = if (online) Settings.world else 0, worldName = Settings.worldName) } fun Player.visibleOnline(friend: Player): Boolean { @@ -178,10 +178,10 @@ fun notifyBefriends(player: Player, online: Boolean, notify: (Player, String) -> players .filter { it.friend(player) && notify(it, player.privateStatus) } .forEach { friend -> - friend.updateFriend(Friend(player.name, player.previousName, world = if (online) World.id else 0, worldName = World.name)) + friend.updateFriend(Friend(player.name, player.previousName, world = if (online) Settings.world else 0, worldName = Settings.worldName)) } } fun String.updateFriend(friend: Player, online: Boolean) { - players.get(this)?.updateFriend(Friend(friend.name, friend.previousName, world = if (online) World.id else 0, worldName = World.name)) + players.get(this)?.updateFriend(Friend(friend.name, friend.previousName, world = if (online) Settings.world else 0, worldName = Settings.worldName)) } \ No newline at end of file diff --git a/game/src/main/kotlin/world/gregs/voidps/world/community/friend/NameChange.kts b/game/src/main/kotlin/world/gregs/voidps/world/community/friend/NameChange.kts index dcee69a09..8b4a02eb3 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/community/friend/NameChange.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/community/friend/NameChange.kts @@ -6,7 +6,7 @@ import world.gregs.voidps.engine.client.ui.event.modCommand import world.gregs.voidps.engine.client.updateFriend import world.gregs.voidps.engine.client.variable.remaining import world.gregs.voidps.engine.client.variable.start -import world.gregs.voidps.engine.entity.World +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.player.Players import world.gregs.voidps.engine.entity.character.player.isAdmin import world.gregs.voidps.engine.entity.character.player.name @@ -40,7 +40,7 @@ modCommand("rename") { players .filter { it.friend(player) } .forEach { friend -> - friend.updateFriend(Friend(toName, previous, renamed = true, world = World.id, worldName = World.name)) + friend.updateFriend(Friend(toName, previous, renamed = true, world = Settings.world, worldName = Settings.worldName)) } player.message("Your name has been successfully changed to '$toName'.") player.message("You can change your name again in 30 days.") diff --git a/game/src/test/kotlin/world/gregs/voidps/world/community/friend/FriendTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/community/friend/FriendTest.kt index df34f5a73..ef41b7836 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/community/friend/FriendTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/community/friend/FriendTest.kt @@ -35,7 +35,7 @@ internal class FriendTest : WorldTest() { tick() verify { - client.sendFriendsList(listOf(Friend("player", "", world = World.id, worldName = World.name))) + client.sendFriendsList(listOf(Friend("player", "", world = 16, worldName = "World 16"))) } assertContains(player.friends, "friend") } @@ -107,7 +107,7 @@ internal class FriendTest : WorldTest() { tick() verify { - client.sendFriendsList(listOf(Friend("player", "", world = 0, worldName = World.name))) + client.sendFriendsList(listOf(Friend("player", "", world = 0, worldName = "World 16"))) } assertTrue(player.friends.isEmpty()) } diff --git a/game/src/test/kotlin/world/gregs/voidps/world/community/friend/IgnoreTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/community/friend/IgnoreTest.kt index 2404278fa..ee28cc9d1 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/community/friend/IgnoreTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/community/friend/IgnoreTest.kt @@ -111,7 +111,7 @@ internal class IgnoreTest : WorldTest() { tick() verify { - client.sendFriendsList(listOf(Friend("player", "", world = World.id, worldName = World.name))) + client.sendFriendsList(listOf(Friend("player", "", world = 16, worldName = "World 16"))) } assertTrue(player.ignores.isEmpty()) } diff --git a/game/src/test/kotlin/world/gregs/voidps/world/community/friend/PrivateChatStatusTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/community/friend/PrivateChatStatusTest.kt index 7dc6f99d3..85ed8797f 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/community/friend/PrivateChatStatusTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/community/friend/PrivateChatStatusTest.kt @@ -52,8 +52,8 @@ internal class PrivateChatStatusTest : WorldTest() { } verify { - player.client?.sendFriendsList(listOf(Friend("friend", "", world = World.id, worldName = World.name))) - admin.client?.sendFriendsList(listOf(Friend("player", "", world = World.id, worldName = World.name))) + player.client?.sendFriendsList(listOf(Friend("friend", "", world = 16, worldName = "World 16"))) + admin.client?.sendFriendsList(listOf(Friend("player", "", world = 16, worldName = "World 16"))) } verify(exactly = 0) { friend.client?.sendFriendsList(any()) @@ -71,9 +71,9 @@ internal class PrivateChatStatusTest : WorldTest() { } verify { - player.client?.sendFriendsList(listOf(Friend("friend", "", world = World.id, worldName = World.name))) - friend.client?.sendFriendsList(listOf(Friend("player", "", world = World.id, worldName = World.name))) - admin.client?.sendFriendsList(listOf(Friend("player", "", world = World.id, worldName = World.name))) + player.client?.sendFriendsList(listOf(Friend("friend", "", world = 16, worldName = "World 16"))) + friend.client?.sendFriendsList(listOf(Friend("player", "", world = 16, worldName = "World 16"))) + admin.client?.sendFriendsList(listOf(Friend("player", "", world = 16, worldName = "World 16"))) } verify(exactly = 0) { befriend.client?.sendFriendsList(any()) @@ -90,10 +90,10 @@ internal class PrivateChatStatusTest : WorldTest() { } verify { - player.client?.sendFriendsList(listOf(Friend("friend", "", world = World.id, worldName = World.name))) - friend.client?.sendFriendsList(listOf(Friend("player", "", world = World.id, worldName = World.name))) - admin.client?.sendFriendsList(listOf(Friend("player", "", world = World.id, worldName = World.name))) - befriend.client?.sendFriendsList(listOf(Friend("player", "", world = World.id, worldName = World.name))) + player.client?.sendFriendsList(listOf(Friend("friend", "", world = 16, worldName = "World 16"))) + friend.client?.sendFriendsList(listOf(Friend("player", "", world = 16, worldName = "World 16"))) + admin.client?.sendFriendsList(listOf(Friend("player", "", world = 16, worldName = "World 16"))) + befriend.client?.sendFriendsList(listOf(Friend("player", "", world = 16, worldName = "World 16"))) } verify(exactly = 0) { stranger.client?.sendFriendsList(any()) @@ -108,7 +108,7 @@ internal class PrivateChatStatusTest : WorldTest() { tick() verify { - befriend.client?.sendFriendsList(listOf(Friend("player", "", world = World.id, worldName = World.name))) + befriend.client?.sendFriendsList(listOf(Friend("player", "", world = 16, worldName = "World 16"))) } verify(exactly = 0) { stranger.client?.sendFriendsList(any()) @@ -130,7 +130,7 @@ internal class PrivateChatStatusTest : WorldTest() { tick() verify { - friend.client?.sendFriendsList(listOf(Friend("player", "", world = World.id, worldName = World.name))) + friend.client?.sendFriendsList(listOf(Friend("player", "", world = 16, worldName = "World 16"))) } verify(exactly = 0) { admin.client?.sendFriendsList(any()) @@ -147,7 +147,7 @@ internal class PrivateChatStatusTest : WorldTest() { tick() verify { - befriend.client?.sendFriendsList(listOf(Friend("player", "", world = World.id, worldName = World.name))) + befriend.client?.sendFriendsList(listOf(Friend("player", "", world = 16, worldName = "World 16"))) } verify(exactly = 0) { admin.client?.sendFriendsList(any()) @@ -164,7 +164,7 @@ internal class PrivateChatStatusTest : WorldTest() { tick() verify { - friend.client?.sendFriendsList(listOf(Friend("player", "", world = 0, worldName = World.name))) + friend.client?.sendFriendsList(listOf(Friend("player", "", world = 0, worldName = "World 16"))) } verify(exactly = 0) { admin.client?.sendFriendsList(any()) @@ -181,8 +181,8 @@ internal class PrivateChatStatusTest : WorldTest() { tick() verify { - befriend.client?.sendFriendsList(listOf(Friend("player", "", world = 0, worldName = World.name))) - friend.client?.sendFriendsList(listOf(Friend("player", "", world = 0, worldName = World.name))) + befriend.client?.sendFriendsList(listOf(Friend("player", "", world = 0, worldName = "World 16"))) + friend.client?.sendFriendsList(listOf(Friend("player", "", world = 0, worldName = "World 16"))) } verify(exactly = 0) { admin.client?.sendFriendsList(any()) @@ -198,7 +198,7 @@ internal class PrivateChatStatusTest : WorldTest() { tick() verify { - befriend.client?.sendFriendsList(listOf(Friend("player", "", world = 0, worldName = World.name))) + befriend.client?.sendFriendsList(listOf(Friend("player", "", world = 0, worldName = "World 16"))) } verify(exactly = 0) { friend.client?.sendFriendsList(any()) From c456a917ed73996e73c57e707d7c9d9e08c374a8 Mon Sep 17 00:00:00 2001 From: GregHib Date: Thu, 9 Jan 2025 22:57:06 +0000 Subject: [PATCH 11/25] Convert missed property loading --- .../world/gregs/voidps/engine/EngineModules.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt index f3b4f8506..4577153fa 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt @@ -42,15 +42,15 @@ val engineModule = module { } single { val homeTile = Tile( - x = Settings["homeX", 0], - y = Settings["homeY", 0], - level = Settings["homeLevel", 0] + x = Settings["home.x", 0], + y = Settings["home.y", 0], + level = Settings["home.level", 0] ) - AccountManager(get(), get(), get(), get(), get(), get(), homeTile, get(), get(), get(), get(), getProperty("experienceRate", "1.0").toDouble()) + AccountManager(get(), get(), get(), get(), get(), get(), homeTile, get(), get(), get(), get(), Settings["experienceRate", 1.0]) } // IO single { Yaml(YamlReaderConfiguration(2, 8, VERY_FAST_LOAD_FACTOR)) } - single { if (getProperty("storage", "") == "database") { + single { if (Settings["storage", ""] == "database") { DatabaseStorage.connect( Settings["database_username"], Settings["database_password"], @@ -64,9 +64,9 @@ val engineModule = module { if (!saves.exists()) { saves.mkdir() } - FileStorage(get(), saves, get(), getProperty("experienceRate", "1.0").toDouble()) + FileStorage(get(), saves, get(), Settings["experienceRate", 1.0]) } } - single { PlayerAccountLoader(get(), get(), get(), get(), get(), Contexts.Game, getProperty("experienceRate", "1.0").toDouble()) } + single { PlayerAccountLoader(get(), get(), get(), get(), get(), Contexts.Game, Settings["experienceRate", 1.0]) } // Map single { ZoneBatchUpdates() } single { DynamicZones(get(), get(), get()) } From cf037ffd7bb4a216a490322c975e5b517de8f641 Mon Sep 17 00:00:00 2001 From: GregHib Date: Fri, 10 Jan 2025 00:29:15 +0000 Subject: [PATCH 12/25] Refactor game.properties --- .../kotlin/world/gregs/voidps/cache/Cache.kt | 2 +- .../world/gregs/voidps/cache/CacheLoader.kt | 6 +- .../cache/secure/VersionTableBuilderTest.kt | 4 +- docker-compose.yml | 8 +- .../gregs/voidps/engine/EngineModules.kt | 32 +- .../engine/data/definition/AmmoDefinitions.kt | 2 +- .../data/definition/AnimationDefinitions.kt | 2 +- .../engine/data/definition/AreaDefinitions.kt | 2 +- .../data/definition/CategoryDefinitions.kt | 2 +- .../definition/ClientScriptDefinitions.kt | 2 +- .../data/definition/DiangoCodeDefinitions.kt | 2 +- .../engine/data/definition/EnumDefinitions.kt | 2 +- .../engine/data/definition/FontDefinitions.kt | 2 +- .../engine/data/definition/GearDefinitions.kt | 2 +- .../data/definition/GraphicDefinitions.kt | 2 +- .../data/definition/HuntModeDefinitions.kt | 2 +- .../data/definition/InterfaceDefinitions.kt | 4 +- .../data/definition/InventoryDefinitions.kt | 2 +- .../engine/data/definition/ItemDefinitions.kt | 2 +- .../data/definition/ItemOnItemDefinitions.kt | 2 +- .../data/definition/JingleDefinitions.kt | 2 +- .../engine/data/definition/MidiDefinitions.kt | 2 +- .../engine/data/definition/NPCDefinitions.kt | 2 +- .../data/definition/ObjectDefinitions.kt | 2 +- .../data/definition/ParameterDefinitions.kt | 2 +- .../data/definition/PatrolDefinitions.kt | 2 +- .../data/definition/PrayerDefinitions.kt | 2 +- .../data/definition/QuestDefinitions.kt | 2 +- .../data/definition/RenderEmoteDefinitions.kt | 2 +- .../data/definition/SoundDefinitions.kt | 2 +- .../data/definition/SpellDefinitions.kt | 2 +- .../data/definition/StructDefinitions.kt | 2 +- .../data/definition/VariableDefinitions.kt | 2 +- .../definition/WeaponAnimationDefinitions.kt | 2 +- .../data/definition/WeaponStyleDefinitions.kt | 2 +- .../world/gregs/voidps/engine/entity/World.kt | 2 +- .../engine/entity/character/mode/Wander.kt | 2 +- .../engine/entity/item/drop/DropTables.kt | 2 +- .../gregs/voidps/engine/data/SettingsTest.kt | 24 +- .../main/kotlin/world/gregs/voidps/Main.kt | 6 +- .../world/gregs/voidps/bot/BotSpawns.kts | 5 +- .../bot/navigation/graph/NavigationGraph.kt | 2 +- .../world/gregs/voidps/script/ScriptLoader.kt | 2 +- .../dnd/shootingstar/ShootingStar.kts | 6 +- .../voidps/world/activity/quest/Books.kt | 2 +- .../skill/agility/course/BarbarianOutpost.kts | 12 +- .../skill/agility/course/GnomeAdvanced.kts | 4 +- .../gregs/voidps/world/community/Rights.kts | 2 +- .../voidps/world/community/friend/Friends.kt | 4 +- .../voidps/world/interact/entity/Movement.kts | 40 ++- .../entity/combat/hit/CombatHitsplats.kts | 4 +- .../interact/entity/death/PlayerDeath.kts | 2 +- .../world/interact/entity/obj/Teleports.kt | 2 +- .../entity/player/music/MusicTracks.kt | 2 +- .../world/interact/world/spawn/ItemSpawns.kt | 2 +- .../world/interact/world/spawn/NPCSpawns.kt | 2 +- .../interact/world/spawn/ObjectSpawns.kt | 2 +- game/src/main/resources/game.properties | 321 +++++++++++++----- .../world/interact/entity/npc/NPCTest.kt | 2 +- .../combat/magic/spell/CombinationRuneTest.kt | 4 +- .../player/combat/magic/spell/SpellTest.kt | 2 +- .../gregs/voidps/world/script/WorldTest.kt | 4 +- game/src/test/resources/test.properties | 117 ++++--- .../world/gregs/voidps/network/FileServer.kt | 6 +- .../world/gregs/voidps/network/GameServer.kt | 2 +- .../world/gregs/voidps/network/LoginServer.kt | 8 +- .../gregs/voidps/network/file/FileProvider.kt | 2 +- .../gregs/voidps/network/file/PrefetchKeys.kt | 2 +- .../gregs/voidps/network/FileServerTest.kt | 8 +- .../gregs/voidps/network/GameServerTest.kt | 4 +- .../gregs/voidps/network/LoginServerTest.kt | 8 +- .../voidps/tools/AnimationDefinitions.kt | 2 +- .../voidps/tools/ClientScriptDefinitions.kt | 2 +- .../voidps/tools/DropTableDefinitions.kt | 2 +- .../gregs/voidps/tools/EnumDefinitions.kt | 3 +- .../gregs/voidps/tools/FontDefinitions.kt | 2 +- .../gregs/voidps/tools/GraphicDefinitions.kt | 2 +- .../voidps/tools/IdentityKitDefinitions.kt | 2 +- .../voidps/tools/InterfaceDefinitions.kt | 2 +- .../voidps/tools/InventoryDefinitions.kt | 2 +- .../gregs/voidps/tools/ItemDefinitions.kt | 10 +- .../gregs/voidps/tools/NPCDefinitions.kt | 10 +- .../gregs/voidps/tools/ObjectDefinitions.kt | 2 +- .../world/gregs/voidps/tools/OreIdentifier.kt | 2 +- .../gregs/voidps/tools/QuestDefinitions.kt | 2 +- .../voidps/tools/QuickChatDefinitions.kt | 2 +- .../tools/RenderAnimationDefinitions.kt | 2 +- .../gregs/voidps/tools/StructDefinitions.kt | 2 +- .../gregs/voidps/tools/VarBitDefinitions.kt | 2 +- .../gregs/voidps/tools/WorldMapDefinitions.kt | 2 +- .../voidps/tools/WorldMapInfoDefinitions.kt | 2 +- .../gregs/voidps/tools/cache/DumpEnums.kt | 2 +- .../world/gregs/voidps/tools/cache/DumpMap.kt | 2 +- .../gregs/voidps/tools/cache/DumpSprites.kt | 2 +- .../gregs/voidps/tools/cache/DumpStructs.kt | 2 +- .../gregs/voidps/tools/cache/DumpStyles.kt | 2 +- .../voidps/tools/cache/HashCodeMatcher.kt | 2 +- .../world/gregs/voidps/tools/cache/Xteas.kt | 2 +- .../tools/convert/InventoryConverter.kt | 4 +- .../definition/item/ItemDefinitionPatcher.kt | 4 +- .../definition/item/ItemDefinitionPipeline.kt | 2 +- .../definition/npc/NPCDefinitionPipeline.kt | 2 +- .../obj/ObjectDefinitionPipeline.kt | 2 +- .../voidps/tools/detail/AnimationNames.kt | 2 +- .../gregs/voidps/tools/detail/GraphicNames.kt | 2 +- .../gregs/voidps/tools/detail/NPCNames.kt | 2 +- .../voidps/tools/graph/MapGraphLoader.kt | 4 +- .../voidps/tools/map/obj/ObjectUsageFinder.kt | 2 +- .../tools/map/obj/WorldMapLinkIdentifier.kt | 6 +- .../voidps/tools/map/render/WorldMapDumper.kt | 4 +- .../gregs/voidps/tools/map/view/MapViewer.kt | 2 +- .../wiki/scrape/RunescapeWikiModifier.kt | 2 +- tools/src/main/resources/tool.properties | 28 +- 113 files changed, 507 insertions(+), 367 deletions(-) diff --git a/cache/src/main/kotlin/world/gregs/voidps/cache/Cache.kt b/cache/src/main/kotlin/world/gregs/voidps/cache/Cache.kt index 51906aefe..d8c70e7b2 100644 --- a/cache/src/main/kotlin/world/gregs/voidps/cache/Cache.kt +++ b/cache/src/main/kotlin/world/gregs/voidps/cache/Cache.kt @@ -42,7 +42,7 @@ interface Cache { companion object { fun load(properties: Properties): Cache { - val live = properties.getProperty("live").toBoolean() + val live = properties.getProperty("game.live").toBoolean() val loader = if (live) MemoryCache else FileCache return loader.load(properties) } diff --git a/cache/src/main/kotlin/world/gregs/voidps/cache/CacheLoader.kt b/cache/src/main/kotlin/world/gregs/voidps/cache/CacheLoader.kt index 2f43ac9e0..9a94f4c8c 100644 --- a/cache/src/main/kotlin/world/gregs/voidps/cache/CacheLoader.kt +++ b/cache/src/main/kotlin/world/gregs/voidps/cache/CacheLoader.kt @@ -10,9 +10,9 @@ import java.util.* interface CacheLoader { fun load(properties: Properties, xteas: Map? = null): Cache { - val fileModulus = BigInteger(properties.getProperty("fileModulus"), 16) - val filePrivate = BigInteger(properties.getProperty("filePrivate"), 16) - val cachePath = properties.getProperty("cachePath") + val fileModulus = BigInteger(properties.getProperty("security.file.modulus"), 16) + val filePrivate = BigInteger(properties.getProperty("security.file.private"), 16) + val cachePath = properties.getProperty("storage.cache.path") val threadUsage = properties.getProperty("threadUsage", "1.0").toDouble() return load(cachePath, filePrivate, fileModulus, threadUsage = threadUsage) } diff --git a/cache/src/test/kotlin/world/gregs/voidps/cache/secure/VersionTableBuilderTest.kt b/cache/src/test/kotlin/world/gregs/voidps/cache/secure/VersionTableBuilderTest.kt index ef26036e8..a6d920c3f 100644 --- a/cache/src/test/kotlin/world/gregs/voidps/cache/secure/VersionTableBuilderTest.kt +++ b/cache/src/test/kotlin/world/gregs/voidps/cache/secure/VersionTableBuilderTest.kt @@ -72,8 +72,8 @@ class VersionTableBuilderTest { val properties = Properties() properties.load(FileInputStream("../game/src/main/resources/private.properties")) - val exponent = BigInteger(properties.getProperty("gamePrivate"), 16) - val modulus = BigInteger(properties.getProperty("gameModulus"), 16) + val exponent = BigInteger(properties.getProperty("security.game.private"), 16) + val modulus = BigInteger(properties.getProperty("security.game.modulus"), 16) val table = VersionTableBuilder(exponent, modulus, indexCount) for (i in 0 until indexCount) { val index = library.index(i) diff --git a/docker-compose.yml b/docker-compose.yml index c71a327ca..a2bae31f5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,10 +6,10 @@ services: - ./data/saves/:/app/data/saves environment: storage: database - database_username: postgres - database_password: password - database_driver: org.postgresql.Driver - database_jdbc_url: jdbc:postgresql://db:5432/game?reWriteBatchedInserts=true + storage.database.username: postgres + storage.database.password: password + storage.database.driver: org.postgresql.Driver + storage.database.jdbcUrl: jdbc:postgresql://db:5432/game?reWriteBatchedInserts=true ports: - "43594:43594" depends_on: diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt index 4577153fa..919f6e7af 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt @@ -33,47 +33,47 @@ val engineModule = module { // Entities single { NPCs(get(), get(), get(), get()) } single { Players() } - single { GameObjects(get(), get(), get(), get(), Settings["loadUnusedObjects", false]).apply { get().register(this) } } + single { GameObjects(get(), get(), get(), get(), Settings["development.loadAllObjects", false]).apply { get().register(this) } } single { FloorItems(get(), get()).apply { get().register(this) } } single { FloorItemTracking(get(), get(), get()) } single { Hunting(get(), get(), get(), get(), get(), get()) } single { - SaveQueue(get(), SafeStorage(File(Settings["storageFailDirectory"]))) + SaveQueue(get(), SafeStorage(File(Settings["storage.players.errors"]))) } single { val homeTile = Tile( - x = Settings["home.x", 0], - y = Settings["home.y", 0], - level = Settings["home.level", 0] + x = Settings["world.home.x", 0], + y = Settings["world.home.y", 0], + level = Settings["world.home.level", 0] ) - AccountManager(get(), get(), get(), get(), get(), get(), homeTile, get(), get(), get(), get(), Settings["experienceRate", 1.0]) + AccountManager(get(), get(), get(), get(), get(), get(), homeTile, get(), get(), get(), get(), Settings["world.experienceRate", 1.0]) } // IO single { Yaml(YamlReaderConfiguration(2, 8, VERY_FAST_LOAD_FACTOR)) } - single { if (Settings["storage", ""] == "database") { + single { if (Settings["storage.type", "files"] == "database") { DatabaseStorage.connect( - Settings["database_username"], - Settings["database_password"], - Settings["database_driver"], - Settings["database_jdbc_url"], - Settings["database_pool", 2], + Settings["storage.database.username"], + Settings["storage.database.password"], + Settings["storage.database.driver"], + Settings["storage.database.jdbcUrl"], + Settings["storage.database.poolSize", 2], ) DatabaseStorage() } else { - val saves = File(Settings["savePath"]) + val saves = File(Settings["storage.players.path"]) if (!saves.exists()) { saves.mkdir() } - FileStorage(get(), saves, get(), Settings["experienceRate", 1.0]) + FileStorage(get(), saves, get(), Settings["world.experienceRate", 1.0]) } } - single { PlayerAccountLoader(get(), get(), get(), get(), get(), Contexts.Game, Settings["experienceRate", 1.0]) } + single { PlayerAccountLoader(get(), get(), get(), get(), get(), Contexts.Game, Settings["world.experienceRate", 1.0]) } // Map single { ZoneBatchUpdates() } single { DynamicZones(get(), get(), get()) } single(createdAtStart = true) { AreaDefinitions().load() } // Network single { - ConnectionQueue(Settings["connectionPerTickCap", 1]) + ConnectionQueue(Settings["network.maxLoginsPerTick", 1]) } single(createdAtStart = true) { GameObjectCollisionAdd(get()) } single(createdAtStart = true) { GameObjectCollisionRemove(get()) } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AmmoDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AmmoDefinitions.kt index f96a2c2bf..7e1e3ef98 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AmmoDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AmmoDefinitions.kt @@ -18,7 +18,7 @@ class AmmoDefinitions : DefinitionsDecoder { override lateinit var ids: Map @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = Settings["ammoDefinitionsPath"]): AmmoDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.ammoGroups"]): AmmoDefinitions { timedLoad("ammo definition") { decode(yaml, path) { id, key, extras -> val items = extras?.get("items") as? List diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AnimationDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AnimationDefinitions.kt index 72a6174d6..08a44c0ea 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AnimationDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AnimationDefinitions.kt @@ -14,7 +14,7 @@ class AnimationDefinitions( override fun empty() = AnimationDefinition.EMPTY - fun load(yaml: Yaml = get(), path: String = Settings["animationDefinitionsPath"]): AnimationDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.animations"]): AnimationDefinitions { timedLoad("animation extra") { decode(yaml, path) } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AreaDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AreaDefinitions.kt index b82fbf50b..20d65014d 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AreaDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AreaDefinitions.kt @@ -34,7 +34,7 @@ class AreaDefinitions( } @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = Settings["areaPath"]): AreaDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["map.areas"]): AreaDefinitions { timedLoad("map area") { val config = object : YamlReaderConfiguration(2, 2) { override fun set(map: MutableMap, key: String, value: Any, indent: Int, parentMap: String?) { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/CategoryDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/CategoryDefinitions.kt index c318593ea..f0713fdca 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/CategoryDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/CategoryDefinitions.kt @@ -15,7 +15,7 @@ class CategoryDefinitions : DefinitionsDecoder { override lateinit var definitions: Array override lateinit var ids: Map - fun load(yaml: Yaml = get(), path: String = Settings["categoryDefinitionsPath"]): CategoryDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.categories"]): CategoryDefinitions { timedLoad("category definition") { decode(yaml, path) { id, key, _ -> CategoryDefinition(id = id, stringId = key) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ClientScriptDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ClientScriptDefinitions.kt index 71daa80df..f482af061 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ClientScriptDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ClientScriptDefinitions.kt @@ -12,7 +12,7 @@ class ClientScriptDefinitions : DefinitionsDecoder { override lateinit var definitions: Array override lateinit var ids: Map - fun load(yaml: Yaml = get(), path: String = Settings["clientScriptDefinitionsPath"]): ClientScriptDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.clientScripts"]): ClientScriptDefinitions { timedLoad("client script definition") { decode(yaml, path) { id, key, _ -> ClientScriptDefinition(id = id, stringId = key) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/DiangoCodeDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/DiangoCodeDefinitions.kt index 03d732fe4..d222fd6ee 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/DiangoCodeDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/DiangoCodeDefinitions.kt @@ -18,7 +18,7 @@ class DiangoCodeDefinitions { fun getOrNull(code: String) = definitions[code] @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = Settings["diangoCodeDefinitionsPath"], itemDefinitions: ItemDefinitions? = null): DiangoCodeDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.diangoCodes"], itemDefinitions: ItemDefinitions? = null): DiangoCodeDefinitions { timedLoad("diango code definition") { val config = object : YamlReaderConfiguration(2, 2) { override fun add(list: MutableList, value: Any, parentMap: String?) { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/EnumDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/EnumDefinitions.kt index 77d58a21f..e14777d01 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/EnumDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/EnumDefinitions.kt @@ -34,7 +34,7 @@ class EnumDefinitions( return structs.get(struct)[param, default] } - fun load(yaml: Yaml = get(), path: String = Settings["enumDefinitionsPath"]): EnumDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.enums"]): EnumDefinitions { timedLoad("enum extra") { decode(yaml, path) } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/FontDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/FontDefinitions.kt index fc35a19f7..932557599 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/FontDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/FontDefinitions.kt @@ -14,7 +14,7 @@ class FontDefinitions( override fun empty() = FontDefinition.EMPTY - fun load(yaml: Yaml = get(), path: String = Settings["fontDefinitionsPath"]): FontDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.fonts"]): FontDefinitions { timedLoad("font extra") { decode(yaml, path) } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/GearDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/GearDefinitions.kt index d1a2ed7a7..adcb48518 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/GearDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/GearDefinitions.kt @@ -19,7 +19,7 @@ class GearDefinitions { fun get(style: String): List = definitions[style] ?: emptyList() @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = Settings["gearDefinitionsPath"]): GearDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.gearSets"]): GearDefinitions { timedLoad("gear definition") { var count = 0 val config = object : YamlReaderConfiguration() { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/GraphicDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/GraphicDefinitions.kt index f13994ced..c4e8180d0 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/GraphicDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/GraphicDefinitions.kt @@ -14,7 +14,7 @@ class GraphicDefinitions( override fun empty() = GraphicDefinition.EMPTY - fun load(yaml: Yaml = get(), path: String = Settings["graphicDefinitionsPath"]): GraphicDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.graphics"]): GraphicDefinitions { timedLoad("graphic extra") { decode(yaml, path) } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/HuntModeDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/HuntModeDefinitions.kt index 6db5650cc..d8d676ae1 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/HuntModeDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/HuntModeDefinitions.kt @@ -16,7 +16,7 @@ class HuntModeDefinitions { } @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = Settings["huntPath"]): HuntModeDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.huntModes"]): HuntModeDefinitions { timedLoad("hunt mode") { val config = object : YamlReaderConfiguration(2, 2) { override fun set(map: MutableMap, key: String, value: Any, indent: Int, parentMap: String?) { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/InterfaceDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/InterfaceDefinitions.kt index 347cee5da..d1de0e800 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/InterfaceDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/InterfaceDefinitions.kt @@ -40,8 +40,8 @@ class InterfaceDefinitions( fun load( yaml: Yaml = get(), - path: String = Settings["interfacesPath"], - typePath: String = Settings["interfaceTypesPath"] + path: String = Settings["definitions.interfaces"], + typePath: String = Settings["definitions.interfaces.types"] ): InterfaceDefinitions { timedLoad("interface extra") { val ids = Object2IntOpenHashMap() diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/InventoryDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/InventoryDefinitions.kt index 967734755..810a3c5e0 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/InventoryDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/InventoryDefinitions.kt @@ -17,7 +17,7 @@ class InventoryDefinitions( override fun empty() = InventoryDefinition.EMPTY @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = Settings["inventoryDefinitionsPath"], itemDefs: ItemDefinitions = get()): InventoryDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.inventories"], itemDefs: ItemDefinitions = get()): InventoryDefinitions { timedLoad("inventory extra") { val ids = Object2IntOpenHashMap() val config = object : DefinitionConfig(ids, definitions) { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ItemDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ItemDefinitions.kt index 6698a6bb4..45978d705 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ItemDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ItemDefinitions.kt @@ -27,7 +27,7 @@ class ItemDefinitions( override fun empty() = ItemDefinition.EMPTY - fun load(yaml: Yaml = get(), path: String = Settings["itemDefinitionsPath"]): ItemDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.items"]): ItemDefinitions { timedLoad("item extra") { val equipment = IntArray(definitions.size) { -1 } var index = 0 diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ItemOnItemDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ItemOnItemDefinitions.kt index 301696ee9..e278320f5 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ItemOnItemDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ItemOnItemDefinitions.kt @@ -25,7 +25,7 @@ class ItemOnItemDefinitions { fun contains(one: Item, two: Item) = definitions.containsKey(id(one, two)) || definitions.containsKey(id(two, one)) @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = Settings["itemOnItemDefinitionsPath"], itemDefinitions: ItemDefinitions = get()): ItemOnItemDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.itemOnItem"], itemDefinitions: ItemDefinitions = get()): ItemOnItemDefinitions { timedLoad("item on item definition") { val definitions = Object2ObjectOpenHashMap>() var count = 0 diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/JingleDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/JingleDefinitions.kt index 3727ef63f..cfa8dc678 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/JingleDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/JingleDefinitions.kt @@ -12,7 +12,7 @@ class JingleDefinitions : DefinitionsDecoder { override lateinit var definitions: Array override lateinit var ids: Map - fun load(yaml: Yaml = get(), path: String = Settings["jingleDefinitionsPath"]): JingleDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.jingles"]): JingleDefinitions { timedLoad("jingle definition") { decode(yaml, path) { id, key, _ -> JingleDefinition(id = id, stringId = key) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/MidiDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/MidiDefinitions.kt index 3db1025ff..b03826729 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/MidiDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/MidiDefinitions.kt @@ -12,7 +12,7 @@ class MidiDefinitions : DefinitionsDecoder { override lateinit var definitions: Array override lateinit var ids: Map - fun load(yaml: Yaml = get(), path: String = Settings["midiDefinitionsPath"]): MidiDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.midis"]): MidiDefinitions { timedLoad("midi definition") { decode(yaml, path) { id, key, _ -> MidiDefinition(id = id, stringId = key) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/NPCDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/NPCDefinitions.kt index 3f440650a..34731e1e5 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/NPCDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/NPCDefinitions.kt @@ -21,7 +21,7 @@ class NPCDefinitions( override fun empty() = NPCDefinition.EMPTY @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = Settings["npcDefinitionsPath"]): NPCDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.npcs"]): NPCDefinitions { timedLoad("npc extra") { val ids = Object2IntOpenHashMap() this.ids = ids diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ObjectDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ObjectDefinitions.kt index cee6cb092..81f5d22a7 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ObjectDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ObjectDefinitions.kt @@ -25,7 +25,7 @@ class ObjectDefinitions( override fun empty() = ObjectDefinition.EMPTY @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = Settings["objectDefinitionsPath"]): ObjectDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.objects"]): ObjectDefinitions { timedLoad("object extra") { val ids = Object2IntOpenHashMap() this.ids = ids diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ParameterDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ParameterDefinitions.kt index c73c2eba2..b18a44c57 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ParameterDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ParameterDefinitions.kt @@ -25,7 +25,7 @@ class ParameterDefinitions( override lateinit var parameters: Map private val logger = InlineLogger() - fun load(yaml: Yaml = get(), path: String = Settings["parameterDefinitionsPath"]): ParameterDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.parameters"]): ParameterDefinitions { timedLoad("parameter definition") { val size = decode(yaml, path) { id, key, _ -> ParameterDefinition(id = id, stringId = key) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/PatrolDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/PatrolDefinitions.kt index c38c3ff4c..8f6cad74a 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/PatrolDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/PatrolDefinitions.kt @@ -15,7 +15,7 @@ class PatrolDefinitions { fun get(key: String) = definitions[key] ?: PatrolDefinition() @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = Settings["patrolDefinitionsPath"]): PatrolDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.patrols"]): PatrolDefinitions { timedLoad("patrol definition") { val definitions = Object2ObjectOpenHashMap() val config = object : YamlReaderConfiguration() { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/PrayerDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/PrayerDefinitions.kt index 6a8830197..0fbfdd5b2 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/PrayerDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/PrayerDefinitions.kt @@ -28,7 +28,7 @@ class PrayerDefinitions { fun getGroup(group: Int) = groups[group] @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = Settings["prayerDefinitionsPath"]): PrayerDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.prayers"]): PrayerDefinitions { timedLoad("prayer definition") { val definitions = Object2ObjectOpenHashMap() val prayers = Int2ObjectArrayMap() diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/QuestDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/QuestDefinitions.kt index c8d6e887f..e28c65142 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/QuestDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/QuestDefinitions.kt @@ -12,7 +12,7 @@ class QuestDefinitions : DefinitionsDecoder { override lateinit var definitions: Array override lateinit var ids: Map - fun load(yaml: Yaml = get(), path: String = Settings["questDefinitionsPath"]): QuestDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.quests"]): QuestDefinitions { timedLoad("quest definition") { decode(yaml, path) { id, key, extras -> QuestDefinition(id = id, stringId = key, extras = extras) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/RenderEmoteDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/RenderEmoteDefinitions.kt index 218513b5a..d672806ed 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/RenderEmoteDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/RenderEmoteDefinitions.kt @@ -12,7 +12,7 @@ class RenderEmoteDefinitions : DefinitionsDecoder { override lateinit var definitions: Array override lateinit var ids: Map - fun load(yaml: Yaml = get(), path: String = Settings["renderEmoteDefinitionsPath"]): RenderEmoteDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.renderEmotes"]): RenderEmoteDefinitions { timedLoad("render emote definition") { decode(yaml, path) { id, key, _ -> RenderEmoteDefinition(id = id, stringId = key) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/SoundDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/SoundDefinitions.kt index 966fec4b6..17607a988 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/SoundDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/SoundDefinitions.kt @@ -12,7 +12,7 @@ class SoundDefinitions : DefinitionsDecoder { override lateinit var definitions: Array override lateinit var ids: Map - fun load(yaml: Yaml = get(), path: String = Settings["soundDefinitionsPath"]): SoundDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.sounds"]): SoundDefinitions { timedLoad("sound definition") { decode(yaml, path) { id, key, _ -> SoundDefinition(id = id, stringId = key) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/SpellDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/SpellDefinitions.kt index 620408e02..3285126ba 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/SpellDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/SpellDefinitions.kt @@ -15,7 +15,7 @@ class SpellDefinitions { fun get(key: String) = definitions[key] ?: SpellDefinition() @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = Settings["spellDefinitionsPath"]): SpellDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.spells"]): SpellDefinitions { timedLoad("spell definition") { val definitions = Object2ObjectOpenHashMap() val config = object : YamlReaderConfiguration() { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/StructDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/StructDefinitions.kt index cc16a6b19..fed69b16c 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/StructDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/StructDefinitions.kt @@ -17,7 +17,7 @@ class StructDefinitions( override fun empty() = StructDefinition.EMPTY - fun load(yaml: Yaml = get(), path: String = Settings["structDefinitionsPath"]): StructDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.structs"]): StructDefinitions { timedLoad("struct extra") { decode(yaml, path) } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/VariableDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/VariableDefinitions.kt index c03102189..40fba7b62 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/VariableDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/VariableDefinitions.kt @@ -24,7 +24,7 @@ class VariableDefinitions { fun getVarp(id: Int) = varpIds[id] @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = Settings["definitionsPath"]): VariableDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.path"]): VariableDefinitions { timedLoad("variable definition") { val definitions = Object2ObjectOpenHashMap() val files = File(path).listFiles()?.filter { it.name.startsWith("variables-") } ?: emptyList() diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/WeaponAnimationDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/WeaponAnimationDefinitions.kt index d6b431fdd..fb48a7bed 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/WeaponAnimationDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/WeaponAnimationDefinitions.kt @@ -16,7 +16,7 @@ class WeaponAnimationDefinitions { fun getOrNull(key: String) = definitions[key] - fun load(yaml: Yaml = get(), path: String = Settings["weaponAnimationDefinitionsPath"]): WeaponAnimationDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.weapons.animations"]): WeaponAnimationDefinitions { timedLoad("weapon animation definition") { val definitions = Object2ObjectOpenHashMap() val config = object : YamlReaderConfiguration() { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/WeaponStyleDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/WeaponStyleDefinitions.kt index 797645004..53994bdfd 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/WeaponStyleDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/WeaponStyleDefinitions.kt @@ -12,7 +12,7 @@ class WeaponStyleDefinitions : DefinitionsDecoder { override lateinit var definitions: Array override lateinit var ids: Map - fun load(yaml: Yaml = get(), path: String = Settings["weaponStyleDefinitionsPath"]): WeaponStyleDefinitions { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.weapons.styles"]): WeaponStyleDefinitions { timedLoad("weapon style definition") { decode(yaml, path) { id, key, extras -> WeaponStyleDefinition.fromMap(id, key, extras!!) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt index 5412cea96..b843e3a16 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/World.kt @@ -22,7 +22,7 @@ object World : Entity, Variable, EventDispatcher, Runnable, KoinComponent { private val logger = InlineLogger() val members: Boolean - get() = Settings["members", false] + get() = Settings["world.members", false] fun start() { emit(Spawn) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/Wander.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/Wander.kt index c15644406..6ee6a8ee6 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/Wander.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/Wander.kt @@ -46,6 +46,6 @@ class Wander( } companion object { - fun wanders(npc: NPC) = Settings["randomWalk", false] && npc.def.walkMask.toInt() and 0x1 != 0 && npc.def.walkMask.toInt() and 0x2 != 0 && npc.def.contains("wander_radius") + fun wanders(npc: NPC) = Settings["world.npcs.randomWalk", false] && npc.def.walkMask.toInt() and 0x1 != 0 && npc.def.walkMask.toInt() and 0x2 != 0 && npc.def.contains("wander_radius") } } \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/item/drop/DropTables.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/item/drop/DropTables.kt index 9d52cd1d8..12da21808 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/item/drop/DropTables.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/item/drop/DropTables.kt @@ -17,7 +17,7 @@ class DropTables { fun getValue(key: String) = tables.getValue(key) - fun load(yaml: Yaml = get(), path: String = Settings["dropsPath"], itemDefinitions: ItemDefinitions? = null): DropTables { + fun load(yaml: Yaml = get(), path: String = Settings["spawns.drops"], itemDefinitions: ItemDefinitions? = null): DropTables { timedLoad("drop table") { val config = object : YamlReaderConfiguration() { override fun add(list: MutableList, value: Any, parentMap: String?) { diff --git a/engine/src/test/kotlin/world/gregs/voidps/engine/data/SettingsTest.kt b/engine/src/test/kotlin/world/gregs/voidps/engine/data/SettingsTest.kt index b0a2665d8..2d8d82b30 100644 --- a/engine/src/test/kotlin/world/gregs/voidps/engine/data/SettingsTest.kt +++ b/engine/src/test/kotlin/world/gregs/voidps/engine/data/SettingsTest.kt @@ -15,19 +15,19 @@ class SettingsTest { } private val example = """ - name=Void - port=43594 - experienceRate=10.0 - active=true + game.name=Void + game.port=43594 + world.experienceRate=10.0 + game.live=true """.trimIndent() @Test fun `Load settings`() { settings.load(example) - assertEquals("Void", settings["name"]) - assertEquals(43594, settings["port", -1]) - assertEquals(10.0, settings["experienceRate", -10.0]) - assertEquals(true, settings["active", false]) + assertEquals("Void", settings["game.name"]) + assertEquals(43594, settings["game.port", -1]) + assertEquals(10.0, settings["world.experienceRate", -10.0]) + assertEquals(true, settings["game.live", false]) } @Test @@ -46,16 +46,16 @@ class SettingsTest { @Test fun `Get an incorrect format setting returns default`() { settings.load(example) - assertEquals(1234, settings["name", 1234]) + assertEquals(1234, settings["game.name", 1234]) } @Test fun `Override settings`() { settings.load(example) - settings.load("name=Void 2") + settings.load("game.name=Void 2") - assertEquals("Void 2", settings["name"]) - assertEquals(43594, settings["port", -1]) + assertEquals("Void 2", settings["game.name"]) + assertEquals(43594, settings["game.port", -1]) } private fun Settings.load(string: String) = load(string.byteInputStream(Charsets.UTF_8)) diff --git a/game/src/main/kotlin/world/gregs/voidps/Main.kt b/game/src/main/kotlin/world/gregs/voidps/Main.kt index 3439cec22..418fc5655 100644 --- a/game/src/main/kotlin/world/gregs/voidps/Main.kt +++ b/game/src/main/kotlin/world/gregs/voidps/Main.kt @@ -42,12 +42,12 @@ object Main : CoroutineScope { fun main(args: Array) { val startTime = System.currentTimeMillis() val properties = settings() - name = Settings["name"] + name = Settings["game.name"] // File server val cache = timed("cache") { Cache.load(properties) } val server = GameServer.load(cache, properties) - val job = server.start(Settings["port"].toInt()) + val job = server.start(Settings["game.port"].toInt()) // Content try { @@ -95,7 +95,7 @@ object Main : CoroutineScope { } private fun cache(cache: Cache) = module { - val members = Settings["members", false] + val members = Settings["world.members", false] single(createdAtStart = true) { MapDefinitions(CollisionDecoder(get()), get(), get(), cache).loadCache() } single(createdAtStart = true) { Huffman().load(cache.data(Index.HUFFMAN, 1)!!) } single(createdAtStart = true) { ObjectDefinitions(ObjectDecoder(members, lowDetail = false, get()).load(cache)).load() } diff --git a/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts b/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts index 5cd3b6a79..99aec2bda 100644 --- a/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts +++ b/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts @@ -35,7 +35,6 @@ import kotlin.reflect.KClass val areas: AreaDefinitions by inject() val lumbridge = areas["lumbridge_teleport"] -val botCount = Settings["bots", 0] val bots = mutableListOf() val enums: EnumDefinitions by inject() @@ -44,7 +43,7 @@ val structs: StructDefinitions by inject() var counter = 0 worldSpawn { - if (botCount > 0) { + if (Settings["world.bots", 0] > 0) { World.timers.start("bot_spawn") } Events.events.all = { player, event -> @@ -57,7 +56,7 @@ worldTimerStart("bot_spawn") { } worldTimerTick("bot_spawn") { - if (counter > botCount) { + if (counter > Settings["world.bots", 0]) { cancel() return@worldTimerTick } diff --git a/game/src/main/kotlin/world/gregs/voidps/bot/navigation/graph/NavigationGraph.kt b/game/src/main/kotlin/world/gregs/voidps/bot/navigation/graph/NavigationGraph.kt index f1144803d..0da97de34 100644 --- a/game/src/main/kotlin/world/gregs/voidps/bot/navigation/graph/NavigationGraph.kt +++ b/game/src/main/kotlin/world/gregs/voidps/bot/navigation/graph/NavigationGraph.kt @@ -47,7 +47,7 @@ class NavigationGraph( } @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = Settings["navGraphPath"]): NavigationGraph { + fun load(yaml: Yaml = get(), path: String = Settings["map.navGraph"]): NavigationGraph { timedLoad("ai nav graph edge") { val config = object : YamlReaderConfiguration(2, 2) { override fun add(list: MutableList, value: Any, parentMap: String?) { diff --git a/game/src/main/kotlin/world/gregs/voidps/script/ScriptLoader.kt b/game/src/main/kotlin/world/gregs/voidps/script/ScriptLoader.kt index 69b3239be..1cc5b1f20 100644 --- a/game/src/main/kotlin/world/gregs/voidps/script/ScriptLoader.kt +++ b/game/src/main/kotlin/world/gregs/voidps/script/ScriptLoader.kt @@ -9,7 +9,7 @@ import kotlin.system.measureTimeMillis private val logger = InlineLogger("ScriptLoader") -fun loadScripts(scriptPackage: String = Settings["scriptPackage"], botScriptPackage: String = Settings["botScriptPackage"]) { +fun loadScripts(scriptPackage: String = Settings["storage.scripts.package"], botScriptPackage: String = Settings["storage.scripts.bots.package"]) { var scriptCount = 0 val found = mutableSetOf() val isJar = Main::class.java.getResource("${Main::class.simpleName}.class")?.protocol == "jar" diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts index 2adcb524b..2eb8e8888 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts @@ -56,15 +56,15 @@ val players: Players by inject() val logger = InlineLogger() worldSpawn { - if (Settings["shootingStars", false]) { + if (Settings["events.shootingStars.enabled", false]) { eventUpdate() } } settingsReload { - if (Settings["shootingStars", false] && !World.contains("shooting_star_event_timer")) { + if (Settings["events.shootingStars.enabled", false] && !World.contains("shooting_star_event_timer")) { eventUpdate() - } else if (!Settings["shootingStars", false] && World.contains("shooting_star_event_timer")) { + } else if (!Settings["events.shootingStars.enabled", false] && World.contains("shooting_star_event_timer")) { World.clearQueue("shooting_star_event_timer") } } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/Books.kt b/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/Books.kt index 18481d971..ac1e20763 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/Books.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/Books.kt @@ -21,7 +21,7 @@ class Books { fun title(name: String) = titles.getOrDefault(name, "") @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = Settings["bookPath"]): Books { + fun load(yaml: Yaml = get(), path: String = Settings["definitions.books"]): Books { timedLoad("book") { val config = object : YamlReaderConfiguration(2, 2) { override fun add(list: MutableList, value: Any, parentMap: String?) { diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/agility/course/BarbarianOutpost.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/agility/course/BarbarianOutpost.kts index 83477cb80..251b48a93 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/agility/course/BarbarianOutpost.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/agility/course/BarbarianOutpost.kts @@ -48,7 +48,7 @@ objectOperate("Swing-on", "barbarian_outpost_rope_swing") { player.walkTo(player.tile.copy(y = 3554)) player.clear("face_entity") player.face(Direction.SOUTH) - val disable = Settings["disableAdvancedAgilityCourseFailure", false] + val disable = Settings["agility.disableCourseFailure", false] val success = disable || Level.success(player.levels.get(Skill.Agility), 70) // 50% success at 35 // player.message("The rope swing is being used at the moment.", ChatType.Filter) player.start("input_delay", if (success) 5 else 8) @@ -70,7 +70,7 @@ objectOperate("Swing-on", "barbarian_outpost_rope_swing") { player.walkTo(player.tile.copy(y = 9949), noCollision = true, noRun = true) // player.message("", ChatType.Filter) TODO } - if (success || Settings["disableAdvancedAgilityCourseFailLapSkip", false]) { + if (success || Settings["agility.disableFailLapSkip", false]) { player.agilityStage(1) } } @@ -78,7 +78,7 @@ objectOperate("Swing-on", "barbarian_outpost_rope_swing") { objectOperate("Walk-across", "barbarian_outpost_log_balance") { player.start("input_delay", 12) - val disable = Settings["disableAdvancedAgilityCourseFailure", false] + val disable = Settings["agility.disableCourseFailure", false] val success = disable || Level.success(player.levels.get(Skill.Agility), 93) // 62.1% success rate at 35 player.strongQueue("agility_log_balance") { onCancel = { @@ -111,7 +111,7 @@ objectOperate("Walk-across", "barbarian_outpost_log_balance") { player.clearRenderEmote() player.damage(random.nextInt(30, 52)) } - if (success || Settings["disableAdvancedAgilityCourseFailLapSkip", false]) { + if (success || Settings["agility.disableFailLapSkip", false]) { player.agilityStage(2) } } @@ -131,7 +131,7 @@ objectOperate("Climb-over", "barbarian_outpost_obstacle_net") { objectOperate("Walk-across", "barbarian_outpost_balancing_ledge") { player.start("input_delay", 6) player.setAnimation("ledge_stand_right") - val disable = Settings["disableAdvancedAgilityCourseFailure", false] + val disable = Settings["agility.disableCourseFailure", false] val success = disable || Level.success(player.levels.get(Skill.Agility), 93) // 62.1% success rate player.strongQueue("agility_ledge_balance", 1) { onCancel = { @@ -166,7 +166,7 @@ objectOperate("Walk-across", "barbarian_outpost_balancing_ledge") { // player.message("", ChatType.Filter) // TODO // Skip stage so lap doesn't count at end } - if (success || Settings["disableAdvancedAgilityCourseFailLapSkip", false]) { + if (success || Settings["agility.disableFailLapSkip", false]) { player.agilityStage(4) } } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/agility/course/GnomeAdvanced.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/agility/course/GnomeAdvanced.kts index 4292acc3d..4e20a9247 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/agility/course/GnomeAdvanced.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/agility/course/GnomeAdvanced.kts @@ -50,7 +50,7 @@ objectApproach("Run-across", "gnome_sign_post_advanced") { // Pausing for 2 ticks to ensure we're in the correct spot. // arriveDelay() wouldn't work as objectApproach is called before Movement.tick where "last_movement" is set pause(2) - val disable = Settings["disableAdvancedAgilityCourseFailure", false] + val disable = Settings["agility.disableCourseFailure", false] val success = disable || Level.success(player.levels.get(Skill.Agility), -8..286) // failure rate 4.68-1.17% from 85-88 player.face(Direction.EAST) player.setAnimation("gnome_wall_${if (success) "run" else "fail"}") @@ -74,7 +74,7 @@ objectApproach("Run-across", "gnome_sign_post_advanced") { player.damage((player.levels.get(Skill.Constitution) - 10).coerceAtMost(65)) } // Skip stage so lap doesn't count at end - if (success || Settings["disableAdvancedAgilityCourseFailLapSkip", false]) { + if (success || Settings["agility.disableFailLapSkip", false]) { player.agilityStage(5) } player.clearAnimation() diff --git a/game/src/main/kotlin/world/gregs/voidps/world/community/Rights.kts b/game/src/main/kotlin/world/gregs/voidps/world/community/Rights.kts index 107c6e909..e0951c25a 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/community/Rights.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/community/Rights.kts @@ -12,7 +12,7 @@ import world.gregs.voidps.engine.entity.playerSpawn import world.gregs.voidps.engine.get playerSpawn { player -> - if (player.name == Settings.getOrNull("admin") && player.rights != PlayerRights.Admin) { + if (player.name == Settings.getOrNull("admin.name") && player.rights != PlayerRights.Admin) { player.rights = PlayerRights.Admin player.message("Rights set to Admin. Please re-log to activate.") } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/community/friend/Friends.kt b/game/src/main/kotlin/world/gregs/voidps/world/community/friend/Friends.kt index 4d412fcd2..6f74a4f95 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/community/friend/Friends.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/community/friend/Friends.kt @@ -6,7 +6,7 @@ import world.gregs.voidps.engine.entity.character.player.Player fun Player.friend(other: Player) = this != other && friends.contains(other.accountName) val Settings.world: Int - get() = this["world", 16] + get() = this["world.id", 16] val Settings.worldName: String - get() = this["worldName", "World 16"] \ No newline at end of file + get() = this["world.name", "World 16"] \ No newline at end of file diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/Movement.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/Movement.kts index 9e4da4535..f9bfc233a 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/Movement.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/Movement.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.interact.entity import org.rsmod.game.pathfinder.flag.CollisionFlag import world.gregs.voidps.engine.data.Settings +import world.gregs.voidps.engine.entity.* import world.gregs.voidps.engine.entity.character.Character import world.gregs.voidps.engine.entity.character.mode.move.move import world.gregs.voidps.engine.entity.character.mode.move.npcMove @@ -9,9 +10,6 @@ import world.gregs.voidps.engine.entity.character.npc.NPCs import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.Players import world.gregs.voidps.engine.entity.character.size -import world.gregs.voidps.engine.entity.characterDespawn -import world.gregs.voidps.engine.entity.npcSpawn -import world.gregs.voidps.engine.entity.playerSpawn import world.gregs.voidps.engine.inject import world.gregs.voidps.engine.map.collision.Collisions import world.gregs.voidps.type.Tile @@ -23,40 +21,46 @@ val npcs: NPCs by inject() val players: Players by inject() playerSpawn { player -> - if (players.add(player) && Settings["characterCollision", false]) { + if (players.add(player) && Settings["world.players.collision", false]) { add(player) } } -npcSpawn { npc -> - if (Settings["characterCollision", false]) { - add(npc) +move { + if (Settings["world.players.collision", false]) { + move(character, from, to) } } -npcDeath { npc -> - remove(npc) -} - -characterDespawn { character -> - if (Settings["characterCollision", false]) { - remove(character) +playerDespawn { player -> + if (Settings["world.players.collision", false]) { + remove(player) } } -move { - if (Settings["characterCollision", false]) { - move(character, from, to) +npcSpawn { npc -> + if (Settings["world.npcs.collision", false]) { + add(npc) } } npcMove { - if (Settings["characterCollision", false] && !character.dead) { + if (Settings["world.npcs.collision", false] && !character.dead) { move(character, from, to) } npcs.update(from, to, npc) } +npcDeath { npc -> + remove(npc) +} + +npcDespawn { npc -> + if (Settings["world.npcs.collision", false]) { + remove(npc) + } +} + fun add(char: Character) { val mask = entity(char) val size = char.size diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/combat/hit/CombatHitsplats.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/combat/hit/CombatHitsplats.kts index f30311353..5ed99cb4d 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/combat/hit/CombatHitsplats.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/combat/hit/CombatHitsplats.kts @@ -18,12 +18,12 @@ characterCombatHit { character -> } var damage = damage var soak = 0 - if (Settings["damageSoak", true] && damage > 200) { + if (Settings["combat.damageSoak", true] && damage > 200) { val percent = character["absorb_$type", 10] / 100.0 soak = floor((damage - 200) * percent).toInt() damage -= soak } - if (Settings["showSoak", true] || soak <= 0) { + if (Settings["combat.showSoak", true] || soak <= 0) { soak = -1 } val dealers = character.damageDealers diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/PlayerDeath.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/PlayerDeath.kts index d18006b06..add8610c5 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/PlayerDeath.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/PlayerDeath.kts @@ -46,7 +46,7 @@ val Character.damageDealers: MutableMap get() = getOrPut("damage_dealers") { mutableMapOf() } val respawnTile: Tile - get() = Tile(Settings["homeX", 0], Settings["homeY", 0], Settings["homeLevel", 0]) + get() = Tile(Settings["world.home.x", 0], Settings["world.home.y", 0], Settings["world.home.level", 0]) playerDeath { player -> player.dead = true diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/obj/Teleports.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/obj/Teleports.kt index 091f74ed9..d238c9dc4 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/obj/Teleports.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/obj/Teleports.kt @@ -71,7 +71,7 @@ class Teleports { } @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = Settings["teleportsPath"]): Teleports { + fun load(yaml: Yaml = get(), path: String = Settings["map.teleports"]): Teleports { timedLoad("object teleport") { val config = object : YamlReaderConfiguration() { override fun add(list: MutableList, value: Any, parentMap: String?) { diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/music/MusicTracks.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/music/MusicTracks.kt index 75059d57d..689fc2008 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/music/MusicTracks.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/music/MusicTracks.kt @@ -24,7 +24,7 @@ class MusicTracks { } @Suppress("UNCHECKED_CAST") - fun load(yaml: Yaml = get(), path: String = Settings["musicPath"]): MusicTracks { + fun load(yaml: Yaml = get(), path: String = Settings["map.music"]): MusicTracks { timedLoad("music track") { var count = 0 val tracks = Int2ObjectOpenHashMap>() diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/ItemSpawns.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/ItemSpawns.kt index 2e4386e43..775d2f327 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/ItemSpawns.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/ItemSpawns.kt @@ -32,7 +32,7 @@ fun loadItemSpawns( items: FloorItems, spawns: ItemSpawns, yaml: Yaml = get(), - path: String = Settings["itemSpawnsPath"] + path: String = Settings["spawns.items"] ) { timedLoad("item spawn") { spawns.clear() diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/NPCSpawns.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/NPCSpawns.kt index 8f843394b..e72aa163f 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/NPCSpawns.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/NPCSpawns.kt @@ -14,7 +14,7 @@ import world.gregs.yaml.read.YamlReaderConfiguration fun loadNpcSpawns( npcs: NPCs, yaml: Yaml = get(), - path: String = Settings["npcSpawnsPath"] + path: String = Settings["spawns.npcs"] ) { timedLoad("npc spawn") { npcs.clear() diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/ObjectSpawns.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/ObjectSpawns.kt index a219cf175..2735d1e4d 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/ObjectSpawns.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/world/spawn/ObjectSpawns.kt @@ -15,7 +15,7 @@ import world.gregs.yaml.read.YamlReaderConfiguration fun loadObjectSpawns( objects: GameObjects, yaml: Yaml = get(), - path: String = Settings["objectsPath"], + path: String = Settings["spawns.objects"], definitions: ObjectDefinitions = get(), ) = timedLoad("object spawn") { objects.reset() diff --git a/game/src/main/resources/game.properties b/game/src/main/resources/game.properties index 0faea6431..819d00c0c 100644 --- a/game/src/main/resources/game.properties +++ b/game/src/main/resources/game.properties @@ -1,90 +1,231 @@ -# Game Settings -name=Void -port=43594 -revision=634 -# World -live=false -world=1 -members=true -homeX=3221 -homeY=3219 -experienceRate=1.0 -bots=10 -maxPlayers=2048 -admin=Greg -loginLimit=10 -randomWalk=true -characterCollision=true -loadUnusedObjects=true -connectionPerTickCap=25 -showSoak=true -damageSoak=true -# Events -shootingStars=true -# Content -disableAdvancedAgilityCourseFailure=false -disableAdvancedAgilityCourseFailLapSkip=false -# Files -fileServer=true -## Storage -storage=files -savePath=./data/saves/ -#storage=database -#database_username=postgres -#database_password=password -#database_driver=org.postgresql.Driver -#database_jdbc_url=jdbc:postgresql://localhost:5432/game?reWriteBatchedInserts=true -#database_pool=4 -cachePath=./data/cache/ -scriptPackage=world.gregs.voidps.world -botScriptPackage=world.gregs.voidps.bot -storageFailDirectory=./data/errors/ -## Spawns -objectsPath=./data/spawns/object-spawns.yml -npcSpawnsPath=./data/spawns/npc-spawns.yml -itemSpawnsPath=./data/spawns/item-spawns.yml -dropsPath=./data/spawns/drops.yml -## Map -areaPath=./data/map/areas.yml -teleportsPath=./data/map/teleports.yml -musicPath=./data/map/music-tracks.yml -navGraphPath=./data/map/nav-graph.yml -## Definitions -definitionsPath=./data/definitions/ -bookPath=./data/definitions/books.yml -huntPath=./data/definitions/hunt-modes.yml -interfacesPath=./data/definitions/interfaces.yml -interfaceTypesPath=./data/definitions/interface-types.yml -objectDefinitionsPath=./data/definitions/objects.yml -npcDefinitionsPath=./data/definitions/npcs.yml -itemDefinitionsPath=./data/definitions/items.yml -animationDefinitionsPath=./data/definitions/animations.yml -graphicDefinitionsPath=./data/definitions/graphics.yml -inventoryDefinitionsPath=./data/definitions/inventories.yml -soundDefinitionsPath=./data/definitions/sounds.yml -questDefinitionsPath=./data/definitions/quests.yml -renderEmoteDefinitionsPath=./data/definitions/render-emotes.yml -midiDefinitionsPath=./data/definitions/midis.yml -jingleDefinitionsPath=./data/definitions/jingles.yml -spellDefinitionsPath=./data/definitions/spells.yml -patrolDefinitionsPath=./data/definitions/patrols.yml -prayerDefinitionsPath=./data/definitions/prayers.yml -itemOnItemDefinitionsPath=./data/definitions/item-on-item.yml -diangoCodeDefinitionsPath=./data/definitions/diango-codes.yml -gearDefinitionsPath=./data/definitions/gear-sets.yml -enumDefinitionsPath=./data/definitions/enums.yml -structDefinitionsPath=./data/definitions/structs.yml -fontDefinitionsPath=./data/definitions/fonts.yml -weaponStyleDefinitionsPath=./data/definitions/weapon-styles.yml -weaponAnimationDefinitionsPath=./data/definitions/weapon-animations.yml -ammoDefinitionsPath=./data/definitions/ammo-groups.yml -categoryDefinitionsPath=./data/definitions/categories.yml -parameterDefinitionsPath=./data/definitions/parameters.yml -clientScriptDefinitionsPath=./data/definitions/scripts.yml -# RSA Keys -gameModulus=ea3680fdebf2621da7a33601ba39925ee203b3fc80775cd3727bf27fd8c0791c803e0bdb42b8b5257567177f8569024569da9147cef59009ed016af6007e57a556f1754f09ca84dd39a03287f7e41e8626fd78ab3b53262bd63f2e37403a549980bf3077bd402b82ef5fac269eb3c04d2a9b7712a67a018321ceba6c3bfb8f7f -gamePrivate=8330565e649c16d32f841f0b26a97ad044def821164045b176adf0ae25d5e1c0d2206ef9b8ccc7429d194ab33622149096f3436f2a80a7d6b77794d7087dbc4f21239a4012b18afa3d1bede29d63f33bc553885f7117aa5d842231fae613d6e612c651249e66b7c67d565b21e68202798ccdbd0cc6dea3f6d033e719cb75ea01 -fileModulus=d6808be939bbfd2ec4e96b1581ce3e1144b526e7643a72e3c64fbb902724fbfcf14ab601da6d6f8dbb57d1c369d080d9fc392abeb7886e0076d07f2aea5810e540d2817fd1967e35b39cc95cf7c9170b5fb55f5bf95524b60e938f0d64614bc365b87d66963a8cc8664e32875366099ef297180d01c7c3842162865e11d92299 -filePrivate=bd7a119cf43de5f90141fb30a5582ca58e5ec2bdd560780a522c2e4fb8f4478f790978db0c3a6d36f28d31a2ff7e89c384b46ed8c740c182b1719d53a86c2086f376d1c213785fd35c2aac5648195d10681d00a8c801dcebc1c7645daad5824c95430324a71228bb43be1bb7df6ac6ca8587f0848cf765fb850f40486b5475ed -# File server prefetch file list -prefetchKeys=104,79328,55571,46770,24563,299978,44375,0,4177,2822,100024,617990,155187,332544,388139,682557,18883,19031,16187,1248,6254,526,119,741556,821698,3671,2908 \ No newline at end of file +#=================================== +# General Game Settings +#=================================== + +# The name of the game server +game.name=Void + +# The port the game server will listen on +game.port=43594 + +# The game revision (affects client compatibility) +game.revision=634 + +# Set to 'true' the server will run in live mode storing all data in memory +game.live=false + + +#=================================== +# World Settings +#=================================== + +# The ID of the world (useful for multi-world setups) +world.id=1 + +# The Name of the world +world.name=World 1 + +# Whether this world is members-only +world.members=true + +# The default home spawn coordinates (X, Y, Level) +world.home.x=3221 +world.home.y=3219 +#world.home.level=0 + +# Experience multiplier (1.0 = normal XP rate) +world.experienceRate=1.0 + +# The number of AI-controlled bots to populate the world +world.bots=10 + +# The maximum number of players that can be online at once +world.players.max=2048 + +# Whether players can be collided with +world.players.collision=true + +# Whether NPCs can be collided with +world.npcs.collision=true + +# Whether NPCs can move randomly +world.npcs.randomWalk=true + + +#=================================== +# Gameplay Mechanics +#=================================== + +# The admin username (always sets administrative privileges on login) +admin.name=Greg + +# Number of accounts one ip address can log into at the same time. +network.maxClientPerIP=10 + +# Maximum number of players to allow login per tick +network.maxLoginsPerTick=25 + +# Load all objects into memory +development.loadAllObjects=true + + +#=================================== +# Content Customization +#=================================== + +# Whether shooting stars appear as an event in the game world +events.shootingStars.enabled=true + +# Whether reducing hits by equipment absorption is enabled in combat mechanics +combat.damageSoak=true + +# Whether to display blue damage soaking next to hit splats +combat.showSoak=true + +# Disable players failing obstacles on advanced agility courses +agility.disableCourseFailure=false + +# Disable skipping laps towards Agile when failing advanced courses +agility.disableFailLapSkip=true + + +#=================================== +# Storage & File System +#=================================== + +# The type of storage backend (options: files, database) +storage.type=files + +# The directory where player save files are stored +storage.players.path=./data/saves/ + +# The directory where failed player save files are stored +storage.players.errors=./data/errors/ + +# The directory where game cache data is stored +storage.cache.path=./data/cache/ + +# The type of file server backend (options: internal, external) +storage.cache.server=internal + +# The package path for general game scripts +storage.scripts.package=world.gregs.voidps.world + +# The package path for bot AI scripts +storage.scripts.bots.package=world.gregs.voidps.bot + +# Database configuration (uncomment to enable database storage) +#storage.database.username=postgres +#storage.database.password=password +#storage.database.driver=org.postgresql.Driver +#storage.database.jdbcUrl=jdbc:postgresql://localhost:5432/game?reWriteBatchedInserts=true +#storage.database.poolSize=4 + + +#=================================== +# Spawn Configuration +#=================================== + +# Path to the object spawns file +spawns.objects=./data/spawns/object-spawns.yml + +# Path to the npc spawns file +spawns.npcs=./data/spawns/npc-spawns.yml + +# Path to the floor item spawns file +spawns.items=./data/spawns/item-spawns.yml + +# Path to the npc item drops file +spawns.drops=./data/spawns/drops.yml + + +#=================================== +# Map & Navigation +#=================================== + +# Path to the area definitions file +map.areas=./data/map/areas.yml + +# Path to the teleport location definitions file +map.teleports=./data/map/teleports.yml + +# Path to the music track location data +map.music=./data/map/music-tracks.yml + +# Path to the navigation graph data +map.navGraph=./data/map/nav-graph.yml + + +#=================================== +# Game Definitions +#=================================== + +# The base directory for all game definitions +definitions.path=./data/definitions/ + +# Paths to specific game content definitions +definitions.objects=./data/definitions/objects.yml +definitions.items=./data/definitions/items.yml +definitions.itemOnItem=./data/definitions/item-on-item.yml +definitions.animations=./data/definitions/animations.yml +definitions.graphics=./data/definitions/graphics.yml +definitions.sounds=./data/definitions/sounds.yml +definitions.midis=./data/definitions/midis.yml +definitions.jingles=./data/definitions/jingles.yml + +# Paths to interface related definitions +definitions.books=./data/definitions/books.yml +definitions.fonts=./data/definitions/fonts.yml +definitions.inventories=./data/definitions/inventories.yml +definitions.interfaces=./data/definitions/interfaces.yml +definitions.interfaces.types=./data/definitions/interface-types.yml + +# Paths to npc related definitions +definitions.npcs=./data/definitions/npcs.yml +definitions.huntModes=./data/definitions/hunt-modes.yml +definitions.patrols=./data/definitions/patrols.yml +definitions.diangoCodes=./data/definitions/diango-codes.yml + +# Paths to player related definitions +definitions.spells=./data/definitions/spells.yml +definitions.prayers=./data/definitions/prayers.yml +definitions.quests=./data/definitions/quests.yml +definitions.renderEmotes=./data/definitions/render-emotes.yml + +# Paths to equipment related definitions +definitions.weapons.styles=./data/definitions/weapon-styles.yml +definitions.weapons.animations=./data/definitions/weapon-animations.yml +definitions.ammoGroups=./data/definitions/ammo-groups.yml +definitions.gearSets=./data/definitions/gear-sets.yml + +# Paths to client related definitions +definitions.enums=./data/definitions/enums.yml +definitions.structs=./data/definitions/structs.yml +definitions.categories=./data/definitions/categories.yml +definitions.parameters=./data/definitions/parameters.yml +definitions.clientScripts=./data/definitions/scripts.yml + + +#=================================== +# Security & RSA Encryption Keys +#=================================== + +# RSA public modulus for game authentication +security.game.modulus=ea3680fdebf2621da7a33601ba39925ee203b3fc80775cd3727bf27fd8c0791c803e0bdb42b8b5257567177f8569024569da9147cef59009ed016af6007e57a556f1754f09ca84dd39a03287f7e41e8626fd78ab3b53262bd63f2e37403a549980bf3077bd402b82ef5fac269eb3c04d2a9b7712a67a018321ceba6c3bfb8f7f + +# RSA private key for game authentication +security.game.private=8330565e649c16d32f841f0b26a97ad044def821164045b176adf0ae25d5e1c0d2206ef9b8ccc7429d194ab33622149096f3436f2a80a7d6b77794d7087dbc4f21239a4012b18afa3d1bede29d63f33bc553885f7117aa5d842231fae613d6e612c651249e66b7c67d565b21e68202798ccdbd0cc6dea3f6d033e719cb75ea01 + +# RSA public modulus for file server authentication +security.file.modulus=d6808be939bbfd2ec4e96b1581ce3e1144b526e7643a72e3c64fbb902724fbfcf14ab601da6d6f8dbb57d1c369d080d9fc392abeb7886e0076d07f2aea5810e540d2817fd1967e35b39cc95cf7c9170b5fb55f5bf95524b60e938f0d64614bc365b87d66963a8cc8664e32875366099ef297180d01c7c3842162865e11d92299 + +# RSA private key for file server authentication +security.file.private=bd7a119cf43de5f90141fb30a5582ca58e5ec2bdd560780a522c2e4fb8f4478f790978db0c3a6d36f28d31a2ff7e89c384b46ed8c740c182b1719d53a86c2086f376d1c213785fd35c2aac5648195d10681d00a8c801dcebc1c7645daad5824c95430324a71228bb43be1bb7df6ac6ca8587f0848cf765fb850f40486b5475ed + + +#=================================== +# Prefetch System (File Server Optimization) +#=================================== + +# List of file IDs to be prefetched by the file server +prefetch.keys=104,79328,55571,46770,24563,299978,44375,0,4177,2822,100024,617990,155187,332544,388139,682557,18883,19031,16187,1248,6254,526,119,741556,821698,3671,2908 \ No newline at end of file diff --git a/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/npc/NPCTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/npc/NPCTest.kt index cf0a2bca5..6a2d2ca41 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/npc/NPCTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/npc/NPCTest.kt @@ -9,7 +9,7 @@ internal class NPCTest : WorldTest() { @Test fun `Man randomly walks around`() { - settings["randomWalk"] = "true" + settings["world.npcs.randomWalk"] = "true" val spawn = emptyTile val npc = createNPC("chicken", spawn) { npc -> npc["area"] = Rectangle(spawn.minus(25, 25), 50, 50) diff --git a/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/CombinationRuneTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/CombinationRuneTest.kt index 16ce9461d..65a30fb5d 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/CombinationRuneTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/CombinationRuneTest.kt @@ -22,7 +22,7 @@ class CombinationRuneTest : MagicSpellTest() { Triple("lava_rune", "earth_rune", "fire_rune") ).map { (combo, element1, element2) -> dynamicTest("Remove ${combo.replace("_", " ")}s") { - Settings.load(mapOf("members" to "true")) + Settings.load(mapOf("world.members" to "true")) val player = player() setItems(Item(element1, 2), Item(element2, 1), Item("chaos_rune", 1)) @@ -52,7 +52,7 @@ class CombinationRuneTest : MagicSpellTest() { "lava_rune" to "fire_rune" ).map { (combo, element) -> dynamicTest("Use ${element.replace("_", " ")}s when out of ${combo.replace("_", " ")}s") { - Settings.load(mapOf("members" to "true")) + Settings.load(mapOf("world.members" to "true")) val player = player() setItems(Item(element, 2)) diff --git a/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/SpellTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/SpellTest.kt index 7a4abac3f..a7ec2bb2b 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/SpellTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/interact/entity/player/combat/magic/spell/SpellTest.kt @@ -46,7 +46,7 @@ class SpellTest : MagicSpellTest() { @Test fun `Members spell`() { - Settings.load(mapOf("members" to "false")) + Settings.load(mapOf("world.members" to "false")) World.start() val player = player() diff --git a/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt index c050eb555..6d1734640 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt @@ -189,7 +189,7 @@ abstract class WorldTest : KoinTest { } loadScripts() MapDefinitions(CollisionDecoder(get()), get(), get(), cache).loadCache() - saves = File(Settings["savePath"]) + saves = File(Settings["storage.players.path"]) saves?.mkdirs() val millis = measureTimeMillis { val handler = InterfaceHandler(get(), get(), get()) @@ -256,7 +256,7 @@ abstract class WorldTest : KoinTest { } companion object { - private val cache: Cache by lazy { MemoryCache(Settings["cachePath"]) } + private val cache: Cache by lazy { MemoryCache(Settings["storage.cache.path"]) } private val huffman: Huffman by lazy { Huffman().load(cache.data(Index.HUFFMAN, 1)!!) } private val ammoDefinitions: AmmoDefinitions by lazy { AmmoDefinitions().load() } private val parameterDefinitions: ParameterDefinitions by lazy { ParameterDefinitions(CategoryDefinitions().load(), ammoDefinitions).load() } diff --git a/game/src/test/resources/test.properties b/game/src/test/resources/test.properties index 22876e40e..6df7a53dd 100644 --- a/game/src/test/resources/test.properties +++ b/game/src/test/resources/test.properties @@ -1,61 +1,58 @@ # Game Settings -name=Void -port=43594 -dataPath=../data/ -cachePath=../data/cache/ -savePath=../data/test-saves/ -scriptPackage=world.gregs.voidps.world -botScriptPackage=world.gregs.voidps.bot -storageFailDirectory=../data/errors/ -interfacesPath=../data/definitions/interfaces.yml -interfaceTypesPath=../data/definitions/interface-types.yml -objectsPath=../data/spawns/object-spawns.yml -teleportsPath=../data/map/teleports.yml -musicPath=../data/map/music-tracks.yml -navGraphPath=../data/map/nav-graph.yml -areaPath=../data/map/areas.yml -npcSpawnsPath=../data/spawns/npc-spawns.yml -itemSpawnsPath=../data/spawns/item-spawns.yml -definitionsPath=../data/definitions/ -huntPath=../data/definitions/hunt-modes.yml -objectDefinitionsPath=../data/definitions/objects.yml -npcDefinitionsPath=../data/definitions/npcs.yml -itemDefinitionsPath=../data/definitions/items.yml -animationDefinitionsPath=../data/definitions/animations.yml -graphicDefinitionsPath=../data/definitions/graphics.yml -inventoryDefinitionsPath=../data/definitions/inventories.yml -soundDefinitionsPath=../data/definitions/sounds.yml -questDefinitionsPath=../data/definitions/quests.yml -renderEmoteDefinitionsPath=../data/definitions/render-emotes.yml -midiDefinitionsPath=../data/definitions/midis.yml -jingleDefinitionsPath=../data/definitions/jingles.yml -itemOnItemDefinitionsPath=../data/definitions/item-on-item.yml -diangoCodeDefinitionsPath=../data/definitions/diango-codes.yml -spellDefinitionsPath=../data/definitions/spells.yml -patrolDefinitionsPath=../data/definitions/patrols.yml -prayerDefinitionsPath=../data/definitions/prayers.yml -gearDefinitionsPath=../data/definitions/gear-sets.yml -enumDefinitionsPath=../data/definitions/enums.yml -structDefinitionsPath=../data/definitions/structs.yml -fontDefinitionsPath=../data/definitions/fonts.yml -weaponStyleDefinitionsPath=../data/definitions/weapon-styles.yml -weaponAnimationDefinitionsPath=../data/definitions/weapon-animations.yml -ammoDefinitionsPath=../data/definitions/ammo-groups.yml -categoryDefinitionsPath=../data/definitions/categories.yml -parameterDefinitionsPath=../data/definitions/parameters.yml -clientScriptDefinitionsPath=../data/definitions/scripts.yml -dropsPath=../data/spawns/drops.yml -bookPath=../data/definitions/books.yml -revision=634 -maxPlayers=2048 -loginLimit=5 -homeX=3221 -homeY=3219 -connectionPerTickCap=25 -eventBufferLimit=25 -randomWalk=false -members=true -characterCollision=true -loadUnusedObjects=true -disableAdvancedAgilityCourseFailure=false -disableAdvancedAgilityCourseFailLapSkip=false +game.name=Void +game.port=43594 +storage.cache.path=../data/cache/ +storage.players.path=../data/test-saves/ +storage.scripts.package=world.gregs.voidps.world +storage.scripts.bots.package=world.gregs.voidps.bot +storage.players.errors=../data/errors/ +definitions.interfaces=../data/definitions/interfaces.yml +definitions.interfaces.types=../data/definitions/interface-types.yml +spawns.objects=../data/spawns/object-spawns.yml +map.teleports=../data/map/teleports.yml +map.music=../data/map/music-tracks.yml +map.navGraph=../data/map/nav-graph.yml +map.areas=../data/map/areas.yml +spawns.npcs=../data/spawns/npc-spawns.yml +spawns.items=../data/spawns/item-spawns.yml +definitions.path=../data/definitions/ +definitions.huntModes=../data/definitions/hunt-modes.yml +definitions.objects=../data/definitions/objects.yml +definitions.npcs=../data/definitions/npcs.yml +definitions.items=../data/definitions/items.yml +definitions.animations=../data/definitions/animations.yml +definitions.graphics=../data/definitions/graphics.yml +definitions.inventories=../data/definitions/inventories.yml +definitions.sounds=../data/definitions/sounds.yml +definitions.quests=../data/definitions/quests.yml +definitions.renderEmotes=../data/definitions/render-emotes.yml +definitions.midis=../data/definitions/midis.yml +definitions.jingles=../data/definitions/jingles.yml +definitions.itemOnItem=../data/definitions/item-on-item.yml +definitions.diangoCodes=../data/definitions/diango-codes.yml +definitions.spells=../data/definitions/spells.yml +definitions.patrols=../data/definitions/patrols.yml +definitions.prayers=../data/definitions/prayers.yml +definitions.gearSets=../data/definitions/gear-sets.yml +definitions.enums=../data/definitions/enums.yml +definitions.structs=../data/definitions/structs.yml +definitions.fonts=../data/definitions/fonts.yml +definitions.weapons.styles=../data/definitions/weapon-styles.yml +definitions.weapons.animations=../data/definitions/weapon-animations.yml +definitions.ammoGroups=../data/definitions/ammo-groups.yml +definitions.categories=../data/definitions/categories.yml +definitions.parameters=../data/definitions/parameters.yml +definitions.clientScripts=../data/definitions/scripts.yml +spawns.drops=../data/spawns/drops.yml +definitions.books=../data/definitions/books.yml +game.revision=634 +world.players.max=2048 +network.maxClientPerIP=5 +world.home.x=3221 +world.home.y=3219 +network.maxLoginsPerTick=25 +world.npcs.randomWalk=false +world.members=true +world.npcs.collision=true +world.players.collision=true +development.loadAllObjects=true diff --git a/network/src/main/kotlin/world/gregs/voidps/network/FileServer.kt b/network/src/main/kotlin/world/gregs/voidps/network/FileServer.kt index 43d26ede6..5b9de4290 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/FileServer.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/FileServer.kt @@ -112,12 +112,12 @@ class FileServer( private const val ACKNOWLEDGE_ID = 3 fun load(cache: Cache, properties: Properties): Server { - val fileServer = properties.getProperty("fileServer").toBoolean() - if (!fileServer) { + val fileServer = properties.getProperty("storage.cache.server") + if (fileServer == "external") { return offlineFileServer() } val fileProvider: FileProvider = FileProvider.load(cache, properties) - val revision = properties.getProperty("revision").toInt() + val revision = properties.getProperty("game.revision").toInt() val prefetchKeys = prefetchKeys(cache, properties) return FileServer(revision, prefetchKeys, fileProvider) } diff --git a/network/src/main/kotlin/world/gregs/voidps/network/GameServer.kt b/network/src/main/kotlin/world/gregs/voidps/network/GameServer.kt index 22e70b2a7..59388bb5a 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/GameServer.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/GameServer.kt @@ -93,7 +93,7 @@ class GameServer( @ExperimentalUnsignedTypes fun load(cache: Cache, properties: Properties): GameServer { - val limit = properties.getProperty("loginLimit").toInt() + val limit = properties.getProperty("network.maxClientPerIP").toInt() val fileServer = FileServer.load(cache, properties) return GameServer(fileServer, ConnectionTracker(limit)) } diff --git a/network/src/main/kotlin/world/gregs/voidps/network/LoginServer.kt b/network/src/main/kotlin/world/gregs/voidps/network/LoginServer.kt index b7f92dfe7..989f7d941 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/LoginServer.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/LoginServer.kt @@ -163,10 +163,10 @@ class LoginServer( private val logger = InlineLogger() fun load(properties: Properties, protocol: Array, loader: AccountLoader): LoginServer { - val gameModulus = BigInteger(properties.getProperty("gameModulus"), 16) - val gamePrivate = BigInteger(properties.getProperty("gamePrivate"), 16) - val revision = properties.getProperty("revision").toInt() - val maxPlayers = properties.getProperty("maxPlayers").toInt() + val gameModulus = BigInteger(properties.getProperty("security.game.modulus"), 16) + val gamePrivate = BigInteger(properties.getProperty("security.game.private"), 16) + val revision = properties.getProperty("game.revision").toInt() + val maxPlayers = properties.getProperty("world.players.max").toInt() return LoginServer(protocol, revision, maxPlayers, gameModulus, gamePrivate, loader) } } diff --git a/network/src/main/kotlin/world/gregs/voidps/network/file/FileProvider.kt b/network/src/main/kotlin/world/gregs/voidps/network/file/FileProvider.kt index ea23889f5..b7aa8e193 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/file/FileProvider.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/file/FileProvider.kt @@ -40,7 +40,7 @@ interface FileProvider { fun load(cache: Cache, properties: Properties): FileProvider { val start = System.currentTimeMillis() - val live = properties.getProperty("live").toBoolean() + val live = properties.getProperty("game.live").toBoolean() val provider = if (live) MemoryFileProvider(cache) else CacheFileProvider(cache) logger.info { "Loaded file provider in ${System.currentTimeMillis() - start}ms" } return provider diff --git a/network/src/main/kotlin/world/gregs/voidps/network/file/PrefetchKeys.kt b/network/src/main/kotlin/world/gregs/voidps/network/file/PrefetchKeys.kt index 84ccc23c1..f575ed3ef 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/file/PrefetchKeys.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/file/PrefetchKeys.kt @@ -5,7 +5,7 @@ import world.gregs.voidps.cache.Index import java.util.* fun prefetchKeys(cache: Cache, properties: Properties): IntArray { - val existing = properties["prefetchKeys"] as? String + val existing = properties["prefetch.keys"] as? String return existing?.split(",")?.map { it.toInt() }?.toIntArray() ?: generatePrefetchKeys(cache) } diff --git a/network/src/test/kotlin/world/gregs/voidps/network/FileServerTest.kt b/network/src/test/kotlin/world/gregs/voidps/network/FileServerTest.kt index d2e038a94..7f6b7a93a 100644 --- a/network/src/test/kotlin/world/gregs/voidps/network/FileServerTest.kt +++ b/network/src/test/kotlin/world/gregs/voidps/network/FileServerTest.kt @@ -211,7 +211,7 @@ class FileServerTest { val readChannel = ByteChannel(autoFlush = true) val writeChannel = ByteChannel(autoFlush = true) val properties = Properties() - properties.setProperty("fileServer", "false") + properties.setProperty("storage.cache.server", "external") val server = FileServer.load(mockk(relaxed = true), properties) @@ -230,10 +230,10 @@ class FileServerTest { val readChannel = ByteChannel(autoFlush = true) val writeChannel = ByteChannel(autoFlush = true) val properties = Properties() - properties.setProperty("fileServer", "true") - properties.setProperty("revision", "123") + properties.setProperty("storage.cache.server", "internal") + properties.setProperty("game.revision", "123") val prefetchKeys = listOf(1, 2, 3, 4) - properties.setProperty("prefetchKeys", prefetchKeys.joinToString(",")) + properties.setProperty("prefetch.keys", prefetchKeys.joinToString(",")) val server = FileServer.load(mockk(relaxed = true), properties) val job = launch { diff --git a/network/src/test/kotlin/world/gregs/voidps/network/GameServerTest.kt b/network/src/test/kotlin/world/gregs/voidps/network/GameServerTest.kt index f902f3357..b16f6762d 100644 --- a/network/src/test/kotlin/world/gregs/voidps/network/GameServerTest.kt +++ b/network/src/test/kotlin/world/gregs/voidps/network/GameServerTest.kt @@ -155,8 +155,8 @@ internal class GameServerTest { val readChannel = ByteChannel(autoFlush = true) val writeChannel = ByteChannel(autoFlush = true) val properties = Properties() - properties.setProperty("loginLimit", "0") - properties.setProperty("fileServer", "false") + properties.setProperty("network.maxClientPerIP", "0") + properties.setProperty("storage.cache.server", "false") server = GameServer.load(mockk(relaxed = true), properties) launch { diff --git a/network/src/test/kotlin/world/gregs/voidps/network/LoginServerTest.kt b/network/src/test/kotlin/world/gregs/voidps/network/LoginServerTest.kt index 404d7fa61..8eff7399d 100644 --- a/network/src/test/kotlin/world/gregs/voidps/network/LoginServerTest.kt +++ b/network/src/test/kotlin/world/gregs/voidps/network/LoginServerTest.kt @@ -348,10 +348,10 @@ internal class LoginServerTest { @Test fun `Load from properties`() = runTest { val properties = Properties() - properties.setProperty("gameModulus", modulus.toString(16)) - properties.setProperty("gamePrivate", "10001") - properties.setProperty("revision", "123") - properties.setProperty("maxPlayers", "10") + properties.setProperty("security.game.modulus", modulus.toString(16)) + properties.setProperty("security.game.private", "10001") + properties.setProperty("game.revision", "123") + properties.setProperty("world.players.max", "10") server = LoginServer.load(properties, protocol, accounts) val readChannel = ByteChannel(autoFlush = true) val writeChannel = ByteChannel(autoFlush = true) diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/AnimationDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/AnimationDefinitions.kt index dbeda0f82..77e54c6ef 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/AnimationDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/AnimationDefinitions.kt @@ -7,7 +7,7 @@ import world.gregs.voidps.cache.definition.decoder.AnimationDecoderFull object AnimationDefinitions { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = AnimationDecoderFull().load(cache) val match = decoder[10289].frames for (i in decoder.indices) { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/ClientScriptDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/ClientScriptDefinitions.kt index dd7c14c00..c125a4902 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/ClientScriptDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/ClientScriptDefinitions.kt @@ -8,7 +8,7 @@ import world.gregs.voidps.cache.definition.decoder.ClientScriptDecoder object ClientScriptDefinitions { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = ClientScriptDecoder().load(cache) for (i in decoder.indices) { // if (i != 1142) { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/DropTableDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/DropTableDefinitions.kt index f3118c909..7a32aeb07 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/DropTableDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/DropTableDefinitions.kt @@ -21,7 +21,7 @@ object DropTableDefinitions { fileProperties("/tool.properties") modules(module { @Suppress("USELESS_CAST") - single { CacheDelegate(Settings["cachePath"]) as Cache } + single { CacheDelegate(Settings["storage.cache.path"]) as Cache } single { ItemDefinitions(ItemDecoder().load(get())).load(Yaml()) } }) } diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/EnumDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/EnumDefinitions.kt index c6517c29a..8dff907ec 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/EnumDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/EnumDefinitions.kt @@ -3,13 +3,12 @@ package world.gregs.voidps.tools import world.gregs.voidps.cache.Cache import world.gregs.voidps.cache.CacheDelegate import world.gregs.voidps.cache.definition.decoder.EnumDecoder -import world.gregs.voidps.engine.data.Settings object EnumDefinitions { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = EnumDecoder().load(cache) for (i in decoder.indices) { val def = decoder.getOrNull(i) ?: continue diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/FontDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/FontDefinitions.kt index 78d6ce793..2c72835e4 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/FontDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/FontDefinitions.kt @@ -9,7 +9,7 @@ object FontDefinitions { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val definitions = FontDecoder().load(cache) val font = definitions[cache.archiveId(FONT_METRICS, "q8_full")] println(font.textWidth("This is a string")) diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/GraphicDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/GraphicDefinitions.kt index bd0ede983..80760d0ae 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/GraphicDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/GraphicDefinitions.kt @@ -7,7 +7,7 @@ import world.gregs.voidps.cache.definition.decoder.GraphicDecoder object GraphicDefinitions { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = GraphicDecoder().load(cache) println(decoder[212]) for (i in decoder.indices) { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/IdentityKitDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/IdentityKitDefinitions.kt index 4caae8220..6c91b727b 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/IdentityKitDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/IdentityKitDefinitions.kt @@ -7,7 +7,7 @@ import world.gregs.voidps.cache.config.decoder.IdentityKitDecoder object IdentityKitDefinitions { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = IdentityKitDecoder().load(cache) println(decoder.lastIndex) for (i in decoder.indices) { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/InterfaceDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/InterfaceDefinitions.kt index 43c8d5e68..822f67029 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/InterfaceDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/InterfaceDefinitions.kt @@ -7,7 +7,7 @@ import world.gregs.voidps.cache.definition.decoder.InterfaceDecoderFull object InterfaceDefinitions { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = InterfaceDecoderFull().load(cache) for (i in decoder.indices) { val def = decoder.getOrNull(i) ?: continue diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/InventoryDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/InventoryDefinitions.kt index e44bd2f1a..7d1b8cecd 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/InventoryDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/InventoryDefinitions.kt @@ -7,7 +7,7 @@ import world.gregs.voidps.cache.config.decoder.InventoryDecoder object InventoryDefinitions { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = InventoryDecoder().load(cache) for (i in decoder.indices) { val def = decoder.getOrNull(i) ?: continue diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/ItemDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/ItemDefinitions.kt index 9d2feb80a..7aa26b2c3 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/ItemDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/ItemDefinitions.kt @@ -13,12 +13,12 @@ object ItemDefinitions { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val yaml = Yaml() - val categories = CategoryDefinitions().load(yaml, property("categoryDefinitionsPath")) - val ammo = AmmoDefinitions().load(yaml, property("ammoDefinitionsPath")) - val parameters = ParameterDefinitions(categories, ammo).load(yaml, property("parameterDefinitionsPath")) - val decoder = ItemDefinitions(ItemDecoder(parameters).load(cache)).load(yaml, property("itemDefinitionsPath")) + val categories = CategoryDefinitions().load(yaml, property("definitions.categories")) + val ammo = AmmoDefinitions().load(yaml, property("definitions.ammoGroups")) + val parameters = ParameterDefinitions(categories, ammo).load(yaml, property("definitions.parameters")) + val decoder = ItemDefinitions(ItemDecoder(parameters).load(cache)).load(yaml, property("definitions.items")) for (i in decoder.definitions.indices) { val def = decoder.getOrNull(i) ?: continue if(def.stringId.contains("anchor")) diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/NPCDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/NPCDefinitions.kt index 186413058..7670863f5 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/NPCDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/NPCDefinitions.kt @@ -12,13 +12,13 @@ import world.gregs.yaml.Yaml object NPCDefinitions { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val yaml = Yaml() - val categories = CategoryDefinitions().load(yaml, property("categoryDefinitionsPath")) - val ammo = AmmoDefinitions().load(yaml, property("ammoDefinitionsPath")) - val parameters = ParameterDefinitions(categories, ammo).load(yaml, property("parameterDefinitionsPath")) + val categories = CategoryDefinitions().load(yaml, property("definitions.categories")) + val ammo = AmmoDefinitions().load(yaml, property("definitions.ammoGroups")) + val parameters = ParameterDefinitions(categories, ammo).load(yaml, property("definitions.parameters")) val definitions = NPCDecoder(true, parameters).load(cache) - val decoder = NPCDefinitions(definitions).load(yaml, property("npcDefinitionsPath")) + val decoder = NPCDefinitions(definitions).load(yaml, property("definitions.npcs")) for (i in decoder.definitions.indices) { val def = decoder.getOrNull(i) ?: continue if (def.name.contains("diango", ignoreCase = true)) { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/ObjectDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/ObjectDefinitions.kt index fed50beb2..5e45cc6a7 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/ObjectDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/ObjectDefinitions.kt @@ -11,7 +11,7 @@ object ObjectDefinitions { @JvmStatic fun main(args: Array) { val cache = CacheDelegate("./data/cache") - val definitions = ObjectDefinitions(ObjectDecoder(member = true, lowDetail = false).load(cache)).load(Yaml(), property("objectDefinitionsPath")) + val definitions = ObjectDefinitions(ObjectDecoder(member = true, lowDetail = false).load(cache)).load(Yaml(), property("definitions.objects")) for (def in definitions.definitions) { println("${def.id} ${def.name}") } diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/OreIdentifier.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/OreIdentifier.kt index f7383e3b6..e268f8f4d 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/OreIdentifier.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/OreIdentifier.kt @@ -8,7 +8,7 @@ object OreIdentifier { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = ObjectDecoderFull(members = false, lowDetail = false).load(cache) val map = mapOf( 3184 to 1, diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/QuestDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/QuestDefinitions.kt index 8824a774e..63a466a8b 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/QuestDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/QuestDefinitions.kt @@ -8,7 +8,7 @@ object QuestDefinitions { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = QuestDecoder().load(cache) for (i in decoder.indices) { val def = decoder.getOrNull(i) ?: continue diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/QuickChatDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/QuickChatDefinitions.kt index 9225d7632..ed185d3df 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/QuickChatDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/QuickChatDefinitions.kt @@ -11,7 +11,7 @@ import world.gregs.voidps.cache.definition.decoder.QuickChatPhraseDecoder object QuickChatDefinitions { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val options = QuickChatOptionDecoder() val phrases = QuickChatPhraseDecoder().load(cache) val enums = EnumDecoder() diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/RenderAnimationDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/RenderAnimationDefinitions.kt index 00a8d7872..4b2a064de 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/RenderAnimationDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/RenderAnimationDefinitions.kt @@ -8,7 +8,7 @@ object RenderAnimationDefinitions { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = RenderAnimationDecoder().load(cache) for (i in decoder.indices) { val def = decoder.getOrNull(i) ?: continue diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/StructDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/StructDefinitions.kt index 55c99926e..44dab400d 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/StructDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/StructDefinitions.kt @@ -9,7 +9,7 @@ object StructDefinitions { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = StructDecoder().load(cache) val set = mutableSetOf() for (i in decoder.indices) { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/VarBitDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/VarBitDefinitions.kt index 57ef43af6..086613e57 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/VarBitDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/VarBitDefinitions.kt @@ -8,7 +8,7 @@ import world.gregs.voidps.cache.definition.decoder.VarBitDecoder object VarBitDefinitions { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = VarBitDecoder().load(cache) val varpDecoder = PlayerVariableParameterDecoder().load(cache) for (i in decoder.indices) { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/WorldMapDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/WorldMapDefinitions.kt index aecbcde28..220092da7 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/WorldMapDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/WorldMapDefinitions.kt @@ -7,7 +7,7 @@ import world.gregs.voidps.cache.definition.decoder.WorldMapDetailsDecoder object WorldMapDefinitions { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = WorldMapDetailsDecoder().load(cache) for (i in decoder.indices) { val def = decoder.getOrNull(i) ?: continue diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/WorldMapInfoDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/WorldMapInfoDefinitions.kt index 93538fa0f..aacd7700f 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/WorldMapInfoDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/WorldMapInfoDefinitions.kt @@ -7,7 +7,7 @@ import world.gregs.voidps.cache.config.decoder.WorldMapInfoDecoder object WorldMapInfoDefinitions { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = WorldMapInfoDecoder().load(cache) for (i in decoder.indices) { val def = decoder.getOrNull(i) ?: continue diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpEnums.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpEnums.kt index e840f3881..8d0cbf0c2 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpEnums.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpEnums.kt @@ -9,7 +9,7 @@ import java.io.File object DumpEnums { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = EnumDecoder().load(cache) val builder = StringBuilder() for (i in decoder.indices) { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpMap.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpMap.kt index 70ce1f34f..09d892565 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpMap.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpMap.kt @@ -10,7 +10,7 @@ import java.io.File object DumpMap { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val xteas: Xteas = Xteas().load() val region = Region(12341) val tiles = cache.data(Index.MAPS, "m${region.x}_${region.y}")!! diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpSprites.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpSprites.kt index f0a634315..731ad9e42 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpSprites.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpSprites.kt @@ -11,7 +11,7 @@ object DumpSprites { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = SpriteDecoder().load(cache) println(decoder.lastIndex) val directory = File("./temp/sprites/") diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpStructs.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpStructs.kt index 13d06a0a2..b5bd8ae92 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpStructs.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpStructs.kt @@ -9,7 +9,7 @@ import java.io.File object DumpStructs { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = StructDecoder().load(cache) val builder = StringBuilder() for (i in decoder.indices) { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpStyles.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpStyles.kt index f61d43079..71c6d4019 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpStyles.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpStyles.kt @@ -41,7 +41,7 @@ object DumpStyles { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = ClientScriptDecoder().load(cache) val clientScript = decoder[1142] load(clientScript) diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/HashCodeMatcher.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/HashCodeMatcher.kt index 31ecdbb12..e225c3529 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/HashCodeMatcher.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/HashCodeMatcher.kt @@ -212,7 +212,7 @@ object HashCodeMatcher { } private fun dumpHashes() { - val lib = CacheLibrary.create(property("cachePath")) + val lib = CacheLibrary.create(property("storage.cache.path")) val hashes = File("./temp/hashes/hashes.txt") hashes.delete() for (index in lib.indices()) { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/Xteas.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/Xteas.kt index e9fd8a3d9..88553562c 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/Xteas.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/Xteas.kt @@ -17,7 +17,7 @@ data class Xteas( } fun load( - path: String = Settings["xteaPath"], + path: String = Settings["storage.xteas"], key: String = Settings["xteaJsonKey", DEFAULT_KEY], value: String = Settings["xteaJsonValue", DEFAULT_VALUE] ): Xteas { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/convert/InventoryConverter.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/convert/InventoryConverter.kt index 545b04275..b196b835b 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/convert/InventoryConverter.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/convert/InventoryConverter.kt @@ -28,9 +28,9 @@ object InventoryConverter { val yaml = Yaml() val otherDecoder = InventoryDecoder().load(otherCache) val targetDecoder = InventoryDecoder().load(targetCache) - val itemDefinitions = ItemDefinitions(ItemDecoder().load(targetCache)).load(yaml, property("itemDefinitionsPath")) + val itemDefinitions = ItemDefinitions(ItemDecoder().load(targetCache)).load(yaml, property("definitions.items")) val encoder = InventoryEncoder() - val data: MutableMap = yaml.load>(property("inventoryDefinitionsPath")).toMutableMap() + val data: MutableMap = yaml.load>(property("definitions.inventories")).toMutableMap() var counter = 0 for (index in targetDecoder.indices) { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/item/ItemDefinitionPatcher.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/item/ItemDefinitionPatcher.kt index 6a19105f5..0e0810d98 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/item/ItemDefinitionPatcher.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/item/ItemDefinitionPatcher.kt @@ -10,10 +10,10 @@ import world.gregs.yaml.Yaml object ItemDefinitionPatcher { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = ItemDecoder().load(cache) val yaml = Yaml() - val current = ItemDefinitions(ItemDecoder().load(cache)).load(yaml, property("itemDefinitionsPath")) + val current = ItemDefinitions(ItemDecoder().load(cache)).load(yaml, property("definitions.items")) val newer = ItemDefinitions(ItemDecoder().load(cache)).load(yaml, "./items.yml") val map = mutableMapOf() for (id in decoder.indices) { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/item/ItemDefinitionPipeline.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/item/ItemDefinitionPipeline.kt index 74d12fe8f..9be0ce1f1 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/item/ItemDefinitionPipeline.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/item/ItemDefinitionPipeline.kt @@ -54,7 +54,7 @@ object ItemDefinitionPipeline { val revisionDate = LocalDate.of(2011, Month.JANUARY, 31)// 634 val start = System.currentTimeMillis() - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = ItemDecoder().load(cache) val pages = getPages(decoder, rs2Wiki) diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/npc/NPCDefinitionPipeline.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/npc/NPCDefinitionPipeline.kt index 789315b72..d487d73eb 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/npc/NPCDefinitionPipeline.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/npc/NPCDefinitionPipeline.kt @@ -31,7 +31,7 @@ object NPCDefinitionPipeline { fun main(args: Array) { val rs2Wiki = Wiki.load("${System.getProperty("user.home")}\\Downloads\\runescape_pages_full\\runescapewiki-latest-pages-articles-2011-01-31.xml") val start = System.currentTimeMillis() - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = NPCDecoder(true).load(cache) val pages = getPages(decoder, rs2Wiki) val output = buildNPCExtras(decoder, pages) diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/obj/ObjectDefinitionPipeline.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/obj/ObjectDefinitionPipeline.kt index c58639b87..967ca810d 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/obj/ObjectDefinitionPipeline.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/obj/ObjectDefinitionPipeline.kt @@ -50,7 +50,7 @@ private object ObjectDefinitionPipeline { @JvmStatic fun main(args: Array) { val start = System.currentTimeMillis() - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = ObjectDecoderFull(members = true, lowDetail = false).load(cache) val pages = decoder.indices.mapNotNull { val def = decoder.getOrNull(it) diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/detail/AnimationNames.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/detail/AnimationNames.kt index ba6144b0a..db6b43868 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/detail/AnimationNames.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/detail/AnimationNames.kt @@ -20,7 +20,7 @@ object AnimationNames { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val yaml = Yaml() val decoder = AnimationDecoderFull().load(cache) val itemDecoder = ItemDecoderFull().load(cache) diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/detail/GraphicNames.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/detail/GraphicNames.kt index 92550e778..22ee76419 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/detail/GraphicNames.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/detail/GraphicNames.kt @@ -20,7 +20,7 @@ object GraphicNames { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val models = mutableMapOf>() addItemModels(cache, models) addNPCModels(cache, models) diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/detail/NPCNames.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/detail/NPCNames.kt index b257419a5..33ad8bd4b 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/detail/NPCNames.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/detail/NPCNames.kt @@ -15,7 +15,7 @@ private class NPCNames(val decoder: Array) : NameDumper() { companion object { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = NPCDecoder(member = true).load(cache) val yaml= Yaml() val names = NPCNames(decoder) diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/graph/MapGraphLoader.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/graph/MapGraphLoader.kt index b6727881f..433ec748e 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/graph/MapGraphLoader.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/graph/MapGraphLoader.kt @@ -17,10 +17,10 @@ object MapGraphLoader { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val collisions: Collisions = Collisions() val objectDefinitions = ObjectDefinitions(ObjectDecoder(member = true, lowDetail = false).load(cache)) - .load(Yaml(), property("objectDefinitionsPath")) + .load(Yaml(), property("definitions.objects")) val objects = GameObjects(GameObjectCollisionAdd(collisions), GameObjectCollisionRemove(collisions), ZoneBatchUpdates(), objectDefinitions) val xteas: Xteas = Xteas().load() val graph = MapGraph(objects, xteas, cache, collisions) diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/map/obj/ObjectUsageFinder.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/map/obj/ObjectUsageFinder.kt index 5953e192e..6bef3cc3a 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/map/obj/ObjectUsageFinder.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/map/obj/ObjectUsageFinder.kt @@ -14,7 +14,7 @@ object ObjectUsageFinder { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val xteas = Xteas() val decoder = ObjectDecoderFull(members = false, lowDetail = false).load(cache) val maps = MapDecoder(xteas).load(cache) diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/map/obj/WorldMapLinkIdentifier.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/map/obj/WorldMapLinkIdentifier.kt index 856b36da6..847964e63 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/map/obj/WorldMapLinkIdentifier.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/map/obj/WorldMapLinkIdentifier.kt @@ -25,11 +25,11 @@ object WorldMapLinkIdentifier { @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) - val xteas: Xteas = Xteas().load(property("xteaPath"), propertyOrNull("xteaJsonKey") ?: Xteas.DEFAULT_KEY, propertyOrNull("xteaJsonValue") ?: Xteas.DEFAULT_VALUE) + val cache: Cache = CacheDelegate(property("storage.cache.path")) + val xteas: Xteas = Xteas().load(property("storage.xteas"), propertyOrNull("xteaJsonKey") ?: Xteas.DEFAULT_KEY, propertyOrNull("xteaJsonValue") ?: Xteas.DEFAULT_VALUE) val worldMapDetailsDecoder = WorldMapDetailsDecoder().load(cache) val worldMapIconDecoder = WorldMapIconDecoder().load(cache) - val definitions: ObjectDefinitions = ObjectDefinitions(ObjectDecoder(member = true, lowDetail = false).load(cache)).load(Yaml(), property("objectDefinitionsPath")) + val definitions: ObjectDefinitions = ObjectDefinitions(ObjectDecoder(member = true, lowDetail = false).load(cache)).load(Yaml(), property("definitions.objects")) val mapDecoder = MapDecoder(xteas).load(cache) val collisions = Collisions() val collisionDecoder = CollisionDecoder(collisions) diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/WorldMapDumper.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/WorldMapDumper.kt index 24deb9cac..c093c3472 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/WorldMapDumper.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/WorldMapDumper.kt @@ -34,10 +34,10 @@ object WorldMapDumper { fileProperties("/tool.properties") modules( module { - single { MemoryCache(Settings["cachePath"]) as Cache } + single { MemoryCache(Settings["storage.cache.path"]) as Cache } single { MapDecoder(get()) } single(createdAtStart = true) { - Xteas()//.load(Settings["xteaPath"], Settings["xteaJsonKey", Xteas.DEFAULT_KEY], Settings["xteaJsonValue", Xteas.DEFAULT_VALUE]) + Xteas()//.load(Settings["storage.xteas"], Settings["xteaJsonKey", Xteas.DEFAULT_KEY], Settings["xteaJsonValue", Xteas.DEFAULT_VALUE]) } }) }.koin diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/MapViewer.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/MapViewer.kt index a13f3e035..cf99d8f5f 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/MapViewer.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/MapViewer.kt @@ -36,7 +36,7 @@ class MapViewer { val collisions = Collisions() if (DISPLAY_AREA_COLLISIONS || DISPLAY_ALL_COLLISIONS) { val objectDefinitions = ObjectDefinitions(ObjectDecoder(member = true, lowDetail = false).load(cache)) - .load(Yaml(), property("objectDefinitionsPath")) + .load(Yaml(), property("definitions.objects")) val objects = GameObjects(GameObjectCollisionAdd(collisions), GameObjectCollisionRemove(collisions), ZoneBatchUpdates(), objectDefinitions) MapDefinitions(CollisionDecoder(collisions), objectDefinitions, objects, cache).loadCache() } diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiModifier.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiModifier.kt index 33fd0ac56..9186bb9e6 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiModifier.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiModifier.kt @@ -21,7 +21,7 @@ internal object RunescapeWikiModifier { @Suppress("UNCHECKED_CAST") @JvmStatic fun main(args: Array) { - val cache: Cache = CacheDelegate(property("cachePath")) + val cache: Cache = CacheDelegate(property("storage.cache.path")) val decoder = ItemDecoder().load(cache) val file = File("./data/dump/ItemsPretty.json") diff --git a/tools/src/main/resources/tool.properties b/tools/src/main/resources/tool.properties index da5124727..6be15f6fb 100644 --- a/tools/src/main/resources/tool.properties +++ b/tools/src/main/resources/tool.properties @@ -1,15 +1,15 @@ # Game Settings -name=Void -cachePath=./data/cache/ -savePath=./data/saves/ -xteaPath=./tools/src/main/resources/xteas.dat -homeX=3087 -homeY=3497 -connectionPerTickCap=1000 -objectDefinitionsPath=./data/definitions/objects.yml -npcDefinitionsPath=./data/definitions/npcs.yml -itemDefinitionsPath=./data/definitions/items.yml -animationDefinitionsPath=./data/definitions/animations.yml -graphicDefinitionsPath=./data/definitions/graphics.yml -inventoryDefinitionsPath=./data/definitions/inventories.yml -dropsPath=./data/spawns/drops.yml \ No newline at end of file +game.name=Void +storage.cache.path=./data/cache/ +storage.players.path=./data/saves/ +storage.xteas=./tools/src/main/resources/xteas.dat +world.home.x=3087 +world.home.y=3497 +network.maxLoginsPerTick=1000 +definitions.objects=./data/definitions/objects.yml +definitions.npcs=./data/definitions/npcs.yml +definitions.items=./data/definitions/items.yml +definitions.animations=./data/definitions/animations.yml +definitions.graphics=./data/definitions/graphics.yml +definitions.inventories=./data/definitions/inventories.yml +spawns.drops=./data/spawns/drops.yml \ No newline at end of file From 1062675d2a1c0dc0f7ca3a74039a412d26d5846b Mon Sep 17 00:00:00 2001 From: GregHib Date: Fri, 10 Jan 2025 00:42:25 +0000 Subject: [PATCH 13/25] Add shooting star respawn time settings and command --- .../dnd/shootingstar/ShootingStar.kts | 25 ++++++++++++++++--- .../dnd/shootingstar/ShootingStarHandler.kt | 4 --- game/src/main/resources/game.properties | 6 +++++ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts index 2eb8e8888..51680f3f7 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts @@ -3,6 +3,7 @@ package world.gregs.voidps.world.activity.dnd.shootingstar import com.github.michaelbull.logging.InlineLogger import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.ui.chat.plural +import world.gregs.voidps.engine.client.ui.event.adminCommand import world.gregs.voidps.engine.client.variable.start import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.definition.data.Rock @@ -23,6 +24,7 @@ import world.gregs.voidps.engine.entity.obj.* import world.gregs.voidps.engine.entity.objectDespawn import world.gregs.voidps.engine.entity.playerSpawn import world.gregs.voidps.engine.entity.worldSpawn +import world.gregs.voidps.engine.event.Events import world.gregs.voidps.engine.inject import world.gregs.voidps.engine.inv.add import world.gregs.voidps.engine.inv.inventory @@ -40,7 +42,6 @@ import world.gregs.voidps.type.Tile import world.gregs.voidps.type.random import world.gregs.voidps.world.activity.dnd.shootingstar.ShootingStarHandler.currentActiveObject import world.gregs.voidps.world.activity.dnd.shootingstar.ShootingStarHandler.currentStarTile -import world.gregs.voidps.world.activity.dnd.shootingstar.ShootingStarHandler.startEvent import world.gregs.voidps.world.activity.dnd.shootingstar.ShootingStarHandler.totalCollected import world.gregs.voidps.world.interact.dialogue.Happy import world.gregs.voidps.world.interact.dialogue.Sad @@ -69,8 +70,26 @@ settingsReload { } } +adminCommand("star") { + cleanseEvent(true) + val minutes = content.toIntOrNull() + if (minutes != null) { + World.clearQueue("shooting_star_event_timer") + eventUpdate(minutes) + } else if (minutes == -1) { + World.clearQueue("shooting_star_event_timer") + } else { + startCrashedStarEvent() + } +} + fun eventUpdate() { - World.queue("shooting_star_event_timer", startEvent) { + val minutes = Settings["events.shootingStars.minRespawnTimeMinutes", 60]..Settings["events.shootingStars.maxRespawnTimeMinutes", 60] + eventUpdate(minutes.random(random)) +} + +fun eventUpdate(minutes: Int) { + World.queue("shooting_star_event_timer", TimeUnit.MINUTES.toTicks(minutes)) { if (currentStarTile != Tile.EMPTY) { cleanseEvent(true) logger.info { "There was already an active star, deleted it and started a new event" } @@ -160,7 +179,7 @@ playerSpawn { player -> } } -timerStart("shooting_star_bonus_ore_timer") { player -> +timerStart("shooting_star_bonus_ore_timer") { interval = TimeUnit.SECONDS.toTicks(1) } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStarHandler.kt b/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStarHandler.kt index 369f0219a..c13290026 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStarHandler.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStarHandler.kt @@ -8,11 +8,8 @@ import world.gregs.voidps.engine.entity.obj.remove import world.gregs.voidps.engine.entity.obj.replace import world.gregs.voidps.engine.inv.add import world.gregs.voidps.engine.inv.inventory -import world.gregs.voidps.engine.timer.toTicks import world.gregs.voidps.type.Tile -import world.gregs.voidps.type.random import world.gregs.voidps.world.interact.entity.sound.areaSound -import java.util.concurrent.TimeUnit import kotlin.random.Random object ShootingStarHandler { @@ -21,7 +18,6 @@ object ShootingStarHandler { var totalCollected: Int = 0 var currentStarTile = Tile.EMPTY var currentActiveObject: GameObject? = null - val startEvent = TimeUnit.HOURS.toTicks(random.nextInt(1, 2)) fun addStarDustCollected() { totalCollected++ diff --git a/game/src/main/resources/game.properties b/game/src/main/resources/game.properties index 819d00c0c..d9d855b92 100644 --- a/game/src/main/resources/game.properties +++ b/game/src/main/resources/game.properties @@ -76,6 +76,12 @@ development.loadAllObjects=true # Whether shooting stars appear as an event in the game world events.shootingStars.enabled=true +# The time (in minutes) before a Shooting Star respawns. +# A new star will appear a random time between the min and max values, after the last star. +# (identical values will spawn exactly every X minutes) +events.shootingStars.minRespawnTimeMinutes=60 +events.shootingStars.maxRespawnTimeMinutes=120 + # Whether reducing hits by equipment absorption is enabled in combat mechanics combat.damageSoak=true From e5e25050378961eea0c57a1defbea33ef26b29c2 Mon Sep 17 00:00:00 2001 From: GregHib Date: Fri, 10 Jan 2025 00:48:37 +0000 Subject: [PATCH 14/25] Add global event message --- .../world/activity/dnd/shootingstar/ShootingStar.kts | 7 +++++++ game/src/main/resources/game.properties | 3 +++ 2 files changed, 10 insertions(+) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts index 51680f3f7..3de8e3c32 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts @@ -2,7 +2,9 @@ package world.gregs.voidps.world.activity.dnd.shootingstar import com.github.michaelbull.logging.InlineLogger import world.gregs.voidps.engine.client.message +import world.gregs.voidps.engine.client.ui.chat.Colours import world.gregs.voidps.engine.client.ui.chat.plural +import world.gregs.voidps.engine.client.ui.chat.toTag import world.gregs.voidps.engine.client.ui.event.adminCommand import world.gregs.voidps.engine.client.variable.start import world.gregs.voidps.engine.data.Settings @@ -103,6 +105,11 @@ fun startCrashedStarEvent() { val location = StarLocationData.entries.random() currentStarTile = location.tile val tier = random.nextInt(1, 9) + if (Settings["events.messages", false]) { + for (player in players) { + player.message("${Colours.DARK_RED.toTag()}A star has crashed at ${location.description}.") + } + } logger.info { "Crashed star event has started at: $location (${currentStarTile.x}, ${currentStarTile.y}) tier ${tier}." } val shootingStarShadow: NPC? = npcs.add("shooting_star_shadow", Tile(currentStarTile.x, currentStarTile.y + 6), Direction.NONE) shootingStarShadow?.walkTo(currentStarTile, noCollision = true, noRun = true) diff --git a/game/src/main/resources/game.properties b/game/src/main/resources/game.properties index d9d855b92..9fc2ad667 100644 --- a/game/src/main/resources/game.properties +++ b/game/src/main/resources/game.properties @@ -73,6 +73,9 @@ development.loadAllObjects=true # Content Customization #=================================== +# Whether events broadcast a global message +events.messages=true + # Whether shooting stars appear as an event in the game world events.shootingStars.enabled=true From fda9a6b0ca54a79e1114fc9fdebfffd12a07f730 Mon Sep 17 00:00:00 2001 From: GregHib Date: Fri, 10 Jan 2025 00:50:52 +0000 Subject: [PATCH 15/25] Add toggle for esse pouch degrading --- .../world/activity/skill/runecrafting/EssencePouch.kts | 5 ++++- game/src/main/resources/game.properties | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/runecrafting/EssencePouch.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/runecrafting/EssencePouch.kts index 46343f4e7..83c3b256b 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/runecrafting/EssencePouch.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/runecrafting/EssencePouch.kts @@ -3,6 +3,7 @@ package world.gregs.voidps.world.activity.skill.runecrafting import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.ui.chat.plural import world.gregs.voidps.engine.client.ui.interact.itemOnItems +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.chat.inventoryFull import world.gregs.voidps.engine.entity.item.Item @@ -82,7 +83,9 @@ inventoryItem("Empty", *pouches) { player.inventoryFull() return@inventoryItem } - player.inventory.discharge(player, slot) + if (Settings["runecrafting.pouch.degrade", true]) { + player.inventory.discharge(player, slot) + } player["${id}_essence"] = essence - added } diff --git a/game/src/main/resources/game.properties b/game/src/main/resources/game.properties index 9fc2ad667..6703e57ef 100644 --- a/game/src/main/resources/game.properties +++ b/game/src/main/resources/game.properties @@ -97,6 +97,9 @@ agility.disableCourseFailure=false # Disable skipping laps towards Agile when failing advanced courses agility.disableFailLapSkip=true +# Degrade runecrafting essence pouches when in use +runecrafting.pouch.degrade=true + #=================================== # Storage & File System From 91369a7fdd42bfbd1fc58444291307129ef5815b Mon Sep 17 00:00:00 2001 From: GregHib Date: Fri, 10 Jan 2025 00:53:53 +0000 Subject: [PATCH 16/25] Add infinite run energy toggle --- .../voidps/world/interact/entity/player/energy/Energy.kts | 3 ++- game/src/main/resources/game.properties | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/energy/Energy.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/energy/Energy.kts index 79e577f20..eb9ba5211 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/energy/Energy.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/energy/Energy.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.interact.entity.player.energy import world.gregs.voidps.engine.GameLoop import world.gregs.voidps.engine.client.variable.hasClock +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.mode.move.move import world.gregs.voidps.engine.entity.character.move.running import world.gregs.voidps.engine.entity.character.player.Player @@ -35,7 +36,7 @@ fun getRestoreAmount(player: Player): Int { } move({ it.visuals.runStep != -1 }) { player -> - if (player["last_energy_drain", -1] == GameLoop.tick) { + if (player["last_energy_drain", -1] == GameLoop.tick || !Settings["players.energy.drain", true]) { return@move } player["last_energy_drain"] = GameLoop.tick diff --git a/game/src/main/resources/game.properties b/game/src/main/resources/game.properties index 6703e57ef..b539a4f56 100644 --- a/game/src/main/resources/game.properties +++ b/game/src/main/resources/game.properties @@ -73,6 +73,9 @@ development.loadAllObjects=true # Content Customization #=================================== +# Whether players energy drains while running +players.energy.drain=true + # Whether events broadcast a global message events.messages=true From 56818312f3e04e7a415c02fe6b09e2327d1fd895 Mon Sep 17 00:00:00 2001 From: GregHib Date: Fri, 10 Jan 2025 01:03:14 +0000 Subject: [PATCH 17/25] Add bots random walk setting --- .../world/gregs/voidps/bot/BotSpawns.kts | 9 +++++++- .../world/gregs/voidps/bot/TaskManager.kt | 22 +++++++++++-------- .../world/gregs/voidps/bot/WalkingBot.kts | 5 +++-- game/src/main/resources/game.properties | 3 +++ 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts b/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts index 99aec2bda..e1189bbf6 100644 --- a/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts +++ b/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts @@ -9,6 +9,7 @@ import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.definition.AreaDefinitions import world.gregs.voidps.engine.data.definition.EnumDefinitions import world.gregs.voidps.engine.data.definition.StructDefinitions +import world.gregs.voidps.engine.data.settingsReload import world.gregs.voidps.engine.entity.MAX_PLAYERS import world.gregs.voidps.engine.entity.World import world.gregs.voidps.engine.entity.character.move.running @@ -51,6 +52,12 @@ worldSpawn { } } +settingsReload { + if (Settings["world.bots", 0] > bots.size) { + World.timers.start("bot_spawn") + } +} + worldTimerStart("bot_spawn") { interval = TimeUnit.MINUTES.toTicks(1) } @@ -67,7 +74,7 @@ adminCommand("bots") { val count = content.toIntOrNull() ?: 1 GlobalScope.launch { repeat(count) { - if (it % 25 == 0) { + if (it % Settings["network.maxLoginsPerTick", 25] == 0) { suspendCancellableCoroutine { cont -> World.queue("bot_${counter}") { cont.resume(Unit) diff --git a/game/src/main/kotlin/world/gregs/voidps/bot/TaskManager.kt b/game/src/main/kotlin/world/gregs/voidps/bot/TaskManager.kt index 73d65e6fe..32d7a9e7c 100644 --- a/game/src/main/kotlin/world/gregs/voidps/bot/TaskManager.kt +++ b/game/src/main/kotlin/world/gregs/voidps/bot/TaskManager.kt @@ -6,6 +6,15 @@ import java.util.* class TaskManager { private val queue = LinkedList() + private var idle = Task( + name = "do nothing", + block = { + repeat(random.nextInt(10, 100)) { + bot.await("tick") + } + }, + spaces = Int.MAX_VALUE + ) fun register(task: Task, test: Boolean = false) { if (DEBUG && !(DEBUG && test)) { @@ -24,16 +33,11 @@ class TaskManager { .minByOrNull { it.distanceTo(bot.tile) } ?: idle } + fun idle(task: Task) { + idle = task + } + companion object { - val idle = Task( - name = "do nothing", - block = { - repeat(random.nextInt(10, 100)) { - bot.await("tick") - } - }, - spaces = Int.MAX_VALUE - ) const val DEBUG = false } } \ No newline at end of file diff --git a/game/src/main/kotlin/world/gregs/voidps/bot/WalkingBot.kts b/game/src/main/kotlin/world/gregs/voidps/bot/WalkingBot.kts index 6f84a0f32..5039ccc4e 100644 --- a/game/src/main/kotlin/world/gregs/voidps/bot/WalkingBot.kts +++ b/game/src/main/kotlin/world/gregs/voidps/bot/WalkingBot.kts @@ -1,6 +1,7 @@ package world.gregs.voidps.bot import world.gregs.voidps.bot.navigation.await +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.worldSpawn import world.gregs.voidps.engine.inject import world.gregs.voidps.network.client.instruction.Walk @@ -21,7 +22,7 @@ worldSpawn { spaces = Int.MAX_VALUE, requirements = emptyList() ) - if (TaskManager.DEBUG) { - tasks.register(task, true) + if (Settings["world.bots.randomWalk", false]) { + tasks.idle(task) } } \ No newline at end of file diff --git a/game/src/main/resources/game.properties b/game/src/main/resources/game.properties index b539a4f56..586e86cea 100644 --- a/game/src/main/resources/game.properties +++ b/game/src/main/resources/game.properties @@ -39,6 +39,9 @@ world.experienceRate=1.0 # The number of AI-controlled bots to populate the world world.bots=10 +# AI-controlled bots with no tasks will move randomly +world.bots.randomWalk=false + # The maximum number of players that can be online at once world.players.max=2048 From bf56bccde4e52ac6c880b98bb04c17d819d3d5b0 Mon Sep 17 00:00:00 2001 From: GregHib Date: Fri, 10 Jan 2025 01:04:49 +0000 Subject: [PATCH 18/25] Add networked bots as dev setting --- .../src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts | 2 +- .../main/kotlin/world/gregs/voidps/bot/TaskManager.kt | 9 +-------- game/src/main/resources/game.properties | 3 +++ 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts b/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts index e1189bbf6..bc43f42da 100644 --- a/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts +++ b/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts @@ -115,7 +115,7 @@ fun spawn() { val name = "Bot ${++counter}" val bot = Player(tile = lumbridge.random(), accountName = name) bot.initBot() - loader.connect(bot, if (TaskManager.DEBUG) DummyClient() else null) + loader.connect(bot, if (Settings["development.bots.live", false]) DummyClient() else null) setAppearance(bot) if (bot.inventory.isEmpty()) { bot.inventory.add("coins", 10000) diff --git a/game/src/main/kotlin/world/gregs/voidps/bot/TaskManager.kt b/game/src/main/kotlin/world/gregs/voidps/bot/TaskManager.kt index 32d7a9e7c..405d18d4e 100644 --- a/game/src/main/kotlin/world/gregs/voidps/bot/TaskManager.kt +++ b/game/src/main/kotlin/world/gregs/voidps/bot/TaskManager.kt @@ -16,10 +16,7 @@ class TaskManager { spaces = Int.MAX_VALUE ) - fun register(task: Task, test: Boolean = false) { - if (DEBUG && !(DEBUG && test)) { - return - } + fun register(task: Task) { queue.add(task) } @@ -36,8 +33,4 @@ class TaskManager { fun idle(task: Task) { idle = task } - - companion object { - const val DEBUG = false - } } \ No newline at end of file diff --git a/game/src/main/resources/game.properties b/game/src/main/resources/game.properties index 586e86cea..3e5e01177 100644 --- a/game/src/main/resources/game.properties +++ b/game/src/main/resources/game.properties @@ -71,6 +71,9 @@ network.maxLoginsPerTick=25 # Load all objects into memory development.loadAllObjects=true +# Give bots dummy network connections +development.bots.live=false + #=================================== # Content Customization From 69e8d54ed8b891e678890cea7ee6b7ef7e7786d1 Mon Sep 17 00:00:00 2001 From: GregHib Date: Fri, 10 Jan 2025 01:11:38 +0000 Subject: [PATCH 19/25] Add lumbridge safe zone setting --- .../voidps/world/interact/entity/npc/combat/Aggression.kts | 4 ++++ game/src/main/resources/game.properties | 3 +++ 2 files changed, 7 insertions(+) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/combat/Aggression.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/combat/Aggression.kts index ff0dbb706..556f38c2d 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/combat/Aggression.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/combat/Aggression.kts @@ -1,5 +1,6 @@ package world.gregs.voidps.world.interact.entity.npc.combat +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.Character import world.gregs.voidps.engine.entity.character.mode.combat.CombatMovement import world.gregs.voidps.engine.entity.character.mode.interact.Interact @@ -13,6 +14,9 @@ huntPlayer(mode = "aggressive") { npc -> if (attacking(npc, target)) { return@huntPlayer } + if (Settings["world.npcs.safeZone", false] && npc.tile.region.id == 12850) { + return@huntPlayer + } npc.mode = Interact(npc, target, PlayerOption(npc, target, "Attack")) } diff --git a/game/src/main/resources/game.properties b/game/src/main/resources/game.properties index 3e5e01177..abb1f4f6b 100644 --- a/game/src/main/resources/game.properties +++ b/game/src/main/resources/game.properties @@ -54,6 +54,9 @@ world.npcs.collision=true # Whether NPCs can move randomly world.npcs.randomWalk=true +# Whether Lumbridge is an NPC aggression-free area +world.npcs.safeZone=true + #=================================== # Gameplay Mechanics From 967002cb787557b33c3e115ed753e31769d68f96 Mon Sep 17 00:00:00 2001 From: GregHib Date: Fri, 10 Jan 2025 16:06:27 +0000 Subject: [PATCH 20/25] More refactoring --- .../kotlin/world/gregs/voidps/cache/Cache.kt | 2 +- .../gregs/voidps/engine/data/SettingsTest.kt | 20 ++--- .../main/kotlin/world/gregs/voidps/Main.kt | 4 +- .../world/gregs/voidps/bot/BotSpawns.kts | 6 +- .../world/gregs/voidps/bot/WalkingBot.kts | 2 +- .../gregs/voidps/world/community/Rights.kts | 2 +- game/src/main/resources/game.properties | 81 +++++++++++-------- game/src/test/resources/test.properties | 6 +- .../world/gregs/voidps/network/FileServer.kt | 2 +- .../world/gregs/voidps/network/LoginServer.kt | 2 +- .../gregs/voidps/network/file/FileProvider.kt | 2 +- .../gregs/voidps/network/FileServerTest.kt | 2 +- .../gregs/voidps/network/LoginServerTest.kt | 2 +- tools/src/main/resources/tool.properties | 2 +- 14 files changed, 75 insertions(+), 60 deletions(-) diff --git a/cache/src/main/kotlin/world/gregs/voidps/cache/Cache.kt b/cache/src/main/kotlin/world/gregs/voidps/cache/Cache.kt index d8c70e7b2..407d43324 100644 --- a/cache/src/main/kotlin/world/gregs/voidps/cache/Cache.kt +++ b/cache/src/main/kotlin/world/gregs/voidps/cache/Cache.kt @@ -42,7 +42,7 @@ interface Cache { companion object { fun load(properties: Properties): Cache { - val live = properties.getProperty("game.live").toBoolean() + val live = properties.getProperty("server.live").toBoolean() val loader = if (live) MemoryCache else FileCache return loader.load(properties) } diff --git a/engine/src/test/kotlin/world/gregs/voidps/engine/data/SettingsTest.kt b/engine/src/test/kotlin/world/gregs/voidps/engine/data/SettingsTest.kt index 2d8d82b30..793d77615 100644 --- a/engine/src/test/kotlin/world/gregs/voidps/engine/data/SettingsTest.kt +++ b/engine/src/test/kotlin/world/gregs/voidps/engine/data/SettingsTest.kt @@ -15,19 +15,19 @@ class SettingsTest { } private val example = """ - game.name=Void - game.port=43594 + server.name=Void + network.port=43594 world.experienceRate=10.0 - game.live=true + server.live=true """.trimIndent() @Test fun `Load settings`() { settings.load(example) - assertEquals("Void", settings["game.name"]) - assertEquals(43594, settings["game.port", -1]) + assertEquals("Void", settings["server.name"]) + assertEquals(43594, settings["network.port", -1]) assertEquals(10.0, settings["world.experienceRate", -10.0]) - assertEquals(true, settings["game.live", false]) + assertEquals(true, settings["server.live", false]) } @Test @@ -46,16 +46,16 @@ class SettingsTest { @Test fun `Get an incorrect format setting returns default`() { settings.load(example) - assertEquals(1234, settings["game.name", 1234]) + assertEquals(1234, settings["server.name", 1234]) } @Test fun `Override settings`() { settings.load(example) - settings.load("game.name=Void 2") + settings.load("server.name=Void 2") - assertEquals("Void 2", settings["game.name"]) - assertEquals(43594, settings["game.port", -1]) + assertEquals("Void 2", settings["server.name"]) + assertEquals(43594, settings["network.port", -1]) } private fun Settings.load(string: String) = load(string.byteInputStream(Charsets.UTF_8)) diff --git a/game/src/main/kotlin/world/gregs/voidps/Main.kt b/game/src/main/kotlin/world/gregs/voidps/Main.kt index 418fc5655..c38380b92 100644 --- a/game/src/main/kotlin/world/gregs/voidps/Main.kt +++ b/game/src/main/kotlin/world/gregs/voidps/Main.kt @@ -42,12 +42,12 @@ object Main : CoroutineScope { fun main(args: Array) { val startTime = System.currentTimeMillis() val properties = settings() - name = Settings["game.name"] + name = Settings["server.name"] // File server val cache = timed("cache") { Cache.load(properties) } val server = GameServer.load(cache, properties) - val job = server.start(Settings["game.port"].toInt()) + val job = server.start(Settings["network.port"].toInt()) // Content try { diff --git a/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts b/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts index bc43f42da..c71ec1457 100644 --- a/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts +++ b/game/src/main/kotlin/world/gregs/voidps/bot/BotSpawns.kts @@ -44,7 +44,7 @@ val structs: StructDefinitions by inject() var counter = 0 worldSpawn { - if (Settings["world.bots", 0] > 0) { + if (Settings["bots.count", 0] > 0) { World.timers.start("bot_spawn") } Events.events.all = { player, event -> @@ -53,7 +53,7 @@ worldSpawn { } settingsReload { - if (Settings["world.bots", 0] > bots.size) { + if (Settings["bots.count", 0] > bots.size) { World.timers.start("bot_spawn") } } @@ -63,7 +63,7 @@ worldTimerStart("bot_spawn") { } worldTimerTick("bot_spawn") { - if (counter > Settings["world.bots", 0]) { + if (counter > Settings["bots.count", 0]) { cancel() return@worldTimerTick } diff --git a/game/src/main/kotlin/world/gregs/voidps/bot/WalkingBot.kts b/game/src/main/kotlin/world/gregs/voidps/bot/WalkingBot.kts index 5039ccc4e..8a8977bcc 100644 --- a/game/src/main/kotlin/world/gregs/voidps/bot/WalkingBot.kts +++ b/game/src/main/kotlin/world/gregs/voidps/bot/WalkingBot.kts @@ -22,7 +22,7 @@ worldSpawn { spaces = Int.MAX_VALUE, requirements = emptyList() ) - if (Settings["world.bots.randomWalk", false]) { + if (Settings["bots.randomWalk", false]) { tasks.idle(task) } } \ No newline at end of file diff --git a/game/src/main/kotlin/world/gregs/voidps/world/community/Rights.kts b/game/src/main/kotlin/world/gregs/voidps/world/community/Rights.kts index e0951c25a..5f2aadbfd 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/community/Rights.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/community/Rights.kts @@ -12,7 +12,7 @@ import world.gregs.voidps.engine.entity.playerSpawn import world.gregs.voidps.engine.get playerSpawn { player -> - if (player.name == Settings.getOrNull("admin.name") && player.rights != PlayerRights.Admin) { + if (player.name == Settings.getOrNull("development.admin.name") && player.rights != PlayerRights.Admin) { player.rights = PlayerRights.Admin player.message("Rights set to Admin. Please re-log to activate.") } diff --git a/game/src/main/resources/game.properties b/game/src/main/resources/game.properties index abb1f4f6b..60fe00058 100644 --- a/game/src/main/resources/game.properties +++ b/game/src/main/resources/game.properties @@ -1,18 +1,29 @@ #=================================== -# General Game Settings +# Server Settings #=================================== # The name of the game server -game.name=Void +server.name=Void + +# The game revision (affects client compatibility) +server.revision=634 + +# Stable high performance mode but slower to start-up and uses more memory +server.live=false + + +#=================================== +# Network Settings +#=================================== # The port the game server will listen on -game.port=43594 +network.port=43594 -# The game revision (affects client compatibility) -game.revision=634 +# Number of accounts one ip address can log into at the same time. +network.maxClientPerIP=10 -# Set to 'true' the server will run in live mode storing all data in memory -game.live=false +# Maximum number of players to allow login per tick +network.maxLoginsPerTick=25 #=================================== @@ -36,12 +47,6 @@ world.home.y=3219 # Experience multiplier (1.0 = normal XP rate) world.experienceRate=1.0 -# The number of AI-controlled bots to populate the world -world.bots=10 - -# AI-controlled bots with no tasks will move randomly -world.bots.randomWalk=false - # The maximum number of players that can be online at once world.players.max=2048 @@ -59,17 +64,11 @@ world.npcs.safeZone=true #=================================== -# Gameplay Mechanics +# Development & Debugging #=================================== # The admin username (always sets administrative privileges on login) -admin.name=Greg - -# Number of accounts one ip address can log into at the same time. -network.maxClientPerIP=10 - -# Maximum number of players to allow login per tick -network.maxLoginsPerTick=25 +development.admin.name=Greg # Load all objects into memory development.loadAllObjects=true @@ -79,23 +78,22 @@ development.bots.live=false #=================================== -# Content Customization +# AI & Bots #=================================== -# Whether players energy drains while running -players.energy.drain=true +# The number of AI-controlled bots spawned on startup +bots.count=10 -# Whether events broadcast a global message -events.messages=true +# AI-controlled bots with no tasks will move randomly +bots.randomWalk=false -# Whether shooting stars appear as an event in the game world -events.shootingStars.enabled=true -# The time (in minutes) before a Shooting Star respawns. -# A new star will appear a random time between the min and max values, after the last star. -# (identical values will spawn exactly every X minutes) -events.shootingStars.minRespawnTimeMinutes=60 -events.shootingStars.maxRespawnTimeMinutes=120 +#=================================== +# Gameplay Mechanics +#=================================== + +# Whether players energy drains while running +players.energy.drain=true # Whether reducing hits by equipment absorption is enabled in combat mechanics combat.damageSoak=true @@ -113,6 +111,23 @@ agility.disableFailLapSkip=true runecrafting.pouch.degrade=true +#=================================== +# Content & Events +#=================================== + +# Whether events broadcast a global message +events.messages=true + +# Whether shooting stars appear as an event in the game world +events.shootingStars.enabled=true + +# The time (in minutes) before a Shooting Star respawns. +# A new star will appear a random time between the min and max values, after the last star. +# (identical values will spawn exactly every X minutes) +events.shootingStars.minRespawnTimeMinutes=60 +events.shootingStars.maxRespawnTimeMinutes=120 + + #=================================== # Storage & File System #=================================== diff --git a/game/src/test/resources/test.properties b/game/src/test/resources/test.properties index 6df7a53dd..22b9115a6 100644 --- a/game/src/test/resources/test.properties +++ b/game/src/test/resources/test.properties @@ -1,6 +1,6 @@ # Game Settings -game.name=Void -game.port=43594 +server.name=Void +network.port=43594 storage.cache.path=../data/cache/ storage.players.path=../data/test-saves/ storage.scripts.package=world.gregs.voidps.world @@ -45,7 +45,7 @@ definitions.parameters=../data/definitions/parameters.yml definitions.clientScripts=../data/definitions/scripts.yml spawns.drops=../data/spawns/drops.yml definitions.books=../data/definitions/books.yml -game.revision=634 +server.revision=634 world.players.max=2048 network.maxClientPerIP=5 world.home.x=3221 diff --git a/network/src/main/kotlin/world/gregs/voidps/network/FileServer.kt b/network/src/main/kotlin/world/gregs/voidps/network/FileServer.kt index 5b9de4290..f7ceb7f97 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/FileServer.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/FileServer.kt @@ -117,7 +117,7 @@ class FileServer( return offlineFileServer() } val fileProvider: FileProvider = FileProvider.load(cache, properties) - val revision = properties.getProperty("game.revision").toInt() + val revision = properties.getProperty("server.revision").toInt() val prefetchKeys = prefetchKeys(cache, properties) return FileServer(revision, prefetchKeys, fileProvider) } diff --git a/network/src/main/kotlin/world/gregs/voidps/network/LoginServer.kt b/network/src/main/kotlin/world/gregs/voidps/network/LoginServer.kt index 989f7d941..a356de506 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/LoginServer.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/LoginServer.kt @@ -165,7 +165,7 @@ class LoginServer( fun load(properties: Properties, protocol: Array, loader: AccountLoader): LoginServer { val gameModulus = BigInteger(properties.getProperty("security.game.modulus"), 16) val gamePrivate = BigInteger(properties.getProperty("security.game.private"), 16) - val revision = properties.getProperty("game.revision").toInt() + val revision = properties.getProperty("server.revision").toInt() val maxPlayers = properties.getProperty("world.players.max").toInt() return LoginServer(protocol, revision, maxPlayers, gameModulus, gamePrivate, loader) } diff --git a/network/src/main/kotlin/world/gregs/voidps/network/file/FileProvider.kt b/network/src/main/kotlin/world/gregs/voidps/network/file/FileProvider.kt index b7aa8e193..51d0acf5f 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/file/FileProvider.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/file/FileProvider.kt @@ -40,7 +40,7 @@ interface FileProvider { fun load(cache: Cache, properties: Properties): FileProvider { val start = System.currentTimeMillis() - val live = properties.getProperty("game.live").toBoolean() + val live = properties.getProperty("server.live").toBoolean() val provider = if (live) MemoryFileProvider(cache) else CacheFileProvider(cache) logger.info { "Loaded file provider in ${System.currentTimeMillis() - start}ms" } return provider diff --git a/network/src/test/kotlin/world/gregs/voidps/network/FileServerTest.kt b/network/src/test/kotlin/world/gregs/voidps/network/FileServerTest.kt index 7f6b7a93a..4e766e39e 100644 --- a/network/src/test/kotlin/world/gregs/voidps/network/FileServerTest.kt +++ b/network/src/test/kotlin/world/gregs/voidps/network/FileServerTest.kt @@ -231,7 +231,7 @@ class FileServerTest { val writeChannel = ByteChannel(autoFlush = true) val properties = Properties() properties.setProperty("storage.cache.server", "internal") - properties.setProperty("game.revision", "123") + properties.setProperty("server.revision", "123") val prefetchKeys = listOf(1, 2, 3, 4) properties.setProperty("prefetch.keys", prefetchKeys.joinToString(",")) val server = FileServer.load(mockk(relaxed = true), properties) diff --git a/network/src/test/kotlin/world/gregs/voidps/network/LoginServerTest.kt b/network/src/test/kotlin/world/gregs/voidps/network/LoginServerTest.kt index 8eff7399d..d9c6dfe4a 100644 --- a/network/src/test/kotlin/world/gregs/voidps/network/LoginServerTest.kt +++ b/network/src/test/kotlin/world/gregs/voidps/network/LoginServerTest.kt @@ -350,7 +350,7 @@ internal class LoginServerTest { val properties = Properties() properties.setProperty("security.game.modulus", modulus.toString(16)) properties.setProperty("security.game.private", "10001") - properties.setProperty("game.revision", "123") + properties.setProperty("server.revision", "123") properties.setProperty("world.players.max", "10") server = LoginServer.load(properties, protocol, accounts) val readChannel = ByteChannel(autoFlush = true) diff --git a/tools/src/main/resources/tool.properties b/tools/src/main/resources/tool.properties index 6be15f6fb..0f40940f4 100644 --- a/tools/src/main/resources/tool.properties +++ b/tools/src/main/resources/tool.properties @@ -1,5 +1,5 @@ # Game Settings -game.name=Void +server.name=Void storage.cache.path=./data/cache/ storage.players.path=./data/saves/ storage.xteas=./tools/src/main/resources/xteas.dat From 8bb82f6a2f939a90521563d18dc01aa1b227e88c Mon Sep 17 00:00:00 2001 From: GregHib Date: Fri, 10 Jan 2025 16:33:05 +0000 Subject: [PATCH 21/25] More organising and add a few startup configs --- .../world/gregs/voidps/bot/WalkingBot.kts | 2 +- .../dnd/shootingstar/ShootingStar.kts | 2 +- .../world/interact/world/map/Introduction.kts | 23 ++++-- game/src/main/resources/game.properties | 76 ++++++++++++------- 4 files changed, 65 insertions(+), 38 deletions(-) diff --git a/game/src/main/kotlin/world/gregs/voidps/bot/WalkingBot.kts b/game/src/main/kotlin/world/gregs/voidps/bot/WalkingBot.kts index 8a8977bcc..6e930cc3a 100644 --- a/game/src/main/kotlin/world/gregs/voidps/bot/WalkingBot.kts +++ b/game/src/main/kotlin/world/gregs/voidps/bot/WalkingBot.kts @@ -22,7 +22,7 @@ worldSpawn { spaces = Int.MAX_VALUE, requirements = emptyList() ) - if (Settings["bots.randomWalk", false]) { + if (Settings["bots.idle", "nothing"] == "randomWalk") { tasks.idle(task) } } \ No newline at end of file diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts index 3de8e3c32..830f4e1c5 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts @@ -105,7 +105,7 @@ fun startCrashedStarEvent() { val location = StarLocationData.entries.random() currentStarTile = location.tile val tier = random.nextInt(1, 9) - if (Settings["events.messages", false]) { + if (Settings["world.messages", false]) { for (player in players) { player.message("${Colours.DARK_RED.toTag()}A star has crashed at ${location.description}.") } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/world/map/Introduction.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/world/map/Introduction.kts index 99003ac9c..683ed2e1e 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/world/map/Introduction.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/world/map/Introduction.kts @@ -6,6 +6,7 @@ import world.gregs.voidps.engine.client.ui.event.interfaceClose import world.gregs.voidps.engine.client.ui.open import world.gregs.voidps.engine.client.variable.start import world.gregs.voidps.engine.client.variable.stop +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.World import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.chat.ChatType @@ -19,14 +20,18 @@ import world.gregs.voidps.world.activity.bank.bank import world.gregs.voidps.world.interact.dialogue.type.statement playerSpawn(priority = true) { player -> - player.message("Welcome to Void.", ChatType.Welcome) - if (!player.contains("creation")) { - if (!player.isBot) { - player.start("delay", -1) - World.queue("welcome_${player.name}", 1) { - player.open("character_creation") - } + player.message("Welcome to ${Settings["server.name"]}.", ChatType.Welcome) + if (player.contains("creation")) { + return@playerSpawn + } + if (Settings["world.start.creation", true] && !player.isBot) { + player.start("delay", -1) + World.queue("welcome_${player.name}", 1) { + player.open("character_creation") } + } else { + player.flagAppearance() + setup(player) } } @@ -41,6 +46,10 @@ fun setup(player: Player) { } player.stop("delay") player["creation"] = System.currentTimeMillis() + + if (!Settings["world.setup.gear", true]) { + return + } player.bank.add("coins", 25) player.inventory.apply { add("bronze_hatchet") diff --git a/game/src/main/resources/game.properties b/game/src/main/resources/game.properties index 60fe00058..42e149f6a 100644 --- a/game/src/main/resources/game.properties +++ b/game/src/main/resources/game.properties @@ -26,6 +26,20 @@ network.maxClientPerIP=10 network.maxLoginsPerTick=25 +#=================================== +# Development & Debugging +#=================================== + +# The admin username (always sets administrative privileges on login) +development.admin.name=Greg + +# Load all objects into memory +development.loadAllObjects=true + +# Give bots dummy network connections +development.bots.live=false + + #=================================== # World Settings #=================================== @@ -44,15 +58,28 @@ world.home.x=3221 world.home.y=3219 #world.home.level=0 +# Whether content should broadcast global messages +world.messages=true + # Experience multiplier (1.0 = normal XP rate) world.experienceRate=1.0 +#------- Player Rules ------- + # The maximum number of players that can be online at once world.players.max=2048 # Whether players can be collided with world.players.collision=true +# Show new accounts the character creation screen +world.start.creation=true + +# Give new accounts starting gear +world.start.gear=true + +#------- NPC Rules ------- + # Whether NPCs can be collided with world.npcs.collision=true @@ -63,50 +90,33 @@ world.npcs.randomWalk=true world.npcs.safeZone=true -#=================================== -# Development & Debugging -#=================================== - -# The admin username (always sets administrative privileges on login) -development.admin.name=Greg - -# Load all objects into memory -development.loadAllObjects=true - -# Give bots dummy network connections -development.bots.live=false - - -#=================================== -# AI & Bots -#=================================== - -# The number of AI-controlled bots spawned on startup -bots.count=10 - -# AI-controlled bots with no tasks will move randomly -bots.randomWalk=false - - #=================================== # Gameplay Mechanics #=================================== +#------- Player Attributes ------- + # Whether players energy drains while running players.energy.drain=true +#------- Combat Mechanics ------- + # Whether reducing hits by equipment absorption is enabled in combat mechanics combat.damageSoak=true # Whether to display blue damage soaking next to hit splats combat.showSoak=true +#------- Agility ------- + # Disable players failing obstacles on advanced agility courses agility.disableCourseFailure=false # Disable skipping laps towards Agile when failing advanced courses agility.disableFailLapSkip=true +#------- Runecrafting ------- + # Degrade runecrafting essence pouches when in use runecrafting.pouch.degrade=true @@ -115,9 +125,6 @@ runecrafting.pouch.degrade=true # Content & Events #=================================== -# Whether events broadcast a global message -events.messages=true - # Whether shooting stars appear as an event in the game world events.shootingStars.enabled=true @@ -128,6 +135,17 @@ events.shootingStars.minRespawnTimeMinutes=60 events.shootingStars.maxRespawnTimeMinutes=120 +#=================================== +# AI & Bots +#=================================== + +# The number of AI-controlled bots spawned on startup +bots.count=10 + +# What tasks to give AI-controlled bots with no tasks (options: nothing, randomWalk) +bots.idle=randomWalk + + #=================================== # Storage & File System #=================================== @@ -267,4 +285,4 @@ security.file.private=bd7a119cf43de5f90141fb30a5582ca58e5ec2bdd560780a522c2e4fb8 #=================================== # List of file IDs to be prefetched by the file server -prefetch.keys=104,79328,55571,46770,24563,299978,44375,0,4177,2822,100024,617990,155187,332544,388139,682557,18883,19031,16187,1248,6254,526,119,741556,821698,3671,2908 \ No newline at end of file +prefetch.keys=104,79328,55571,46770,24563,299978,44375,0,4177,2822,100024,617990,155187,332544,388139,682557,18883,19031,16187,1248,6254,526,119,741556,821698,3671,2908 From 84585c5d139254fd55daa1a11b28d2f20078931c Mon Sep 17 00:00:00 2001 From: GregHib Date: Fri, 10 Jan 2025 17:15:31 +0000 Subject: [PATCH 22/25] Make home tile and exp rate settings dynamic --- .../gregs/voidps/engine/EngineModules.kt | 43 ++++++++----------- .../engine/client/PlayerAccountLoader.kt | 6 +-- .../voidps/engine/data/AccountManager.kt | 8 ++-- .../voidps/engine/data/json/FileStorage.kt | 7 +-- .../data/yaml/PlayerYamlReaderConfig.kt | 9 ++-- .../engine/client/PlayerAccountLoaderTest.kt | 2 +- .../voidps/engine/data/AccountManagerTest.kt | 11 +++-- .../engine/data/json/FileStorageTest.kt | 10 ++--- .../interact/entity/death/PlayerDeath.kts | 2 +- 9 files changed, 44 insertions(+), 54 deletions(-) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt index 919f6e7af..91edde126 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/EngineModules.kt @@ -40,33 +40,28 @@ val engineModule = module { single { SaveQueue(get(), SafeStorage(File(Settings["storage.players.errors"]))) } - single { - val homeTile = Tile( - x = Settings["world.home.x", 0], - y = Settings["world.home.y", 0], - level = Settings["world.home.level", 0] - ) - AccountManager(get(), get(), get(), get(), get(), get(), homeTile, get(), get(), get(), get(), Settings["world.experienceRate", 1.0]) - } + single { AccountManager(get(), get(), get(), get(), get(), get(), get(), get(), get(), get()) } // IO single { Yaml(YamlReaderConfiguration(2, 8, VERY_FAST_LOAD_FACTOR)) } - single { if (Settings["storage.type", "files"] == "database") { - DatabaseStorage.connect( - Settings["storage.database.username"], - Settings["storage.database.password"], - Settings["storage.database.driver"], - Settings["storage.database.jdbcUrl"], - Settings["storage.database.poolSize", 2], - ) - DatabaseStorage() - } else { - val saves = File(Settings["storage.players.path"]) - if (!saves.exists()) { - saves.mkdir() + single { + if (Settings["storage.type", "files"] == "database") { + DatabaseStorage.connect( + Settings["storage.database.username"], + Settings["storage.database.password"], + Settings["storage.database.driver"], + Settings["storage.database.jdbcUrl"], + Settings["storage.database.poolSize", 2], + ) + DatabaseStorage() + } else { + val saves = File(Settings["storage.players.path"]) + if (!saves.exists()) { + saves.mkdir() + } + FileStorage(get(), saves) } - FileStorage(get(), saves, get(), Settings["world.experienceRate", 1.0]) - } } - single { PlayerAccountLoader(get(), get(), get(), get(), get(), Contexts.Game, Settings["world.experienceRate", 1.0]) } + } + single { PlayerAccountLoader(get(), get(), get(), get(), get(), Contexts.Game) } // Map single { ZoneBatchUpdates() } single { DynamicZones(get(), get(), get()) } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoader.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoader.kt index 3b205e878..20fcd72c2 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoader.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoader.kt @@ -7,6 +7,7 @@ import kotlinx.coroutines.withContext import world.gregs.voidps.engine.data.AccountManager import world.gregs.voidps.engine.data.AccountStorage import world.gregs.voidps.engine.data.SaveQueue +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.definition.AccountDefinitions import world.gregs.voidps.engine.entity.World import world.gregs.voidps.engine.entity.character.player.Player @@ -29,8 +30,7 @@ class PlayerAccountLoader( private val accounts: AccountManager, private val saveQueue: SaveQueue, private val accountDefinitions: AccountDefinitions, - private val gameContext: CoroutineDispatcher, - private val experienceRate: Double + private val gameContext: CoroutineDispatcher ) : AccountLoader { private val logger = InlineLogger() @@ -52,7 +52,7 @@ class PlayerAccountLoader( client.disconnect(Response.ACCOUNT_ONLINE) return null } - val player = storage.load(username)?.toPlayer(experienceRate) ?: accounts.create(username, passwordHash) + val player = storage.load(username)?.toPlayer(Settings["world.experienceRate", 1.0]) ?: accounts.create(username, passwordHash) logger.info { "Player $username loaded and queued for login." } connect(player, client, displayMode) return player.instructions diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/AccountManager.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/AccountManager.kt index 7ac39d773..29801e376 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/AccountManager.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/AccountManager.kt @@ -35,17 +35,17 @@ class AccountManager( private val accountDefinitions: AccountDefinitions, private val collisionStrategyProvider: CollisionStrategyProvider, private val variableDefinitions: VariableDefinitions, - private val homeTile: Tile, private val saveQueue: SaveQueue, private val connectionQueue: ConnectionQueue, private val players: Players, - private val areaDefinitions: AreaDefinitions, - private val experienceRate: Double + private val areaDefinitions: AreaDefinitions ) { private val validItems = ValidItemRestriction(itemDefinitions) + private val homeTile: Tile + get() = Tile(Settings["world.home.x", 0], Settings["world.home.y", 0], Settings["world.home.level", 0]) fun create(name: String, passwordHash: String): Player { - return Player(tile = homeTile, accountName = name, passwordHash = passwordHash, experience = Experience(rate = experienceRate)).apply { + return Player(tile = homeTile, accountName = name, passwordHash = passwordHash, experience = Experience(rate = Settings["world.experienceRate", 1.0])).apply { this["creation"] = System.currentTimeMillis() this["new_player"] = true } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/json/FileStorage.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/json/FileStorage.kt index 9680819bb..fe4698e06 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/json/FileStorage.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/json/FileStorage.kt @@ -4,7 +4,6 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import world.gregs.voidps.engine.data.AccountStorage import world.gregs.voidps.engine.data.PlayerSave import world.gregs.voidps.engine.data.config.AccountDefinition -import world.gregs.voidps.engine.data.definition.ItemDefinitions import world.gregs.voidps.engine.data.yaml.PlayerYamlReaderConfig import world.gregs.voidps.engine.data.yaml.PlayerYamlWriterConfig import world.gregs.voidps.engine.entity.character.player.chat.clan.Clan @@ -20,9 +19,7 @@ import java.io.File @Suppress("UNCHECKED_CAST") class FileStorage( private val yaml: Yaml, - private val directory: File, - itemDefinitions: ItemDefinitions, - experienceRate: Double + private val directory: File ) : AccountStorage { private val config = object : YamlReaderConfiguration() { override fun set(map: MutableMap, key: String, value: Any, indent: Int, parentMap: String?) { @@ -82,7 +79,7 @@ class FileStorage( } private val writeConfig = PlayerYamlWriterConfig() - private val readerConfig = PlayerYamlReaderConfig(itemDefinitions, experienceRate) + private val readerConfig = PlayerYamlReaderConfig() override fun save(accounts: List) { for (account in accounts) { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/yaml/PlayerYamlReaderConfig.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/yaml/PlayerYamlReaderConfig.kt index 4683b0f47..998f77f25 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/yaml/PlayerYamlReaderConfig.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/yaml/PlayerYamlReaderConfig.kt @@ -1,6 +1,6 @@ package world.gregs.voidps.engine.data.yaml -import world.gregs.voidps.engine.data.definition.ItemDefinitions +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.player.chat.clan.ClanRank import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.entity.character.player.skill.exp.Experience @@ -9,10 +9,7 @@ import world.gregs.voidps.engine.entity.item.Item import world.gregs.voidps.type.Tile import world.gregs.yaml.read.YamlReaderConfiguration -internal class PlayerYamlReaderConfig( - private val itemDefinitions: ItemDefinitions, - private val experienceRate: Double -) : YamlReaderConfiguration() { +internal class PlayerYamlReaderConfig : YamlReaderConfiguration() { override fun add(list: MutableList, value: Any, parentMap: String?) { if (value is Map<*, *> && value.containsKey("id")) { val id = value["id"] as String @@ -37,7 +34,7 @@ internal class PlayerYamlReaderConfig( val exp = Experience( experience = (value["experience"] as List).toDoubleArray(), blocked = (value["blocked"] as List).toMutableSet(), - rate = experienceRate + rate = Settings["world.experienceRate", 1.0] ) super.set(map, key, exp, indent, parentMap) } else if (key == "levels") { diff --git a/engine/src/test/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoaderTest.kt b/engine/src/test/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoaderTest.kt index dbb52f8a8..1e076b541 100644 --- a/engine/src/test/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoaderTest.kt +++ b/engine/src/test/kotlin/world/gregs/voidps/engine/client/PlayerAccountLoaderTest.kt @@ -56,7 +56,7 @@ internal class PlayerAccountLoaderTest : KoinMock() { saveQueue = SaveQueue(storage, scope = TestScope()) definitions = AccountDefinitions(mutableMapOf("name" to AccountDefinition("name", "oldName", "", "hash"))) accounts = mockk(relaxed = true) - loader = PlayerAccountLoader(queue, storage, accounts, saveQueue, definitions, UnconfinedTestDispatcher(), 1.0) + loader = PlayerAccountLoader(queue, storage, accounts, saveQueue, definitions, UnconfinedTestDispatcher()) } @Test diff --git a/engine/src/test/kotlin/world/gregs/voidps/engine/data/AccountManagerTest.kt b/engine/src/test/kotlin/world/gregs/voidps/engine/data/AccountManagerTest.kt index 503be9187..ed8cb8f16 100644 --- a/engine/src/test/kotlin/world/gregs/voidps/engine/data/AccountManagerTest.kt +++ b/engine/src/test/kotlin/world/gregs/voidps/engine/data/AccountManagerTest.kt @@ -3,6 +3,7 @@ package world.gregs.voidps.engine.data import io.mockk.mockk import io.mockk.mockkStatic import io.mockk.verify +import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -53,6 +54,7 @@ class AccountManagerTest : KoinMock() { override fun load(accountName: String): PlayerSave? = null } + Settings.load(mapOf("world.home.x" to "1234", "world.home.y" to "5432", "world.experienceRate" to "1.0")) manager = AccountManager( interfaceDefinitions = get(), inventoryDefinitions = inventoryDefinitions, @@ -60,12 +62,10 @@ class AccountManagerTest : KoinMock() { accountDefinitions = AccountDefinitions(), collisionStrategyProvider = CollisionStrategyProvider(), variableDefinitions = VariableDefinitions(), - homeTile = Tile(1234, 5432), saveQueue = SaveQueue(storage), connectionQueue = connectionQueue, areaDefinitions = get(), - players = Players(), - experienceRate = 1.0 + players = Players() ) } @@ -120,4 +120,9 @@ class AccountManagerTest : KoinMock() { client.disconnect() } } + + @AfterEach + fun teardown() { + Settings.clear() + } } \ No newline at end of file diff --git a/engine/src/test/kotlin/world/gregs/voidps/engine/data/json/FileStorageTest.kt b/engine/src/test/kotlin/world/gregs/voidps/engine/data/json/FileStorageTest.kt index 8a3ed0df3..7ad1968cb 100644 --- a/engine/src/test/kotlin/world/gregs/voidps/engine/data/json/FileStorageTest.kt +++ b/engine/src/test/kotlin/world/gregs/voidps/engine/data/json/FileStorageTest.kt @@ -19,24 +19,20 @@ class FileStorageTest : AccountStorageTest() { override lateinit var storage: AccountStorage - private val itemDefinitions = ItemDefinitions(Array(30000) { ItemDefinition.EMPTY }).apply { - ids = emptyMap() - } - @BeforeEach fun setup() { - storage = FileStorage(Yaml(), directory, itemDefinitions, 1.0) + storage = FileStorage(Yaml(), directory) } @Test fun `Invalid directory returns no names`() { - val storage = FileStorage(Yaml(), directory.resolve("invalid"), itemDefinitions, 1.0) + val storage = FileStorage(Yaml(), directory.resolve("invalid")) assertTrue(storage.names().isEmpty()) } @Test fun `Invalid directory returns no clans`() { - val storage = FileStorage(Yaml(), directory.resolve("invalid"), itemDefinitions, 1.0) + val storage = FileStorage(Yaml(), directory.resolve("invalid")) assertTrue(storage.clans().isEmpty()) } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/PlayerDeath.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/PlayerDeath.kts index add8610c5..a3281b6b2 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/PlayerDeath.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/PlayerDeath.kts @@ -46,7 +46,7 @@ val Character.damageDealers: MutableMap get() = getOrPut("damage_dealers") { mutableMapOf() } val respawnTile: Tile - get() = Tile(Settings["world.home.x", 0], Settings["world.home.y", 0], Settings["world.home.level", 0]) + get() = Tile(Settings["world.home.x", 0], Settings["world.home.y", 0], Settings["world.home.level", 0]) playerDeath { player -> player.dead = true From cb73da63e20c91b9206d5f371c2859e7ba75a7b2 Mon Sep 17 00:00:00 2001 From: GregHib Date: Fri, 10 Jan 2025 17:19:40 +0000 Subject: [PATCH 23/25] Replace Main.name with server.name setting --- game/src/main/kotlin/world/gregs/voidps/Main.kt | 13 +++++-------- .../world/activity/achievement/ExplorerJack.kts | 4 ++-- .../voidps/world/interact/entity/npc/Banker.kts | 4 ++-- .../world/map/varrock/BartenderBlueMoonInn.kts | 3 ++- .../world/gregs/voidps/world/script/WorldTest.kt | 1 - 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/game/src/main/kotlin/world/gregs/voidps/Main.kt b/game/src/main/kotlin/world/gregs/voidps/Main.kt index c38380b92..cea626b9c 100644 --- a/game/src/main/kotlin/world/gregs/voidps/Main.kt +++ b/game/src/main/kotlin/world/gregs/voidps/Main.kt @@ -23,7 +23,6 @@ import world.gregs.voidps.network.GameServer import world.gregs.voidps.network.LoginServer import world.gregs.voidps.network.login.protocol.decoders import world.gregs.voidps.script.loadScripts -import java.io.File import java.util.* import kotlin.coroutines.CoroutineContext @@ -34,19 +33,17 @@ import kotlin.coroutines.CoroutineContext object Main : CoroutineScope { override val coroutineContext: CoroutineContext = Contexts.Game - lateinit var name: String private val logger = InlineLogger() @OptIn(ExperimentalUnsignedTypes::class) @JvmStatic fun main(args: Array) { val startTime = System.currentTimeMillis() - val properties = settings() - name = Settings["server.name"] + val settings = settings() // File server - val cache = timed("cache") { Cache.load(properties) } - val server = GameServer.load(cache, properties) + val cache = timed("cache") { Cache.load(settings) } + val server = GameServer.load(cache, settings) val job = server.start(Settings["network.port"].toInt()) // Content @@ -60,7 +57,7 @@ object Main : CoroutineScope { // Login server val decoders = decoders(get()) val accountLoader: PlayerAccountLoader = get() - val loginServer = LoginServer.load(properties, decoders, accountLoader) + val loginServer = LoginServer.load(settings, decoders, accountLoader) // Game world val stages = getTickStages() @@ -68,7 +65,7 @@ object Main : CoroutineScope { val scope = CoroutineScope(Contexts.Game) val engine = GameLoop(stages).start(scope) server.loginServer = loginServer - logger.info { "$name loaded in ${System.currentTimeMillis() - startTime}ms" } + logger.info { "${Settings["server.name"]} loaded in ${System.currentTimeMillis() - startTime}ms" } runBlocking { try { job.join() diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/ExplorerJack.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/ExplorerJack.kts index 41e6b7692..807a2ea78 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/ExplorerJack.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/ExplorerJack.kts @@ -3,8 +3,8 @@ package world.gregs.voidps.world.activity.achievement import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.sendScript import world.gregs.voidps.engine.client.variable.BitwiseValues +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.definition.VariableDefinitions -import world.gregs.voidps.Main.name import world.gregs.voidps.engine.entity.character.npc.NPCOption import world.gregs.voidps.engine.entity.character.npc.npcOperate import world.gregs.voidps.engine.entity.character.player.Player @@ -25,7 +25,7 @@ import world.gregs.voidps.world.interact.dialogue.type.player npcOperate("Talk-to", "explorer_jack") { if (player["introducing_explorer_jack_task", "uncompleted"] == "uncompleted") { - npc("Ah! Welcome to ${name}, lad. My name's Explorer jack. I'm an explorer by trade, and I'm one of the Taskmasters around these parts") + npc("Ah! Welcome to ${Settings["server.name"]}, lad. My name's Explorer jack. I'm an explorer by trade, and I'm one of the Taskmasters around these parts") player("Taskmaster? What Tasks are you Master of?") whatIsTaskSystem() } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Banker.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Banker.kts index 1387955e7..ecca786eb 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Banker.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Banker.kts @@ -1,8 +1,8 @@ package world.gregs.voidps.world.interact.entity.npc -import world.gregs.voidps.Main.name import world.gregs.voidps.engine.client.ui.dialogue.talkWith import world.gregs.voidps.engine.client.ui.open +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.NPCs import world.gregs.voidps.engine.entity.character.npc.npcApproach @@ -46,7 +46,7 @@ suspend fun CharacterContext.menu() { option("I'd like to see my collection box.", block = { player.open("collection_box") }) option("I'd like to see my Returned Items box.", block = { player.open("returned_items") }) option("What is this place?") { - npc("This is a branch of the Bank of $name. We have branches in many towns.") + npc("This is a branch of the Bank of ${Settings["server.name"]}. We have branches in many towns.") choice { option("And what do you do?") { npc("We will look after your items and money for you. Leave your valuables with us if you want to keep them safe.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderBlueMoonInn.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderBlueMoonInn.kts index 43a8fc060..6556ca1be 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderBlueMoonInn.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderBlueMoonInn.kts @@ -3,6 +3,7 @@ package world.gregs.voidps.world.map.varrock import world.gregs.voidps.Main import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.ui.interact.itemOnNPCApproach +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.forceChat import world.gregs.voidps.engine.entity.character.mode.interact.TargetNPCContext import world.gregs.voidps.engine.entity.character.npc.npcApproach @@ -38,7 +39,7 @@ npcApproach("Talk-to", "bartender_blue_moon_inn") { choice { option("Oh ah well...") option("Game? What are you talking about?") { - npc("This world around us... is an online game... called ${Main.name}.") + npc("This world around us... is an online game... called ${Settings["server.name"]}.") player("Nope, still don't understand what you are talking about. What does 'online' mean?") npc("It's a sort of connection between magic boxes across the world, big boxes on people's desktops and little ones people can carry. They can talk to each other to play games.") player("I give up. You're obviously completely mad!") diff --git a/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt index 6d1734640..f4ae99940 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt @@ -148,7 +148,6 @@ abstract class WorldTest : KoinTest { @BeforeAll fun beforeAll() { - Main.name = "test" properties = Properties() properties.load(WorldTest::class.java.getResourceAsStream("/test.properties")!!) settings = Settings.load(properties) From a2a7e2699882d30c5916bc78a5242abb477e0dbd Mon Sep 17 00:00:00 2001 From: GregHib Date: Fri, 10 Jan 2025 17:30:48 +0000 Subject: [PATCH 24/25] Fix network test --- .../src/test/kotlin/world/gregs/voidps/network/GameServerTest.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/network/src/test/kotlin/world/gregs/voidps/network/GameServerTest.kt b/network/src/test/kotlin/world/gregs/voidps/network/GameServerTest.kt index b16f6762d..0db18b9cf 100644 --- a/network/src/test/kotlin/world/gregs/voidps/network/GameServerTest.kt +++ b/network/src/test/kotlin/world/gregs/voidps/network/GameServerTest.kt @@ -157,6 +157,7 @@ internal class GameServerTest { val properties = Properties() properties.setProperty("network.maxClientPerIP", "0") properties.setProperty("storage.cache.server", "false") + properties.setProperty("server.revision", "634") server = GameServer.load(mockk(relaxed = true), properties) launch { From 64641f1edf3e6d7fd8f2da479ffdf72402f7d1d0 Mon Sep 17 00:00:00 2001 From: GregHib Date: Fri, 10 Jan 2025 17:34:43 +0000 Subject: [PATCH 25/25] Remove unused imports --- .../voidps/world/activity/dnd/shootingstar/ShootingStar.kts | 1 - .../gregs/voidps/world/interact/entity/death/PlayerDeath.kts | 1 - .../world/gregs/voidps/world/interact/entity/gfx/SpawnGraphic.kt | 1 - .../world/gregs/voidps/world/interact/entity/npc/shop/Price.kt | 1 - .../gregs/voidps/world/map/varrock/BartenderBlueMoonInn.kts | 1 - 5 files changed, 5 deletions(-) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts index 830f4e1c5..5b46d0930 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/dnd/shootingstar/ShootingStar.kts @@ -26,7 +26,6 @@ import world.gregs.voidps.engine.entity.obj.* import world.gregs.voidps.engine.entity.objectDespawn import world.gregs.voidps.engine.entity.playerSpawn import world.gregs.voidps.engine.entity.worldSpawn -import world.gregs.voidps.engine.event.Events import world.gregs.voidps.engine.inject import world.gregs.voidps.engine.inv.add import world.gregs.voidps.engine.inv.inventory diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/PlayerDeath.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/PlayerDeath.kts index a3281b6b2..f3c14c117 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/PlayerDeath.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/PlayerDeath.kts @@ -15,7 +15,6 @@ import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.entity.characterSpawn import world.gregs.voidps.engine.entity.item.Item import world.gregs.voidps.engine.entity.item.floor.FloorItems -import world.gregs.voidps.engine.get import world.gregs.voidps.engine.inject import world.gregs.voidps.engine.inv.* import world.gregs.voidps.engine.map.Spiral diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/gfx/SpawnGraphic.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/gfx/SpawnGraphic.kt index ac7cff528..f75a25f83 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/gfx/SpawnGraphic.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/gfx/SpawnGraphic.kt @@ -3,7 +3,6 @@ package world.gregs.voidps.world.interact.entity.gfx import world.gregs.voidps.engine.client.update.batch.ZoneBatchUpdates import world.gregs.voidps.engine.data.definition.GraphicDefinitions import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.inject import world.gregs.voidps.network.login.protocol.encode.zone.GraphicAddition import world.gregs.voidps.type.Direction import world.gregs.voidps.type.Tile diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/shop/Price.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/shop/Price.kt index abcd8c5aa..22baaeaa0 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/shop/Price.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/shop/Price.kt @@ -4,7 +4,6 @@ import world.gregs.voidps.engine.data.definition.EnumDefinitions import world.gregs.voidps.engine.data.definition.ItemDefinitions import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.get -import world.gregs.voidps.engine.inject import kotlin.math.max import kotlin.math.min diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderBlueMoonInn.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderBlueMoonInn.kts index 6556ca1be..12e77c82b 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderBlueMoonInn.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderBlueMoonInn.kts @@ -1,6 +1,5 @@ package world.gregs.voidps.world.map.varrock -import world.gregs.voidps.Main import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.ui.interact.itemOnNPCApproach import world.gregs.voidps.engine.data.Settings