Fixed #1454 - resource object name should be resource class

This commit is contained in:
Josh Larson
2024-11-30 18:51:47 -06:00
parent ba7c071e91
commit 5759a5549a
4 changed files with 65 additions and 11 deletions

View File

@@ -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)

View File

@@ -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 <http://www.gnu.org/licenses/>. *
***********************************************************************************/
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<StringId, String>()
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()
}
}
}
}

View File

@@ -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)