Merge branch 'main' into moreMovementAi

This commit is contained in:
David Markowitz 2023-08-12 21:57:07 -07:00
commit 1b54387677
157 changed files with 559 additions and 666 deletions

View File

@ -18,3 +18,5 @@ __maria_db_connector_compile_jobs__=1
__enable_testing__=1 __enable_testing__=1
# The path to OpenSSL. Change this if your OpenSSL install path is different than the default. # The path to OpenSSL. Change this if your OpenSSL install path is different than the default.
OPENSSL_ROOT_DIR=/usr/local/opt/openssl@3/ OPENSSL_ROOT_DIR=/usr/local/opt/openssl@3/
# Uncomment the below line to cache the entire CDClient into memory
# CDCLIENT_CACHE_ALL=1

View File

@ -136,6 +136,13 @@ NiPoint3& NiPoint3::operator+=(const NiPoint3& point) {
return *this; return *this;
} }
NiPoint3& NiPoint3::operator*=(const float scalar) {
this->x *= scalar;
this->y *= scalar;
this->z *= scalar;
return *this;
}
//! Operator for subtraction of vectors //! Operator for subtraction of vectors
NiPoint3 NiPoint3::operator-(const NiPoint3& point) const { NiPoint3 NiPoint3::operator-(const NiPoint3& point) const {
return NiPoint3(this->x - point.x, this->y - point.y, this->z - point.z); return NiPoint3(this->x - point.x, this->y - point.y, this->z - point.z);

View File

@ -138,6 +138,8 @@ public:
//! Operator for addition of vectors //! Operator for addition of vectors
NiPoint3& operator+=(const NiPoint3& point); NiPoint3& operator+=(const NiPoint3& point);
NiPoint3& operator*=(const float scalar);
//! Operator for subtraction of vectors //! Operator for subtraction of vectors
NiPoint3 operator-(const NiPoint3& point) const; NiPoint3 operator-(const NiPoint3& point) const;

View File

@ -13,15 +13,7 @@
#include <sstream> #include <sstream>
#include <iostream> #include <iostream>
// Enable this to cache all entries in each table for fast access, comes with more memory cost //! The CDClient Database namespace
//#define CDCLIENT_CACHE_ALL
/*!
\file CDClientDatabase.hpp
\brief An interface between the CDClient.sqlite file and the server
*/
//! The CDClient Database namespace
namespace CDClientDatabase { namespace CDClientDatabase {
//! Opens a connection with the CDClient //! Opens a connection with the CDClient

View File

@ -38,43 +38,53 @@
#include "CDFeatureGatingTable.h" #include "CDFeatureGatingTable.h"
#include "CDRailActivatorComponent.h" #include "CDRailActivatorComponent.h"
// Uncomment this to cache the full cdclient database into memory. This will make the server load faster, but will use more memory.
// A vanilla CDClient takes about 46MB of memory + the regular world data.
// #define CDCLIENT_CACHE_ALL
#ifdef CDCLIENT_CACHE_ALL
#define CDCLIENT_DONT_CACHE_TABLE(x) x
#else
#define CDCLIENT_DONT_CACHE_TABLE(x)
#endif
CDClientManager::CDClientManager() { CDClientManager::CDClientManager() {
CDActivityRewardsTable::Instance(); CDActivityRewardsTable::Instance().LoadValuesFromDatabase();
CDAnimationsTable::Instance(); CDActivitiesTable::Instance().LoadValuesFromDatabase();
CDBehaviorParameterTable::Instance(); CDCLIENT_DONT_CACHE_TABLE(CDAnimationsTable::Instance().LoadValuesFromDatabase());
CDBehaviorTemplateTable::Instance(); CDBehaviorParameterTable::Instance().LoadValuesFromDatabase();
CDComponentsRegistryTable::Instance(); CDBehaviorTemplateTable::Instance().LoadValuesFromDatabase();
CDCurrencyTableTable::Instance(); CDBrickIDTableTable::Instance().LoadValuesFromDatabase();
CDDestructibleComponentTable::Instance(); CDComponentsRegistryTable::Instance().LoadValuesFromDatabase();
CDEmoteTableTable::Instance(); CDCurrencyTableTable::Instance().LoadValuesFromDatabase();
CDInventoryComponentTable::Instance(); CDDestructibleComponentTable::Instance().LoadValuesFromDatabase();
CDItemComponentTable::Instance(); CDEmoteTableTable::Instance().LoadValuesFromDatabase();
CDItemSetsTable::Instance(); CDFeatureGatingTable::Instance().LoadValuesFromDatabase();
CDItemSetSkillsTable::Instance(); CDInventoryComponentTable::Instance().LoadValuesFromDatabase();
CDLevelProgressionLookupTable::Instance(); CDCLIENT_DONT_CACHE_TABLE(CDItemComponentTable::Instance().LoadValuesFromDatabase());
CDLootMatrixTable::Instance(); CDItemSetSkillsTable::Instance().LoadValuesFromDatabase();
CDLootTableTable::Instance(); CDItemSetsTable::Instance().LoadValuesFromDatabase();
CDMissionNPCComponentTable::Instance(); CDLevelProgressionLookupTable::Instance().LoadValuesFromDatabase();
CDMissionTasksTable::Instance(); CDLootMatrixTable::Instance().LoadValuesFromDatabase();
CDMissionsTable::Instance(); CDLootTableTable::Instance().LoadValuesFromDatabase();
CDObjectSkillsTable::Instance(); CDMissionEmailTable::Instance().LoadValuesFromDatabase();
CDObjectsTable::Instance(); CDMissionNPCComponentTable::Instance().LoadValuesFromDatabase();
CDPhysicsComponentTable::Instance(); CDMissionTasksTable::Instance().LoadValuesFromDatabase();
CDRebuildComponentTable::Instance(); CDMissionsTable::Instance().LoadValuesFromDatabase();
CDScriptComponentTable::Instance(); CDMovementAIComponentTable::Instance().LoadValuesFromDatabase();
CDSkillBehaviorTable::Instance(); CDObjectSkillsTable::Instance().LoadValuesFromDatabase();
CDZoneTableTable::Instance(); CDCLIENT_DONT_CACHE_TABLE(CDObjectsTable::Instance().LoadValuesFromDatabase());
CDVendorComponentTable::Instance(); CDPhysicsComponentTable::Instance().LoadValuesFromDatabase();
CDActivitiesTable::Instance(); CDPackageComponentTable::Instance().LoadValuesFromDatabase();
CDPackageComponentTable::Instance(); CDProximityMonitorComponentTable::Instance().LoadValuesFromDatabase();
CDProximityMonitorComponentTable::Instance(); CDPropertyEntranceComponentTable::Instance().LoadValuesFromDatabase();
CDMovementAIComponentTable::Instance(); CDPropertyTemplateTable::Instance().LoadValuesFromDatabase();
CDBrickIDTableTable::Instance(); CDRailActivatorComponentTable::Instance().LoadValuesFromDatabase();
CDRarityTableTable::Instance(); CDRarityTableTable::Instance().LoadValuesFromDatabase();
CDMissionEmailTable::Instance(); CDRebuildComponentTable::Instance().LoadValuesFromDatabase();
CDRewardsTable::Instance(); CDRewardsTable::Instance().LoadValuesFromDatabase();
CDPropertyEntranceComponentTable::Instance(); CDScriptComponentTable::Instance().LoadValuesFromDatabase();
CDPropertyTemplateTable::Instance(); CDSkillBehaviorTable::Instance().LoadValuesFromDatabase();
CDFeatureGatingTable::Instance(); CDVendorComponentTable::Instance().LoadValuesFromDatabase();
CDRailActivatorComponentTable::Instance(); CDZoneTableTable::Instance().LoadValuesFromDatabase();
} }

View File

@ -1,7 +1,6 @@
#include "CDActivitiesTable.h" #include "CDActivitiesTable.h"
CDActivitiesTable::CDActivitiesTable(void) { void CDActivitiesTable::LoadValuesFromDatabase() {
// 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");
@ -55,8 +54,3 @@ std::vector<CDActivities> CDActivitiesTable::Query(std::function<bool(CDActiviti
return data; return data;
} }
std::vector<CDActivities> CDActivitiesTable::GetEntries(void) const {
return this->entries;
}

View File

@ -30,9 +30,10 @@ private:
std::vector<CDActivities> entries; std::vector<CDActivities> entries;
public: public:
CDActivitiesTable(); void LoadValuesFromDatabase();
// 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; const std::vector<CDActivities>& GetEntries() const { return this->entries; }
}; };

View File

@ -1,6 +1,6 @@
#include "CDActivityRewardsTable.h" #include "CDActivityRewardsTable.h"
CDActivityRewardsTable::CDActivityRewardsTable(void) { void CDActivityRewardsTable::LoadValuesFromDatabase() {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -43,8 +43,3 @@ std::vector<CDActivityRewards> CDActivityRewardsTable::Query(std::function<bool(
return data; return data;
} }
std::vector<CDActivityRewards> CDActivityRewardsTable::GetEntries(void) const {
return this->entries;
}

View File

@ -18,10 +18,10 @@ private:
std::vector<CDActivityRewards> entries; std::vector<CDActivityRewards> entries;
public: public:
CDActivityRewardsTable(); void LoadValuesFromDatabase();
// 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; std::vector<CDActivityRewards> GetEntries() const;
}; };

View File

@ -2,6 +2,35 @@
#include "GeneralUtils.h" #include "GeneralUtils.h"
#include "Game.h" #include "Game.h"
void CDAnimationsTable::LoadValuesFromDatabase() {
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Animations");
while (!tableData.eof()) {
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();
}
tableData.finalize();
}
bool CDAnimationsTable::CacheData(CppSQLite3Statement& queryToCache) { bool CDAnimationsTable::CacheData(CppSQLite3Statement& queryToCache) {
auto tableData = queryToCache.execQuery(); auto tableData = queryToCache.execQuery();
// If we received a bad lookup, cache it anyways so we do not run the query again. // If we received a bad lookup, cache it anyways so we do not run the query again.

View File

@ -27,6 +27,7 @@ class CDAnimationsTable : public CDTable<CDAnimationsTable> {
typedef std::string AnimationID; typedef std::string AnimationID;
typedef std::pair<std::string, AnimationGroupID> CDAnimationKey; typedef std::pair<std::string, AnimationGroupID> CDAnimationKey;
public: public:
void LoadValuesFromDatabase();
/** /**
* 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

View File

@ -1,15 +1,15 @@
#include "CDBehaviorParameterTable.h" #include "CDBehaviorParameterTable.h"
#include "GeneralUtils.h" #include "GeneralUtils.h"
uint64_t GetHash(const uint32_t behaviorID, const uint32_t parameterID) { uint64_t GetKey(const uint32_t behaviorID, const uint32_t parameterID) {
uint64_t hash = behaviorID; uint64_t key = behaviorID;
hash <<= 31U; key <<= 31U;
hash |= parameterID; key |= parameterID;
return hash; return key;
} }
CDBehaviorParameterTable::CDBehaviorParameterTable() { void CDBehaviorParameterTable::LoadValuesFromDatabase() {
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BehaviorParameter"); auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BehaviorParameter");
while (!tableData.eof()) { while (!tableData.eof()) {
uint32_t behaviorID = tableData.getIntField("behaviorID", -1); uint32_t behaviorID = tableData.getIntField("behaviorID", -1);
@ -21,7 +21,7 @@ CDBehaviorParameterTable::CDBehaviorParameterTable() {
} else { } else {
parameterId = m_ParametersList.insert(std::make_pair(candidateStringToAdd, m_ParametersList.size())).first->second; parameterId = m_ParametersList.insert(std::make_pair(candidateStringToAdd, m_ParametersList.size())).first->second;
} }
uint64_t hash = GetHash(behaviorID, parameterId); uint64_t hash = GetKey(behaviorID, parameterId);
float value = tableData.getFloatField("value", -1.0f); float value = tableData.getFloatField("value", -1.0f);
m_Entries.insert(std::make_pair(hash, value)); m_Entries.insert(std::make_pair(hash, value));
@ -34,7 +34,7 @@ CDBehaviorParameterTable::CDBehaviorParameterTable() {
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 = this->m_ParametersList.find(name);
if (parameterID == this->m_ParametersList.end()) return defaultValue; if (parameterID == this->m_ParametersList.end()) return defaultValue;
auto hash = GetHash(behaviorID, parameterID->second); auto hash = GetKey(behaviorID, parameterID->second);
// Search for specific parameter // Search for specific parameter
auto it = m_Entries.find(hash); auto it = m_Entries.find(hash);
@ -45,7 +45,7 @@ std::map<std::string, float> CDBehaviorParameterTable::GetParametersByBehaviorID
uint64_t hashBase = behaviorID; uint64_t hashBase = behaviorID;
std::map<std::string, float> returnInfo; std::map<std::string, float> returnInfo;
for (auto& [parameterString, parameterId] : m_ParametersList) { for (auto& [parameterString, parameterId] : m_ParametersList) {
uint64_t hash = GetHash(hashBase, parameterId); uint64_t hash = GetKey(hashBase, parameterId);
auto infoCandidate = m_Entries.find(hash); auto infoCandidate = m_Entries.find(hash);
if (infoCandidate != m_Entries.end()) { if (infoCandidate != m_Entries.end()) {
returnInfo.insert(std::make_pair(parameterString, infoCandidate->second)); returnInfo.insert(std::make_pair(parameterString, infoCandidate->second));

View File

@ -12,7 +12,7 @@ private:
std::unordered_map<BehaviorParameterHash, BehaviorParameterValue> m_Entries; std::unordered_map<BehaviorParameterHash, BehaviorParameterValue> m_Entries;
std::unordered_map<std::string, uint32_t> m_ParametersList; std::unordered_map<std::string, uint32_t> m_ParametersList;
public: public:
CDBehaviorParameterTable(); void LoadValuesFromDatabase();
float GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue = 0); float GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue = 0);

View File

@ -1,6 +1,6 @@
#include "CDBehaviorTemplateTable.h" #include "CDBehaviorTemplateTable.h"
CDBehaviorTemplateTable::CDBehaviorTemplateTable(void) { void CDBehaviorTemplateTable::LoadValuesFromDatabase() {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -48,7 +48,7 @@ std::vector<CDBehaviorTemplate> CDBehaviorTemplateTable::Query(std::function<boo
return data; return data;
} }
std::vector<CDBehaviorTemplate> CDBehaviorTemplateTable::GetEntries(void) const { const std::vector<CDBehaviorTemplate>& CDBehaviorTemplateTable::GetEntries() const {
return this->entries; return this->entries;
} }
@ -64,4 +64,3 @@ const CDBehaviorTemplate CDBehaviorTemplateTable::GetByBehaviorID(uint32_t behav
return entry->second; return entry->second;
} }
} }

View File

@ -19,11 +19,12 @@ private:
std::unordered_map<uint32_t, CDBehaviorTemplate> entriesMappedByBehaviorID; std::unordered_map<uint32_t, CDBehaviorTemplate> entriesMappedByBehaviorID;
std::unordered_set<std::string> m_EffectHandles; std::unordered_set<std::string> m_EffectHandles;
public: public:
CDBehaviorTemplateTable(); void LoadValuesFromDatabase();
// 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 std::vector<CDBehaviorTemplate>& GetEntries(void) const;
const CDBehaviorTemplate GetByBehaviorID(uint32_t behaviorID); const CDBehaviorTemplate GetByBehaviorID(uint32_t behaviorID);
}; };

View File

@ -1,6 +1,6 @@
#include "CDBrickIDTableTable.h" #include "CDBrickIDTableTable.h"
CDBrickIDTableTable::CDBrickIDTableTable(void) { void CDBrickIDTableTable::LoadValuesFromDatabase() {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -39,7 +39,7 @@ std::vector<CDBrickIDTable> CDBrickIDTableTable::Query(std::function<bool(CDBric
return data; return data;
} }
std::vector<CDBrickIDTable> CDBrickIDTableTable::GetEntries(void) const { const std::vector<CDBrickIDTable>& CDBrickIDTableTable::GetEntries() const {
return this->entries; return this->entries;
} }

View File

@ -21,9 +21,9 @@ private:
std::vector<CDBrickIDTable> entries; std::vector<CDBrickIDTable> entries;
public: public:
CDBrickIDTableTable(); void LoadValuesFromDatabase();
// 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; const std::vector<CDBrickIDTable>& GetEntries() const;
}; };

View File

@ -1,27 +1,37 @@
#include "CDComponentsRegistryTable.h" #include "CDComponentsRegistryTable.h"
#include "eReplicaComponentType.h" #include "eReplicaComponentType.h"
#define CDCLIENT_CACHE_ALL void CDComponentsRegistryTable::LoadValuesFromDatabase() {
CDComponentsRegistryTable::CDComponentsRegistryTable(void) {
#ifdef CDCLIENT_CACHE_ALL
// First, get the size of the table
unsigned int size = 0;
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ComponentsRegistry");
while (!tableSize.eof()) {
size = tableSize.getIntField(0, 0);
tableSize.nextRow();
}
tableSize.finalize();
// Reserve the size
//this->entries.reserve(size);
// Now get the data // Now get the data
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ComponentsRegistry"); auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ComponentsRegistry");
while (!tableData.eof()) {
CDComponentsRegistry entry;
entry.id = tableData.getIntField("id", -1);
entry.component_type = static_cast<eReplicaComponentType>(tableData.getIntField("component_type", 0));
entry.component_id = tableData.getIntField("component_id", -1);
this->mappedEntries.insert_or_assign(((uint64_t)entry.component_type) << 32 | ((uint64_t)entry.id), entry.component_id);
this->mappedEntries.insert_or_assign(entry.id, 0);
tableData.nextRow();
}
tableData.finalize();
}
int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue) {
auto exists = mappedEntries.find(id);
if (exists != mappedEntries.end()) {
auto iter = mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id));
return iter == mappedEntries.end() ? defaultValue : iter->second;
}
// Now get the data. Get all components of this entity so we dont do a query for each component
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM ComponentsRegistry WHERE id = ?;");
query.bind(1, static_cast<int32_t>(id));
auto tableData = query.execQuery();
while (!tableData.eof()) { while (!tableData.eof()) {
CDComponentsRegistry entry; CDComponentsRegistry entry;
entry.id = tableData.getIntField("id", -1); entry.id = tableData.getIntField("id", -1);
@ -33,61 +43,10 @@ CDComponentsRegistryTable::CDComponentsRegistryTable(void) {
tableData.nextRow(); tableData.nextRow();
} }
tableData.finalize(); mappedEntries.insert_or_assign(id, 0);
#endif
} auto iter = this->mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id));
int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue) { return iter == this->mappedEntries.end() ? defaultValue : iter->second;
const auto& iter = this->mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id));
if (iter == this->mappedEntries.end()) {
return defaultValue;
}
return iter->second;
#ifndef CDCLIENT_CACHE_ALL
// Now get the data
std::stringstream query;
query << "SELECT * FROM ComponentsRegistry WHERE id = " << std::to_string(id);
auto tableData = CDClientDatabase::ExecuteQuery(query.str());
while (!tableData.eof()) {
CDComponentsRegistry entry;
entry.id = tableData.getIntField("id", -1);
entry.component_type = tableData.getIntField("component_type", -1);
entry.component_id = tableData.getIntField("component_id", -1);
//this->entries.push_back(entry);
//Darwin's stuff:
const auto& it = this->mappedEntries.find(entry.id);
if (it != mappedEntries.end()) {
const auto& iter = it->second.find(entry.component_type);
if (iter == it->second.end()) {
it->second.insert(std::make_pair(entry.component_type, entry.component_id));
}
} else {
std::map<unsigned int, unsigned int> map;
map.insert(std::make_pair(entry.component_type, entry.component_id));
this->mappedEntries.insert(std::make_pair(entry.id, map));
}
tableData.nextRow();
}
tableData.finalize();
const auto& it2 = this->mappedEntries.find(id);
if (it2 != mappedEntries.end()) {
const auto& iter = it2->second.find(componentType);
if (iter != it2->second.end()) {
return iter->second;
}
}
return defaultValue;
#endif
} }

View File

@ -13,9 +13,9 @@ struct CDComponentsRegistry {
class CDComponentsRegistryTable : public CDTable<CDComponentsRegistryTable> { class CDComponentsRegistryTable : public CDTable<CDComponentsRegistryTable> {
private: private:
std::map<uint64_t, uint32_t> mappedEntries; //id, component_type, component_id std::unordered_map<uint64_t, uint32_t> mappedEntries; //id, component_type, component_id
public: public:
CDComponentsRegistryTable(); void LoadValuesFromDatabase();
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

@ -1,7 +1,7 @@
#include "CDCurrencyTableTable.h" #include "CDCurrencyTableTable.h"
//! Constructor //! Constructor
CDCurrencyTableTable::CDCurrencyTableTable(void) { void CDCurrencyTableTable::LoadValuesFromDatabase() {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -43,7 +43,7 @@ std::vector<CDCurrencyTable> CDCurrencyTableTable::Query(std::function<bool(CDCu
return data; return data;
} }
std::vector<CDCurrencyTable> CDCurrencyTableTable::GetEntries(void) const { const std::vector<CDCurrencyTable>& CDCurrencyTableTable::GetEntries() const {
return this->entries; return this->entries;
} }

View File

@ -23,9 +23,9 @@ private:
std::vector<CDCurrencyTable> entries; std::vector<CDCurrencyTable> entries;
public: public:
CDCurrencyTableTable(); void LoadValuesFromDatabase();
// 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);
std::vector<CDCurrencyTable> GetEntries(void) const; const std::vector<CDCurrencyTable>& GetEntries() const;
}; };

View File

@ -1,8 +1,6 @@
#include "CDDestructibleComponentTable.h" #include "CDDestructibleComponentTable.h"
//! Constructor void CDDestructibleComponentTable::LoadValuesFromDatabase() {
CDDestructibleComponentTable::CDDestructibleComponentTable(void) {
// 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 DestructibleComponent"); auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM DestructibleComponent");
@ -52,7 +50,7 @@ std::vector<CDDestructibleComponent> CDDestructibleComponentTable::Query(std::fu
return data; return data;
} }
std::vector<CDDestructibleComponent> CDDestructibleComponentTable::GetEntries(void) const { const std::vector<CDDestructibleComponent>& CDDestructibleComponentTable::GetEntries() const {
return this->entries; return this->entries;
} }

View File

@ -25,9 +25,9 @@ private:
std::vector<CDDestructibleComponent> entries; std::vector<CDDestructibleComponent> entries;
public: public:
CDDestructibleComponentTable(); void LoadValuesFromDatabase();
// 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);
std::vector<CDDestructibleComponent> GetEntries(void) const; const std::vector<CDDestructibleComponent>& GetEntries(void) const;
}; };

View File

@ -1,40 +1,26 @@
#include "CDEmoteTable.h" #include "CDEmoteTable.h"
//! Constructor void CDEmoteTableTable::LoadValuesFromDatabase() {
CDEmoteTableTable::CDEmoteTableTable(void) {
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) { auto itr = entries.find(id);
if (e.first == id) return e.second; return itr != entries.end() ? &itr->second : nullptr;
}
return nullptr;
} }

View File

@ -28,11 +28,10 @@ struct CDEmoteTable {
class CDEmoteTableTable : public CDTable<CDEmoteTableTable> { class CDEmoteTableTable : public CDTable<CDEmoteTableTable> {
private: private:
std::map<int, CDEmoteTable*> entries; std::map<int, CDEmoteTable> entries;
public: public:
CDEmoteTableTable(); void LoadValuesFromDatabase();
~CDEmoteTableTable();
// Returns an emote by ID // Returns an emote by ID
CDEmoteTable* GetEmote(int id); CDEmoteTable* GetEmote(int id);
}; };

View File

@ -1,7 +1,6 @@
#include "CDFeatureGatingTable.h" #include "CDFeatureGatingTable.h"
//! Constructor void CDFeatureGatingTable::LoadValuesFromDatabase() {
CDFeatureGatingTable::CDFeatureGatingTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -53,7 +52,7 @@ bool CDFeatureGatingTable::FeatureUnlocked(const std::string& feature) const {
return false; return false;
} }
std::vector<CDFeatureGating> CDFeatureGatingTable::GetEntries(void) const { const std::vector<CDFeatureGating>& CDFeatureGatingTable::GetEntries() const {
return this->entries; return this->entries;
} }

View File

@ -16,11 +16,12 @@ private:
std::vector<CDFeatureGating> entries; std::vector<CDFeatureGating> entries;
public: public:
CDFeatureGatingTable(); void LoadValuesFromDatabase();
// 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);
bool FeatureUnlocked(const std::string& feature) const; bool FeatureUnlocked(const std::string& feature) const;
std::vector<CDFeatureGating> GetEntries(void) const; const std::vector<CDFeatureGating>& GetEntries(void) const;
}; };

View File

@ -1,7 +1,6 @@
#include "CDInventoryComponentTable.h" #include "CDInventoryComponentTable.h"
//! Constructor void CDInventoryComponentTable::LoadValuesFromDatabase() {
CDInventoryComponentTable::CDInventoryComponentTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -42,7 +41,7 @@ std::vector<CDInventoryComponent> CDInventoryComponentTable::Query(std::function
return data; return data;
} }
std::vector<CDInventoryComponent> CDInventoryComponentTable::GetEntries(void) const { const std::vector<CDInventoryComponent>& CDInventoryComponentTable::GetEntries() const {
return this->entries; return this->entries;
} }

View File

@ -15,9 +15,9 @@ private:
std::vector<CDInventoryComponent> entries; std::vector<CDInventoryComponent> entries;
public: public:
CDInventoryComponentTable(); void LoadValuesFromDatabase();
// 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);
std::vector<CDInventoryComponent> GetEntries(void) const; const std::vector<CDInventoryComponent>& GetEntries() const;
}; };

View File

@ -3,11 +3,7 @@
CDItemComponent CDItemComponentTable::Default = {}; CDItemComponent CDItemComponentTable::Default = {};
//! Constructor void CDItemComponentTable::LoadValuesFromDatabase() {
CDItemComponentTable::CDItemComponentTable(void) {
Default = CDItemComponent();
#ifdef CDCLIENT_CACHE_ALL
// 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 ItemComponent"); auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ItemComponent");
@ -55,13 +51,13 @@ CDItemComponentTable::CDItemComponentTable(void) {
entry.currencyLOT = tableData.getIntField("currencyLOT", -1); entry.currencyLOT = tableData.getIntField("currencyLOT", -1);
entry.altCurrencyCost = tableData.getIntField("altCurrencyCost", -1); entry.altCurrencyCost = tableData.getIntField("altCurrencyCost", -1);
entry.subItems = tableData.getStringField("subItems", ""); entry.subItems = tableData.getStringField("subItems", "");
entry.audioEventUse = tableData.getStringField("audioEventUse", ""); UNUSED_COLUMN(entry.audioEventUse = tableData.getStringField("audioEventUse", ""));
entry.noEquipAnimation = tableData.getIntField("noEquipAnimation", -1) == 1 ? true : false; entry.noEquipAnimation = tableData.getIntField("noEquipAnimation", -1) == 1 ? true : false;
entry.commendationLOT = tableData.getIntField("commendationLOT", -1); entry.commendationLOT = tableData.getIntField("commendationLOT", -1);
entry.commendationCost = tableData.getIntField("commendationCost", -1); entry.commendationCost = tableData.getIntField("commendationCost", -1);
entry.audioEquipMetaEventSet = tableData.getStringField("audioEquipMetaEventSet", ""); UNUSED_COLUMN(entry.audioEquipMetaEventSet = tableData.getStringField("audioEquipMetaEventSet", ""));
entry.currencyCosts = tableData.getStringField("currencyCosts", ""); entry.currencyCosts = tableData.getStringField("currencyCosts", "");
entry.ingredientInfo = tableData.getStringField("ingredientInfo", ""); UNUSED_COLUMN(entry.ingredientInfo = tableData.getStringField("ingredientInfo", ""));
entry.locStatus = tableData.getIntField("locStatus", -1); entry.locStatus = tableData.getIntField("locStatus", -1);
entry.forgeType = tableData.getIntField("forgeType", -1); entry.forgeType = tableData.getIntField("forgeType", -1);
entry.SellMultiplier = tableData.getFloatField("SellMultiplier", -1.0f); entry.SellMultiplier = tableData.getFloatField("SellMultiplier", -1.0f);
@ -71,7 +67,6 @@ CDItemComponentTable::CDItemComponentTable(void) {
} }
tableData.finalize(); tableData.finalize();
#endif
} }
const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int skillID) { const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int skillID) {
@ -80,12 +75,10 @@ const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int s
return it->second; return it->second;
} }
#ifndef CDCLIENT_CACHE_ALL auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM ItemComponent WHERE id = ?;");
std::stringstream query; query.bind(1, static_cast<int32_t>(skillID));
query << "SELECT * FROM ItemComponent WHERE id = " << std::to_string(skillID); auto tableData = query.execQuery();
auto tableData = CDClientDatabase::ExecuteQuery(query.str());
if (tableData.eof()) { if (tableData.eof()) {
entries.insert(std::make_pair(skillID, Default)); entries.insert(std::make_pair(skillID, Default));
return Default; return Default;
@ -144,7 +137,6 @@ const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int s
if (it2 != this->entries.end()) { if (it2 != this->entries.end()) {
return it2->second; return it2->second;
} }
#endif
return Default; return Default;
} }

View File

@ -54,7 +54,7 @@ private:
std::map<unsigned int, CDItemComponent> entries; std::map<unsigned int, CDItemComponent> entries;
public: public:
CDItemComponentTable(); void LoadValuesFromDatabase();
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

@ -1,7 +1,6 @@
#include "CDItemSetSkillsTable.h" #include "CDItemSetSkillsTable.h"
//! Constructor void CDItemSetSkillsTable::LoadValuesFromDatabase() {
CDItemSetSkillsTable::CDItemSetSkillsTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -41,7 +40,7 @@ std::vector<CDItemSetSkills> CDItemSetSkillsTable::Query(std::function<bool(CDIt
return data; return data;
} }
std::vector<CDItemSetSkills> CDItemSetSkillsTable::GetEntries(void) const { const std::vector<CDItemSetSkills>& CDItemSetSkillsTable::GetEntries() const {
return this->entries; return this->entries;
} }

View File

@ -14,11 +14,11 @@ private:
std::vector<CDItemSetSkills> entries; std::vector<CDItemSetSkills> entries;
public: public:
CDItemSetSkillsTable(); void LoadValuesFromDatabase();
// 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);
std::vector<CDItemSetSkills> GetEntries(void) const; const std::vector<CDItemSetSkills>& GetEntries() const;
std::vector<CDItemSetSkills> GetBySkillID(unsigned int SkillSetID); std::vector<CDItemSetSkills> GetBySkillID(unsigned int SkillSetID);
}; };

View File

@ -1,7 +1,6 @@
#include "CDItemSetsTable.h" #include "CDItemSetsTable.h"
//! Constructor void CDItemSetsTable::LoadValuesFromDatabase() {
CDItemSetsTable::CDItemSetsTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -53,7 +52,7 @@ std::vector<CDItemSets> CDItemSetsTable::Query(std::function<bool(CDItemSets)> p
return data; return data;
} }
std::vector<CDItemSets> CDItemSetsTable::GetEntries(void) const { const std::vector<CDItemSets>& CDItemSetsTable::GetEntries() const {
return this->entries; return this->entries;
} }

View File

@ -26,10 +26,10 @@ private:
std::vector<CDItemSets> entries; std::vector<CDItemSets> entries;
public: public:
CDItemSetsTable(); void LoadValuesFromDatabase();
// 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);
std::vector<CDItemSets> GetEntries(void) const; const std::vector<CDItemSets>& GetEntries(void) const;
}; };

View File

@ -1,7 +1,6 @@
#include "CDLevelProgressionLookupTable.h" #include "CDLevelProgressionLookupTable.h"
//! Constructor void CDLevelProgressionLookupTable::LoadValuesFromDatabase() {
CDLevelProgressionLookupTable::CDLevelProgressionLookupTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -32,7 +31,6 @@ CDLevelProgressionLookupTable::CDLevelProgressionLookupTable(void) {
tableData.finalize(); tableData.finalize();
} }
//! Queries the table with a custom "where" clause
std::vector<CDLevelProgressionLookup> CDLevelProgressionLookupTable::Query(std::function<bool(CDLevelProgressionLookup)> predicate) { std::vector<CDLevelProgressionLookup> CDLevelProgressionLookupTable::Query(std::function<bool(CDLevelProgressionLookup)> predicate) {
std::vector<CDLevelProgressionLookup> data = cpplinq::from(this->entries) std::vector<CDLevelProgressionLookup> data = cpplinq::from(this->entries)
@ -42,8 +40,7 @@ std::vector<CDLevelProgressionLookup> CDLevelProgressionLookupTable::Query(std::
return data; return data;
} }
//! Gets all the entries in the table const std::vector<CDLevelProgressionLookup>& CDLevelProgressionLookupTable::GetEntries() const {
std::vector<CDLevelProgressionLookup> CDLevelProgressionLookupTable::GetEntries(void) const {
return this->entries; return this->entries;
} }

View File

@ -14,10 +14,10 @@ private:
std::vector<CDLevelProgressionLookup> entries; std::vector<CDLevelProgressionLookup> entries;
public: public:
CDLevelProgressionLookupTable(); void LoadValuesFromDatabase();
// 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);
// Gets all the entries in the table const std::vector<CDLevelProgressionLookup>& GetEntries() const;
std::vector<CDLevelProgressionLookup> GetEntries(void) const;
}; };

View File

@ -1,7 +1,6 @@
#include "CDLootMatrixTable.h" #include "CDLootMatrixTable.h"
//! Constructor void CDLootMatrixTable::LoadValuesFromDatabase() {
CDLootMatrixTable::CDLootMatrixTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -47,7 +46,7 @@ std::vector<CDLootMatrix> CDLootMatrixTable::Query(std::function<bool(CDLootMatr
return data; return data;
} }
const std::vector<CDLootMatrix>& CDLootMatrixTable::GetEntries(void) const { const std::vector<CDLootMatrix>& CDLootMatrixTable::GetEntries() const {
return this->entries; return this->entries;
} }

View File

@ -20,10 +20,10 @@ private:
std::vector<CDLootMatrix> entries; std::vector<CDLootMatrix> entries;
public: public:
CDLootMatrixTable(); void LoadValuesFromDatabase();
// 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);
const std::vector<CDLootMatrix>& GetEntries(void) const; const std::vector<CDLootMatrix>& GetEntries() const;
}; };

View File

@ -1,7 +1,6 @@
#include "CDLootTableTable.h" #include "CDLootTableTable.h"
//! Constructor void CDLootTableTable::LoadValuesFromDatabase() {
CDLootTableTable::CDLootTableTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -46,7 +45,7 @@ std::vector<CDLootTable> CDLootTableTable::Query(std::function<bool(CDLootTable)
} }
//! Gets all the entries in the table //! Gets all the entries in the table
const std::vector<CDLootTable>& CDLootTableTable::GetEntries(void) const { const std::vector<CDLootTable>& CDLootTableTable::GetEntries() const {
return this->entries; return this->entries;
} }

View File

@ -16,10 +16,10 @@ private:
std::vector<CDLootTable> entries; std::vector<CDLootTable> entries;
public: public:
CDLootTableTable(); void LoadValuesFromDatabase();
// 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);
const std::vector<CDLootTable>& GetEntries(void) const; const std::vector<CDLootTable>& GetEntries() const;
}; };

View File

@ -1,7 +1,6 @@
#include "CDMissionEmailTable.h" #include "CDMissionEmailTable.h"
//! Constructor void CDMissionEmailTable::LoadValuesFromDatabase() {
CDMissionEmailTable::CDMissionEmailTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -48,7 +47,7 @@ std::vector<CDMissionEmail> CDMissionEmailTable::Query(std::function<bool(CDMiss
} }
//! Gets all the entries in the table //! Gets all the entries in the table
std::vector<CDMissionEmail> CDMissionEmailTable::GetEntries(void) const { const std::vector<CDMissionEmail>& CDMissionEmailTable::GetEntries() const {
return this->entries; return this->entries;
} }

View File

@ -20,9 +20,9 @@ private:
std::vector<CDMissionEmail> entries; std::vector<CDMissionEmail> entries;
public: public:
CDMissionEmailTable(); void LoadValuesFromDatabase();
// 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);
std::vector<CDMissionEmail> GetEntries(void) const; const std::vector<CDMissionEmail>& GetEntries() const;
}; };

View File

@ -1,7 +1,6 @@
#include "CDMissionNPCComponentTable.h" #include "CDMissionNPCComponentTable.h"
//! Constructor void CDMissionNPCComponentTable::LoadValuesFromDatabase() {
CDMissionNPCComponentTable::CDMissionNPCComponentTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -45,7 +44,7 @@ std::vector<CDMissionNPCComponent> CDMissionNPCComponentTable::Query(std::functi
} }
//! Gets all the entries in the table //! Gets all the entries in the table
std::vector<CDMissionNPCComponent> CDMissionNPCComponentTable::GetEntries(void) const { const std::vector<CDMissionNPCComponent>& CDMissionNPCComponentTable::GetEntries() const {
return this->entries; return this->entries;
} }

View File

@ -16,12 +16,12 @@ private:
std::vector<CDMissionNPCComponent> entries; std::vector<CDMissionNPCComponent> entries;
public: public:
CDMissionNPCComponentTable(); void LoadValuesFromDatabase();
// 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);
// Gets all the entries in the table // Gets all the entries in the table
std::vector<CDMissionNPCComponent> GetEntries(void) const; const std::vector<CDMissionNPCComponent>& GetEntries() const;
}; };

View File

@ -1,7 +1,6 @@
#include "CDMissionTasksTable.h" #include "CDMissionTasksTable.h"
//! Constructor void CDMissionTasksTable::LoadValuesFromDatabase() {
CDMissionTasksTable::CDMissionTasksTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -56,16 +55,14 @@ std::vector<CDMissionTasks*> CDMissionTasksTable::GetByMissionID(uint32_t missio
for (auto& entry : this->entries) { for (auto& entry : this->entries) {
if (entry.id == missionID) { if (entry.id == missionID) {
CDMissionTasks* task = const_cast<CDMissionTasks*>(&entry); tasks.push_back(&entry);
tasks.push_back(task);
} }
} }
return tasks; return tasks;
} }
const std::vector<CDMissionTasks>& CDMissionTasksTable::GetEntries(void) const { const std::vector<CDMissionTasks>& CDMissionTasksTable::GetEntries() const {
return this->entries; return this->entries;
} }

View File

@ -24,12 +24,12 @@ private:
std::vector<CDMissionTasks> entries; std::vector<CDMissionTasks> entries;
public: public:
CDMissionTasksTable(); void LoadValuesFromDatabase();
// 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);
std::vector<CDMissionTasks*> GetByMissionID(uint32_t missionID); std::vector<CDMissionTasks*> GetByMissionID(uint32_t missionID);
const std::vector<CDMissionTasks>& GetEntries(void) const; const std::vector<CDMissionTasks>& GetEntries() const;
}; };

View File

@ -2,8 +2,7 @@
CDMissions CDMissionsTable::Default = {}; CDMissions CDMissionsTable::Default = {};
//! Constructor void CDMissionsTable::LoadValuesFromDatabase() {
CDMissionsTable::CDMissionsTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;

View File

@ -65,12 +65,12 @@ private:
std::vector<CDMissions> entries; std::vector<CDMissions> entries;
public: public:
CDMissionsTable(); void LoadValuesFromDatabase();
// 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);
// Gets all the entries in the table // Gets all the entries in the table
const std::vector<CDMissions>& GetEntries(void) const; const std::vector<CDMissions>& GetEntries() const;
const CDMissions* GetPtrByMissionID(uint32_t missionID) const; const CDMissions* GetPtrByMissionID(uint32_t missionID) const;

View File

@ -1,7 +1,6 @@
#include "CDMovementAIComponentTable.h" #include "CDMovementAIComponentTable.h"
//! Constructor void CDMovementAIComponentTable::LoadValuesFromDatabase() {
CDMovementAIComponentTable::CDMovementAIComponentTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -37,7 +36,6 @@ CDMovementAIComponentTable::CDMovementAIComponentTable(void) {
tableData.finalize(); tableData.finalize();
} }
//! Queries the table with a custom "where" clause
std::vector<CDMovementAIComponent> CDMovementAIComponentTable::Query(std::function<bool(CDMovementAIComponent)> predicate) { std::vector<CDMovementAIComponent> CDMovementAIComponentTable::Query(std::function<bool(CDMovementAIComponent)> predicate) {
std::vector<CDMovementAIComponent> data = cpplinq::from(this->entries) std::vector<CDMovementAIComponent> data = cpplinq::from(this->entries)
@ -47,8 +45,7 @@ std::vector<CDMovementAIComponent> CDMovementAIComponentTable::Query(std::functi
return data; return data;
} }
//! Gets all the entries in the table const std::vector<CDMovementAIComponent>& CDMovementAIComponentTable::GetEntries(void) const {
std::vector<CDMovementAIComponent> CDMovementAIComponentTable::GetEntries(void) const {
return this->entries; return this->entries;
} }

View File

@ -19,10 +19,10 @@ private:
std::vector<CDMovementAIComponent> entries; std::vector<CDMovementAIComponent> entries;
public: public:
CDMovementAIComponentTable(); void LoadValuesFromDatabase();
// 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);
// Gets all the entries in the table // Gets all the entries in the table
std::vector<CDMovementAIComponent> GetEntries(void) const; const std::vector<CDMovementAIComponent>& GetEntries() const;
}; };

View File

@ -1,7 +1,6 @@
#include "CDObjectSkillsTable.h" #include "CDObjectSkillsTable.h"
//! Constructor void CDObjectSkillsTable::LoadValuesFromDatabase() {
CDObjectSkillsTable::CDObjectSkillsTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -33,7 +32,6 @@ CDObjectSkillsTable::CDObjectSkillsTable(void) {
tableData.finalize(); tableData.finalize();
} }
//! Queries the table with a custom "where" clause
std::vector<CDObjectSkills> CDObjectSkillsTable::Query(std::function<bool(CDObjectSkills)> predicate) { std::vector<CDObjectSkills> CDObjectSkillsTable::Query(std::function<bool(CDObjectSkills)> predicate) {
std::vector<CDObjectSkills> data = cpplinq::from(this->entries) std::vector<CDObjectSkills> data = cpplinq::from(this->entries)
@ -43,7 +41,6 @@ std::vector<CDObjectSkills> CDObjectSkillsTable::Query(std::function<bool(CDObje
return data; return data;
} }
//! Gets all the entries in the table const std::vector<CDObjectSkills>& CDObjectSkillsTable::GetEntries() const {
std::vector<CDObjectSkills> CDObjectSkillsTable::GetEntries(void) const {
return this->entries; return this->entries;
} }

View File

@ -15,12 +15,12 @@ private:
std::vector<CDObjectSkills> entries; std::vector<CDObjectSkills> entries;
public: public:
CDObjectSkillsTable(); void LoadValuesFromDatabase();
// 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);
// Gets all the entries in the table // Gets all the entries in the table
std::vector<CDObjectSkills> GetEntries(void) const; const std::vector<CDObjectSkills>& GetEntries() const;
}; };

View File

@ -1,8 +1,6 @@
#include "CDObjectsTable.h" #include "CDObjectsTable.h"
//! Constructor void CDObjectsTable::LoadValuesFromDatabase() {
CDObjectsTable::CDObjectsTable(void) {
#ifdef CDCLIENT_CACHE_ALL
// 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 Objects"); auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Objects");
@ -20,25 +18,24 @@ CDObjectsTable::CDObjectsTable(void) {
CDObjects entry; CDObjects entry;
entry.id = tableData.getIntField("id", -1); entry.id = tableData.getIntField("id", -1);
entry.name = tableData.getStringField("name", ""); entry.name = tableData.getStringField("name", "");
entry.placeable = tableData.getIntField("placeable", -1); UNUSED_COLUMN(entry.placeable = tableData.getIntField("placeable", -1);)
entry.type = tableData.getStringField("type", ""); entry.type = tableData.getStringField("type", "");
entry.description = tableData.getStringField("description", ""); UNUSED_COLUMN(entry.description = tableData.getStringField("description", "");)
entry.localize = tableData.getIntField("localize", -1); UNUSED_COLUMN(entry.localize = tableData.getIntField("localize", -1);)
entry.npcTemplateID = tableData.getIntField("npcTemplateID", -1); UNUSED_COLUMN(entry.npcTemplateID = tableData.getIntField("npcTemplateID", -1);)
entry.displayName = tableData.getStringField("displayName", ""); UNUSED_COLUMN(entry.displayName = tableData.getStringField("displayName", "");)
entry.interactionDistance = tableData.getFloatField("interactionDistance", -1.0f); entry.interactionDistance = tableData.getFloatField("interactionDistance", -1.0f);
entry.nametag = tableData.getIntField("nametag", -1); UNUSED_COLUMN(entry.nametag = tableData.getIntField("nametag", -1);)
entry._internalNotes = tableData.getStringField("_internalNotes", ""); UNUSED_COLUMN(entry._internalNotes = tableData.getStringField("_internalNotes", "");)
entry.locStatus = tableData.getIntField("locStatus", -1); UNUSED_COLUMN(entry.locStatus = tableData.getIntField("locStatus", -1);)
entry.gate_version = tableData.getStringField("gate_version", ""); UNUSED_COLUMN(entry.gate_version = tableData.getStringField("gate_version", "");)
entry.HQ_valid = tableData.getIntField("HQ_valid", -1); UNUSED_COLUMN(entry.HQ_valid = tableData.getIntField("HQ_valid", -1);)
this->entries.insert(std::make_pair(entry.id, entry)); this->entries.insert(std::make_pair(entry.id, entry));
tableData.nextRow(); tableData.nextRow();
} }
tableData.finalize(); tableData.finalize();
#endif
m_default.id = 0; m_default.id = 0;
} }
@ -49,12 +46,10 @@ const CDObjects& CDObjectsTable::GetByID(unsigned int LOT) {
return it->second; return it->second;
} }
#ifndef CDCLIENT_CACHE_ALL auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM Objects WHERE id = ?;");
std::stringstream query; query.bind(1, static_cast<int32_t>(LOT));
query << "SELECT * FROM Objects WHERE id = " << std::to_string(LOT); auto tableData = query.execQuery();
auto tableData = CDClientDatabase::ExecuteQuery(query.str());
if (tableData.eof()) { if (tableData.eof()) {
this->entries.insert(std::make_pair(LOT, m_default)); this->entries.insert(std::make_pair(LOT, m_default));
return m_default; return m_default;
@ -88,7 +83,6 @@ const CDObjects& CDObjectsTable::GetByID(unsigned int LOT) {
if (it2 != entries.end()) { if (it2 != entries.end()) {
return it2->second; return it2->second;
} }
#endif
return m_default; return m_default;
} }

View File

@ -26,7 +26,7 @@ private:
CDObjects m_default; CDObjects m_default;
public: public:
CDObjectsTable(); void LoadValuesFromDatabase();
// Gets an entry by ID // Gets an entry by ID
const CDObjects& GetByID(unsigned int LOT); const CDObjects& GetByID(unsigned int LOT);
}; };

View File

@ -1,7 +1,6 @@
#include "CDPackageComponentTable.h" #include "CDPackageComponentTable.h"
//! Constructor void CDPackageComponentTable::LoadValuesFromDatabase() {
CDPackageComponentTable::CDPackageComponentTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -43,7 +42,7 @@ std::vector<CDPackageComponent> CDPackageComponentTable::Query(std::function<boo
} }
//! Gets all the entries in the table //! Gets all the entries in the table
std::vector<CDPackageComponent> CDPackageComponentTable::GetEntries(void) const { const std::vector<CDPackageComponent>& CDPackageComponentTable::GetEntries() const {
return this->entries; return this->entries;
} }

View File

@ -14,9 +14,9 @@ private:
std::vector<CDPackageComponent> entries; std::vector<CDPackageComponent> entries;
public: public:
CDPackageComponentTable(void); void LoadValuesFromDatabase();
// Queries the table with a custom "where" clause // Queries the table with a custom "where" clause
std::vector<CDPackageComponent> Query(std::function<bool(CDPackageComponent)> predicate); std::vector<CDPackageComponent> Query(std::function<bool(CDPackageComponent)> predicate);
std::vector<CDPackageComponent> GetEntries(void) const; const std::vector<CDPackageComponent>& GetEntries() const;
}; };

View File

@ -1,46 +1,35 @@
#include "CDPhysicsComponentTable.h" #include "CDPhysicsComponentTable.h"
CDPhysicsComponentTable::CDPhysicsComponentTable(void) { void CDPhysicsComponentTable::LoadValuesFromDatabase() {
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PhysicsComponent"); auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PhysicsComponent");
while (!tableData.eof()) { while (!tableData.eof()) {
CDPhysicsComponent* entry = new CDPhysicsComponent(); CDPhysicsComponent entry;
entry->id = tableData.getIntField("id", -1); entry.id = tableData.getIntField("id", -1);
entry->bStatic = tableData.getIntField("static", -1) != 0; entry.bStatic = tableData.getIntField("static", -1) != 0;
entry->physicsAsset = tableData.getStringField("physics_asset", ""); entry.physicsAsset = tableData.getStringField("physics_asset", "");
UNUSED(entry->jump = tableData.getIntField("jump", -1) != 0); UNUSED(entry->jump = tableData.getIntField("jump", -1) != 0);
UNUSED(entry->doublejump = tableData.getIntField("doublejump", -1) != 0); UNUSED(entry->doublejump = tableData.getIntField("doublejump", -1) != 0);
entry->speed = tableData.getFloatField("speed", -1); entry.speed = tableData.getFloatField("speed", -1);
UNUSED(entry->rotSpeed = tableData.getFloatField("rotSpeed", -1)); UNUSED(entry->rotSpeed = tableData.getFloatField("rotSpeed", -1));
entry->playerHeight = tableData.getFloatField("playerHeight"); entry.playerHeight = tableData.getFloatField("playerHeight");
entry->playerRadius = tableData.getFloatField("playerRadius"); entry.playerRadius = tableData.getFloatField("playerRadius");
entry->pcShapeType = tableData.getIntField("pcShapeType"); entry.pcShapeType = tableData.getIntField("pcShapeType");
entry->collisionGroup = tableData.getIntField("collisionGroup"); entry.collisionGroup = tableData.getIntField("collisionGroup");
UNUSED(entry->airSpeed = tableData.getFloatField("airSpeed")); UNUSED(entry->airSpeed = tableData.getFloatField("airSpeed"));
UNUSED(entry->boundaryAsset = tableData.getStringField("boundaryAsset")); UNUSED(entry->boundaryAsset = tableData.getStringField("boundaryAsset"));
UNUSED(entry->jumpAirSpeed = tableData.getFloatField("jumpAirSpeed")); UNUSED(entry->jumpAirSpeed = tableData.getFloatField("jumpAirSpeed"));
UNUSED(entry->friction = tableData.getFloatField("friction")); UNUSED(entry->friction = tableData.getFloatField("friction"));
UNUSED(entry->gravityVolumeAsset = tableData.getStringField("gravityVolumeAsset")); UNUSED(entry->gravityVolumeAsset = tableData.getStringField("gravityVolumeAsset"));
m_entries.insert(std::make_pair(entry->id, entry)); m_entries.insert(std::make_pair(entry.id, entry));
tableData.nextRow(); tableData.nextRow();
} }
tableData.finalize(); tableData.finalize();
} }
CDPhysicsComponentTable::~CDPhysicsComponentTable() {
for (auto e : m_entries) {
if (e.second) delete e.second;
}
m_entries.clear();
}
CDPhysicsComponent* CDPhysicsComponentTable::GetByID(unsigned int componentID) { CDPhysicsComponent* CDPhysicsComponentTable::GetByID(unsigned int componentID) {
for (auto e : m_entries) { auto itr = m_entries.find(componentID);
if (e.first == componentID) return e.second; return itr != m_entries.end() ? &itr->second : nullptr;
}
return nullptr;
} }

View File

@ -23,12 +23,11 @@ struct CDPhysicsComponent {
class CDPhysicsComponentTable : public CDTable<CDPhysicsComponentTable> { class CDPhysicsComponentTable : public CDTable<CDPhysicsComponentTable> {
public: public:
CDPhysicsComponentTable(); void LoadValuesFromDatabase();
~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);
private: private:
std::map<unsigned int, CDPhysicsComponent*> m_entries; std::map<unsigned int, CDPhysicsComponent> m_entries;
}; };

View File

@ -1,7 +1,6 @@
#include "CDPropertyEntranceComponentTable.h" #include "CDPropertyEntranceComponentTable.h"
CDPropertyEntranceComponentTable::CDPropertyEntranceComponentTable() { void CDPropertyEntranceComponentTable::LoadValuesFromDatabase() {
// First, get the size of the table // First, get the size of the table
size_t size = 0; size_t size = 0;

View File

@ -11,12 +11,12 @@ struct CDPropertyEntranceComponent {
class CDPropertyEntranceComponentTable : public CDTable<CDPropertyEntranceComponentTable> { class CDPropertyEntranceComponentTable : public CDTable<CDPropertyEntranceComponentTable> {
public: public:
CDPropertyEntranceComponentTable(); void LoadValuesFromDatabase();
// 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);
// Gets all the entries in the table // Gets all the entries in the table
[[nodiscard]] std::vector<CDPropertyEntranceComponent> GetEntries() const { return entries; } [[nodiscard]] const std::vector<CDPropertyEntranceComponent>& GetEntries() const { return entries; }
private: private:
std::vector<CDPropertyEntranceComponent> entries{}; std::vector<CDPropertyEntranceComponent> entries{};
CDPropertyEntranceComponent defaultEntry{}; CDPropertyEntranceComponent defaultEntry{};

View File

@ -1,6 +1,6 @@
#include "CDPropertyTemplateTable.h" #include "CDPropertyTemplateTable.h"
CDPropertyTemplateTable::CDPropertyTemplateTable() { void CDPropertyTemplateTable::LoadValuesFromDatabase() {
// First, get the size of the table // First, get the size of the table
size_t size = 0; size_t size = 0;

View File

@ -10,7 +10,7 @@ struct CDPropertyTemplate {
class CDPropertyTemplateTable : public CDTable<CDPropertyTemplateTable> { class CDPropertyTemplateTable : public CDTable<CDPropertyTemplateTable> {
public: public:
CDPropertyTemplateTable(); void LoadValuesFromDatabase();
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

@ -1,7 +1,6 @@
#include "CDProximityMonitorComponentTable.h" #include "CDProximityMonitorComponentTable.h"
//! Constructor void CDProximityMonitorComponentTable::LoadValuesFromDatabase() {
CDProximityMonitorComponentTable::CDProximityMonitorComponentTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -33,7 +32,6 @@ CDProximityMonitorComponentTable::CDProximityMonitorComponentTable(void) {
tableData.finalize(); tableData.finalize();
} }
//! Queries the table with a custom "where" clause
std::vector<CDProximityMonitorComponent> CDProximityMonitorComponentTable::Query(std::function<bool(CDProximityMonitorComponent)> predicate) { std::vector<CDProximityMonitorComponent> CDProximityMonitorComponentTable::Query(std::function<bool(CDProximityMonitorComponent)> predicate) {
std::vector<CDProximityMonitorComponent> data = cpplinq::from(this->entries) std::vector<CDProximityMonitorComponent> data = cpplinq::from(this->entries)
@ -43,8 +41,7 @@ std::vector<CDProximityMonitorComponent> CDProximityMonitorComponentTable::Query
return data; return data;
} }
//! Gets all the entries in the table const std::vector<CDProximityMonitorComponent>& CDProximityMonitorComponentTable::GetEntries() const {
std::vector<CDProximityMonitorComponent> CDProximityMonitorComponentTable::GetEntries(void) const {
return this->entries; return this->entries;
} }

View File

@ -15,9 +15,9 @@ private:
std::vector<CDProximityMonitorComponent> entries; std::vector<CDProximityMonitorComponent> entries;
public: public:
CDProximityMonitorComponentTable(void); void LoadValuesFromDatabase();
//! Queries the table with a custom "where" clause //! Queries the table with a custom "where" clause
std::vector<CDProximityMonitorComponent> Query(std::function<bool(CDProximityMonitorComponent)> predicate); std::vector<CDProximityMonitorComponent> Query(std::function<bool(CDProximityMonitorComponent)> predicate);
std::vector<CDProximityMonitorComponent> GetEntries(void) const; const std::vector<CDProximityMonitorComponent>& GetEntries() const;
}; };

View File

@ -1,7 +1,7 @@
#include "CDRailActivatorComponent.h" #include "CDRailActivatorComponent.h"
#include "GeneralUtils.h" #include "GeneralUtils.h"
CDRailActivatorComponentTable::CDRailActivatorComponentTable() { void CDRailActivatorComponentTable::LoadValuesFromDatabase() {
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM RailActivatorComponent;"); auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM RailActivatorComponent;");
while (!tableData.eof()) { while (!tableData.eof()) {
CDRailActivatorComponent entry; CDRailActivatorComponent entry;
@ -52,7 +52,7 @@ CDRailActivatorComponent CDRailActivatorComponentTable::GetEntryByID(int32_t id)
return {}; return {};
} }
std::vector<CDRailActivatorComponent> CDRailActivatorComponentTable::GetEntries() const { const std::vector<CDRailActivatorComponent>& CDRailActivatorComponentTable::GetEntries() const {
return m_Entries; return m_Entries;
} }

View File

@ -22,10 +22,10 @@ struct CDRailActivatorComponent {
class CDRailActivatorComponentTable : public CDTable<CDRailActivatorComponentTable> { class CDRailActivatorComponentTable : public CDTable<CDRailActivatorComponentTable> {
public: public:
CDRailActivatorComponentTable(); void LoadValuesFromDatabase();
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]] const std::vector<CDRailActivatorComponent>& GetEntries() const;
private: private:
static std::pair<uint32_t, std::u16string> EffectPairFromString(std::string& str); static std::pair<uint32_t, std::u16string> EffectPairFromString(std::string& str);
std::vector<CDRailActivatorComponent> m_Entries{}; std::vector<CDRailActivatorComponent> m_Entries{};

View File

@ -1,7 +1,6 @@
#include "CDRarityTableTable.h" #include "CDRarityTableTable.h"
//! Constructor void CDRarityTableTable::LoadValuesFromDatabase() {
CDRarityTableTable::CDRarityTableTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -44,7 +43,7 @@ std::vector<CDRarityTable> CDRarityTableTable::Query(std::function<bool(CDRarity
} }
//! Gets all the entries in the table //! Gets all the entries in the table
const std::vector<CDRarityTable>& CDRarityTableTable::GetEntries(void) const { const std::vector<CDRarityTable>& CDRarityTableTable::GetEntries() const {
return this->entries; return this->entries;
} }

View File

@ -31,7 +31,7 @@ private:
std::vector<CDRarityTable> entries; std::vector<CDRarityTable> entries;
public: public:
CDRarityTableTable(); void LoadValuesFromDatabase();
// 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

@ -1,7 +1,6 @@
#include "CDRebuildComponentTable.h" #include "CDRebuildComponentTable.h"
//! Constructor void CDRebuildComponentTable::LoadValuesFromDatabase() {
CDRebuildComponentTable::CDRebuildComponentTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -39,7 +38,6 @@ CDRebuildComponentTable::CDRebuildComponentTable(void) {
tableData.finalize(); tableData.finalize();
} }
//! Queries the table with a custom "where" clause
std::vector<CDRebuildComponent> CDRebuildComponentTable::Query(std::function<bool(CDRebuildComponent)> predicate) { std::vector<CDRebuildComponent> CDRebuildComponentTable::Query(std::function<bool(CDRebuildComponent)> predicate) {
std::vector<CDRebuildComponent> data = cpplinq::from(this->entries) std::vector<CDRebuildComponent> data = cpplinq::from(this->entries)
@ -49,8 +47,7 @@ std::vector<CDRebuildComponent> CDRebuildComponentTable::Query(std::function<boo
return data; return data;
} }
//! Gets all the entries in the table const std::vector<CDRebuildComponent>& CDRebuildComponentTable::GetEntries() const {
std::vector<CDRebuildComponent> CDRebuildComponentTable::GetEntries(void) const {
return this->entries; return this->entries;
} }

View File

@ -21,10 +21,10 @@ private:
std::vector<CDRebuildComponent> entries; std::vector<CDRebuildComponent> entries;
public: public:
CDRebuildComponentTable(); void LoadValuesFromDatabase();
// 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);
std::vector<CDRebuildComponent> GetEntries() const; const std::vector<CDRebuildComponent>& GetEntries() const;
}; };

View File

@ -1,35 +1,27 @@
#include "CDRewardsTable.h" #include "CDRewardsTable.h"
CDRewardsTable::CDRewardsTable(void) { void CDRewardsTable::LoadValuesFromDatabase() {
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Rewards"); auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Rewards");
while (!tableData.eof()) { while (!tableData.eof()) {
CDRewards* entry = new CDRewards(); CDRewards entry;
entry->id = tableData.getIntField("id", -1); entry.id = tableData.getIntField("id", -1);
entry->levelID = tableData.getIntField("LevelID", -1); entry.levelID = tableData.getIntField("LevelID", -1);
entry->missionID = tableData.getIntField("MissionID", -1); entry.missionID = tableData.getIntField("MissionID", -1);
entry->rewardType = tableData.getIntField("RewardType", -1); entry.rewardType = tableData.getIntField("RewardType", -1);
entry->value = tableData.getIntField("value", -1); entry.value = tableData.getIntField("value", -1);
entry->count = tableData.getIntField("count", -1); entry.count = tableData.getIntField("count", -1);
m_entries.insert(std::make_pair(entry->id, entry)); m_entries.insert(std::make_pair(entry.id, entry));
tableData.nextRow(); tableData.nextRow();
} }
tableData.finalize(); tableData.finalize();
} }
CDRewardsTable::~CDRewardsTable(void) { std::vector<CDRewards> CDRewardsTable::GetByLevelID(uint32_t levelID) {
for (auto e : m_entries) { std::vector<CDRewards> result{};
if (e.second) delete e.second;
}
m_entries.clear();
}
std::vector<CDRewards*> CDRewardsTable::GetByLevelID(uint32_t levelID) {
std::vector<CDRewards*> result{};
for (const auto& e : m_entries) { for (const auto& e : m_entries) {
if (e.second->levelID == levelID) result.push_back(e.second); if (e.second.levelID == levelID) result.push_back(e.second);
} }
return result; return result;

View File

@ -13,12 +13,11 @@ struct CDRewards {
class CDRewardsTable : public CDTable<CDRewardsTable> { class CDRewardsTable : public CDTable<CDRewardsTable> {
public: public:
CDRewardsTable(); void LoadValuesFromDatabase();
~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);
private: private:
std::map<uint32_t, CDRewards*> m_entries; std::map<uint32_t, CDRewards> m_entries;
}; };

View File

@ -1,7 +1,6 @@
#include "CDScriptComponentTable.h" #include "CDScriptComponentTable.h"
//! Constructor void CDScriptComponentTable::LoadValuesFromDatabase() {
CDScriptComponentTable::CDScriptComponentTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;

View File

@ -15,7 +15,7 @@ private:
CDScriptComponent m_ToReturnWhenNoneFound; CDScriptComponent m_ToReturnWhenNoneFound;
public: public:
CDScriptComponentTable(); void LoadValuesFromDatabase();
// Gets an entry by scriptID // Gets an entry by scriptID
const CDScriptComponent& GetByID(unsigned int id); const CDScriptComponent& GetByID(unsigned int id);
}; };

View File

@ -1,8 +1,6 @@
#include "CDSkillBehaviorTable.h" #include "CDSkillBehaviorTable.h"
//#include "Logger.hpp"
//! Constructor void CDSkillBehaviorTable::LoadValuesFromDatabase() {
CDSkillBehaviorTable::CDSkillBehaviorTable(void) {
m_empty = CDSkillBehavior(); m_empty = CDSkillBehavior();
// First, get the size of the table // First, get the size of the table
@ -51,13 +49,6 @@ CDSkillBehaviorTable::CDSkillBehaviorTable(void) {
tableData.finalize(); tableData.finalize();
} }
//! Queries the table with a custom "where" clause
std::vector<CDSkillBehavior> CDSkillBehaviorTable::Query(std::function<bool(CDSkillBehavior)> predicate) {
std::vector<CDSkillBehavior> data; //So MSVC shuts up
return data;
}
//! Gets an entry by ID
const CDSkillBehavior& CDSkillBehaviorTable::GetSkillByID(unsigned int skillID) { const CDSkillBehavior& CDSkillBehaviorTable::GetSkillByID(unsigned int skillID) {
std::map<unsigned int, CDSkillBehavior>::iterator it = this->entries.find(skillID); std::map<unsigned int, CDSkillBehavior>::iterator it = this->entries.find(skillID);
if (it != this->entries.end()) { if (it != this->entries.end()) {

View File

@ -31,9 +31,7 @@ private:
CDSkillBehavior m_empty; CDSkillBehavior m_empty;
public: public:
CDSkillBehaviorTable(); void LoadValuesFromDatabase();
// Queries the table with a custom "where" clause
std::vector<CDSkillBehavior> Query(std::function<bool(CDSkillBehavior)> predicate);
// Gets an entry by skillID // Gets an entry by skillID
const CDSkillBehavior& GetSkillByID(unsigned int skillID); const CDSkillBehavior& GetSkillByID(unsigned int skillID);

View File

@ -1,7 +1,6 @@
#include "CDVendorComponentTable.h" #include "CDVendorComponentTable.h"
//! Constructor void CDVendorComponentTable::LoadValuesFromDatabase() {
CDVendorComponentTable::CDVendorComponentTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;
@ -45,7 +44,7 @@ std::vector<CDVendorComponent> CDVendorComponentTable::Query(std::function<bool(
} }
//! Gets all the entries in the table //! Gets all the entries in the table
std::vector<CDVendorComponent> CDVendorComponentTable::GetEntries(void) const { const std::vector<CDVendorComponent>& CDVendorComponentTable::GetEntries() const {
return this->entries; return this->entries;
} }

View File

@ -16,10 +16,10 @@ private:
std::vector<CDVendorComponent> entries; std::vector<CDVendorComponent> entries;
public: public:
CDVendorComponentTable(); void LoadValuesFromDatabase();
// 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);
std::vector<CDVendorComponent> GetEntries(void) const; const std::vector<CDVendorComponent>& GetEntries(void) const;
}; };

View File

@ -1,7 +1,6 @@
#include "CDZoneTableTable.h" #include "CDZoneTableTable.h"
//! Constructor void CDZoneTableTable::LoadValuesFromDatabase() {
CDZoneTableTable::CDZoneTableTable(void) {
// First, get the size of the table // First, get the size of the table
unsigned int size = 0; unsigned int size = 0;

View File

@ -38,7 +38,7 @@ private:
std::map<unsigned int, CDZoneTable> m_Entries; std::map<unsigned int, CDZoneTable> m_Entries;
public: public:
CDZoneTableTable(); void LoadValuesFromDatabase();
// 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

@ -1019,62 +1019,60 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
*/ */
bool destroyableSerialized = false; bool destroyableSerialized = false;
bool bIsInitialUpdate = false; bool bIsInitialUpdate = packetType == eReplicaPacketType::CONSTRUCTION;
if (packetType == eReplicaPacketType::CONSTRUCTION) bIsInitialUpdate = true;
unsigned int flags = 0;
PossessableComponent* possessableComponent; PossessableComponent* possessableComponent;
if (TryGetComponent(eReplicaComponentType::POSSESSABLE, possessableComponent)) { if (TryGetComponent(eReplicaComponentType::POSSESSABLE, possessableComponent)) {
possessableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); possessableComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
ModuleAssemblyComponent* moduleAssemblyComponent; ModuleAssemblyComponent* moduleAssemblyComponent;
if (TryGetComponent(eReplicaComponentType::MODULE_ASSEMBLY, moduleAssemblyComponent)) { if (TryGetComponent(eReplicaComponentType::MODULE_ASSEMBLY, moduleAssemblyComponent)) {
moduleAssemblyComponent->Serialize(outBitStream, bIsInitialUpdate, flags); moduleAssemblyComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
ControllablePhysicsComponent* controllablePhysicsComponent; ControllablePhysicsComponent* controllablePhysicsComponent;
if (TryGetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS, controllablePhysicsComponent)) { if (TryGetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS, controllablePhysicsComponent)) {
controllablePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags); controllablePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
SimplePhysicsComponent* simplePhysicsComponent; SimplePhysicsComponent* simplePhysicsComponent;
if (TryGetComponent(eReplicaComponentType::SIMPLE_PHYSICS, simplePhysicsComponent)) { if (TryGetComponent(eReplicaComponentType::SIMPLE_PHYSICS, simplePhysicsComponent)) {
simplePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags); simplePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
RigidbodyPhantomPhysicsComponent* rigidbodyPhantomPhysics; RigidbodyPhantomPhysicsComponent* rigidbodyPhantomPhysics;
if (TryGetComponent(eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS, rigidbodyPhantomPhysics)) { if (TryGetComponent(eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS, rigidbodyPhantomPhysics)) {
rigidbodyPhantomPhysics->Serialize(outBitStream, bIsInitialUpdate, flags); rigidbodyPhantomPhysics->Serialize(outBitStream, bIsInitialUpdate);
} }
VehiclePhysicsComponent* vehiclePhysicsComponent; VehiclePhysicsComponent* vehiclePhysicsComponent;
if (TryGetComponent(eReplicaComponentType::VEHICLE_PHYSICS, vehiclePhysicsComponent)) { if (TryGetComponent(eReplicaComponentType::VEHICLE_PHYSICS, vehiclePhysicsComponent)) {
vehiclePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags); vehiclePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
PhantomPhysicsComponent* phantomPhysicsComponent; PhantomPhysicsComponent* phantomPhysicsComponent;
if (TryGetComponent(eReplicaComponentType::PHANTOM_PHYSICS, phantomPhysicsComponent)) { if (TryGetComponent(eReplicaComponentType::PHANTOM_PHYSICS, phantomPhysicsComponent)) {
phantomPhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags); phantomPhysicsComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
SoundTriggerComponent* soundTriggerComponent; SoundTriggerComponent* soundTriggerComponent;
if (TryGetComponent(eReplicaComponentType::SOUND_TRIGGER, soundTriggerComponent)) { if (TryGetComponent(eReplicaComponentType::SOUND_TRIGGER, soundTriggerComponent)) {
soundTriggerComponent->Serialize(outBitStream, bIsInitialUpdate, flags); soundTriggerComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
RacingSoundTriggerComponent* racingSoundTriggerComponent; RacingSoundTriggerComponent* racingSoundTriggerComponent;
if (TryGetComponent(eReplicaComponentType::RACING_SOUND_TRIGGER, racingSoundTriggerComponent)) { if (TryGetComponent(eReplicaComponentType::RACING_SOUND_TRIGGER, racingSoundTriggerComponent)) {
racingSoundTriggerComponent->Serialize(outBitStream, bIsInitialUpdate, flags); racingSoundTriggerComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
BuffComponent* buffComponent; BuffComponent* buffComponent;
if (TryGetComponent(eReplicaComponentType::BUFF, buffComponent)) { if (TryGetComponent(eReplicaComponentType::BUFF, buffComponent)) {
buffComponent->Serialize(outBitStream, bIsInitialUpdate, flags); buffComponent->Serialize(outBitStream, bIsInitialUpdate);
DestroyableComponent* destroyableComponent; DestroyableComponent* destroyableComponent;
if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent)) { if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent)) {
destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); destroyableComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
destroyableSerialized = true; destroyableSerialized = true;
} }
@ -1082,7 +1080,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
if (HasComponent(eReplicaComponentType::COLLECTIBLE)) { if (HasComponent(eReplicaComponentType::COLLECTIBLE)) {
DestroyableComponent* destroyableComponent; DestroyableComponent* destroyableComponent;
if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) { if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) {
destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); destroyableComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
destroyableSerialized = true; destroyableSerialized = true;
outBitStream->Write(m_CollectibleID); // Collectable component outBitStream->Write(m_CollectibleID); // Collectable component
@ -1090,7 +1088,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
PetComponent* petComponent; PetComponent* petComponent;
if (TryGetComponent(eReplicaComponentType::PET, petComponent)) { if (TryGetComponent(eReplicaComponentType::PET, petComponent)) {
petComponent->Serialize(outBitStream, bIsInitialUpdate, flags); petComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
CharacterComponent* characterComponent; CharacterComponent* characterComponent;
@ -1098,7 +1096,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
PossessorComponent* possessorComponent; PossessorComponent* possessorComponent;
if (TryGetComponent(eReplicaComponentType::POSSESSOR, possessorComponent)) { if (TryGetComponent(eReplicaComponentType::POSSESSOR, possessorComponent)) {
possessorComponent->Serialize(outBitStream, bIsInitialUpdate, flags); possessorComponent->Serialize(outBitStream, bIsInitialUpdate);
} else { } else {
// Should never happen, but just to be safe // Should never happen, but just to be safe
outBitStream->Write0(); outBitStream->Write0();
@ -1106,7 +1104,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
LevelProgressionComponent* levelProgressionComponent; LevelProgressionComponent* levelProgressionComponent;
if (TryGetComponent(eReplicaComponentType::LEVEL_PROGRESSION, levelProgressionComponent)) { if (TryGetComponent(eReplicaComponentType::LEVEL_PROGRESSION, levelProgressionComponent)) {
levelProgressionComponent->Serialize(outBitStream, bIsInitialUpdate, flags); levelProgressionComponent->Serialize(outBitStream, bIsInitialUpdate);
} else { } else {
// Should never happen, but just to be safe // Should never happen, but just to be safe
outBitStream->Write0(); outBitStream->Write0();
@ -1114,13 +1112,13 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
PlayerForcedMovementComponent* playerForcedMovementComponent; PlayerForcedMovementComponent* playerForcedMovementComponent;
if (TryGetComponent(eReplicaComponentType::PLAYER_FORCED_MOVEMENT, playerForcedMovementComponent)) { if (TryGetComponent(eReplicaComponentType::PLAYER_FORCED_MOVEMENT, playerForcedMovementComponent)) {
playerForcedMovementComponent->Serialize(outBitStream, bIsInitialUpdate, flags); playerForcedMovementComponent->Serialize(outBitStream, bIsInitialUpdate);
} else { } else {
// Should never happen, but just to be safe // Should never happen, but just to be safe
outBitStream->Write0(); outBitStream->Write0();
} }
characterComponent->Serialize(outBitStream, bIsInitialUpdate, flags); characterComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
if (HasComponent(eReplicaComponentType::ITEM)) { if (HasComponent(eReplicaComponentType::ITEM)) {
@ -1129,93 +1127,93 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
InventoryComponent* inventoryComponent; InventoryComponent* inventoryComponent;
if (TryGetComponent(eReplicaComponentType::INVENTORY, inventoryComponent)) { if (TryGetComponent(eReplicaComponentType::INVENTORY, inventoryComponent)) {
inventoryComponent->Serialize(outBitStream, bIsInitialUpdate, flags); inventoryComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
ScriptComponent* scriptComponent; ScriptComponent* scriptComponent;
if (TryGetComponent(eReplicaComponentType::SCRIPT, scriptComponent)) { if (TryGetComponent(eReplicaComponentType::SCRIPT, scriptComponent)) {
scriptComponent->Serialize(outBitStream, bIsInitialUpdate, flags); scriptComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
SkillComponent* skillComponent; SkillComponent* skillComponent;
if (TryGetComponent(eReplicaComponentType::SKILL, skillComponent)) { if (TryGetComponent(eReplicaComponentType::SKILL, skillComponent)) {
skillComponent->Serialize(outBitStream, bIsInitialUpdate, flags); skillComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
BaseCombatAIComponent* baseCombatAiComponent; BaseCombatAIComponent* baseCombatAiComponent;
if (TryGetComponent(eReplicaComponentType::BASE_COMBAT_AI, baseCombatAiComponent)) { if (TryGetComponent(eReplicaComponentType::BASE_COMBAT_AI, baseCombatAiComponent)) {
baseCombatAiComponent->Serialize(outBitStream, bIsInitialUpdate, flags); baseCombatAiComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
RebuildComponent* rebuildComponent; RebuildComponent* rebuildComponent;
if (TryGetComponent(eReplicaComponentType::QUICK_BUILD, rebuildComponent)) { if (TryGetComponent(eReplicaComponentType::QUICK_BUILD, rebuildComponent)) {
DestroyableComponent* destroyableComponent; DestroyableComponent* destroyableComponent;
if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) { if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) {
destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); destroyableComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
destroyableSerialized = true; destroyableSerialized = true;
rebuildComponent->Serialize(outBitStream, bIsInitialUpdate, flags); rebuildComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
MovingPlatformComponent* movingPlatformComponent; MovingPlatformComponent* movingPlatformComponent;
if (TryGetComponent(eReplicaComponentType::MOVING_PLATFORM, movingPlatformComponent)) { if (TryGetComponent(eReplicaComponentType::MOVING_PLATFORM, movingPlatformComponent)) {
movingPlatformComponent->Serialize(outBitStream, bIsInitialUpdate, flags); movingPlatformComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
SwitchComponent* switchComponent; SwitchComponent* switchComponent;
if (TryGetComponent(eReplicaComponentType::SWITCH, switchComponent)) { if (TryGetComponent(eReplicaComponentType::SWITCH, switchComponent)) {
switchComponent->Serialize(outBitStream, bIsInitialUpdate, flags); switchComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
VendorComponent* vendorComponent; VendorComponent* vendorComponent;
if (TryGetComponent(eReplicaComponentType::VENDOR, vendorComponent)) { if (TryGetComponent(eReplicaComponentType::VENDOR, vendorComponent)) {
vendorComponent->Serialize(outBitStream, bIsInitialUpdate, flags); vendorComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
DonationVendorComponent* donationVendorComponent; DonationVendorComponent* donationVendorComponent;
if (TryGetComponent(eReplicaComponentType::DONATION_VENDOR, donationVendorComponent)) { if (TryGetComponent(eReplicaComponentType::DONATION_VENDOR, donationVendorComponent)) {
donationVendorComponent->Serialize(outBitStream, bIsInitialUpdate, flags); donationVendorComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
BouncerComponent* bouncerComponent; BouncerComponent* bouncerComponent;
if (TryGetComponent(eReplicaComponentType::BOUNCER, bouncerComponent)) { if (TryGetComponent(eReplicaComponentType::BOUNCER, bouncerComponent)) {
bouncerComponent->Serialize(outBitStream, bIsInitialUpdate, flags); bouncerComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
ScriptedActivityComponent* scriptedActivityComponent; ScriptedActivityComponent* scriptedActivityComponent;
if (TryGetComponent(eReplicaComponentType::SCRIPTED_ACTIVITY, scriptedActivityComponent)) { if (TryGetComponent(eReplicaComponentType::SCRIPTED_ACTIVITY, scriptedActivityComponent)) {
scriptedActivityComponent->Serialize(outBitStream, bIsInitialUpdate, flags); scriptedActivityComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
ShootingGalleryComponent* shootingGalleryComponent; ShootingGalleryComponent* shootingGalleryComponent;
if (TryGetComponent(eReplicaComponentType::SHOOTING_GALLERY, shootingGalleryComponent)) { if (TryGetComponent(eReplicaComponentType::SHOOTING_GALLERY, shootingGalleryComponent)) {
shootingGalleryComponent->Serialize(outBitStream, bIsInitialUpdate, flags); shootingGalleryComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
RacingControlComponent* racingControlComponent; RacingControlComponent* racingControlComponent;
if (TryGetComponent(eReplicaComponentType::RACING_CONTROL, racingControlComponent)) { if (TryGetComponent(eReplicaComponentType::RACING_CONTROL, racingControlComponent)) {
racingControlComponent->Serialize(outBitStream, bIsInitialUpdate, flags); racingControlComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
LUPExhibitComponent* lupExhibitComponent; LUPExhibitComponent* lupExhibitComponent;
if (TryGetComponent(eReplicaComponentType::LUP_EXHIBIT, lupExhibitComponent)) { if (TryGetComponent(eReplicaComponentType::LUP_EXHIBIT, lupExhibitComponent)) {
lupExhibitComponent->Serialize(outBitStream, bIsInitialUpdate, flags); lupExhibitComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
ModelComponent* modelComponent; ModelComponent* modelComponent;
if (TryGetComponent(eReplicaComponentType::MODEL, modelComponent)) { if (TryGetComponent(eReplicaComponentType::MODEL, modelComponent)) {
modelComponent->Serialize(outBitStream, bIsInitialUpdate, flags); modelComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
RenderComponent* renderComponent; RenderComponent* renderComponent;
if (TryGetComponent(eReplicaComponentType::RENDER, renderComponent)) { if (TryGetComponent(eReplicaComponentType::RENDER, renderComponent)) {
renderComponent->Serialize(outBitStream, bIsInitialUpdate, flags); renderComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
if (modelComponent) { if (modelComponent) {
DestroyableComponent* destroyableComponent; DestroyableComponent* destroyableComponent;
if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) { if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) {
destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); destroyableComponent->Serialize(outBitStream, bIsInitialUpdate);
destroyableSerialized = true; destroyableSerialized = true;
} }
} }
@ -1230,10 +1228,6 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
outBitStream->Write0(); outBitStream->Write0();
} }
void Entity::ResetFlags() {
// Unused
}
void Entity::UpdateXMLDoc(tinyxml2::XMLDocument* doc) { void Entity::UpdateXMLDoc(tinyxml2::XMLDocument* doc) {
//This function should only ever be called from within Character, meaning doc should always exist when this is called. //This function should only ever be called from within Character, meaning doc should always exist when this is called.
//Naturally, we don't include any non-player components in this update function. //Naturally, we don't include any non-player components in this update function.

View File

@ -174,7 +174,6 @@ public:
void WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacketType packetType); void WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacketType packetType);
void WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType packetType); void WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType packetType);
void ResetFlags();
void UpdateXMLDoc(tinyxml2::XMLDocument* doc); void UpdateXMLDoc(tinyxml2::XMLDocument* doc);
void Update(float deltaTime); void Update(float deltaTime);

View File

@ -583,12 +583,6 @@ bool EntityManager::GetGhostingEnabled() const {
return m_GhostingEnabled; return m_GhostingEnabled;
} }
void EntityManager::ResetFlags() {
for (const auto& e : m_Entities) {
e.second->ResetFlags();
}
}
void EntityManager::ScheduleForKill(Entity* entity) { void EntityManager::ScheduleForKill(Entity* entity) {
// Deactivate switches if they die // Deactivate switches if they die
if (!entity) if (!entity)

View File

@ -59,8 +59,6 @@ public:
Entity* GetGhostCandidate(int32_t id); Entity* GetGhostCandidate(int32_t id);
bool GetGhostingEnabled() const; bool GetGhostingEnabled() const;
void ResetFlags();
void ScheduleForKill(Entity* entity); void ScheduleForKill(Entity* entity);
void ScheduleForDeletion(LWOOBJID entity); void ScheduleForDeletion(LWOOBJID entity);

View File

@ -520,7 +520,7 @@ bool BaseCombatAIComponent::IsMech() {
} }
void BaseCombatAIComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void BaseCombatAIComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write(m_DirtyStateOrTarget || bIsInitialUpdate); outBitStream->Write(m_DirtyStateOrTarget || bIsInitialUpdate);
if (m_DirtyStateOrTarget || bIsInitialUpdate) { if (m_DirtyStateOrTarget || bIsInitialUpdate) {
outBitStream->Write(uint32_t(m_State)); outBitStream->Write(uint32_t(m_State));

View File

@ -53,7 +53,7 @@ public:
~BaseCombatAIComponent() override; ~BaseCombatAIComponent() override;
void Update(float deltaTime) override; void Update(float deltaTime) override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
/** /**
* Get the current behavioral state of the enemy * Get the current behavioral state of the enemy

View File

@ -22,7 +22,7 @@ BouncerComponent::BouncerComponent(Entity* parent) : Component(parent) {
BouncerComponent::~BouncerComponent() { BouncerComponent::~BouncerComponent() {
} }
void BouncerComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void BouncerComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write(m_PetEnabled); outBitStream->Write(m_PetEnabled);
if (m_PetEnabled) { if (m_PetEnabled) {
outBitStream->Write(m_PetBouncerEnabled); outBitStream->Write(m_PetBouncerEnabled);

View File

@ -17,7 +17,7 @@ public:
BouncerComponent(Entity* parentEntity); BouncerComponent(Entity* parentEntity);
~BouncerComponent() override; ~BouncerComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
Entity* GetParentEntity() const; Entity* GetParentEntity() const;

View File

@ -20,7 +20,7 @@ BuffComponent::BuffComponent(Entity* parent) : Component(parent) {
BuffComponent::~BuffComponent() { BuffComponent::~BuffComponent() {
} }
void BuffComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void BuffComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
if (!bIsInitialUpdate) return; if (!bIsInitialUpdate) return;
if (m_Buffs.empty()) { if (m_Buffs.empty()) {
outBitStream->Write0(); outBitStream->Write0();

View File

@ -54,7 +54,7 @@ public:
void UpdateXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
void Update(float deltaTime) override; void Update(float deltaTime) override;

View File

@ -70,7 +70,7 @@ bool CharacterComponent::LandingAnimDisabled(int zoneID) {
CharacterComponent::~CharacterComponent() { CharacterComponent::~CharacterComponent() {
} }
void CharacterComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void CharacterComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
if (bIsInitialUpdate) { if (bIsInitialUpdate) {
outBitStream->Write0(); outBitStream->Write0();

View File

@ -70,7 +70,7 @@ public:
void LoadFromXml(tinyxml2::XMLDocument* doc) override; void LoadFromXml(tinyxml2::XMLDocument* doc) override;
void UpdateXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
/** /**
* Updates the rocket configuration using a LOT string separated by commas * Updates the rocket configuration using a LOT string separated by commas

View File

@ -28,3 +28,7 @@ void Component::UpdateXml(tinyxml2::XMLDocument* doc) {
void Component::LoadFromXml(tinyxml2::XMLDocument* doc) { void Component::LoadFromXml(tinyxml2::XMLDocument* doc) {
} }
void Component::Serialize(RakNet::BitStream* outBitStream, bool isConstruction) {
}

View File

@ -43,6 +43,8 @@ public:
*/ */
virtual void LoadFromXml(tinyxml2::XMLDocument* doc); virtual void LoadFromXml(tinyxml2::XMLDocument* doc);
virtual void Serialize(RakNet::BitStream* outBitStream, bool isConstruction);
protected: protected:
/** /**

View File

@ -76,7 +76,7 @@ void ControllablePhysicsComponent::Update(float deltaTime) {
Game::entityManager->SerializeEntity(m_Parent); Game::entityManager->SerializeEntity(m_Parent);
} }
void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
if (bIsInitialUpdate) { if (bIsInitialUpdate) {
outBitStream->Write(m_InJetpackMode); outBitStream->Write(m_InJetpackMode);
if (m_InJetpackMode) { if (m_InJetpackMode) {
@ -179,12 +179,6 @@ void ControllablePhysicsComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
m_DirtyPosition = true; m_DirtyPosition = true;
} }
void ControllablePhysicsComponent::ResetFlags() {
m_DirtyAngularVelocity = false;
m_DirtyPosition = false;
m_DirtyVelocity = false;
}
void ControllablePhysicsComponent::UpdateXml(tinyxml2::XMLDocument* doc) { void ControllablePhysicsComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char"); tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char");
if (!character) { if (!character) {

View File

@ -27,9 +27,8 @@ public:
~ControllablePhysicsComponent() override; ~ControllablePhysicsComponent() override;
void Update(float deltaTime) override; void Update(float deltaTime) override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
void LoadFromXml(tinyxml2::XMLDocument* doc) override; void LoadFromXml(tinyxml2::XMLDocument* doc) override;
void ResetFlags();
void UpdateXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override;
/** /**

View File

@ -119,7 +119,7 @@ void DestroyableComponent::Reinitialize(LOT templateID) {
} }
} }
void DestroyableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags) { void DestroyableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
if (bIsInitialUpdate) { if (bIsInitialUpdate) {
outBitStream->Write1(); // always write these on construction outBitStream->Write1(); // always write these on construction
outBitStream->Write(m_ImmuneToBasicAttackCount); outBitStream->Write(m_ImmuneToBasicAttackCount);

View File

@ -24,7 +24,7 @@ public:
DestroyableComponent(Entity* parentEntity); DestroyableComponent(Entity* parentEntity);
~DestroyableComponent() override; ~DestroyableComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
void LoadFromXml(tinyxml2::XMLDocument* doc) override; void LoadFromXml(tinyxml2::XMLDocument* doc) override;
void UpdateXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override;

View File

@ -38,8 +38,8 @@ void DonationVendorComponent::SubmitDonation(uint32_t count) {
m_DirtyDonationVendor = true; m_DirtyDonationVendor = true;
} }
void DonationVendorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void DonationVendorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
VendorComponent::Serialize(outBitStream, bIsInitialUpdate, flags); VendorComponent::Serialize(outBitStream, bIsInitialUpdate);
outBitStream->Write(bIsInitialUpdate || m_DirtyDonationVendor); outBitStream->Write(bIsInitialUpdate || m_DirtyDonationVendor);
if (bIsInitialUpdate || m_DirtyDonationVendor) { if (bIsInitialUpdate || m_DirtyDonationVendor) {
outBitStream->Write(m_PercentComplete); outBitStream->Write(m_PercentComplete);

Some files were not shown because too many files have changed in this diff Show More