diff --git a/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/DynamicLairLoader.kt b/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/DynamicLairLoader.kt new file mode 100644 index 000000000..6d881ad26 --- /dev/null +++ b/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/DynamicLairLoader.kt @@ -0,0 +1,59 @@ +/*********************************************************************************** + * Copyright (c) 2023 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * --------------------------------------------------------------------------------* + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + ***********************************************************************************/ +package com.projectswg.holocore.resources.support.data.server_info.loader + +import com.projectswg.holocore.resources.support.data.server_info.SdbLoader +import com.projectswg.holocore.resources.support.data.server_info.SdbLoader.SdbResultSet +import java.io.File + +class DynamicLairLoader : DataLoader() { + + private val lairIdToDynamicLair = mutableMapOf() + + fun getDynamicLairInfo(lairId: String): DynamicLairInfo? { + return lairIdToDynamicLair[lairId] + } + + override fun load() { + val set = SdbLoader.load(File("serverdata/spawn/dynamic/dynamic_lairs.sdb")) + + set.use { + while (set.next()) { + val lairId = set.getText("lair_id") + val dynamicLairInfo = DynamicLairInfo(set) + + lairIdToDynamicLair[lairId] = dynamicLairInfo + } + } + } + + class DynamicLairInfo(set: SdbResultSet) { + val iffTemplate = set.getText("iff_template") + val npcSpawnRadius = set.getInt("npc_spawn_radius") + val gcw = set.getBoolean("gcw") + } +} \ No newline at end of file diff --git a/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/ServerData.kt b/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/ServerData.kt index b38809f04..f65bb9488 100644 --- a/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/ServerData.kt +++ b/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/ServerData.kt @@ -1,5 +1,5 @@ /*********************************************************************************** - * Copyright (c) 2019 /// Project SWG /// www.projectswg.com * + * Copyright (c) 2023 /// Project SWG /// www.projectswg.com * * * * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * @@ -101,6 +101,7 @@ object ServerData { val badges by SoftDataLoaderDelegate(::BadgeLoader) val mappingTemplates by SoftDataLoaderDelegate(::MappingTemplateLoader) val speciesRestrictions by SoftDataLoaderDelegate(::SpeciesRestrictionLoader) + val dynamicLairs by SoftDataLoaderDelegate(::DynamicLairLoader) private class WeakDataLoaderDelegate(loaderCreator: () -> T): DataLoaderDelegate(::WeakReference, loaderCreator) private class SoftDataLoaderDelegate(loaderCreator: () -> T): DataLoaderDelegate(::SoftReference, loaderCreator) diff --git a/src/test/java/com/projectswg/holocore/resources/support/data/server_info/loader/DynamicLairLoaderTest.kt b/src/test/java/com/projectswg/holocore/resources/support/data/server_info/loader/DynamicLairLoaderTest.kt new file mode 100644 index 000000000..47f8eca17 --- /dev/null +++ b/src/test/java/com/projectswg/holocore/resources/support/data/server_info/loader/DynamicLairLoaderTest.kt @@ -0,0 +1,39 @@ +/*********************************************************************************** + * Copyright (c) 2023 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * --------------------------------------------------------------------------------* + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + ***********************************************************************************/ +package com.projectswg.holocore.resources.support.data.server_info.loader + +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test + +class DynamicLairLoaderTest { + @Test + fun `can load dynamic lair`() { + val dynamicLairInfo = ServerData.dynamicLairs.getDynamicLairInfo("lair_bearded_jax") + + assertNotNull(dynamicLairInfo) + } +} \ No newline at end of file