From 79094b66642da05705d91b61b43e4316ab7a572b Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Sun, 16 Jul 2023 00:27:30 -0700 Subject: [PATCH] wow --- dDatabase/CDClientManager.cpp | 80 ------------- dDatabase/CDClientManager.h | 26 ----- dDatabase/CMakeLists.txt | 1 - dDatabase/Tables/CDActivitiesTable.cpp | 16 ++- dDatabase/Tables/CDActivitiesTable.h | 10 +- dDatabase/Tables/CDActivityRewardsTable.cpp | 16 ++- dDatabase/Tables/CDActivityRewardsTable.h | 11 +- dDatabase/Tables/CDAnimationsTable.cpp | 110 ++++++++++-------- dDatabase/Tables/CDAnimationsTable.h | 24 +--- dDatabase/Tables/CDBehaviorParameterTable.cpp | 11 +- dDatabase/Tables/CDBehaviorParameterTable.h | 10 +- dDatabase/Tables/CDBehaviorTemplateTable.cpp | 24 ++-- dDatabase/Tables/CDBehaviorTemplateTable.h | 19 +-- dDatabase/Tables/CDBrickIDTableTable.cpp | 17 ++- dDatabase/Tables/CDBrickIDTableTable.h | 10 +- dDatabase/Tables/CDComponentsRegistryTable.h | 6 +- dDatabase/Tables/CDCurrencyTableTable.h | 4 +- .../Tables/CDDestructibleComponentTable.h | 4 +- dDatabase/Tables/CDEmoteTable.cpp | 42 +++---- dDatabase/Tables/CDEmoteTable.h | 9 +- dDatabase/Tables/CDFeatureGatingTable.h | 4 +- dDatabase/Tables/CDInventoryComponentTable.h | 4 +- dDatabase/Tables/CDItemComponentTable.h | 4 +- dDatabase/Tables/CDItemSetSkillsTable.h | 4 +- dDatabase/Tables/CDItemSetsTable.h | 4 +- .../Tables/CDLevelProgressionLookupTable.h | 4 +- dDatabase/Tables/CDLootMatrixTable.h | 4 +- dDatabase/Tables/CDLootTableTable.h | 4 +- dDatabase/Tables/CDMissionEmailTable.h | 4 +- dDatabase/Tables/CDMissionNPCComponentTable.h | 4 +- dDatabase/Tables/CDMissionTasksTable.h | 4 +- dDatabase/Tables/CDMissionsTable.h | 4 +- dDatabase/Tables/CDMovementAIComponentTable.h | 4 +- dDatabase/Tables/CDObjectSkillsTable.h | 4 +- dDatabase/Tables/CDObjectsTable.h | 4 +- dDatabase/Tables/CDPackageComponentTable.h | 2 +- dDatabase/Tables/CDPhysicsComponentTable.h | 5 +- .../Tables/CDPropertyEntranceComponentTable.h | 4 +- dDatabase/Tables/CDPropertyTemplateTable.h | 4 +- .../Tables/CDProximityMonitorComponentTable.h | 2 +- dDatabase/Tables/CDRailActivatorComponent.h | 4 +- dDatabase/Tables/CDRarityTableTable.h | 4 +- dDatabase/Tables/CDRebuildComponentTable.h | 4 +- dDatabase/Tables/CDRewardsTable.h | 5 +- dDatabase/Tables/CDScriptComponentTable.h | 4 +- dDatabase/Tables/CDSkillBehaviorTable.h | 4 +- dDatabase/Tables/CDTable.h | 6 - dDatabase/Tables/CDVendorComponentTable.h | 4 +- dDatabase/Tables/CDZoneTableTable.h | 4 +- dGame/dBehaviors/Behavior.h | 2 +- 50 files changed, 201 insertions(+), 367 deletions(-) delete mode 100644 dDatabase/CDClientManager.cpp delete mode 100644 dDatabase/CDClientManager.h diff --git a/dDatabase/CDClientManager.cpp b/dDatabase/CDClientManager.cpp deleted file mode 100644 index 9df6ff31..00000000 --- a/dDatabase/CDClientManager.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include "CDClientManager.h" -#include "CDActivityRewardsTable.h" -#include "CDAnimationsTable.h" -#include "CDBehaviorParameterTable.h" -#include "CDBehaviorTemplateTable.h" -#include "CDComponentsRegistryTable.h" -#include "CDCurrencyTableTable.h" -#include "CDDestructibleComponentTable.h" -#include "CDEmoteTable.h" -#include "CDInventoryComponentTable.h" -#include "CDItemComponentTable.h" -#include "CDItemSetsTable.h" -#include "CDItemSetSkillsTable.h" -#include "CDLevelProgressionLookupTable.h" -#include "CDLootMatrixTable.h" -#include "CDLootTableTable.h" -#include "CDMissionNPCComponentTable.h" -#include "CDMissionTasksTable.h" -#include "CDMissionsTable.h" -#include "CDObjectSkillsTable.h" -#include "CDObjectsTable.h" -#include "CDPhysicsComponentTable.h" -#include "CDRebuildComponentTable.h" -#include "CDScriptComponentTable.h" -#include "CDSkillBehaviorTable.h" -#include "CDZoneTableTable.h" -#include "CDVendorComponentTable.h" -#include "CDActivitiesTable.h" -#include "CDPackageComponentTable.h" -#include "CDProximityMonitorComponentTable.h" -#include "CDMovementAIComponentTable.h" -#include "CDBrickIDTableTable.h" -#include "CDRarityTableTable.h" -#include "CDMissionEmailTable.h" -#include "CDRewardsTable.h" -#include "CDPropertyEntranceComponentTable.h" -#include "CDPropertyTemplateTable.h" -#include "CDFeatureGatingTable.h" -#include "CDRailActivatorComponent.h" - -CDClientManager::CDClientManager() { - CDActivityRewardsTable::Instance(); - CDAnimationsTable::Instance(); - CDBehaviorParameterTable::Instance(); - CDBehaviorTemplateTable::Instance(); - CDComponentsRegistryTable::Instance(); - CDCurrencyTableTable::Instance(); - CDDestructibleComponentTable::Instance(); - CDEmoteTableTable::Instance(); - CDInventoryComponentTable::Instance(); - CDItemComponentTable::Instance(); - CDItemSetsTable::Instance(); - CDItemSetSkillsTable::Instance(); - CDLevelProgressionLookupTable::Instance(); - CDLootMatrixTable::Instance(); - CDLootTableTable::Instance(); - CDMissionNPCComponentTable::Instance(); - CDMissionTasksTable::Instance(); - CDMissionsTable::Instance(); - CDObjectSkillsTable::Instance(); - CDObjectsTable::Instance(); - CDPhysicsComponentTable::Instance(); - CDRebuildComponentTable::Instance(); - CDScriptComponentTable::Instance(); - CDSkillBehaviorTable::Instance(); - CDZoneTableTable::Instance(); - CDVendorComponentTable::Instance(); - CDActivitiesTable::Instance(); - CDPackageComponentTable::Instance(); - CDProximityMonitorComponentTable::Instance(); - CDMovementAIComponentTable::Instance(); - CDBrickIDTableTable::Instance(); - CDRarityTableTable::Instance(); - CDMissionEmailTable::Instance(); - CDRewardsTable::Instance(); - CDPropertyEntranceComponentTable::Instance(); - CDPropertyTemplateTable::Instance(); - CDFeatureGatingTable::Instance(); - CDRailActivatorComponentTable::Instance(); -} diff --git a/dDatabase/CDClientManager.h b/dDatabase/CDClientManager.h deleted file mode 100644 index 74069ff4..00000000 --- a/dDatabase/CDClientManager.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include "CDTable.h" - -#include "Singleton.h" - -#define UNUSED_TABLE(v) - -/** - * Initialize the CDClient tables so they are all loaded into memory. - */ -class CDClientManager : public Singleton { -public: - CDClientManager(); - - /** - * Fetch a table from CDClient - * - * @tparam Table type to fetch - * @return A pointer to the requested table. - */ - template - T* GetTable() { - return &T::Instance(); - } -}; diff --git a/dDatabase/CMakeLists.txt b/dDatabase/CMakeLists.txt index 9e55fbe2..59922914 100644 --- a/dDatabase/CMakeLists.txt +++ b/dDatabase/CMakeLists.txt @@ -1,5 +1,4 @@ set(DDATABASE_SOURCES "CDClientDatabase.cpp" - "CDClientManager.cpp" "Database.cpp" "MigrationRunner.cpp") diff --git a/dDatabase/Tables/CDActivitiesTable.cpp b/dDatabase/Tables/CDActivitiesTable.cpp index e1660d66..4d6c32d4 100644 --- a/dDatabase/Tables/CDActivitiesTable.cpp +++ b/dDatabase/Tables/CDActivitiesTable.cpp @@ -1,7 +1,10 @@ #include "CDActivitiesTable.h" -CDActivitiesTable::CDActivitiesTable(void) { +namespace { + std::vector entries; +}; +void CDActivitiesTable::LoadTableIntoMemory() { // First, get the size of the table unsigned int size = 0; auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Activities"); @@ -14,7 +17,7 @@ CDActivitiesTable::CDActivitiesTable(void) { tableSize.finalize(); // Reserve the size - this->entries.reserve(size); + entries.reserve(size); // Now get the data auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Activities"); @@ -40,7 +43,7 @@ CDActivitiesTable::CDActivitiesTable(void) { entry.noTeamLootOnDeath = tableData.getIntField("noTeamLootOnDeath", -1); entry.optionalPercentage = tableData.getFloatField("optionalPercentage", -1.0f); - this->entries.push_back(entry); + entries.push_back(entry); tableData.nextRow(); } @@ -49,14 +52,9 @@ CDActivitiesTable::CDActivitiesTable(void) { std::vector CDActivitiesTable::Query(std::function predicate) { - std::vector data = cpplinq::from(this->entries) + std::vector data = cpplinq::from(entries) >> cpplinq::where(predicate) >> cpplinq::to_vector(); return data; } - -std::vector CDActivitiesTable::GetEntries(void) const { - return this->entries; -} - diff --git a/dDatabase/Tables/CDActivitiesTable.h b/dDatabase/Tables/CDActivitiesTable.h index 4b60afbd..131e3880 100644 --- a/dDatabase/Tables/CDActivitiesTable.h +++ b/dDatabase/Tables/CDActivitiesTable.h @@ -25,14 +25,8 @@ struct CDActivities { float optionalPercentage; }; -class CDActivitiesTable : public CDTable { -private: - std::vector entries; - -public: - CDActivitiesTable(); +namespace CDActivitiesTable { + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - - std::vector GetEntries(void) const; }; diff --git a/dDatabase/Tables/CDActivityRewardsTable.cpp b/dDatabase/Tables/CDActivityRewardsTable.cpp index 65ef1101..9ada2fae 100644 --- a/dDatabase/Tables/CDActivityRewardsTable.cpp +++ b/dDatabase/Tables/CDActivityRewardsTable.cpp @@ -1,7 +1,10 @@ #include "CDActivityRewardsTable.h" -CDActivityRewardsTable::CDActivityRewardsTable(void) { +namespace { + std::vector entries; +}; +void CDActivityRewardsTable::LoadTableIntoMemory() { // First, get the size of the table unsigned int size = 0; auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ActivityRewards"); @@ -14,7 +17,7 @@ CDActivityRewardsTable::CDActivityRewardsTable(void) { tableSize.finalize(); // Reserve the size - this->entries.reserve(size); + entries.reserve(size); // Now get the data auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ActivityRewards"); @@ -28,7 +31,7 @@ CDActivityRewardsTable::CDActivityRewardsTable(void) { entry.ChallengeRating = tableData.getIntField("ChallengeRating", -1); entry.description = tableData.getStringField("description", ""); - this->entries.push_back(entry); + entries.push_back(entry); tableData.nextRow(); } @@ -37,14 +40,9 @@ CDActivityRewardsTable::CDActivityRewardsTable(void) { std::vector CDActivityRewardsTable::Query(std::function predicate) { - std::vector data = cpplinq::from(this->entries) + std::vector data = cpplinq::from(entries) >> cpplinq::where(predicate) >> cpplinq::to_vector(); return data; } - -std::vector CDActivityRewardsTable::GetEntries(void) const { - return this->entries; -} - diff --git a/dDatabase/Tables/CDActivityRewardsTable.h b/dDatabase/Tables/CDActivityRewardsTable.h index b5503fb6..217fb50d 100644 --- a/dDatabase/Tables/CDActivityRewardsTable.h +++ b/dDatabase/Tables/CDActivityRewardsTable.h @@ -13,15 +13,8 @@ struct CDActivityRewards { std::string description; //!< The description }; -class CDActivityRewardsTable : public CDTable { -private: - std::vector entries; - -public: - CDActivityRewardsTable(); +namespace CDActivityRewardsTable { + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - - std::vector GetEntries(void) const; - }; diff --git a/dDatabase/Tables/CDAnimationsTable.cpp b/dDatabase/Tables/CDAnimationsTable.cpp index 76ce0e5a..9145c47f 100644 --- a/dDatabase/Tables/CDAnimationsTable.cpp +++ b/dDatabase/Tables/CDAnimationsTable.cpp @@ -2,52 +2,66 @@ #include "GeneralUtils.h" #include "Game.h" -bool CDAnimationsTable::CacheData(CppSQLite3Statement& queryToCache) { - auto tableData = queryToCache.execQuery(); - // If we received a bad lookup, cache it anyways so we do not run the query again. - if (tableData.eof()) return false; - - do { - std::string animation_type = tableData.getStringField("animation_type", ""); - DluAssert(!animation_type.empty()); - AnimationGroupID animationGroupID = tableData.getIntField("animationGroupID", -1); - DluAssert(animationGroupID != -1); - - CDAnimation entry; - entry.animation_name = tableData.getStringField("animation_name", ""); - entry.chance_to_play = tableData.getFloatField("chance_to_play", 1.0f); - UNUSED_COLUMN(entry.min_loops = tableData.getIntField("min_loops", 0);) - UNUSED_COLUMN(entry.max_loops = tableData.getIntField("max_loops", 0);) - entry.animation_length = tableData.getFloatField("animation_length", 0.0f); - UNUSED_COLUMN(entry.hideEquip = tableData.getIntField("hideEquip", 0) == 1;) - UNUSED_COLUMN(entry.ignoreUpperBody = tableData.getIntField("ignoreUpperBody", 0) == 1;) - UNUSED_COLUMN(entry.restartable = tableData.getIntField("restartable", 0) == 1;) - UNUSED_COLUMN(entry.face_animation_name = tableData.getStringField("face_animation_name", "");) - UNUSED_COLUMN(entry.priority = tableData.getFloatField("priority", 0.0f);) - UNUSED_COLUMN(entry.blendTime = tableData.getFloatField("blendTime", 0.0f);) - - this->animations[CDAnimationKey(animation_type, animationGroupID)].push_back(entry); - tableData.nextRow(); - } while (!tableData.eof()); - - tableData.finalize(); - - return true; -} - -void CDAnimationsTable::CacheAnimations(const CDAnimationKey animationKey) { - auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM Animations WHERE animationGroupID = ? and animation_type = ?"); - query.bind(1, static_cast(animationKey.second)); - query.bind(2, animationKey.first.c_str()); - // If we received a bad lookup, cache it anyways so we do not run the query again. - if (!CacheData(query)) { - this->animations[animationKey]; +namespace { + /** + * Cache all animations given a premade key + */ + void CacheAnimations(const CDAnimationsTable::CDAnimationKey animationKey) { + auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM Animations WHERE animationGroupID = ? and animation_type = ?"); + query.bind(1, static_cast(animationKey.second)); + query.bind(2, animationKey.first.c_str()); + // If we received a bad lookup, cache it anyways so we do not run the query again. + if (!CacheData(query)) { + animations[animationKey]; + } } -} + + /** + * Run the query responsible for caching the data. + */ + bool CacheData(CppSQLite3Statement& queryToCache) { + auto tableData = queryToCache.execQuery(); + // If we received a bad lookup, cache it anyways so we do not run the query again. + if (tableData.eof()) return false; + + do { + std::string animation_type = tableData.getStringField("animation_type", ""); + DluAssert(!animation_type.empty()); + CDAnimationsTable::AnimationGroupID animationGroupID = tableData.getIntField("animationGroupID", -1); + DluAssert(animationGroupID != -1); + + CDAnimation entry; + entry.animation_name = tableData.getStringField("animation_name", ""); + entry.chance_to_play = tableData.getFloatField("chance_to_play", 1.0f); + UNUSED_COLUMN(entry.min_loops = tableData.getIntField("min_loops", 0);); + UNUSED_COLUMN(entry.max_loops = tableData.getIntField("max_loops", 0);); + entry.animation_length = tableData.getFloatField("animation_length", 0.0f); + UNUSED_COLUMN(entry.hideEquip = tableData.getIntField("hideEquip", 0) == 1;); + UNUSED_COLUMN(entry.ignoreUpperBody = tableData.getIntField("ignoreUpperBody", 0) == 1;); + UNUSED_COLUMN(entry.restartable = tableData.getIntField("restartable", 0) == 1;); + UNUSED_COLUMN(entry.face_animation_name = tableData.getStringField("face_animation_name", "");); + UNUSED_COLUMN(entry.priority = tableData.getFloatField("priority", 0.0f);); + UNUSED_COLUMN(entry.blendTime = tableData.getFloatField("blendTime", 0.0f);); + + animations[CDAnimationsTable::CDAnimationKey(animation_type, animationGroupID)].push_back(entry); + tableData.nextRow(); + } while (!tableData.eof()); + + tableData.finalize(); + + return true; + } + + /** + * Each animation is key'd by its animationName and its animationGroupID. Each + * animation has a possible list of animations. This is because there can be animations have a percent chance to play so one is selected at random. + */ + std::map> animations; +}; void CDAnimationsTable::CacheAnimationGroup(AnimationGroupID animationGroupID) { - auto animationEntryCached = this->animations.find(CDAnimationKey("", animationGroupID)); - if (animationEntryCached != this->animations.end()) { + auto animationEntryCached = animations.find(CDAnimationKey("", animationGroupID)); + if (animationEntryCached != animations.end()) { return; } @@ -56,17 +70,17 @@ void CDAnimationsTable::CacheAnimationGroup(AnimationGroupID animationGroupID) { // Cache the query so we don't run the query again. CacheData(query); - this->animations[CDAnimationKey("", animationGroupID)]; + animations[CDAnimationKey("", animationGroupID)]; } CDAnimationLookupResult CDAnimationsTable::GetAnimation(const AnimationID& animationType, const std::string& previousAnimationName, const AnimationGroupID animationGroupID) { CDAnimationKey animationKey(animationType, animationGroupID); - auto animationEntryCached = this->animations.find(animationKey); - if (animationEntryCached == this->animations.end()) { - this->CacheAnimations(animationKey); + auto animationEntryCached = animations.find(animationKey); + if (animationEntryCached == animations.end()) { + CacheAnimations(animationKey); } - auto animationEntry = this->animations.find(animationKey); + auto animationEntry = animations.find(animationKey); // If we have only one animation, return it regardless of the chance to play. if (animationEntry->second.size() == 1) { return CDAnimationLookupResult(animationEntry->second.front()); diff --git a/dDatabase/Tables/CDAnimationsTable.h b/dDatabase/Tables/CDAnimationsTable.h index 65f54d98..f2d0c249 100644 --- a/dDatabase/Tables/CDAnimationsTable.h +++ b/dDatabase/Tables/CDAnimationsTable.h @@ -22,11 +22,11 @@ struct CDAnimation { typedef LookupResult CDAnimationLookupResult; -class CDAnimationsTable : public CDTable { +namespace CDAnimationsTable { typedef int32_t AnimationGroupID; typedef std::string AnimationID; typedef std::pair CDAnimationKey; -public: + void LoadTableIntoMemory(); /** * Given an animationType and the previousAnimationName played, return the next animationType to play. * If there are more than 1 animationTypes that can be played, one is selected at random but also does not allow @@ -43,24 +43,4 @@ public: * Cache a full AnimationGroup by its ID. */ void CacheAnimationGroup(AnimationGroupID animationGroupID); -private: - - /** - * Cache all animations given a premade key - */ - void CacheAnimations(const CDAnimationKey animationKey); - - /** - * Run the query responsible for caching the data. - * @param queryToCache - * @return true - * @return false - */ - bool CacheData(CppSQLite3Statement& queryToCache); - - /** - * Each animation is key'd by its animationName and its animationGroupID. Each - * animation has a possible list of animations. This is because there can be animations have a percent chance to play so one is selected at random. - */ - std::map> animations; }; diff --git a/dDatabase/Tables/CDBehaviorParameterTable.cpp b/dDatabase/Tables/CDBehaviorParameterTable.cpp index 0713e740..24e79a53 100644 --- a/dDatabase/Tables/CDBehaviorParameterTable.cpp +++ b/dDatabase/Tables/CDBehaviorParameterTable.cpp @@ -1,7 +1,12 @@ #include "CDBehaviorParameterTable.h" #include "GeneralUtils.h" -CDBehaviorParameterTable::CDBehaviorParameterTable(void) { +namespace { + std::unordered_map m_Entries; + std::unordered_map m_ParametersList; +}; + +void CDBehaviorParameterTable::LoadTableIntoMemory() { auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BehaviorParameter"); uint32_t uniqueParameterId = 0; uint64_t hash = 0; @@ -28,8 +33,8 @@ CDBehaviorParameterTable::CDBehaviorParameterTable(void) { } float CDBehaviorParameterTable::GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue) { - auto parameterID = this->m_ParametersList.find(name); - if (parameterID == this->m_ParametersList.end()) return defaultValue; + auto parameterID = m_ParametersList.find(name); + if (parameterID == m_ParametersList.end()) return defaultValue; uint64_t hash = behaviorID; diff --git a/dDatabase/Tables/CDBehaviorParameterTable.h b/dDatabase/Tables/CDBehaviorParameterTable.h index b0715684..d37426d3 100644 --- a/dDatabase/Tables/CDBehaviorParameterTable.h +++ b/dDatabase/Tables/CDBehaviorParameterTable.h @@ -11,13 +11,9 @@ struct CDBehaviorParameter { float value; //!< The value of the behavior template }; -class CDBehaviorParameterTable : public CDTable { -private: - std::unordered_map m_Entries; - std::unordered_map m_ParametersList; -public: - CDBehaviorParameterTable(); - float GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue = 0); +namespace CDBehaviorParameterTable { + void LoadTableIntoMemory(); + float GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue = 0.0f); std::map GetParametersByBehaviorID(uint32_t behaviorID); }; diff --git a/dDatabase/Tables/CDBehaviorTemplateTable.cpp b/dDatabase/Tables/CDBehaviorTemplateTable.cpp index 08bc86d1..e1a3667a 100644 --- a/dDatabase/Tables/CDBehaviorTemplateTable.cpp +++ b/dDatabase/Tables/CDBehaviorTemplateTable.cpp @@ -1,6 +1,12 @@ #include "CDBehaviorTemplateTable.h" -CDBehaviorTemplateTable::CDBehaviorTemplateTable(void) { +namespace { + std::vector entries; + std::unordered_map entriesMappedByBehaviorID; + std::unordered_set m_EffectHandles; +}; + +void CDBehaviorTemplateTable::LoadTableIntoMemory() { // First, get the size of the table unsigned int size = 0; @@ -14,7 +20,7 @@ CDBehaviorTemplateTable::CDBehaviorTemplateTable(void) { tableSize.finalize(); // Reserve the size - this->entries.reserve(size); + entries.reserve(size); // Now get the data auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BehaviorTemplate"); @@ -31,8 +37,8 @@ CDBehaviorTemplateTable::CDBehaviorTemplateTable(void) { entry.effectHandle = m_EffectHandles.insert(candidateToAdd).first; } - this->entries.push_back(entry); - this->entriesMappedByBehaviorID.insert(std::make_pair(entry.behaviorID, entry)); + entries.push_back(entry); + entriesMappedByBehaviorID.insert(std::make_pair(entry.behaviorID, entry)); tableData.nextRow(); } @@ -41,20 +47,16 @@ CDBehaviorTemplateTable::CDBehaviorTemplateTable(void) { std::vector CDBehaviorTemplateTable::Query(std::function predicate) { - std::vector data = cpplinq::from(this->entries) + std::vector data = cpplinq::from(entries) >> cpplinq::where(predicate) >> cpplinq::to_vector(); return data; } -std::vector CDBehaviorTemplateTable::GetEntries(void) const { - return this->entries; -} - const CDBehaviorTemplate CDBehaviorTemplateTable::GetByBehaviorID(uint32_t behaviorID) { - auto entry = this->entriesMappedByBehaviorID.find(behaviorID); - if (entry == this->entriesMappedByBehaviorID.end()) { + auto entry = entriesMappedByBehaviorID.find(behaviorID); + if (entry == entriesMappedByBehaviorID.end()) { CDBehaviorTemplate entryToReturn; entryToReturn.behaviorID = 0; entryToReturn.effectHandle = m_EffectHandles.end(); diff --git a/dDatabase/Tables/CDBehaviorTemplateTable.h b/dDatabase/Tables/CDBehaviorTemplateTable.h index f9ac9a09..2b37f84f 100644 --- a/dDatabase/Tables/CDBehaviorTemplateTable.h +++ b/dDatabase/Tables/CDBehaviorTemplateTable.h @@ -6,24 +6,17 @@ #include struct CDBehaviorTemplate { - unsigned int behaviorID; //!< The Behavior ID - unsigned int templateID; //!< The Template ID (LOT) - unsigned int effectID; //!< The Effect ID attached - std::unordered_set::iterator effectHandle; //!< The effect handle + uint32_t behaviorID; //!< The Behavior ID + uint32_t templateID; //!< The Template ID (LOT) + uint32_t effectID; //!< The Effect ID attached + std::unordered_set::iterator effectHandle; //!< The effect handle }; -class CDBehaviorTemplateTable : public CDTable { -private: - std::vector entries; - std::unordered_map entriesMappedByBehaviorID; - std::unordered_set m_EffectHandles; -public: - CDBehaviorTemplateTable(); +namespace CDBehaviorTemplateTable { + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - std::vector GetEntries(void) const; - const CDBehaviorTemplate GetByBehaviorID(uint32_t behaviorID); }; diff --git a/dDatabase/Tables/CDBrickIDTableTable.cpp b/dDatabase/Tables/CDBrickIDTableTable.cpp index 9ad24d39..119ba252 100644 --- a/dDatabase/Tables/CDBrickIDTableTable.cpp +++ b/dDatabase/Tables/CDBrickIDTableTable.cpp @@ -1,6 +1,10 @@ #include "CDBrickIDTableTable.h" -CDBrickIDTableTable::CDBrickIDTableTable(void) { +namespace { + std::vector entries; +}; + +void CDBrickIDTableTable::LoadTableIntoMemory() { // First, get the size of the table unsigned int size = 0; @@ -14,7 +18,7 @@ CDBrickIDTableTable::CDBrickIDTableTable(void) { tableSize.finalize(); // Reserve the size - this->entries.reserve(size); + entries.reserve(size); // Now get the data auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BrickIDTable"); @@ -23,7 +27,7 @@ CDBrickIDTableTable::CDBrickIDTableTable(void) { entry.NDObjectID = tableData.getIntField("NDObjectID", -1); entry.LEGOBrickID = tableData.getIntField("LEGOBrickID", -1); - this->entries.push_back(entry); + entries.push_back(entry); tableData.nextRow(); } @@ -32,14 +36,9 @@ CDBrickIDTableTable::CDBrickIDTableTable(void) { std::vector CDBrickIDTableTable::Query(std::function predicate) { - std::vector data = cpplinq::from(this->entries) + std::vector data = cpplinq::from(entries) >> cpplinq::where(predicate) >> cpplinq::to_vector(); return data; } - -std::vector CDBrickIDTableTable::GetEntries(void) const { - return this->entries; -} - diff --git a/dDatabase/Tables/CDBrickIDTableTable.h b/dDatabase/Tables/CDBrickIDTableTable.h index e2084caf..430f8851 100644 --- a/dDatabase/Tables/CDBrickIDTableTable.h +++ b/dDatabase/Tables/CDBrickIDTableTable.h @@ -16,14 +16,8 @@ struct CDBrickIDTable { //! BrickIDTable table -class CDBrickIDTableTable : public CDTable { -private: - std::vector entries; - -public: - CDBrickIDTableTable(); +namespace CDBrickIDTableTable { + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - - std::vector GetEntries(void) const; }; diff --git a/dDatabase/Tables/CDComponentsRegistryTable.h b/dDatabase/Tables/CDComponentsRegistryTable.h index 990072c9..cc49e3cd 100644 --- a/dDatabase/Tables/CDComponentsRegistryTable.h +++ b/dDatabase/Tables/CDComponentsRegistryTable.h @@ -11,11 +11,9 @@ struct CDComponentsRegistry { }; -class CDComponentsRegistryTable : public CDTable { -private: +namespace CDComponentsRegistryTable { std::map mappedEntries; //id, component_type, component_id -public: - CDComponentsRegistryTable(); + void LoadTableIntoMemory(); int32_t GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue = 0); }; diff --git a/dDatabase/Tables/CDCurrencyTableTable.h b/dDatabase/Tables/CDCurrencyTableTable.h index ec700320..44567d15 100644 --- a/dDatabase/Tables/CDCurrencyTableTable.h +++ b/dDatabase/Tables/CDCurrencyTableTable.h @@ -18,12 +18,12 @@ struct CDCurrencyTable { }; //! CurrencyTable table -class CDCurrencyTableTable : public CDTable { +namespace CDCurrencyTableTable { private: std::vector entries; public: - CDCurrencyTableTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDDestructibleComponentTable.h b/dDatabase/Tables/CDDestructibleComponentTable.h index e42cf486..c7ea4202 100644 --- a/dDatabase/Tables/CDDestructibleComponentTable.h +++ b/dDatabase/Tables/CDDestructibleComponentTable.h @@ -20,12 +20,12 @@ struct CDDestructibleComponent { int difficultyLevel; //!< ??? }; -class CDDestructibleComponentTable : public CDTable { +namespace CDDestructibleComponentTable { private: std::vector entries; public: - CDDestructibleComponentTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDEmoteTable.cpp b/dDatabase/Tables/CDEmoteTable.cpp index aacbdd55..061b8936 100644 --- a/dDatabase/Tables/CDEmoteTable.cpp +++ b/dDatabase/Tables/CDEmoteTable.cpp @@ -1,40 +1,30 @@ #include "CDEmoteTable.h" -//! Constructor -CDEmoteTableTable::CDEmoteTableTable(void) { +namespace { + std::map entries; +}; + +void CDEmoteTableTable::LoadTableIntoMemory() { auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Emotes"); while (!tableData.eof()) { - CDEmoteTable* entry = new CDEmoteTable(); - entry->ID = tableData.getIntField("id", -1); - entry->animationName = tableData.getStringField("animationName", ""); - entry->iconFilename = tableData.getStringField("iconFilename", ""); - entry->channel = tableData.getIntField("channel", -1); - entry->locked = tableData.getIntField("locked", -1) != 0; - entry->localize = tableData.getIntField("localize", -1) != 0; - entry->locState = tableData.getIntField("locStatus", -1); - entry->gateVersion = tableData.getStringField("gate_version", ""); + CDEmoteTable entry; + entry.ID = tableData.getIntField("id", -1); + entry.animationName = tableData.getStringField("animationName", ""); + entry.iconFilename = tableData.getStringField("iconFilename", ""); + entry.channel = tableData.getIntField("channel", -1); + entry.locked = tableData.getIntField("locked", -1) != 0; + entry.localize = tableData.getIntField("localize", -1) != 0; + entry.locState = tableData.getIntField("locStatus", -1); + entry.gateVersion = tableData.getStringField("gate_version", ""); - entries.insert(std::make_pair(entry->ID, entry)); + entries.insert(std::make_pair(entry.ID, entry)); tableData.nextRow(); } tableData.finalize(); } -//! Destructor -CDEmoteTableTable::~CDEmoteTableTable(void) { - for (auto e : entries) { - if (e.second) delete e.second; - } - - entries.clear(); -} - CDEmoteTable* CDEmoteTableTable::GetEmote(int id) { - for (auto e : entries) { - if (e.first == id) return e.second; - } - - return nullptr; + return entries.find(id) != entries.end() ? &entries[id] : nullptr; } diff --git a/dDatabase/Tables/CDEmoteTable.h b/dDatabase/Tables/CDEmoteTable.h index be40c86f..4d9ca7e9 100644 --- a/dDatabase/Tables/CDEmoteTable.h +++ b/dDatabase/Tables/CDEmoteTable.h @@ -26,13 +26,8 @@ struct CDEmoteTable { std::string gateVersion; }; -class CDEmoteTableTable : public CDTable { -private: - std::map entries; - -public: - CDEmoteTableTable(); - ~CDEmoteTableTable(); +namespace CDEmoteTableTable { + void LoadTableIntoMemory(); // Returns an emote by ID CDEmoteTable* GetEmote(int id); }; diff --git a/dDatabase/Tables/CDFeatureGatingTable.h b/dDatabase/Tables/CDFeatureGatingTable.h index 7f536db5..a37df8e3 100644 --- a/dDatabase/Tables/CDFeatureGatingTable.h +++ b/dDatabase/Tables/CDFeatureGatingTable.h @@ -11,12 +11,12 @@ struct CDFeatureGating { std::string description; }; -class CDFeatureGatingTable : public CDTable { +namespace CDFeatureGatingTable { private: std::vector entries; public: - CDFeatureGatingTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDInventoryComponentTable.h b/dDatabase/Tables/CDInventoryComponentTable.h index cbc04d99..ce8ff0f8 100644 --- a/dDatabase/Tables/CDInventoryComponentTable.h +++ b/dDatabase/Tables/CDInventoryComponentTable.h @@ -10,12 +10,12 @@ struct CDInventoryComponent { bool equip; //!< Whether or not to equip the item }; -class CDInventoryComponentTable : public CDTable { +namespace CDInventoryComponentTable { private: std::vector entries; public: - CDInventoryComponentTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDItemComponentTable.h b/dDatabase/Tables/CDItemComponentTable.h index 11c34dd6..a1bdfebf 100644 --- a/dDatabase/Tables/CDItemComponentTable.h +++ b/dDatabase/Tables/CDItemComponentTable.h @@ -49,12 +49,12 @@ struct CDItemComponent { float SellMultiplier; //!< Something to do with early vendors perhaps (but replaced) }; -class CDItemComponentTable : public CDTable { +namespace CDItemComponentTable { private: std::map entries; public: - CDItemComponentTable(); + void LoadTableIntoMemory(); static std::map ParseCraftingCurrencies(const CDItemComponent& itemComponent); // Gets an entry by ID diff --git a/dDatabase/Tables/CDItemSetSkillsTable.h b/dDatabase/Tables/CDItemSetSkillsTable.h index 8328c66b..45cafc05 100644 --- a/dDatabase/Tables/CDItemSetSkillsTable.h +++ b/dDatabase/Tables/CDItemSetSkillsTable.h @@ -9,12 +9,12 @@ struct CDItemSetSkills { unsigned int SkillCastType; //!< The skill cast type }; -class CDItemSetSkillsTable : public CDTable { +namespace CDItemSetSkillsTable { private: std::vector entries; public: - CDItemSetSkillsTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDItemSetsTable.h b/dDatabase/Tables/CDItemSetsTable.h index 6756e7fa..1503f486 100644 --- a/dDatabase/Tables/CDItemSetsTable.h +++ b/dDatabase/Tables/CDItemSetsTable.h @@ -21,12 +21,12 @@ struct CDItemSets { float priority; //!< The priority }; -class CDItemSetsTable : public CDTable { +namespace CDItemSetsTable { private: std::vector entries; public: - CDItemSetsTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDLevelProgressionLookupTable.h b/dDatabase/Tables/CDLevelProgressionLookupTable.h index 070b2e0c..f7ccc299 100644 --- a/dDatabase/Tables/CDLevelProgressionLookupTable.h +++ b/dDatabase/Tables/CDLevelProgressionLookupTable.h @@ -9,12 +9,12 @@ struct CDLevelProgressionLookup { std::string BehaviorEffect; //!< The behavior effect attached to this }; -class CDLevelProgressionLookupTable : public CDTable { +namespace CDLevelProgressionLookupTable { private: std::vector entries; public: - CDLevelProgressionLookupTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDLootMatrixTable.h b/dDatabase/Tables/CDLootMatrixTable.h index c6035841..dd975e2c 100644 --- a/dDatabase/Tables/CDLootMatrixTable.h +++ b/dDatabase/Tables/CDLootMatrixTable.h @@ -15,12 +15,12 @@ struct CDLootMatrix { UNUSED(std::string gate_version); //!< The Gate Version }; -class CDLootMatrixTable : public CDTable { +namespace CDLootMatrixTable { private: std::vector entries; public: - CDLootMatrixTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDLootTableTable.h b/dDatabase/Tables/CDLootTableTable.h index ba6f207e..d5dd791c 100644 --- a/dDatabase/Tables/CDLootTableTable.h +++ b/dDatabase/Tables/CDLootTableTable.h @@ -11,12 +11,12 @@ struct CDLootTable { unsigned int sortPriority; //!< The sorting priority }; -class CDLootTableTable : public CDTable { +namespace CDLootTableTable { private: std::vector entries; public: - CDLootTableTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDMissionEmailTable.h b/dDatabase/Tables/CDMissionEmailTable.h index db2310d4..a1d66bf6 100644 --- a/dDatabase/Tables/CDMissionEmailTable.h +++ b/dDatabase/Tables/CDMissionEmailTable.h @@ -15,12 +15,12 @@ struct CDMissionEmail { }; -class CDMissionEmailTable : public CDTable { +namespace CDMissionEmailTable { private: std::vector entries; public: - CDMissionEmailTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDMissionNPCComponentTable.h b/dDatabase/Tables/CDMissionNPCComponentTable.h index a7aeb145..d7574570 100644 --- a/dDatabase/Tables/CDMissionNPCComponentTable.h +++ b/dDatabase/Tables/CDMissionNPCComponentTable.h @@ -11,12 +11,12 @@ struct CDMissionNPCComponent { std::string gate_version; //!< The gate version }; -class CDMissionNPCComponentTable : public CDTable { +namespace CDMissionNPCComponentTable { private: std::vector entries; public: - CDMissionNPCComponentTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDMissionTasksTable.h b/dDatabase/Tables/CDMissionTasksTable.h index fa213faf..1cecf45f 100644 --- a/dDatabase/Tables/CDMissionTasksTable.h +++ b/dDatabase/Tables/CDMissionTasksTable.h @@ -19,12 +19,12 @@ struct CDMissionTasks { UNUSED(std::string gate_version); //!< ??? }; -class CDMissionTasksTable : public CDTable { +namespace CDMissionTasksTable { private: std::vector entries; public: - CDMissionTasksTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDMissionsTable.h b/dDatabase/Tables/CDMissionsTable.h index e6a44b02..2259720c 100644 --- a/dDatabase/Tables/CDMissionsTable.h +++ b/dDatabase/Tables/CDMissionsTable.h @@ -60,12 +60,12 @@ struct CDMissions { int reward_bankinventory; //!< The amount of bank space this mission rewards }; -class CDMissionsTable : public CDTable { +namespace CDMissionsTable { private: std::vector entries; public: - CDMissionsTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDMovementAIComponentTable.h b/dDatabase/Tables/CDMovementAIComponentTable.h index 84896e2c..ae096adf 100644 --- a/dDatabase/Tables/CDMovementAIComponentTable.h +++ b/dDatabase/Tables/CDMovementAIComponentTable.h @@ -14,12 +14,12 @@ struct CDMovementAIComponent { std::string attachedPath; }; -class CDMovementAIComponentTable : public CDTable { +namespace CDMovementAIComponentTable { private: std::vector entries; public: - CDMovementAIComponentTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDObjectSkillsTable.h b/dDatabase/Tables/CDObjectSkillsTable.h index 4ceaa447..fb3ba1f6 100644 --- a/dDatabase/Tables/CDObjectSkillsTable.h +++ b/dDatabase/Tables/CDObjectSkillsTable.h @@ -10,12 +10,12 @@ struct CDObjectSkills { unsigned int AICombatWeight; //!< ??? }; -class CDObjectSkillsTable : public CDTable { +namespace CDObjectSkillsTable { private: std::vector entries; public: - CDObjectSkillsTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDObjectsTable.h b/dDatabase/Tables/CDObjectsTable.h index 171eddef..6737d509 100644 --- a/dDatabase/Tables/CDObjectsTable.h +++ b/dDatabase/Tables/CDObjectsTable.h @@ -20,13 +20,13 @@ struct CDObjects { UNUSED(unsigned int HQ_valid); //!< Probably used for the Nexus HQ database on LEGOUniverse.com }; -class CDObjectsTable : public CDTable { +namespace CDObjectsTable { private: std::map entries; CDObjects m_default; public: - CDObjectsTable(); + void LoadTableIntoMemory(); // Gets an entry by ID const CDObjects& GetByID(unsigned int LOT); }; diff --git a/dDatabase/Tables/CDPackageComponentTable.h b/dDatabase/Tables/CDPackageComponentTable.h index 6c11ab39..cab28c91 100644 --- a/dDatabase/Tables/CDPackageComponentTable.h +++ b/dDatabase/Tables/CDPackageComponentTable.h @@ -9,7 +9,7 @@ struct CDPackageComponent { unsigned int packageType; }; -class CDPackageComponentTable : public CDTable { +namespace CDPackageComponentTable { private: std::vector entries; diff --git a/dDatabase/Tables/CDPhysicsComponentTable.h b/dDatabase/Tables/CDPhysicsComponentTable.h index e63d337d..1946a550 100644 --- a/dDatabase/Tables/CDPhysicsComponentTable.h +++ b/dDatabase/Tables/CDPhysicsComponentTable.h @@ -21,10 +21,9 @@ struct CDPhysicsComponent { UNUSED(std::string gravityVolumeAsset); }; -class CDPhysicsComponentTable : public CDTable { +namespace CDPhysicsComponentTable { public: - CDPhysicsComponentTable(); - ~CDPhysicsComponentTable(); + void LoadTableIntoMemory(); static const std::string GetTableName() { return "PhysicsComponent"; }; CDPhysicsComponent* GetByID(unsigned int componentID); diff --git a/dDatabase/Tables/CDPropertyEntranceComponentTable.h b/dDatabase/Tables/CDPropertyEntranceComponentTable.h index 925fd1be..3a36f06a 100644 --- a/dDatabase/Tables/CDPropertyEntranceComponentTable.h +++ b/dDatabase/Tables/CDPropertyEntranceComponentTable.h @@ -9,9 +9,9 @@ struct CDPropertyEntranceComponent { std::string groupType; }; -class CDPropertyEntranceComponentTable : public CDTable { +namespace CDPropertyEntranceComponentTable { public: - CDPropertyEntranceComponentTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause CDPropertyEntranceComponent GetByID(uint32_t id); diff --git a/dDatabase/Tables/CDPropertyTemplateTable.h b/dDatabase/Tables/CDPropertyTemplateTable.h index cb075dbf..d447a8bc 100644 --- a/dDatabase/Tables/CDPropertyTemplateTable.h +++ b/dDatabase/Tables/CDPropertyTemplateTable.h @@ -8,9 +8,9 @@ struct CDPropertyTemplate { std::string spawnName; }; -class CDPropertyTemplateTable : public CDTable { +namespace CDPropertyTemplateTable { public: - CDPropertyTemplateTable(); + void LoadTableIntoMemory(); static const std::string GetTableName() { return "PropertyTemplate"; }; CDPropertyTemplate GetByMapID(uint32_t mapID); diff --git a/dDatabase/Tables/CDProximityMonitorComponentTable.h b/dDatabase/Tables/CDProximityMonitorComponentTable.h index 38b7d43b..950e1fc2 100644 --- a/dDatabase/Tables/CDProximityMonitorComponentTable.h +++ b/dDatabase/Tables/CDProximityMonitorComponentTable.h @@ -10,7 +10,7 @@ struct CDProximityMonitorComponent { bool LoadOnServer; }; -class CDProximityMonitorComponentTable : public CDTable { +namespace CDProximityMonitorComponentTable { private: std::vector entries; diff --git a/dDatabase/Tables/CDRailActivatorComponent.h b/dDatabase/Tables/CDRailActivatorComponent.h index 03dd0525..fb2ce89e 100644 --- a/dDatabase/Tables/CDRailActivatorComponent.h +++ b/dDatabase/Tables/CDRailActivatorComponent.h @@ -20,9 +20,9 @@ struct CDRailActivatorComponent { bool showNameBillboard; }; -class CDRailActivatorComponentTable : public CDTable { +namespace CDRailActivatorComponentTable { public: - CDRailActivatorComponentTable(); + void LoadTableIntoMemory(); static const std::string GetTableName() { return "RailActivatorComponent"; }; [[nodiscard]] CDRailActivatorComponent GetEntryByID(int32_t id) const; [[nodiscard]] std::vector GetEntries() const; diff --git a/dDatabase/Tables/CDRarityTableTable.h b/dDatabase/Tables/CDRarityTableTable.h index 592346ed..80fa69fa 100644 --- a/dDatabase/Tables/CDRarityTableTable.h +++ b/dDatabase/Tables/CDRarityTableTable.h @@ -26,12 +26,12 @@ struct CDRarityTable { } }; -class CDRarityTableTable : public CDTable { +namespace CDRarityTableTable { private: std::vector entries; public: - CDRarityTableTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDRebuildComponentTable.h b/dDatabase/Tables/CDRebuildComponentTable.h index db70a47d..05799d7c 100644 --- a/dDatabase/Tables/CDRebuildComponentTable.h +++ b/dDatabase/Tables/CDRebuildComponentTable.h @@ -16,12 +16,12 @@ struct CDRebuildComponent { float time_before_smash; //!< The time before smash }; -class CDRebuildComponentTable : public CDTable { +namespace CDRebuildComponentTable { private: std::vector entries; public: - CDRebuildComponentTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDRewardsTable.h b/dDatabase/Tables/CDRewardsTable.h index 2e079a83..c417f886 100644 --- a/dDatabase/Tables/CDRewardsTable.h +++ b/dDatabase/Tables/CDRewardsTable.h @@ -11,10 +11,9 @@ struct CDRewards { int32_t count; }; -class CDRewardsTable : public CDTable { +namespace CDRewardsTable { public: - CDRewardsTable(); - ~CDRewardsTable(); + void LoadTableIntoMemory(); static const std::string GetTableName() { return "Rewards"; }; std::vector GetByLevelID(uint32_t levelID); diff --git a/dDatabase/Tables/CDScriptComponentTable.h b/dDatabase/Tables/CDScriptComponentTable.h index 77453939..a8de53d6 100644 --- a/dDatabase/Tables/CDScriptComponentTable.h +++ b/dDatabase/Tables/CDScriptComponentTable.h @@ -9,13 +9,13 @@ struct CDScriptComponent { std::string client_script_name; //!< The client script name }; -class CDScriptComponentTable : public CDTable { +namespace CDScriptComponentTable { private: std::map entries; CDScriptComponent m_ToReturnWhenNoneFound; public: - CDScriptComponentTable(); + void LoadTableIntoMemory(); // Gets an entry by scriptID const CDScriptComponent& GetByID(unsigned int id); }; diff --git a/dDatabase/Tables/CDSkillBehaviorTable.h b/dDatabase/Tables/CDSkillBehaviorTable.h index eb3094e0..9b48d178 100644 --- a/dDatabase/Tables/CDSkillBehaviorTable.h +++ b/dDatabase/Tables/CDSkillBehaviorTable.h @@ -25,13 +25,13 @@ struct CDSkillBehavior { UNUSED(unsigned int cancelType); //!< The cancel type (?) }; -class CDSkillBehaviorTable : public CDTable { +namespace CDSkillBehaviorTable { private: std::map entries; CDSkillBehavior m_empty; public: - CDSkillBehaviorTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDTable.h b/dDatabase/Tables/CDTable.h index e4c11fb9..0d689cd5 100644 --- a/dDatabase/Tables/CDTable.h +++ b/dDatabase/Tables/CDTable.h @@ -25,12 +25,6 @@ #pragma warning (disable : 4244) //Disable double to float conversion warnings #pragma warning (disable : 4715) //Disable "not all control paths return a value" -template -class CDTable : public Singleton { -protected: - virtual ~CDTable() = default; -}; - template class LookupResult { typedef std::pair DataType; diff --git a/dDatabase/Tables/CDVendorComponentTable.h b/dDatabase/Tables/CDVendorComponentTable.h index f2666d7e..c0c4a79c 100644 --- a/dDatabase/Tables/CDVendorComponentTable.h +++ b/dDatabase/Tables/CDVendorComponentTable.h @@ -11,12 +11,12 @@ struct CDVendorComponent { unsigned int LootMatrixIndex; //!< LootMatrixIndex of the vendor's items }; -class CDVendorComponentTable : public CDTable { +namespace CDVendorComponentTable { private: std::vector entries; public: - CDVendorComponentTable(); + void LoadTableIntoMemory(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDZoneTableTable.h b/dDatabase/Tables/CDZoneTableTable.h index f844fd25..37e18568 100644 --- a/dDatabase/Tables/CDZoneTableTable.h +++ b/dDatabase/Tables/CDZoneTableTable.h @@ -33,12 +33,12 @@ struct CDZoneTable { UNUSED(bool mountsAllowed); //!< Whether or not mounts are allowed }; -class CDZoneTableTable : public CDTable { +namespace CDZoneTableTable { private: std::map m_Entries; public: - CDZoneTableTable(); + void LoadTableIntoMemory(); // Queries the table with a zoneID to find. const CDZoneTable* Query(unsigned int zoneID); diff --git a/dGame/dBehaviors/Behavior.h b/dGame/dBehaviors/Behavior.h index ca1c23e5..a2891a34 100644 --- a/dGame/dBehaviors/Behavior.h +++ b/dGame/dBehaviors/Behavior.h @@ -11,7 +11,7 @@ struct BehaviorContext; struct BehaviorBranchContext; -class CDBehaviorParameterTable; +namespace CDBehaviorParameterTable; { class Behavior {