mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 17:54:01 +00:00
CDClient cleanup and optimization (#1023)
* CDClient cleanup and optimization - Use static function to get table name - Remove unused GetName function - Replace above function with a static GetTableName function - Remove verbose comments - Remove verbose initializers - Remove need to specify table name when getting a table by name - Remove unused typedef for mac and linux * Re-add unused table Convert tables to singletons - Convert all CDClient tables to singletons - Move Singleton.h to dCommon - Reduce header clutter in CDClientManager
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
#include "eItemType.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
#include "CDComponentsRegistryTable.h"
|
||||
|
||||
std::vector<LOT> Inventory::m_GameMasterRestrictedItems = {
|
||||
1727, // GM Only - JetPack
|
||||
2243, // GM Only - Hammer of Doom
|
||||
@@ -274,9 +276,9 @@ eInventoryType Inventory::FindInventoryTypeForLot(const LOT lot) {
|
||||
}
|
||||
|
||||
const CDItemComponent& Inventory::FindItemComponent(const LOT lot) {
|
||||
auto* registry = CDClientManager::Instance()->GetTable<CDComponentsRegistryTable>("ComponentsRegistry");
|
||||
auto* registry = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
|
||||
|
||||
auto* itemComponents = CDClientManager::Instance()->GetTable<CDItemComponentTable>("ItemComponent");
|
||||
auto* itemComponents = CDClientManager::Instance().GetTable<CDItemComponentTable>();
|
||||
|
||||
const auto componentId = registry->GetByIDAndType(lot, eReplicaComponentType::ITEM);
|
||||
|
||||
@@ -292,7 +294,7 @@ const CDItemComponent& Inventory::FindItemComponent(const LOT lot) {
|
||||
}
|
||||
|
||||
bool Inventory::IsValidItem(const LOT lot) {
|
||||
auto* registry = CDClientManager::Instance()->GetTable<CDComponentsRegistryTable>("ComponentsRegistry");
|
||||
auto* registry = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
|
||||
|
||||
const auto componentId = registry->GetByIDAndType(lot, eReplicaComponentType::ITEM);
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
#include "CDItemComponentTable.h"
|
||||
#include "CDClientManager.h"
|
||||
#include "dCommonVars.h"
|
||||
|
||||
|
@@ -18,6 +18,11 @@
|
||||
#include "Loot.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
#include "CDBrickIDTableTable.h"
|
||||
#include "CDObjectSkillsTable.h"
|
||||
#include "CDComponentsRegistryTable.h"
|
||||
#include "CDPackageComponentTable.h"
|
||||
|
||||
Item::Item(const LWOOBJID id, const LOT lot, Inventory* inventory, const uint32_t slot, const uint32_t count, const bool bound, const std::vector<LDFBaseData*>& config, const LWOOBJID parent, LWOOBJID subKey, eLootSourceType lootSourceType) {
|
||||
if (!Inventory::IsValidItem(lot)) {
|
||||
return;
|
||||
@@ -238,7 +243,7 @@ bool Item::IsEquipped() const {
|
||||
}
|
||||
|
||||
bool Item::Consume() {
|
||||
auto* skillsTable = CDClientManager::Instance()->GetTable<CDObjectSkillsTable>("ObjectSkills");
|
||||
auto* skillsTable = CDClientManager::Instance().GetTable<CDObjectSkillsTable>();
|
||||
|
||||
auto skills = skillsTable->Query([=](const CDObjectSkills entry) {
|
||||
return entry.objectTemplate == static_cast<uint32_t>(lot);
|
||||
@@ -297,12 +302,12 @@ void Item::UseNonEquip(Item* item) {
|
||||
bool success = false;
|
||||
auto inventory = item->GetInventory();
|
||||
if (inventory && inventory->GetType() == eInventoryType::ITEMS) {
|
||||
auto* compRegistryTable = CDClientManager::Instance()->GetTable<CDComponentsRegistryTable>("ComponentsRegistry");
|
||||
auto* compRegistryTable = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
|
||||
const auto packageComponentId = compRegistryTable->GetByIDAndType(lot, eReplicaComponentType::PACKAGE);
|
||||
|
||||
if (packageComponentId == 0) return;
|
||||
|
||||
auto* packCompTable = CDClientManager::Instance()->GetTable<CDPackageComponentTable>("PackageComponent");
|
||||
auto* packCompTable = CDClientManager::Instance().GetTable<CDPackageComponentTable>();
|
||||
auto packages = packCompTable->Query([=](const CDPackageComponent entry) {return entry.id == static_cast<uint32_t>(packageComponentId); });
|
||||
|
||||
auto success = !packages.empty();
|
||||
@@ -380,7 +385,7 @@ void Item::Disassemble(const eInventoryType inventoryType) {
|
||||
}
|
||||
|
||||
void Item::DisassembleModel() {
|
||||
auto* table = CDClientManager::Instance()->GetTable<CDComponentsRegistryTable>("ComponentsRegistry");
|
||||
auto* table = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
|
||||
|
||||
const auto componentId = table->GetByIDAndType(GetLot(), eReplicaComponentType::RENDER);
|
||||
|
||||
@@ -457,7 +462,7 @@ void Item::DisassembleModel() {
|
||||
currentBrick = currentBrick->NextSiblingElement(searchTerm.c_str());
|
||||
}
|
||||
|
||||
auto* brickIDTable = CDClientManager::Instance()->GetTable<CDBrickIDTableTable>("BrickIDTable");
|
||||
auto* brickIDTable = CDClientManager::Instance().GetTable<CDBrickIDTableTable>();
|
||||
|
||||
for (unsigned int part : parts) {
|
||||
const auto brickID = brickIDTable->Query([=](const CDBrickIDTable& entry) {
|
||||
|
@@ -9,6 +9,8 @@
|
||||
#include "eMissionTaskType.h"
|
||||
#include <algorithm>
|
||||
|
||||
#include "CDSkillBehaviorTable.h"
|
||||
|
||||
ItemSet::ItemSet(const uint32_t id, InventoryComponent* inventoryComponent) {
|
||||
this->m_ID = id;
|
||||
this->m_InventoryComponent = inventoryComponent;
|
||||
@@ -127,7 +129,7 @@ void ItemSet::OnEquip(const LOT lot) {
|
||||
auto* missionComponent = m_InventoryComponent->GetParent()->GetComponent<MissionComponent>();
|
||||
|
||||
for (const auto skill : skillSet) {
|
||||
auto* skillTable = CDClientManager::Instance()->GetTable<CDSkillBehaviorTable>("SkillBehavior");
|
||||
auto* skillTable = CDClientManager::Instance().GetTable<CDSkillBehaviorTable>();
|
||||
|
||||
const auto behaviorId = skillTable->GetSkillByID(skill).behaviorID;
|
||||
|
||||
@@ -159,7 +161,7 @@ void ItemSet::OnUnEquip(const LOT lot) {
|
||||
const auto& skillComponent = m_InventoryComponent->GetParent()->GetComponent<SkillComponent>();
|
||||
|
||||
for (const auto skill : skillSet) {
|
||||
auto* skillTable = CDClientManager::Instance()->GetTable<CDSkillBehaviorTable>("SkillBehavior");
|
||||
auto* skillTable = CDClientManager::Instance().GetTable<CDSkillBehaviorTable>();
|
||||
|
||||
const auto behaviorId = skillTable->GetSkillByID(skill).behaviorID;
|
||||
|
||||
|
Reference in New Issue
Block a user