mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-06 10:44:08 +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:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user