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:
David Markowitz
2023-03-17 07:36:21 -07:00
committed by GitHub
parent bd79e9433c
commit 7671cc6865
121 changed files with 399 additions and 1584 deletions

View File

@@ -82,6 +82,9 @@
#include "AMFFormat_BitStream.h"
#include "eReplicaComponentType.h"
#include "CDComponentsRegistryTable.h"
#include "CDObjectsTable.h"
void GameMessages::SendFireEventClientSide(const LWOOBJID& objectID, const SystemAddress& sysAddr, std::u16string args, const LWOOBJID& object, int64_t param1, int param2, const LWOOBJID& sender) {
CBITSTREAM;
CMSGHEADER;
@@ -1077,7 +1080,7 @@ void GameMessages::SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID,
// Currency and powerups should not sync
if (team != nullptr && currency == 0) {
CDObjectsTable* objectsTable = CDClientManager::Instance()->GetTable<CDObjectsTable>("Objects");
CDObjectsTable* objectsTable = CDClientManager::Instance().GetTable<CDObjectsTable>();
const CDObjects& object = objectsTable->GetByID(item);
@@ -4720,8 +4723,8 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti
InventoryComponent* inv = static_cast<InventoryComponent*>(player->GetComponent(eReplicaComponentType::INVENTORY));
if (!inv) return;
CDComponentsRegistryTable* compRegistryTable = CDClientManager::Instance()->GetTable<CDComponentsRegistryTable>("ComponentsRegistry");
CDItemComponentTable* itemComponentTable = CDClientManager::Instance()->GetTable<CDItemComponentTable>("ItemComponent");
CDComponentsRegistryTable* compRegistryTable = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
CDItemComponentTable* itemComponentTable = CDClientManager::Instance().GetTable<CDItemComponentTable>();
int itemCompID = compRegistryTable->GetByIDAndType(item, eReplicaComponentType::ITEM);
CDItemComponent itemComp = itemComponentTable->GetItemComponentByID(itemCompID);
@@ -4812,8 +4815,8 @@ void GameMessages::HandleSellToVendor(RakNet::BitStream* inStream, Entity* entit
Item* item = inv->FindItemById(iObjID);
if (!item) return;
CDComponentsRegistryTable* compRegistryTable = CDClientManager::Instance()->GetTable<CDComponentsRegistryTable>("ComponentsRegistry");
CDItemComponentTable* itemComponentTable = CDClientManager::Instance()->GetTable<CDItemComponentTable>("ItemComponent");
CDComponentsRegistryTable* compRegistryTable = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
CDItemComponentTable* itemComponentTable = CDClientManager::Instance().GetTable<CDItemComponentTable>();
int itemCompID = compRegistryTable->GetByIDAndType(item->GetLot(), eReplicaComponentType::ITEM);
CDItemComponent itemComp = itemComponentTable->GetItemComponentByID(itemCompID);
@@ -4862,8 +4865,8 @@ void GameMessages::HandleBuybackFromVendor(RakNet::BitStream* inStream, Entity*
Item* item = inv->FindItemById(iObjID);
if (!item) return;
CDComponentsRegistryTable* compRegistryTable = CDClientManager::Instance()->GetTable<CDComponentsRegistryTable>("ComponentsRegistry");
CDItemComponentTable* itemComponentTable = CDClientManager::Instance()->GetTable<CDItemComponentTable>("ItemComponent");
CDComponentsRegistryTable* compRegistryTable = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
CDItemComponentTable* itemComponentTable = CDClientManager::Instance().GetTable<CDItemComponentTable>();
int itemCompID = compRegistryTable->GetByIDAndType(item->GetLot(), eReplicaComponentType::ITEM);
CDItemComponent itemComp = itemComponentTable->GetItemComponentByID(itemCompID);
@@ -5101,7 +5104,7 @@ void GameMessages::HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity)
}
}
CDEmoteTableTable* emotes = CDClientManager::Instance()->GetTable<CDEmoteTableTable>("EmoteTable");
CDEmoteTableTable* emotes = CDClientManager::Instance().GetTable<CDEmoteTableTable>();
if (emotes) {
CDEmoteTable* emote = emotes->GetEmote(emoteID);
if (emote) sAnimationName = emote->animationName;