mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-09-05 23:08:31 +00:00
chore: Move database storage containers to be translation unit local to allow for safe references (#1434)
* Move CDClientManager to be a namespace Tested that worlds still load data as expected. Had no use being a singleton anyways. * Move cdclient data storage to tu local containers Allows some data from these containers to be saved on object by reference instead of always needing to copy. iteration 2 - move all unnamed namespace containers to a singular spot - use macro for template specialization and variable declaration - use templates to allow for as little copy paste of types and functions as possible * remember to use typename! compiler believes T::StorageType is accessing a member, not a type. * Update CDClientManager.cpp * move to cpp?
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include "CDFeatureGatingTable.h"
|
||||
#include "CDRailActivatorComponent.h"
|
||||
#include "CDRewardCodesTable.h"
|
||||
#include "CDPetComponentTable.h"
|
||||
|
||||
#include <exception>
|
||||
|
||||
@@ -61,6 +62,55 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// Using a macro to reduce repetitive code and issues from copy and paste.
|
||||
// As a note, ## in a macro is used to concatenate two tokens together.
|
||||
|
||||
#define SPECIALIZE_TABLE_STORAGE(table) \
|
||||
template<> typename table::StorageType& CDClientManager::GetEntriesMutable<table>() { return table##Entries; };
|
||||
|
||||
#define DEFINE_TABLE_STORAGE(table) namespace { table::StorageType table##Entries; }; SPECIALIZE_TABLE_STORAGE(table)
|
||||
|
||||
DEFINE_TABLE_STORAGE(CDActivityRewardsTable);
|
||||
DEFINE_TABLE_STORAGE(CDActivitiesTable);
|
||||
DEFINE_TABLE_STORAGE(CDAnimationsTable);
|
||||
DEFINE_TABLE_STORAGE(CDBehaviorParameterTable);
|
||||
DEFINE_TABLE_STORAGE(CDBehaviorTemplateTable);
|
||||
DEFINE_TABLE_STORAGE(CDBrickIDTableTable);
|
||||
DEFINE_TABLE_STORAGE(CDComponentsRegistryTable);
|
||||
DEFINE_TABLE_STORAGE(CDCurrencyTableTable);
|
||||
DEFINE_TABLE_STORAGE(CDDestructibleComponentTable);
|
||||
DEFINE_TABLE_STORAGE(CDEmoteTableTable);
|
||||
DEFINE_TABLE_STORAGE(CDFeatureGatingTable);
|
||||
DEFINE_TABLE_STORAGE(CDInventoryComponentTable);
|
||||
DEFINE_TABLE_STORAGE(CDItemComponentTable);
|
||||
DEFINE_TABLE_STORAGE(CDItemSetSkillsTable);
|
||||
DEFINE_TABLE_STORAGE(CDItemSetsTable);
|
||||
DEFINE_TABLE_STORAGE(CDLevelProgressionLookupTable);
|
||||
DEFINE_TABLE_STORAGE(CDLootMatrixTable);
|
||||
DEFINE_TABLE_STORAGE(CDLootTableTable);
|
||||
DEFINE_TABLE_STORAGE(CDMissionEmailTable);
|
||||
DEFINE_TABLE_STORAGE(CDMissionNPCComponentTable);
|
||||
DEFINE_TABLE_STORAGE(CDMissionTasksTable);
|
||||
DEFINE_TABLE_STORAGE(CDMissionsTable);
|
||||
DEFINE_TABLE_STORAGE(CDMovementAIComponentTable);
|
||||
DEFINE_TABLE_STORAGE(CDObjectSkillsTable);
|
||||
DEFINE_TABLE_STORAGE(CDObjectsTable);
|
||||
DEFINE_TABLE_STORAGE(CDPhysicsComponentTable);
|
||||
DEFINE_TABLE_STORAGE(CDPackageComponentTable);
|
||||
DEFINE_TABLE_STORAGE(CDPetComponentTable);
|
||||
DEFINE_TABLE_STORAGE(CDProximityMonitorComponentTable);
|
||||
DEFINE_TABLE_STORAGE(CDPropertyEntranceComponentTable);
|
||||
DEFINE_TABLE_STORAGE(CDPropertyTemplateTable);
|
||||
DEFINE_TABLE_STORAGE(CDRailActivatorComponentTable);
|
||||
DEFINE_TABLE_STORAGE(CDRarityTableTable);
|
||||
DEFINE_TABLE_STORAGE(CDRebuildComponentTable);
|
||||
DEFINE_TABLE_STORAGE(CDRewardCodesTable);
|
||||
DEFINE_TABLE_STORAGE(CDRewardsTable);
|
||||
DEFINE_TABLE_STORAGE(CDScriptComponentTable);
|
||||
DEFINE_TABLE_STORAGE(CDSkillBehaviorTable);
|
||||
DEFINE_TABLE_STORAGE(CDVendorComponentTable);
|
||||
DEFINE_TABLE_STORAGE(CDZoneTableTable);
|
||||
|
||||
void CDClientManager::LoadValuesFromDatabase() {
|
||||
if (!CDClientDatabase::isConnected) throw CDClientConnectionException();
|
||||
|
||||
|
Reference in New Issue
Block a user