This commit is contained in:
David Markowitz 2023-07-16 00:27:30 -07:00
parent 455f9470a5
commit 79094b6664
50 changed files with 201 additions and 367 deletions

View File

@ -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();
}

View File

@ -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<CDClientManager> {
public:
CDClientManager();
/**
* Fetch a table from CDClient
*
* @tparam Table type to fetch
* @return A pointer to the requested table.
*/
template<typename T>
T* GetTable() {
return &T::Instance();
}
};

View File

@ -1,5 +1,4 @@
set(DDATABASE_SOURCES "CDClientDatabase.cpp" set(DDATABASE_SOURCES "CDClientDatabase.cpp"
"CDClientManager.cpp"
"Database.cpp" "Database.cpp"
"MigrationRunner.cpp") "MigrationRunner.cpp")

View File

@ -1,7 +1,10 @@
#include "CDActivitiesTable.h" #include "CDActivitiesTable.h"
CDActivitiesTable::CDActivitiesTable(void) { namespace {
std::vector<CDActivities> entries;
};
void CDActivitiesTable::LoadTableIntoMemory() {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Activities"); auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Activities");
@ -14,7 +17,7 @@ CDActivitiesTable::CDActivitiesTable(void) {
tableSize.finalize(); tableSize.finalize();
// Reserve the size // Reserve the size
this->entries.reserve(size); entries.reserve(size);
// Now get the data // Now get the data
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Activities"); auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Activities");
@ -40,7 +43,7 @@ CDActivitiesTable::CDActivitiesTable(void) {
entry.noTeamLootOnDeath = tableData.getIntField("noTeamLootOnDeath", -1); entry.noTeamLootOnDeath = tableData.getIntField("noTeamLootOnDeath", -1);
entry.optionalPercentage = tableData.getFloatField("optionalPercentage", -1.0f); entry.optionalPercentage = tableData.getFloatField("optionalPercentage", -1.0f);
this->entries.push_back(entry); entries.push_back(entry);
tableData.nextRow(); tableData.nextRow();
} }
@ -49,14 +52,9 @@ CDActivitiesTable::CDActivitiesTable(void) {
std::vector<CDActivities> CDActivitiesTable::Query(std::function<bool(CDActivities)> predicate) { std::vector<CDActivities> CDActivitiesTable::Query(std::function<bool(CDActivities)> predicate) {
std::vector<CDActivities> data = cpplinq::from(this->entries) std::vector<CDActivities> data = cpplinq::from(entries)
>> cpplinq::where(predicate) >> cpplinq::where(predicate)
>> cpplinq::to_vector(); >> cpplinq::to_vector();
return data; return data;
} }
std::vector<CDActivities> CDActivitiesTable::GetEntries(void) const {
return this->entries;
}

View File

@ -25,14 +25,8 @@ struct CDActivities {
float optionalPercentage; float optionalPercentage;
}; };
class CDActivitiesTable : public CDTable<CDActivitiesTable> { namespace CDActivitiesTable {
private: void LoadTableIntoMemory();
std::vector<CDActivities> entries;
public:
CDActivitiesTable();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDActivities> Query(std::function<bool(CDActivities)> predicate); std::vector<CDActivities> Query(std::function<bool(CDActivities)> predicate);
std::vector<CDActivities> GetEntries(void) const;
}; };

View File

@ -1,7 +1,10 @@
#include "CDActivityRewardsTable.h" #include "CDActivityRewardsTable.h"
CDActivityRewardsTable::CDActivityRewardsTable(void) { namespace {
std::vector<CDActivityRewards> entries;
};
void CDActivityRewardsTable::LoadTableIntoMemory() {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ActivityRewards"); auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ActivityRewards");
@ -14,7 +17,7 @@ CDActivityRewardsTable::CDActivityRewardsTable(void) {
tableSize.finalize(); tableSize.finalize();
// Reserve the size // Reserve the size
this->entries.reserve(size); entries.reserve(size);
// Now get the data // Now get the data
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ActivityRewards"); auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ActivityRewards");
@ -28,7 +31,7 @@ CDActivityRewardsTable::CDActivityRewardsTable(void) {
entry.ChallengeRating = tableData.getIntField("ChallengeRating", -1); entry.ChallengeRating = tableData.getIntField("ChallengeRating", -1);
entry.description = tableData.getStringField("description", ""); entry.description = tableData.getStringField("description", "");
this->entries.push_back(entry); entries.push_back(entry);
tableData.nextRow(); tableData.nextRow();
} }
@ -37,14 +40,9 @@ CDActivityRewardsTable::CDActivityRewardsTable(void) {
std::vector<CDActivityRewards> CDActivityRewardsTable::Query(std::function<bool(CDActivityRewards)> predicate) { std::vector<CDActivityRewards> CDActivityRewardsTable::Query(std::function<bool(CDActivityRewards)> predicate) {
std::vector<CDActivityRewards> data = cpplinq::from(this->entries) std::vector<CDActivityRewards> data = cpplinq::from(entries)
>> cpplinq::where(predicate) >> cpplinq::where(predicate)
>> cpplinq::to_vector(); >> cpplinq::to_vector();
return data; return data;
} }
std::vector<CDActivityRewards> CDActivityRewardsTable::GetEntries(void) const {
return this->entries;
}

View File

@ -13,15 +13,8 @@ struct CDActivityRewards {
std::string description; //!< The description std::string description; //!< The description
}; };
class CDActivityRewardsTable : public CDTable<CDActivityRewardsTable> { namespace CDActivityRewardsTable {
private: void LoadTableIntoMemory();
std::vector<CDActivityRewards> entries;
public:
CDActivityRewardsTable();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDActivityRewards> Query(std::function<bool(CDActivityRewards)> predicate); std::vector<CDActivityRewards> Query(std::function<bool(CDActivityRewards)> predicate);
std::vector<CDActivityRewards> GetEntries(void) const;
}; };

View File

@ -2,52 +2,66 @@
#include "GeneralUtils.h" #include "GeneralUtils.h"
#include "Game.h" #include "Game.h"
bool CDAnimationsTable::CacheData(CppSQLite3Statement& queryToCache) { namespace {
auto tableData = queryToCache.execQuery(); /**
// If we received a bad lookup, cache it anyways so we do not run the query again. * Cache all animations given a premade key
if (tableData.eof()) return false; */
void CacheAnimations(const CDAnimationsTable::CDAnimationKey animationKey) {
do { auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM Animations WHERE animationGroupID = ? and animation_type = ?");
std::string animation_type = tableData.getStringField("animation_type", ""); query.bind(1, static_cast<int32_t>(animationKey.second));
DluAssert(!animation_type.empty()); query.bind(2, animationKey.first.c_str());
AnimationGroupID animationGroupID = tableData.getIntField("animationGroupID", -1); // If we received a bad lookup, cache it anyways so we do not run the query again.
DluAssert(animationGroupID != -1); if (!CacheData(query)) {
animations[animationKey];
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<int32_t>(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];
} }
}
/**
* 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<CDAnimationsTable::CDAnimationKey, std::list<CDAnimation>> animations;
};
void CDAnimationsTable::CacheAnimationGroup(AnimationGroupID animationGroupID) { void CDAnimationsTable::CacheAnimationGroup(AnimationGroupID animationGroupID) {
auto animationEntryCached = this->animations.find(CDAnimationKey("", animationGroupID)); auto animationEntryCached = animations.find(CDAnimationKey("", animationGroupID));
if (animationEntryCached != this->animations.end()) { if (animationEntryCached != animations.end()) {
return; return;
} }
@ -56,17 +70,17 @@ void CDAnimationsTable::CacheAnimationGroup(AnimationGroupID animationGroupID) {
// Cache the query so we don't run the query again. // Cache the query so we don't run the query again.
CacheData(query); CacheData(query);
this->animations[CDAnimationKey("", animationGroupID)]; animations[CDAnimationKey("", animationGroupID)];
} }
CDAnimationLookupResult CDAnimationsTable::GetAnimation(const AnimationID& animationType, const std::string& previousAnimationName, const AnimationGroupID animationGroupID) { CDAnimationLookupResult CDAnimationsTable::GetAnimation(const AnimationID& animationType, const std::string& previousAnimationName, const AnimationGroupID animationGroupID) {
CDAnimationKey animationKey(animationType, animationGroupID); CDAnimationKey animationKey(animationType, animationGroupID);
auto animationEntryCached = this->animations.find(animationKey); auto animationEntryCached = animations.find(animationKey);
if (animationEntryCached == this->animations.end()) { if (animationEntryCached == animations.end()) {
this->CacheAnimations(animationKey); 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 we have only one animation, return it regardless of the chance to play.
if (animationEntry->second.size() == 1) { if (animationEntry->second.size() == 1) {
return CDAnimationLookupResult(animationEntry->second.front()); return CDAnimationLookupResult(animationEntry->second.front());

View File

@ -22,11 +22,11 @@ struct CDAnimation {
typedef LookupResult<CDAnimation> CDAnimationLookupResult; typedef LookupResult<CDAnimation> CDAnimationLookupResult;
class CDAnimationsTable : public CDTable<CDAnimationsTable> { namespace CDAnimationsTable {
typedef int32_t AnimationGroupID; typedef int32_t AnimationGroupID;
typedef std::string AnimationID; typedef std::string AnimationID;
typedef std::pair<std::string, AnimationGroupID> CDAnimationKey; typedef std::pair<std::string, AnimationGroupID> CDAnimationKey;
public: void LoadTableIntoMemory();
/** /**
* Given an animationType and the previousAnimationName played, return the next animationType to play. * 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 * 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. * Cache a full AnimationGroup by its ID.
*/ */
void CacheAnimationGroup(AnimationGroupID animationGroupID); 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<CDAnimationKey, std::list<CDAnimation>> animations;
}; };

View File

@ -1,7 +1,12 @@
#include "CDBehaviorParameterTable.h" #include "CDBehaviorParameterTable.h"
#include "GeneralUtils.h" #include "GeneralUtils.h"
CDBehaviorParameterTable::CDBehaviorParameterTable(void) { namespace {
std::unordered_map<uint64_t, CDBehaviorParameter> m_Entries;
std::unordered_map<std::string, uint32_t> m_ParametersList;
};
void CDBehaviorParameterTable::LoadTableIntoMemory() {
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BehaviorParameter"); auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BehaviorParameter");
uint32_t uniqueParameterId = 0; uint32_t uniqueParameterId = 0;
uint64_t hash = 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) { float CDBehaviorParameterTable::GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue) {
auto parameterID = this->m_ParametersList.find(name); auto parameterID = m_ParametersList.find(name);
if (parameterID == this->m_ParametersList.end()) return defaultValue; if (parameterID == m_ParametersList.end()) return defaultValue;
uint64_t hash = behaviorID; uint64_t hash = behaviorID;

View File

@ -11,13 +11,9 @@ struct CDBehaviorParameter {
float value; //!< The value of the behavior template float value; //!< The value of the behavior template
}; };
class CDBehaviorParameterTable : public CDTable<CDBehaviorParameterTable> { namespace CDBehaviorParameterTable {
private: void LoadTableIntoMemory();
std::unordered_map<uint64_t, CDBehaviorParameter> m_Entries; float GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue = 0.0f);
std::unordered_map<std::string, uint32_t> m_ParametersList;
public:
CDBehaviorParameterTable();
float GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue = 0);
std::map<std::string, float> GetParametersByBehaviorID(uint32_t behaviorID); std::map<std::string, float> GetParametersByBehaviorID(uint32_t behaviorID);
}; };

View File

@ -1,6 +1,12 @@
#include "CDBehaviorTemplateTable.h" #include "CDBehaviorTemplateTable.h"
CDBehaviorTemplateTable::CDBehaviorTemplateTable(void) { namespace {
std::vector<CDBehaviorTemplate> entries;
std::unordered_map<uint32_t, CDBehaviorTemplate> entriesMappedByBehaviorID;
std::unordered_set<std::string> m_EffectHandles;
};
void CDBehaviorTemplateTable::LoadTableIntoMemory() {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -14,7 +20,7 @@ CDBehaviorTemplateTable::CDBehaviorTemplateTable(void) {
tableSize.finalize(); tableSize.finalize();
// Reserve the size // Reserve the size
this->entries.reserve(size); entries.reserve(size);
// Now get the data // Now get the data
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BehaviorTemplate"); auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BehaviorTemplate");
@ -31,8 +37,8 @@ CDBehaviorTemplateTable::CDBehaviorTemplateTable(void) {
entry.effectHandle = m_EffectHandles.insert(candidateToAdd).first; entry.effectHandle = m_EffectHandles.insert(candidateToAdd).first;
} }
this->entries.push_back(entry); entries.push_back(entry);
this->entriesMappedByBehaviorID.insert(std::make_pair(entry.behaviorID, entry)); entriesMappedByBehaviorID.insert(std::make_pair(entry.behaviorID, entry));
tableData.nextRow(); tableData.nextRow();
} }
@ -41,20 +47,16 @@ CDBehaviorTemplateTable::CDBehaviorTemplateTable(void) {
std::vector<CDBehaviorTemplate> CDBehaviorTemplateTable::Query(std::function<bool(CDBehaviorTemplate)> predicate) { std::vector<CDBehaviorTemplate> CDBehaviorTemplateTable::Query(std::function<bool(CDBehaviorTemplate)> predicate) {
std::vector<CDBehaviorTemplate> data = cpplinq::from(this->entries) std::vector<CDBehaviorTemplate> data = cpplinq::from(entries)
>> cpplinq::where(predicate) >> cpplinq::where(predicate)
>> cpplinq::to_vector(); >> cpplinq::to_vector();
return data; return data;
} }
std::vector<CDBehaviorTemplate> CDBehaviorTemplateTable::GetEntries(void) const {
return this->entries;
}
const CDBehaviorTemplate CDBehaviorTemplateTable::GetByBehaviorID(uint32_t behaviorID) { const CDBehaviorTemplate CDBehaviorTemplateTable::GetByBehaviorID(uint32_t behaviorID) {
auto entry = this->entriesMappedByBehaviorID.find(behaviorID); auto entry = entriesMappedByBehaviorID.find(behaviorID);
if (entry == this->entriesMappedByBehaviorID.end()) { if (entry == entriesMappedByBehaviorID.end()) {
CDBehaviorTemplate entryToReturn; CDBehaviorTemplate entryToReturn;
entryToReturn.behaviorID = 0; entryToReturn.behaviorID = 0;
entryToReturn.effectHandle = m_EffectHandles.end(); entryToReturn.effectHandle = m_EffectHandles.end();

View File

@ -6,24 +6,17 @@
#include <unordered_set> #include <unordered_set>
struct CDBehaviorTemplate { struct CDBehaviorTemplate {
unsigned int behaviorID; //!< The Behavior ID uint32_t behaviorID; //!< The Behavior ID
unsigned int templateID; //!< The Template ID (LOT) uint32_t templateID; //!< The Template ID (LOT)
unsigned int effectID; //!< The Effect ID attached uint32_t effectID; //!< The Effect ID attached
std::unordered_set<std::string>::iterator effectHandle; //!< The effect handle std::unordered_set<std::string>::iterator effectHandle; //!< The effect handle
}; };
class CDBehaviorTemplateTable : public CDTable<CDBehaviorTemplateTable> { namespace CDBehaviorTemplateTable {
private: void LoadTableIntoMemory();
std::vector<CDBehaviorTemplate> entries;
std::unordered_map<uint32_t, CDBehaviorTemplate> entriesMappedByBehaviorID;
std::unordered_set<std::string> m_EffectHandles;
public:
CDBehaviorTemplateTable();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDBehaviorTemplate> Query(std::function<bool(CDBehaviorTemplate)> predicate); std::vector<CDBehaviorTemplate> Query(std::function<bool(CDBehaviorTemplate)> predicate);
std::vector<CDBehaviorTemplate> GetEntries(void) const;
const CDBehaviorTemplate GetByBehaviorID(uint32_t behaviorID); const CDBehaviorTemplate GetByBehaviorID(uint32_t behaviorID);
}; };

View File

@ -1,6 +1,10 @@
#include "CDBrickIDTableTable.h" #include "CDBrickIDTableTable.h"
CDBrickIDTableTable::CDBrickIDTableTable(void) { namespace {
std::vector<CDBrickIDTable> entries;
};
void CDBrickIDTableTable::LoadTableIntoMemory() {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -14,7 +18,7 @@ CDBrickIDTableTable::CDBrickIDTableTable(void) {
tableSize.finalize(); tableSize.finalize();
// Reserve the size // Reserve the size
this->entries.reserve(size); entries.reserve(size);
// Now get the data // Now get the data
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BrickIDTable"); auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BrickIDTable");
@ -23,7 +27,7 @@ CDBrickIDTableTable::CDBrickIDTableTable(void) {
entry.NDObjectID = tableData.getIntField("NDObjectID", -1); entry.NDObjectID = tableData.getIntField("NDObjectID", -1);
entry.LEGOBrickID = tableData.getIntField("LEGOBrickID", -1); entry.LEGOBrickID = tableData.getIntField("LEGOBrickID", -1);
this->entries.push_back(entry); entries.push_back(entry);
tableData.nextRow(); tableData.nextRow();
} }
@ -32,14 +36,9 @@ CDBrickIDTableTable::CDBrickIDTableTable(void) {
std::vector<CDBrickIDTable> CDBrickIDTableTable::Query(std::function<bool(CDBrickIDTable)> predicate) { std::vector<CDBrickIDTable> CDBrickIDTableTable::Query(std::function<bool(CDBrickIDTable)> predicate) {
std::vector<CDBrickIDTable> data = cpplinq::from(this->entries) std::vector<CDBrickIDTable> data = cpplinq::from(entries)
>> cpplinq::where(predicate) >> cpplinq::where(predicate)
>> cpplinq::to_vector(); >> cpplinq::to_vector();
return data; return data;
} }
std::vector<CDBrickIDTable> CDBrickIDTableTable::GetEntries(void) const {
return this->entries;
}

View File

@ -16,14 +16,8 @@ struct CDBrickIDTable {
//! BrickIDTable table //! BrickIDTable table
class CDBrickIDTableTable : public CDTable<CDBrickIDTableTable> { namespace CDBrickIDTableTable {
private: void LoadTableIntoMemory();
std::vector<CDBrickIDTable> entries;
public:
CDBrickIDTableTable();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDBrickIDTable> Query(std::function<bool(CDBrickIDTable)> predicate); std::vector<CDBrickIDTable> Query(std::function<bool(CDBrickIDTable)> predicate);
std::vector<CDBrickIDTable> GetEntries(void) const;
}; };

View File

@ -11,11 +11,9 @@ struct CDComponentsRegistry {
}; };
class CDComponentsRegistryTable : public CDTable<CDComponentsRegistryTable> { namespace CDComponentsRegistryTable {
private:
std::map<uint64_t, uint32_t> mappedEntries; //id, component_type, component_id std::map<uint64_t, uint32_t> mappedEntries; //id, component_type, component_id
public: void LoadTableIntoMemory();
CDComponentsRegistryTable();
int32_t GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue = 0); int32_t GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue = 0);
}; };

View File

@ -18,12 +18,12 @@ struct CDCurrencyTable {
}; };
//! CurrencyTable table //! CurrencyTable table
class CDCurrencyTableTable : public CDTable<CDCurrencyTableTable> { namespace CDCurrencyTableTable {
private: private:
std::vector<CDCurrencyTable> entries; std::vector<CDCurrencyTable> entries;
public: public:
CDCurrencyTableTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDCurrencyTable> Query(std::function<bool(CDCurrencyTable)> predicate); std::vector<CDCurrencyTable> Query(std::function<bool(CDCurrencyTable)> predicate);

View File

@ -20,12 +20,12 @@ struct CDDestructibleComponent {
int difficultyLevel; //!< ??? int difficultyLevel; //!< ???
}; };
class CDDestructibleComponentTable : public CDTable<CDDestructibleComponentTable> { namespace CDDestructibleComponentTable {
private: private:
std::vector<CDDestructibleComponent> entries; std::vector<CDDestructibleComponent> entries;
public: public:
CDDestructibleComponentTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDDestructibleComponent> Query(std::function<bool(CDDestructibleComponent)> predicate); std::vector<CDDestructibleComponent> Query(std::function<bool(CDDestructibleComponent)> predicate);

View File

@ -1,40 +1,30 @@
#include "CDEmoteTable.h" #include "CDEmoteTable.h"
//! Constructor namespace {
CDEmoteTableTable::CDEmoteTableTable(void) { std::map<int, CDEmoteTable> entries;
};
void CDEmoteTableTable::LoadTableIntoMemory() {
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Emotes"); auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Emotes");
while (!tableData.eof()) { while (!tableData.eof()) {
CDEmoteTable* entry = new CDEmoteTable(); CDEmoteTable entry;
entry->ID = tableData.getIntField("id", -1); entry.ID = tableData.getIntField("id", -1);
entry->animationName = tableData.getStringField("animationName", ""); entry.animationName = tableData.getStringField("animationName", "");
entry->iconFilename = tableData.getStringField("iconFilename", ""); entry.iconFilename = tableData.getStringField("iconFilename", "");
entry->channel = tableData.getIntField("channel", -1); entry.channel = tableData.getIntField("channel", -1);
entry->locked = tableData.getIntField("locked", -1) != 0; entry.locked = tableData.getIntField("locked", -1) != 0;
entry->localize = tableData.getIntField("localize", -1) != 0; entry.localize = tableData.getIntField("localize", -1) != 0;
entry->locState = tableData.getIntField("locStatus", -1); entry.locState = tableData.getIntField("locStatus", -1);
entry->gateVersion = tableData.getStringField("gate_version", ""); 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.nextRow();
} }
tableData.finalize(); tableData.finalize();
} }
//! Destructor
CDEmoteTableTable::~CDEmoteTableTable(void) {
for (auto e : entries) {
if (e.second) delete e.second;
}
entries.clear();
}
CDEmoteTable* CDEmoteTableTable::GetEmote(int id) { CDEmoteTable* CDEmoteTableTable::GetEmote(int id) {
for (auto e : entries) { return entries.find(id) != entries.end() ? &entries[id] : nullptr;
if (e.first == id) return e.second;
}
return nullptr;
} }

View File

@ -26,13 +26,8 @@ struct CDEmoteTable {
std::string gateVersion; std::string gateVersion;
}; };
class CDEmoteTableTable : public CDTable<CDEmoteTableTable> { namespace CDEmoteTableTable {
private: void LoadTableIntoMemory();
std::map<int, CDEmoteTable*> entries;
public:
CDEmoteTableTable();
~CDEmoteTableTable();
// Returns an emote by ID // Returns an emote by ID
CDEmoteTable* GetEmote(int id); CDEmoteTable* GetEmote(int id);
}; };

View File

@ -11,12 +11,12 @@ struct CDFeatureGating {
std::string description; std::string description;
}; };
class CDFeatureGatingTable : public CDTable<CDFeatureGatingTable> { namespace CDFeatureGatingTable {
private: private:
std::vector<CDFeatureGating> entries; std::vector<CDFeatureGating> entries;
public: public:
CDFeatureGatingTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDFeatureGating> Query(std::function<bool(CDFeatureGating)> predicate); std::vector<CDFeatureGating> Query(std::function<bool(CDFeatureGating)> predicate);

View File

@ -10,12 +10,12 @@ struct CDInventoryComponent {
bool equip; //!< Whether or not to equip the item bool equip; //!< Whether or not to equip the item
}; };
class CDInventoryComponentTable : public CDTable<CDInventoryComponentTable> { namespace CDInventoryComponentTable {
private: private:
std::vector<CDInventoryComponent> entries; std::vector<CDInventoryComponent> entries;
public: public:
CDInventoryComponentTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDInventoryComponent> Query(std::function<bool(CDInventoryComponent)> predicate); std::vector<CDInventoryComponent> Query(std::function<bool(CDInventoryComponent)> predicate);

View File

@ -49,12 +49,12 @@ struct CDItemComponent {
float SellMultiplier; //!< Something to do with early vendors perhaps (but replaced) float SellMultiplier; //!< Something to do with early vendors perhaps (but replaced)
}; };
class CDItemComponentTable : public CDTable<CDItemComponentTable> { namespace CDItemComponentTable {
private: private:
std::map<unsigned int, CDItemComponent> entries; std::map<unsigned int, CDItemComponent> entries;
public: public:
CDItemComponentTable(); void LoadTableIntoMemory();
static std::map<LOT, uint32_t> ParseCraftingCurrencies(const CDItemComponent& itemComponent); static std::map<LOT, uint32_t> ParseCraftingCurrencies(const CDItemComponent& itemComponent);
// Gets an entry by ID // Gets an entry by ID

View File

@ -9,12 +9,12 @@ struct CDItemSetSkills {
unsigned int SkillCastType; //!< The skill cast type unsigned int SkillCastType; //!< The skill cast type
}; };
class CDItemSetSkillsTable : public CDTable<CDItemSetSkillsTable> { namespace CDItemSetSkillsTable {
private: private:
std::vector<CDItemSetSkills> entries; std::vector<CDItemSetSkills> entries;
public: public:
CDItemSetSkillsTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDItemSetSkills> Query(std::function<bool(CDItemSetSkills)> predicate); std::vector<CDItemSetSkills> Query(std::function<bool(CDItemSetSkills)> predicate);

View File

@ -21,12 +21,12 @@ struct CDItemSets {
float priority; //!< The priority float priority; //!< The priority
}; };
class CDItemSetsTable : public CDTable<CDItemSetsTable> { namespace CDItemSetsTable {
private: private:
std::vector<CDItemSets> entries; std::vector<CDItemSets> entries;
public: public:
CDItemSetsTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDItemSets> Query(std::function<bool(CDItemSets)> predicate); std::vector<CDItemSets> Query(std::function<bool(CDItemSets)> predicate);

View File

@ -9,12 +9,12 @@ struct CDLevelProgressionLookup {
std::string BehaviorEffect; //!< The behavior effect attached to this std::string BehaviorEffect; //!< The behavior effect attached to this
}; };
class CDLevelProgressionLookupTable : public CDTable<CDLevelProgressionLookupTable> { namespace CDLevelProgressionLookupTable {
private: private:
std::vector<CDLevelProgressionLookup> entries; std::vector<CDLevelProgressionLookup> entries;
public: public:
CDLevelProgressionLookupTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDLevelProgressionLookup> Query(std::function<bool(CDLevelProgressionLookup)> predicate); std::vector<CDLevelProgressionLookup> Query(std::function<bool(CDLevelProgressionLookup)> predicate);

View File

@ -15,12 +15,12 @@ struct CDLootMatrix {
UNUSED(std::string gate_version); //!< The Gate Version UNUSED(std::string gate_version); //!< The Gate Version
}; };
class CDLootMatrixTable : public CDTable<CDLootMatrixTable> { namespace CDLootMatrixTable {
private: private:
std::vector<CDLootMatrix> entries; std::vector<CDLootMatrix> entries;
public: public:
CDLootMatrixTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDLootMatrix> Query(std::function<bool(CDLootMatrix)> predicate); std::vector<CDLootMatrix> Query(std::function<bool(CDLootMatrix)> predicate);

View File

@ -11,12 +11,12 @@ struct CDLootTable {
unsigned int sortPriority; //!< The sorting priority unsigned int sortPriority; //!< The sorting priority
}; };
class CDLootTableTable : public CDTable<CDLootTableTable> { namespace CDLootTableTable {
private: private:
std::vector<CDLootTable> entries; std::vector<CDLootTable> entries;
public: public:
CDLootTableTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDLootTable> Query(std::function<bool(CDLootTable)> predicate); std::vector<CDLootTable> Query(std::function<bool(CDLootTable)> predicate);

View File

@ -15,12 +15,12 @@ struct CDMissionEmail {
}; };
class CDMissionEmailTable : public CDTable<CDMissionEmailTable> { namespace CDMissionEmailTable {
private: private:
std::vector<CDMissionEmail> entries; std::vector<CDMissionEmail> entries;
public: public:
CDMissionEmailTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDMissionEmail> Query(std::function<bool(CDMissionEmail)> predicate); std::vector<CDMissionEmail> Query(std::function<bool(CDMissionEmail)> predicate);

View File

@ -11,12 +11,12 @@ struct CDMissionNPCComponent {
std::string gate_version; //!< The gate version std::string gate_version; //!< The gate version
}; };
class CDMissionNPCComponentTable : public CDTable<CDMissionNPCComponentTable> { namespace CDMissionNPCComponentTable {
private: private:
std::vector<CDMissionNPCComponent> entries; std::vector<CDMissionNPCComponent> entries;
public: public:
CDMissionNPCComponentTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDMissionNPCComponent> Query(std::function<bool(CDMissionNPCComponent)> predicate); std::vector<CDMissionNPCComponent> Query(std::function<bool(CDMissionNPCComponent)> predicate);

View File

@ -19,12 +19,12 @@ struct CDMissionTasks {
UNUSED(std::string gate_version); //!< ??? UNUSED(std::string gate_version); //!< ???
}; };
class CDMissionTasksTable : public CDTable<CDMissionTasksTable> { namespace CDMissionTasksTable {
private: private:
std::vector<CDMissionTasks> entries; std::vector<CDMissionTasks> entries;
public: public:
CDMissionTasksTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDMissionTasks> Query(std::function<bool(CDMissionTasks)> predicate); std::vector<CDMissionTasks> Query(std::function<bool(CDMissionTasks)> predicate);

View File

@ -60,12 +60,12 @@ struct CDMissions {
int reward_bankinventory; //!< The amount of bank space this mission rewards int reward_bankinventory; //!< The amount of bank space this mission rewards
}; };
class CDMissionsTable : public CDTable<CDMissionsTable> { namespace CDMissionsTable {
private: private:
std::vector<CDMissions> entries; std::vector<CDMissions> entries;
public: public:
CDMissionsTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDMissions> Query(std::function<bool(CDMissions)> predicate); std::vector<CDMissions> Query(std::function<bool(CDMissions)> predicate);

View File

@ -14,12 +14,12 @@ struct CDMovementAIComponent {
std::string attachedPath; std::string attachedPath;
}; };
class CDMovementAIComponentTable : public CDTable<CDMovementAIComponentTable> { namespace CDMovementAIComponentTable {
private: private:
std::vector<CDMovementAIComponent> entries; std::vector<CDMovementAIComponent> entries;
public: public:
CDMovementAIComponentTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDMovementAIComponent> Query(std::function<bool(CDMovementAIComponent)> predicate); std::vector<CDMovementAIComponent> Query(std::function<bool(CDMovementAIComponent)> predicate);

View File

@ -10,12 +10,12 @@ struct CDObjectSkills {
unsigned int AICombatWeight; //!< ??? unsigned int AICombatWeight; //!< ???
}; };
class CDObjectSkillsTable : public CDTable<CDObjectSkillsTable> { namespace CDObjectSkillsTable {
private: private:
std::vector<CDObjectSkills> entries; std::vector<CDObjectSkills> entries;
public: public:
CDObjectSkillsTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDObjectSkills> Query(std::function<bool(CDObjectSkills)> predicate); std::vector<CDObjectSkills> Query(std::function<bool(CDObjectSkills)> predicate);

View File

@ -20,13 +20,13 @@ struct CDObjects {
UNUSED(unsigned int HQ_valid); //!< Probably used for the Nexus HQ database on LEGOUniverse.com UNUSED(unsigned int HQ_valid); //!< Probably used for the Nexus HQ database on LEGOUniverse.com
}; };
class CDObjectsTable : public CDTable<CDObjectsTable> { namespace CDObjectsTable {
private: private:
std::map<unsigned int, CDObjects> entries; std::map<unsigned int, CDObjects> entries;
CDObjects m_default; CDObjects m_default;
public: public:
CDObjectsTable(); void LoadTableIntoMemory();
// Gets an entry by ID // Gets an entry by ID
const CDObjects& GetByID(unsigned int LOT); const CDObjects& GetByID(unsigned int LOT);
}; };

View File

@ -9,7 +9,7 @@ struct CDPackageComponent {
unsigned int packageType; unsigned int packageType;
}; };
class CDPackageComponentTable : public CDTable<CDPackageComponentTable> { namespace CDPackageComponentTable {
private: private:
std::vector<CDPackageComponent> entries; std::vector<CDPackageComponent> entries;

View File

@ -21,10 +21,9 @@ struct CDPhysicsComponent {
UNUSED(std::string gravityVolumeAsset); UNUSED(std::string gravityVolumeAsset);
}; };
class CDPhysicsComponentTable : public CDTable<CDPhysicsComponentTable> { namespace CDPhysicsComponentTable {
public: public:
CDPhysicsComponentTable(); void LoadTableIntoMemory();
~CDPhysicsComponentTable();
static const std::string GetTableName() { return "PhysicsComponent"; }; static const std::string GetTableName() { return "PhysicsComponent"; };
CDPhysicsComponent* GetByID(unsigned int componentID); CDPhysicsComponent* GetByID(unsigned int componentID);

View File

@ -9,9 +9,9 @@ struct CDPropertyEntranceComponent {
std::string groupType; std::string groupType;
}; };
class CDPropertyEntranceComponentTable : public CDTable<CDPropertyEntranceComponentTable> { namespace CDPropertyEntranceComponentTable {
public: public:
CDPropertyEntranceComponentTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
CDPropertyEntranceComponent GetByID(uint32_t id); CDPropertyEntranceComponent GetByID(uint32_t id);

View File

@ -8,9 +8,9 @@ struct CDPropertyTemplate {
std::string spawnName; std::string spawnName;
}; };
class CDPropertyTemplateTable : public CDTable<CDPropertyTemplateTable> { namespace CDPropertyTemplateTable {
public: public:
CDPropertyTemplateTable(); void LoadTableIntoMemory();
static const std::string GetTableName() { return "PropertyTemplate"; }; static const std::string GetTableName() { return "PropertyTemplate"; };
CDPropertyTemplate GetByMapID(uint32_t mapID); CDPropertyTemplate GetByMapID(uint32_t mapID);

View File

@ -10,7 +10,7 @@ struct CDProximityMonitorComponent {
bool LoadOnServer; bool LoadOnServer;
}; };
class CDProximityMonitorComponentTable : public CDTable<CDProximityMonitorComponentTable> { namespace CDProximityMonitorComponentTable {
private: private:
std::vector<CDProximityMonitorComponent> entries; std::vector<CDProximityMonitorComponent> entries;

View File

@ -20,9 +20,9 @@ struct CDRailActivatorComponent {
bool showNameBillboard; bool showNameBillboard;
}; };
class CDRailActivatorComponentTable : public CDTable<CDRailActivatorComponentTable> { namespace CDRailActivatorComponentTable {
public: public:
CDRailActivatorComponentTable(); void LoadTableIntoMemory();
static const std::string GetTableName() { return "RailActivatorComponent"; }; static const std::string GetTableName() { return "RailActivatorComponent"; };
[[nodiscard]] CDRailActivatorComponent GetEntryByID(int32_t id) const; [[nodiscard]] CDRailActivatorComponent GetEntryByID(int32_t id) const;
[[nodiscard]] std::vector<CDRailActivatorComponent> GetEntries() const; [[nodiscard]] std::vector<CDRailActivatorComponent> GetEntries() const;

View File

@ -26,12 +26,12 @@ struct CDRarityTable {
} }
}; };
class CDRarityTableTable : public CDTable<CDRarityTableTable> { namespace CDRarityTableTable {
private: private:
std::vector<CDRarityTable> entries; std::vector<CDRarityTable> entries;
public: public:
CDRarityTableTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDRarityTable> Query(std::function<bool(CDRarityTable)> predicate); std::vector<CDRarityTable> Query(std::function<bool(CDRarityTable)> predicate);

View File

@ -16,12 +16,12 @@ struct CDRebuildComponent {
float time_before_smash; //!< The time before smash float time_before_smash; //!< The time before smash
}; };
class CDRebuildComponentTable : public CDTable<CDRebuildComponentTable> { namespace CDRebuildComponentTable {
private: private:
std::vector<CDRebuildComponent> entries; std::vector<CDRebuildComponent> entries;
public: public:
CDRebuildComponentTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDRebuildComponent> Query(std::function<bool(CDRebuildComponent)> predicate); std::vector<CDRebuildComponent> Query(std::function<bool(CDRebuildComponent)> predicate);

View File

@ -11,10 +11,9 @@ struct CDRewards {
int32_t count; int32_t count;
}; };
class CDRewardsTable : public CDTable<CDRewardsTable> { namespace CDRewardsTable {
public: public:
CDRewardsTable(); void LoadTableIntoMemory();
~CDRewardsTable();
static const std::string GetTableName() { return "Rewards"; }; static const std::string GetTableName() { return "Rewards"; };
std::vector<CDRewards*> GetByLevelID(uint32_t levelID); std::vector<CDRewards*> GetByLevelID(uint32_t levelID);

View File

@ -9,13 +9,13 @@ struct CDScriptComponent {
std::string client_script_name; //!< The client script name std::string client_script_name; //!< The client script name
}; };
class CDScriptComponentTable : public CDTable<CDScriptComponentTable> { namespace CDScriptComponentTable {
private: private:
std::map<unsigned int, CDScriptComponent> entries; std::map<unsigned int, CDScriptComponent> entries;
CDScriptComponent m_ToReturnWhenNoneFound; CDScriptComponent m_ToReturnWhenNoneFound;
public: public:
CDScriptComponentTable(); void LoadTableIntoMemory();
// Gets an entry by scriptID // Gets an entry by scriptID
const CDScriptComponent& GetByID(unsigned int id); const CDScriptComponent& GetByID(unsigned int id);
}; };

View File

@ -25,13 +25,13 @@ struct CDSkillBehavior {
UNUSED(unsigned int cancelType); //!< The cancel type (?) UNUSED(unsigned int cancelType); //!< The cancel type (?)
}; };
class CDSkillBehaviorTable : public CDTable<CDSkillBehaviorTable> { namespace CDSkillBehaviorTable {
private: private:
std::map<unsigned int, CDSkillBehavior> entries; std::map<unsigned int, CDSkillBehavior> entries;
CDSkillBehavior m_empty; CDSkillBehavior m_empty;
public: public:
CDSkillBehaviorTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDSkillBehavior> Query(std::function<bool(CDSkillBehavior)> predicate); std::vector<CDSkillBehavior> Query(std::function<bool(CDSkillBehavior)> predicate);

View File

@ -25,12 +25,6 @@
#pragma warning (disable : 4244) //Disable double to float conversion warnings #pragma warning (disable : 4244) //Disable double to float conversion warnings
#pragma warning (disable : 4715) //Disable "not all control paths return a value" #pragma warning (disable : 4715) //Disable "not all control paths return a value"
template<class Table>
class CDTable : public Singleton<Table> {
protected:
virtual ~CDTable() = default;
};
template<class T> template<class T>
class LookupResult { class LookupResult {
typedef std::pair<T, bool> DataType; typedef std::pair<T, bool> DataType;

View File

@ -11,12 +11,12 @@ struct CDVendorComponent {
unsigned int LootMatrixIndex; //!< LootMatrixIndex of the vendor's items unsigned int LootMatrixIndex; //!< LootMatrixIndex of the vendor's items
}; };
class CDVendorComponentTable : public CDTable<CDVendorComponentTable> { namespace CDVendorComponentTable {
private: private:
std::vector<CDVendorComponent> entries; std::vector<CDVendorComponent> entries;
public: public:
CDVendorComponentTable(); void LoadTableIntoMemory();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDVendorComponent> Query(std::function<bool(CDVendorComponent)> predicate); std::vector<CDVendorComponent> Query(std::function<bool(CDVendorComponent)> predicate);

View File

@ -33,12 +33,12 @@ struct CDZoneTable {
UNUSED(bool mountsAllowed); //!< Whether or not mounts are allowed UNUSED(bool mountsAllowed); //!< Whether or not mounts are allowed
}; };
class CDZoneTableTable : public CDTable<CDZoneTableTable> { namespace CDZoneTableTable {
private: private:
std::map<unsigned int, CDZoneTable> m_Entries; std::map<unsigned int, CDZoneTable> m_Entries;
public: public:
CDZoneTableTable(); void LoadTableIntoMemory();
// Queries the table with a zoneID to find. // Queries the table with a zoneID to find.
const CDZoneTable* Query(unsigned int zoneID); const CDZoneTable* Query(unsigned int zoneID);

View File

@ -11,7 +11,7 @@
struct BehaviorContext; struct BehaviorContext;
struct BehaviorBranchContext; struct BehaviorBranchContext;
class CDBehaviorParameterTable; namespace CDBehaviorParameterTable; {
class Behavior class Behavior
{ {