From 5759a5549a1fd9bdfd3ef1a8048d197fe780e46b Mon Sep 17 00:00:00 2001 From: Josh Larson Date: Sat, 30 Nov 2024 18:51:47 -0600 Subject: [PATCH] Fixed #1454 - resource object name should be resource class --- pswgcommon | 2 +- .../data/server_info/loader/ServerData.kt | 8 +-- .../data/server_info/loader/StringLoader.kt | 53 +++++++++++++++++++ .../resource/ResourceContainerHelper.kt | 13 ++--- 4 files changed, 65 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/StringLoader.kt diff --git a/pswgcommon b/pswgcommon index 112a1c06c..e29eb920b 160000 --- a/pswgcommon +++ b/pswgcommon @@ -1 +1 @@ -Subproject commit 112a1c06cc55839687532e7aa35f19328df7149c +Subproject commit e29eb920b03a5e8877ed4c1411df3d81d4c07097 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 65163ce1c..e89594640 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,11 +1,10 @@ /*********************************************************************************** * Copyright (c) 2024 /// Project SWG /// www.projectswg.com * * * - * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * ProjectSWG is an emulation project 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. * + * Our goal is to create one or more emulators which will provide servers for * + * players to continue playing a game similar to the one they used to play. * * * * This file is part of Holocore. * * * @@ -84,6 +83,7 @@ object ServerData { val slotArrangements by SoftDataLoaderDelegate(::SlotArrangementLoader) val planetMapCategories by SoftDataLoaderDelegate(::PlanetMapCategoryLoader) val zoneInsertions by SoftDataLoaderDelegate(::TerrainZoneInsertionLoader) + val strings by SoftDataLoaderDelegate(::StringLoader) val terrains by SoftDataLoaderDelegate(::TerrainHeightLoader) val elevators by SoftDataLoaderDelegate(::ElevatorLoader) diff --git a/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/StringLoader.kt b/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/StringLoader.kt new file mode 100644 index 000000000..cf105ab02 --- /dev/null +++ b/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/StringLoader.kt @@ -0,0 +1,53 @@ +/*********************************************************************************** + * Copyright (c) 2024 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is an emulation project for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create one or more emulators which will provide servers for * + * players to continue playing a game similar to the one they used to play. * + * * + * 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.common.data.encodables.oob.StringId +import com.projectswg.holocore.resources.support.data.server_info.SdbLoader +import java.io.File +import kotlin.collections.HashMap + +class StringLoader : DataLoader() { + + private val strings = HashMap() + + operator fun get(stringId: StringId): String? { + return strings[stringId] + } + + override fun load() { + strings.clear() + SdbLoader.load(File("serverdata/strings/strings.sdb")).use { set -> + while (set.next()) { + val key = StringId(set.getText("file"), set.getText("key")) + val value = set.getText("value").replace("\\n", "\n").replace("\\t", "\t") + strings[key] = value.intern() + } + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/projectswg/holocore/services/gameplay/crafting/resource/ResourceContainerHelper.kt b/src/main/java/com/projectswg/holocore/services/gameplay/crafting/resource/ResourceContainerHelper.kt index ce5466002..c42a9995a 100644 --- a/src/main/java/com/projectswg/holocore/services/gameplay/crafting/resource/ResourceContainerHelper.kt +++ b/src/main/java/com/projectswg/holocore/services/gameplay/crafting/resource/ResourceContainerHelper.kt @@ -1,11 +1,10 @@ /*********************************************************************************** * Copyright (c) 2024 /// Project SWG /// www.projectswg.com * * * - * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * ProjectSWG is an emulation project 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. * + * Our goal is to create one or more emulators which will provide servers for * + * players to continue playing a game similar to the one they used to play. * * * * This file is part of Holocore. * * * @@ -31,6 +30,7 @@ import com.projectswg.holocore.intents.support.objects.DestroyObjectIntent import com.projectswg.holocore.intents.support.objects.ObjectCreatedIntent import com.projectswg.holocore.resources.gameplay.crafting.resource.galactic.GalacticResource import com.projectswg.holocore.resources.gameplay.crafting.resource.raw.RawResource +import com.projectswg.holocore.resources.support.data.server_info.loader.ServerData import com.projectswg.holocore.resources.support.data.server_info.loader.ServerData.rawResources import com.projectswg.holocore.resources.support.global.player.Player import com.projectswg.holocore.resources.support.objects.ObjectCreator @@ -63,11 +63,12 @@ object ResourceContainerHelper { private fun createResourceObject(creature: CreatureObject, rawResource: RawResource, resource: GalacticResource, resourceContainerEventHandler: ResourceContainerEventHandler): ResourceContainerObject? { val resourceObject = ObjectCreator.createObjectFromTemplate(rawResource.crateTemplate) as ResourceContainerObject + val rawResourceName = StringId("resource/resource_names", rawResource.parent?.name ?: "") resourceObject.volume = 1 - resourceObject.parentName = StringId("resource/resource_names", rawResource.parent?.name ?: "").toString() + resourceObject.parentName = rawResourceName.toString() resourceObject.resourceType = resource.rawResourceId resourceObject.resourceName = resource.name - resourceObject.objectName = resource.name + resourceObject.objectName = ServerData.strings[rawResourceName] ?: rawResourceName.toString() resourceObject.stats = resource.stats resourceObject.setServerAttribute(ServerAttribute.GALACTIC_RESOURCE_ID, resource.id) resourceObject.containerPermissions = ReadWritePermissions.from(creature)