mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-12-20 11:59:40 -06:00
Compare commits
5 Commits
cdc-fixes
...
AddEntityS
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f76d28584e | ||
|
|
0779f33c2e | ||
|
|
2b1edfa7e5 | ||
|
|
972db85dbf | ||
|
|
7321382fe2 |
80
dDatabase/CDClientManager.cpp
Normal file
80
dDatabase/CDClientManager.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#include "CDClientManager.h"
|
||||
#include "CDActivityRewardsTable.h"
|
||||
#include "CDAnimationsTable.h"
|
||||
#include "CDBehaviorParameterTable.h"
|
||||
#include "CDBehaviorTemplateTable.h"
|
||||
#include "CDComponentsRegistryTable.h"
|
||||
#include "CDCurrencyTableTable.h"
|
||||
#include "CDDestructibleComponentTable.h"
|
||||
#include "CDEmoteTable.h"
|
||||
#include "CDInventoryComponentTable.h"
|
||||
#include "CDItemComponentTable.h"
|
||||
#include "CDItemSetsTable.h"
|
||||
#include "CDItemSetSkillsTable.h"
|
||||
#include "CDLevelProgressionLookupTable.h"
|
||||
#include "CDLootMatrixTable.h"
|
||||
#include "CDLootTableTable.h"
|
||||
#include "CDMissionNPCComponentTable.h"
|
||||
#include "CDMissionTasksTable.h"
|
||||
#include "CDMissionsTable.h"
|
||||
#include "CDObjectSkillsTable.h"
|
||||
#include "CDObjectsTable.h"
|
||||
#include "CDPhysicsComponentTable.h"
|
||||
#include "CDRebuildComponentTable.h"
|
||||
#include "CDScriptComponentTable.h"
|
||||
#include "CDSkillBehaviorTable.h"
|
||||
#include "CDZoneTableTable.h"
|
||||
#include "CDVendorComponentTable.h"
|
||||
#include "CDActivitiesTable.h"
|
||||
#include "CDPackageComponentTable.h"
|
||||
#include "CDProximityMonitorComponentTable.h"
|
||||
#include "CDMovementAIComponentTable.h"
|
||||
#include "CDBrickIDTableTable.h"
|
||||
#include "CDRarityTableTable.h"
|
||||
#include "CDMissionEmailTable.h"
|
||||
#include "CDRewardsTable.h"
|
||||
#include "CDPropertyEntranceComponentTable.h"
|
||||
#include "CDPropertyTemplateTable.h"
|
||||
#include "CDFeatureGatingTable.h"
|
||||
#include "CDRailActivatorComponent.h"
|
||||
|
||||
CDClientManager::CDClientManager() {
|
||||
CDActivityRewardsTable::Instance();
|
||||
CDAnimationsTable::Instance();
|
||||
CDBehaviorParameterTable::Instance();
|
||||
CDBehaviorTemplateTable::Instance();
|
||||
CDComponentsRegistryTable::Instance();
|
||||
CDCurrencyTableTable::Instance();
|
||||
CDDestructibleComponentTable::Instance();
|
||||
CDEmoteTableTable::Instance();
|
||||
CDInventoryComponentTable::Instance();
|
||||
CDItemComponentTable::Instance();
|
||||
CDItemSetsTable::Instance();
|
||||
CDItemSetSkillsTable::Instance();
|
||||
CDLevelProgressionLookupTable::Instance();
|
||||
CDLootMatrixTable::Instance();
|
||||
CDLootTableTable::Instance();
|
||||
CDMissionNPCComponentTable::Instance();
|
||||
CDMissionTasksTable::Instance();
|
||||
CDMissionsTable::Instance();
|
||||
CDObjectSkillsTable::Instance();
|
||||
CDObjectsTable::Instance();
|
||||
CDPhysicsComponentTable::Instance();
|
||||
CDRebuildComponentTable::Instance();
|
||||
CDScriptComponentTable::Instance();
|
||||
CDSkillBehaviorTable::Instance();
|
||||
CDZoneTableTable::Instance();
|
||||
CDVendorComponentTable::Instance();
|
||||
CDActivitiesTable::Instance();
|
||||
CDPackageComponentTable::Instance();
|
||||
CDProximityMonitorComponentTable::Instance();
|
||||
CDMovementAIComponentTable::Instance();
|
||||
CDBrickIDTableTable::Instance();
|
||||
CDRarityTableTable::Instance();
|
||||
CDMissionEmailTable::Instance();
|
||||
CDRewardsTable::Instance();
|
||||
CDPropertyEntranceComponentTable::Instance();
|
||||
CDPropertyTemplateTable::Instance();
|
||||
CDFeatureGatingTable::Instance();
|
||||
CDRailActivatorComponentTable::Instance();
|
||||
}
|
||||
26
dDatabase/CDClientManager.h
Normal file
26
dDatabase/CDClientManager.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "CDTable.h"
|
||||
|
||||
#include "Singleton.h"
|
||||
|
||||
#define UNUSED_TABLE(v)
|
||||
|
||||
/**
|
||||
* Initialize the CDClient tables so they are all loaded into memory.
|
||||
*/
|
||||
class CDClientManager : public Singleton<CDClientManager> {
|
||||
public:
|
||||
CDClientManager();
|
||||
|
||||
/**
|
||||
* Fetch a table from CDClient
|
||||
*
|
||||
* @tparam Table type to fetch
|
||||
* @return A pointer to the requested table.
|
||||
*/
|
||||
template<typename T>
|
||||
T* GetTable() {
|
||||
return &T::Instance();
|
||||
}
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
set(DDATABASE_SOURCES "CDClientDatabase.cpp"
|
||||
"CDClientManager.cpp"
|
||||
"Database.cpp"
|
||||
"MigrationRunner.cpp")
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
#include "CDActivitiesTable.h"
|
||||
|
||||
namespace {
|
||||
std::vector<CDActivities> entries;
|
||||
};
|
||||
CDActivitiesTable::CDActivitiesTable(void) {
|
||||
|
||||
void CDActivitiesTable::LoadTableIntoMemory() {
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Activities");
|
||||
@@ -17,7 +14,7 @@ void CDActivitiesTable::LoadTableIntoMemory() {
|
||||
tableSize.finalize();
|
||||
|
||||
// Reserve the size
|
||||
entries.reserve(size);
|
||||
this->entries.reserve(size);
|
||||
|
||||
// Now get the data
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Activities");
|
||||
@@ -43,7 +40,7 @@ void CDActivitiesTable::LoadTableIntoMemory() {
|
||||
entry.noTeamLootOnDeath = tableData.getIntField("noTeamLootOnDeath", -1);
|
||||
entry.optionalPercentage = tableData.getFloatField("optionalPercentage", -1.0f);
|
||||
|
||||
entries.push_back(entry);
|
||||
this->entries.push_back(entry);
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
@@ -52,9 +49,14 @@ void CDActivitiesTable::LoadTableIntoMemory() {
|
||||
|
||||
std::vector<CDActivities> CDActivitiesTable::Query(std::function<bool(CDActivities)> predicate) {
|
||||
|
||||
std::vector<CDActivities> data = cpplinq::from(entries)
|
||||
std::vector<CDActivities> data = cpplinq::from(this->entries)
|
||||
>> cpplinq::where(predicate)
|
||||
>> cpplinq::to_vector();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
std::vector<CDActivities> CDActivitiesTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,14 @@ struct CDActivities {
|
||||
float optionalPercentage;
|
||||
};
|
||||
|
||||
namespace CDActivitiesTable {
|
||||
void LoadTableIntoMemory();
|
||||
class CDActivitiesTable : public CDTable<CDActivitiesTable> {
|
||||
private:
|
||||
std::vector<CDActivities> entries;
|
||||
|
||||
public:
|
||||
CDActivitiesTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDActivities> Query(std::function<bool(CDActivities)> predicate);
|
||||
|
||||
std::vector<CDActivities> GetEntries(void) const;
|
||||
};
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
#include "CDActivityRewardsTable.h"
|
||||
|
||||
namespace {
|
||||
std::vector<CDActivityRewards> entries;
|
||||
};
|
||||
CDActivityRewardsTable::CDActivityRewardsTable(void) {
|
||||
|
||||
void CDActivityRewardsTable::LoadTableIntoMemory() {
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ActivityRewards");
|
||||
@@ -17,7 +14,7 @@ void CDActivityRewardsTable::LoadTableIntoMemory() {
|
||||
tableSize.finalize();
|
||||
|
||||
// Reserve the size
|
||||
entries.reserve(size);
|
||||
this->entries.reserve(size);
|
||||
|
||||
// Now get the data
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ActivityRewards");
|
||||
@@ -31,7 +28,7 @@ void CDActivityRewardsTable::LoadTableIntoMemory() {
|
||||
entry.ChallengeRating = tableData.getIntField("ChallengeRating", -1);
|
||||
entry.description = tableData.getStringField("description", "");
|
||||
|
||||
entries.push_back(entry);
|
||||
this->entries.push_back(entry);
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
@@ -40,9 +37,14 @@ void CDActivityRewardsTable::LoadTableIntoMemory() {
|
||||
|
||||
std::vector<CDActivityRewards> CDActivityRewardsTable::Query(std::function<bool(CDActivityRewards)> predicate) {
|
||||
|
||||
std::vector<CDActivityRewards> data = cpplinq::from(entries)
|
||||
std::vector<CDActivityRewards> data = cpplinq::from(this->entries)
|
||||
>> cpplinq::where(predicate)
|
||||
>> cpplinq::to_vector();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
std::vector<CDActivityRewards> CDActivityRewardsTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,15 @@ struct CDActivityRewards {
|
||||
std::string description; //!< The description
|
||||
};
|
||||
|
||||
namespace CDActivityRewardsTable {
|
||||
void LoadTableIntoMemory();
|
||||
class CDActivityRewardsTable : public CDTable<CDActivityRewardsTable> {
|
||||
private:
|
||||
std::vector<CDActivityRewards> entries;
|
||||
|
||||
public:
|
||||
CDActivityRewardsTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDActivityRewards> Query(std::function<bool(CDActivityRewards)> predicate);
|
||||
|
||||
std::vector<CDActivityRewards> GetEntries(void) const;
|
||||
|
||||
};
|
||||
|
||||
@@ -2,66 +2,52 @@
|
||||
#include "GeneralUtils.h"
|
||||
#include "Game.h"
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* Cache all animations given a premade key
|
||||
*/
|
||||
void CacheAnimations(const CDAnimationsTable::CDAnimationKey animationKey) {
|
||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM Animations WHERE animationGroupID = ? and animation_type = ?");
|
||||
query.bind(1, static_cast<int32_t>(animationKey.second));
|
||||
query.bind(2, animationKey.first.c_str());
|
||||
// If we received a bad lookup, cache it anyways so we do not run the query again.
|
||||
if (!CacheData(query)) {
|
||||
animations[animationKey];
|
||||
}
|
||||
bool CDAnimationsTable::CacheData(CppSQLite3Statement& queryToCache) {
|
||||
auto tableData = queryToCache.execQuery();
|
||||
// If we received a bad lookup, cache it anyways so we do not run the query again.
|
||||
if (tableData.eof()) return false;
|
||||
|
||||
do {
|
||||
std::string animation_type = tableData.getStringField("animation_type", "");
|
||||
DluAssert(!animation_type.empty());
|
||||
AnimationGroupID animationGroupID = tableData.getIntField("animationGroupID", -1);
|
||||
DluAssert(animationGroupID != -1);
|
||||
|
||||
CDAnimation entry;
|
||||
entry.animation_name = tableData.getStringField("animation_name", "");
|
||||
entry.chance_to_play = tableData.getFloatField("chance_to_play", 1.0f);
|
||||
UNUSED_COLUMN(entry.min_loops = tableData.getIntField("min_loops", 0);)
|
||||
UNUSED_COLUMN(entry.max_loops = tableData.getIntField("max_loops", 0);)
|
||||
entry.animation_length = tableData.getFloatField("animation_length", 0.0f);
|
||||
UNUSED_COLUMN(entry.hideEquip = tableData.getIntField("hideEquip", 0) == 1;)
|
||||
UNUSED_COLUMN(entry.ignoreUpperBody = tableData.getIntField("ignoreUpperBody", 0) == 1;)
|
||||
UNUSED_COLUMN(entry.restartable = tableData.getIntField("restartable", 0) == 1;)
|
||||
UNUSED_COLUMN(entry.face_animation_name = tableData.getStringField("face_animation_name", "");)
|
||||
UNUSED_COLUMN(entry.priority = tableData.getFloatField("priority", 0.0f);)
|
||||
UNUSED_COLUMN(entry.blendTime = tableData.getFloatField("blendTime", 0.0f);)
|
||||
|
||||
this->animations[CDAnimationKey(animation_type, animationGroupID)].push_back(entry);
|
||||
tableData.nextRow();
|
||||
} while (!tableData.eof());
|
||||
|
||||
tableData.finalize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDAnimationsTable::CacheAnimations(const CDAnimationKey animationKey) {
|
||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM Animations WHERE animationGroupID = ? and animation_type = ?");
|
||||
query.bind(1, static_cast<int32_t>(animationKey.second));
|
||||
query.bind(2, animationKey.first.c_str());
|
||||
// If we received a bad lookup, cache it anyways so we do not run the query again.
|
||||
if (!CacheData(query)) {
|
||||
this->animations[animationKey];
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the query responsible for caching the data.
|
||||
*/
|
||||
bool CacheData(CppSQLite3Statement& queryToCache) {
|
||||
auto tableData = queryToCache.execQuery();
|
||||
// If we received a bad lookup, cache it anyways so we do not run the query again.
|
||||
if (tableData.eof()) return false;
|
||||
|
||||
do {
|
||||
std::string animation_type = tableData.getStringField("animation_type", "");
|
||||
DluAssert(!animation_type.empty());
|
||||
CDAnimationsTable::AnimationGroupID animationGroupID = tableData.getIntField("animationGroupID", -1);
|
||||
DluAssert(animationGroupID != -1);
|
||||
|
||||
CDAnimation entry;
|
||||
entry.animation_name = tableData.getStringField("animation_name", "");
|
||||
entry.chance_to_play = tableData.getFloatField("chance_to_play", 1.0f);
|
||||
UNUSED_COLUMN(entry.min_loops = tableData.getIntField("min_loops", 0););
|
||||
UNUSED_COLUMN(entry.max_loops = tableData.getIntField("max_loops", 0););
|
||||
entry.animation_length = tableData.getFloatField("animation_length", 0.0f);
|
||||
UNUSED_COLUMN(entry.hideEquip = tableData.getIntField("hideEquip", 0) == 1;);
|
||||
UNUSED_COLUMN(entry.ignoreUpperBody = tableData.getIntField("ignoreUpperBody", 0) == 1;);
|
||||
UNUSED_COLUMN(entry.restartable = tableData.getIntField("restartable", 0) == 1;);
|
||||
UNUSED_COLUMN(entry.face_animation_name = tableData.getStringField("face_animation_name", ""););
|
||||
UNUSED_COLUMN(entry.priority = tableData.getFloatField("priority", 0.0f););
|
||||
UNUSED_COLUMN(entry.blendTime = tableData.getFloatField("blendTime", 0.0f););
|
||||
|
||||
animations[CDAnimationsTable::CDAnimationKey(animation_type, animationGroupID)].push_back(entry);
|
||||
tableData.nextRow();
|
||||
} while (!tableData.eof());
|
||||
|
||||
tableData.finalize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Each animation is key'd by its animationName and its animationGroupID. Each
|
||||
* animation has a possible list of animations. This is because there can be animations have a percent chance to play so one is selected at random.
|
||||
*/
|
||||
std::map<CDAnimationsTable::CDAnimationKey, std::list<CDAnimation>> animations;
|
||||
};
|
||||
}
|
||||
|
||||
void CDAnimationsTable::CacheAnimationGroup(AnimationGroupID animationGroupID) {
|
||||
auto animationEntryCached = animations.find(CDAnimationKey("", animationGroupID));
|
||||
if (animationEntryCached != animations.end()) {
|
||||
auto animationEntryCached = this->animations.find(CDAnimationKey("", animationGroupID));
|
||||
if (animationEntryCached != this->animations.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -70,17 +56,17 @@ void CDAnimationsTable::CacheAnimationGroup(AnimationGroupID animationGroupID) {
|
||||
|
||||
// Cache the query so we don't run the query again.
|
||||
CacheData(query);
|
||||
animations[CDAnimationKey("", animationGroupID)];
|
||||
this->animations[CDAnimationKey("", animationGroupID)];
|
||||
}
|
||||
|
||||
CDAnimationLookupResult CDAnimationsTable::GetAnimation(const AnimationID& animationType, const std::string& previousAnimationName, const AnimationGroupID animationGroupID) {
|
||||
CDAnimationKey animationKey(animationType, animationGroupID);
|
||||
auto animationEntryCached = animations.find(animationKey);
|
||||
if (animationEntryCached == animations.end()) {
|
||||
CacheAnimations(animationKey);
|
||||
auto animationEntryCached = this->animations.find(animationKey);
|
||||
if (animationEntryCached == this->animations.end()) {
|
||||
this->CacheAnimations(animationKey);
|
||||
}
|
||||
|
||||
auto animationEntry = animations.find(animationKey);
|
||||
auto animationEntry = this->animations.find(animationKey);
|
||||
// If we have only one animation, return it regardless of the chance to play.
|
||||
if (animationEntry->second.size() == 1) {
|
||||
return CDAnimationLookupResult(animationEntry->second.front());
|
||||
|
||||
@@ -22,11 +22,11 @@ struct CDAnimation {
|
||||
|
||||
typedef LookupResult<CDAnimation> CDAnimationLookupResult;
|
||||
|
||||
namespace CDAnimationsTable {
|
||||
class CDAnimationsTable : public CDTable<CDAnimationsTable> {
|
||||
typedef int32_t AnimationGroupID;
|
||||
typedef std::string AnimationID;
|
||||
typedef std::pair<std::string, AnimationGroupID> CDAnimationKey;
|
||||
void LoadTableIntoMemory();
|
||||
public:
|
||||
/**
|
||||
* Given an animationType and the previousAnimationName played, return the next animationType to play.
|
||||
* If there are more than 1 animationTypes that can be played, one is selected at random but also does not allow
|
||||
@@ -43,4 +43,24 @@ namespace CDAnimationsTable {
|
||||
* Cache a full AnimationGroup by its ID.
|
||||
*/
|
||||
void CacheAnimationGroup(AnimationGroupID animationGroupID);
|
||||
private:
|
||||
|
||||
/**
|
||||
* Cache all animations given a premade key
|
||||
*/
|
||||
void CacheAnimations(const CDAnimationKey animationKey);
|
||||
|
||||
/**
|
||||
* Run the query responsible for caching the data.
|
||||
* @param queryToCache
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool CacheData(CppSQLite3Statement& queryToCache);
|
||||
|
||||
/**
|
||||
* Each animation is key'd by its animationName and its animationGroupID. Each
|
||||
* animation has a possible list of animations. This is because there can be animations have a percent chance to play so one is selected at random.
|
||||
*/
|
||||
std::map<CDAnimationKey, std::list<CDAnimation>> animations;
|
||||
};
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
#include "CDBehaviorParameterTable.h"
|
||||
#include "GeneralUtils.h"
|
||||
|
||||
namespace {
|
||||
std::unordered_map<uint64_t, CDBehaviorParameter> m_Entries;
|
||||
std::unordered_map<std::string, uint32_t> m_ParametersList;
|
||||
};
|
||||
|
||||
void CDBehaviorParameterTable::LoadTableIntoMemory() {
|
||||
CDBehaviorParameterTable::CDBehaviorParameterTable(void) {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BehaviorParameter");
|
||||
uint32_t uniqueParameterId = 0;
|
||||
uint64_t hash = 0;
|
||||
@@ -33,8 +28,8 @@ void CDBehaviorParameterTable::LoadTableIntoMemory() {
|
||||
}
|
||||
|
||||
float CDBehaviorParameterTable::GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue) {
|
||||
auto parameterID = m_ParametersList.find(name);
|
||||
if (parameterID == m_ParametersList.end()) return defaultValue;
|
||||
auto parameterID = this->m_ParametersList.find(name);
|
||||
if (parameterID == this->m_ParametersList.end()) return defaultValue;
|
||||
|
||||
uint64_t hash = behaviorID;
|
||||
|
||||
|
||||
@@ -11,9 +11,13 @@ struct CDBehaviorParameter {
|
||||
float value; //!< The value of the behavior template
|
||||
};
|
||||
|
||||
namespace CDBehaviorParameterTable {
|
||||
void LoadTableIntoMemory();
|
||||
float GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue = 0.0f);
|
||||
class CDBehaviorParameterTable : public CDTable<CDBehaviorParameterTable> {
|
||||
private:
|
||||
std::unordered_map<uint64_t, CDBehaviorParameter> m_Entries;
|
||||
std::unordered_map<std::string, uint32_t> m_ParametersList;
|
||||
public:
|
||||
CDBehaviorParameterTable();
|
||||
float GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue = 0);
|
||||
|
||||
std::map<std::string, float> GetParametersByBehaviorID(uint32_t behaviorID);
|
||||
};
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
#include "CDBehaviorTemplateTable.h"
|
||||
|
||||
namespace {
|
||||
std::vector<CDBehaviorTemplate> entries;
|
||||
std::unordered_map<uint32_t, CDBehaviorTemplate> entriesMappedByBehaviorID;
|
||||
std::unordered_set<std::string> m_EffectHandles;
|
||||
};
|
||||
|
||||
void CDBehaviorTemplateTable::LoadTableIntoMemory() {
|
||||
CDBehaviorTemplateTable::CDBehaviorTemplateTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -20,7 +14,7 @@ void CDBehaviorTemplateTable::LoadTableIntoMemory() {
|
||||
tableSize.finalize();
|
||||
|
||||
// Reserve the size
|
||||
entries.reserve(size);
|
||||
this->entries.reserve(size);
|
||||
|
||||
// Now get the data
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BehaviorTemplate");
|
||||
@@ -37,8 +31,8 @@ void CDBehaviorTemplateTable::LoadTableIntoMemory() {
|
||||
entry.effectHandle = m_EffectHandles.insert(candidateToAdd).first;
|
||||
}
|
||||
|
||||
entries.push_back(entry);
|
||||
entriesMappedByBehaviorID.insert(std::make_pair(entry.behaviorID, entry));
|
||||
this->entries.push_back(entry);
|
||||
this->entriesMappedByBehaviorID.insert(std::make_pair(entry.behaviorID, entry));
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
@@ -47,16 +41,20 @@ void CDBehaviorTemplateTable::LoadTableIntoMemory() {
|
||||
|
||||
std::vector<CDBehaviorTemplate> CDBehaviorTemplateTable::Query(std::function<bool(CDBehaviorTemplate)> predicate) {
|
||||
|
||||
std::vector<CDBehaviorTemplate> data = cpplinq::from(entries)
|
||||
std::vector<CDBehaviorTemplate> data = cpplinq::from(this->entries)
|
||||
>> cpplinq::where(predicate)
|
||||
>> cpplinq::to_vector();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
std::vector<CDBehaviorTemplate> CDBehaviorTemplateTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
const CDBehaviorTemplate CDBehaviorTemplateTable::GetByBehaviorID(uint32_t behaviorID) {
|
||||
auto entry = entriesMappedByBehaviorID.find(behaviorID);
|
||||
if (entry == entriesMappedByBehaviorID.end()) {
|
||||
auto entry = this->entriesMappedByBehaviorID.find(behaviorID);
|
||||
if (entry == this->entriesMappedByBehaviorID.end()) {
|
||||
CDBehaviorTemplate entryToReturn;
|
||||
entryToReturn.behaviorID = 0;
|
||||
entryToReturn.effectHandle = m_EffectHandles.end();
|
||||
|
||||
@@ -6,17 +6,24 @@
|
||||
#include <unordered_set>
|
||||
|
||||
struct CDBehaviorTemplate {
|
||||
uint32_t behaviorID; //!< The Behavior ID
|
||||
uint32_t templateID; //!< The Template ID (LOT)
|
||||
uint32_t effectID; //!< The Effect ID attached
|
||||
std::unordered_set<std::string>::iterator effectHandle; //!< The effect handle
|
||||
unsigned int behaviorID; //!< The Behavior ID
|
||||
unsigned int templateID; //!< The Template ID (LOT)
|
||||
unsigned int effectID; //!< The Effect ID attached
|
||||
std::unordered_set<std::string>::iterator effectHandle; //!< The effect handle
|
||||
};
|
||||
|
||||
|
||||
namespace CDBehaviorTemplateTable {
|
||||
void LoadTableIntoMemory();
|
||||
class CDBehaviorTemplateTable : public CDTable<CDBehaviorTemplateTable> {
|
||||
private:
|
||||
std::vector<CDBehaviorTemplate> entries;
|
||||
std::unordered_map<uint32_t, CDBehaviorTemplate> entriesMappedByBehaviorID;
|
||||
std::unordered_set<std::string> m_EffectHandles;
|
||||
public:
|
||||
CDBehaviorTemplateTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDBehaviorTemplate> Query(std::function<bool(CDBehaviorTemplate)> predicate);
|
||||
|
||||
std::vector<CDBehaviorTemplate> GetEntries(void) const;
|
||||
|
||||
const CDBehaviorTemplate GetByBehaviorID(uint32_t behaviorID);
|
||||
};
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "CDBrickIDTableTable.h"
|
||||
|
||||
namespace {
|
||||
std::vector<CDBrickIDTable> entries;
|
||||
};
|
||||
|
||||
void CDBrickIDTableTable::LoadTableIntoMemory() {
|
||||
CDBrickIDTableTable::CDBrickIDTableTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -18,7 +14,7 @@ void CDBrickIDTableTable::LoadTableIntoMemory() {
|
||||
tableSize.finalize();
|
||||
|
||||
// Reserve the size
|
||||
entries.reserve(size);
|
||||
this->entries.reserve(size);
|
||||
|
||||
// Now get the data
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BrickIDTable");
|
||||
@@ -27,7 +23,7 @@ void CDBrickIDTableTable::LoadTableIntoMemory() {
|
||||
entry.NDObjectID = tableData.getIntField("NDObjectID", -1);
|
||||
entry.LEGOBrickID = tableData.getIntField("LEGOBrickID", -1);
|
||||
|
||||
entries.push_back(entry);
|
||||
this->entries.push_back(entry);
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
@@ -36,9 +32,14 @@ void CDBrickIDTableTable::LoadTableIntoMemory() {
|
||||
|
||||
std::vector<CDBrickIDTable> CDBrickIDTableTable::Query(std::function<bool(CDBrickIDTable)> predicate) {
|
||||
|
||||
std::vector<CDBrickIDTable> data = cpplinq::from(entries)
|
||||
std::vector<CDBrickIDTable> data = cpplinq::from(this->entries)
|
||||
>> cpplinq::where(predicate)
|
||||
>> cpplinq::to_vector();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
std::vector<CDBrickIDTable> CDBrickIDTableTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,14 @@ struct CDBrickIDTable {
|
||||
|
||||
|
||||
//! BrickIDTable table
|
||||
namespace CDBrickIDTableTable {
|
||||
void LoadTableIntoMemory();
|
||||
class CDBrickIDTableTable : public CDTable<CDBrickIDTableTable> {
|
||||
private:
|
||||
std::vector<CDBrickIDTable> entries;
|
||||
|
||||
public:
|
||||
CDBrickIDTableTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDBrickIDTable> Query(std::function<bool(CDBrickIDTable)> predicate);
|
||||
|
||||
std::vector<CDBrickIDTable> GetEntries(void) const;
|
||||
};
|
||||
|
||||
@@ -11,9 +11,11 @@ struct CDComponentsRegistry {
|
||||
};
|
||||
|
||||
|
||||
namespace CDComponentsRegistryTable {
|
||||
class CDComponentsRegistryTable : public CDTable<CDComponentsRegistryTable> {
|
||||
private:
|
||||
std::map<uint64_t, uint32_t> mappedEntries; //id, component_type, component_id
|
||||
|
||||
void LoadTableIntoMemory();
|
||||
public:
|
||||
CDComponentsRegistryTable();
|
||||
int32_t GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue = 0);
|
||||
};
|
||||
|
||||
@@ -18,12 +18,12 @@ struct CDCurrencyTable {
|
||||
};
|
||||
|
||||
//! CurrencyTable table
|
||||
namespace CDCurrencyTableTable {
|
||||
class CDCurrencyTableTable : public CDTable<CDCurrencyTableTable> {
|
||||
private:
|
||||
std::vector<CDCurrencyTable> entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDCurrencyTableTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDCurrencyTable> Query(std::function<bool(CDCurrencyTable)> predicate);
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ struct CDDestructibleComponent {
|
||||
int difficultyLevel; //!< ???
|
||||
};
|
||||
|
||||
namespace CDDestructibleComponentTable {
|
||||
class CDDestructibleComponentTable : public CDTable<CDDestructibleComponentTable> {
|
||||
private:
|
||||
std::vector<CDDestructibleComponent> entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDDestructibleComponentTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDDestructibleComponent> Query(std::function<bool(CDDestructibleComponent)> predicate);
|
||||
|
||||
|
||||
@@ -1,30 +1,40 @@
|
||||
#include "CDEmoteTable.h"
|
||||
|
||||
namespace {
|
||||
std::map<int, CDEmoteTable> entries;
|
||||
};
|
||||
|
||||
void CDEmoteTableTable::LoadTableIntoMemory() {
|
||||
//! Constructor
|
||||
CDEmoteTableTable::CDEmoteTableTable(void) {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Emotes");
|
||||
while (!tableData.eof()) {
|
||||
CDEmoteTable entry;
|
||||
entry.ID = tableData.getIntField("id", -1);
|
||||
entry.animationName = tableData.getStringField("animationName", "");
|
||||
entry.iconFilename = tableData.getStringField("iconFilename", "");
|
||||
entry.channel = tableData.getIntField("channel", -1);
|
||||
entry.locked = tableData.getIntField("locked", -1) != 0;
|
||||
entry.localize = tableData.getIntField("localize", -1) != 0;
|
||||
entry.locState = tableData.getIntField("locStatus", -1);
|
||||
entry.gateVersion = tableData.getStringField("gate_version", "");
|
||||
CDEmoteTable* entry = new CDEmoteTable();
|
||||
entry->ID = tableData.getIntField("id", -1);
|
||||
entry->animationName = tableData.getStringField("animationName", "");
|
||||
entry->iconFilename = tableData.getStringField("iconFilename", "");
|
||||
entry->channel = tableData.getIntField("channel", -1);
|
||||
entry->locked = tableData.getIntField("locked", -1) != 0;
|
||||
entry->localize = tableData.getIntField("localize", -1) != 0;
|
||||
entry->locState = tableData.getIntField("locStatus", -1);
|
||||
entry->gateVersion = tableData.getStringField("gate_version", "");
|
||||
|
||||
entries.insert(std::make_pair(entry.ID, entry));
|
||||
entries.insert(std::make_pair(entry->ID, entry));
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
CDEmoteTable* CDEmoteTableTable::GetEmote(int id) {
|
||||
return entries.find(id) != entries.end() ? &entries[id] : nullptr;
|
||||
//! Destructor
|
||||
CDEmoteTableTable::~CDEmoteTableTable(void) {
|
||||
for (auto e : entries) {
|
||||
if (e.second) delete e.second;
|
||||
}
|
||||
|
||||
entries.clear();
|
||||
}
|
||||
|
||||
CDEmoteTable* CDEmoteTableTable::GetEmote(int id) {
|
||||
for (auto e : entries) {
|
||||
if (e.first == id) return e.second;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,13 @@ struct CDEmoteTable {
|
||||
std::string gateVersion;
|
||||
};
|
||||
|
||||
namespace CDEmoteTableTable {
|
||||
void LoadTableIntoMemory();
|
||||
class CDEmoteTableTable : public CDTable<CDEmoteTableTable> {
|
||||
private:
|
||||
std::map<int, CDEmoteTable*> entries;
|
||||
|
||||
public:
|
||||
CDEmoteTableTable();
|
||||
~CDEmoteTableTable();
|
||||
// Returns an emote by ID
|
||||
CDEmoteTable* GetEmote(int id);
|
||||
};
|
||||
|
||||
@@ -11,12 +11,12 @@ struct CDFeatureGating {
|
||||
std::string description;
|
||||
};
|
||||
|
||||
namespace CDFeatureGatingTable {
|
||||
class CDFeatureGatingTable : public CDTable<CDFeatureGatingTable> {
|
||||
private:
|
||||
std::vector<CDFeatureGating> entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDFeatureGatingTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDFeatureGating> Query(std::function<bool(CDFeatureGating)> predicate);
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@ struct CDInventoryComponent {
|
||||
bool equip; //!< Whether or not to equip the item
|
||||
};
|
||||
|
||||
namespace CDInventoryComponentTable {
|
||||
class CDInventoryComponentTable : public CDTable<CDInventoryComponentTable> {
|
||||
private:
|
||||
std::vector<CDInventoryComponent> entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDInventoryComponentTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDInventoryComponent> Query(std::function<bool(CDInventoryComponent)> predicate);
|
||||
|
||||
|
||||
@@ -49,12 +49,12 @@ struct CDItemComponent {
|
||||
float SellMultiplier; //!< Something to do with early vendors perhaps (but replaced)
|
||||
};
|
||||
|
||||
namespace CDItemComponentTable {
|
||||
class CDItemComponentTable : public CDTable<CDItemComponentTable> {
|
||||
private:
|
||||
std::map<unsigned int, CDItemComponent> entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDItemComponentTable();
|
||||
static std::map<LOT, uint32_t> ParseCraftingCurrencies(const CDItemComponent& itemComponent);
|
||||
|
||||
// Gets an entry by ID
|
||||
|
||||
@@ -9,12 +9,12 @@ struct CDItemSetSkills {
|
||||
unsigned int SkillCastType; //!< The skill cast type
|
||||
};
|
||||
|
||||
namespace CDItemSetSkillsTable {
|
||||
class CDItemSetSkillsTable : public CDTable<CDItemSetSkillsTable> {
|
||||
private:
|
||||
std::vector<CDItemSetSkills> entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDItemSetSkillsTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDItemSetSkills> Query(std::function<bool(CDItemSetSkills)> predicate);
|
||||
|
||||
|
||||
@@ -21,12 +21,12 @@ struct CDItemSets {
|
||||
float priority; //!< The priority
|
||||
};
|
||||
|
||||
namespace CDItemSetsTable {
|
||||
class CDItemSetsTable : public CDTable<CDItemSetsTable> {
|
||||
private:
|
||||
std::vector<CDItemSets> entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDItemSetsTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDItemSets> Query(std::function<bool(CDItemSets)> predicate);
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@ struct CDLevelProgressionLookup {
|
||||
std::string BehaviorEffect; //!< The behavior effect attached to this
|
||||
};
|
||||
|
||||
namespace CDLevelProgressionLookupTable {
|
||||
class CDLevelProgressionLookupTable : public CDTable<CDLevelProgressionLookupTable> {
|
||||
private:
|
||||
std::vector<CDLevelProgressionLookup> entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDLevelProgressionLookupTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDLevelProgressionLookup> Query(std::function<bool(CDLevelProgressionLookup)> predicate);
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@ struct CDLootMatrix {
|
||||
UNUSED(std::string gate_version); //!< The Gate Version
|
||||
};
|
||||
|
||||
namespace CDLootMatrixTable {
|
||||
class CDLootMatrixTable : public CDTable<CDLootMatrixTable> {
|
||||
private:
|
||||
std::vector<CDLootMatrix> entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDLootMatrixTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDLootMatrix> Query(std::function<bool(CDLootMatrix)> predicate);
|
||||
|
||||
|
||||
@@ -11,12 +11,12 @@ struct CDLootTable {
|
||||
unsigned int sortPriority; //!< The sorting priority
|
||||
};
|
||||
|
||||
namespace CDLootTableTable {
|
||||
class CDLootTableTable : public CDTable<CDLootTableTable> {
|
||||
private:
|
||||
std::vector<CDLootTable> entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDLootTableTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDLootTable> Query(std::function<bool(CDLootTable)> predicate);
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@ struct CDMissionEmail {
|
||||
};
|
||||
|
||||
|
||||
namespace CDMissionEmailTable {
|
||||
class CDMissionEmailTable : public CDTable<CDMissionEmailTable> {
|
||||
private:
|
||||
std::vector<CDMissionEmail> entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDMissionEmailTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDMissionEmail> Query(std::function<bool(CDMissionEmail)> predicate);
|
||||
|
||||
|
||||
@@ -11,12 +11,12 @@ struct CDMissionNPCComponent {
|
||||
std::string gate_version; //!< The gate version
|
||||
};
|
||||
|
||||
namespace CDMissionNPCComponentTable {
|
||||
class CDMissionNPCComponentTable : public CDTable<CDMissionNPCComponentTable> {
|
||||
private:
|
||||
std::vector<CDMissionNPCComponent> entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDMissionNPCComponentTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDMissionNPCComponent> Query(std::function<bool(CDMissionNPCComponent)> predicate);
|
||||
|
||||
|
||||
@@ -19,12 +19,12 @@ struct CDMissionTasks {
|
||||
UNUSED(std::string gate_version); //!< ???
|
||||
};
|
||||
|
||||
namespace CDMissionTasksTable {
|
||||
class CDMissionTasksTable : public CDTable<CDMissionTasksTable> {
|
||||
private:
|
||||
std::vector<CDMissionTasks> entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDMissionTasksTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDMissionTasks> Query(std::function<bool(CDMissionTasks)> predicate);
|
||||
|
||||
|
||||
@@ -60,12 +60,12 @@ struct CDMissions {
|
||||
int reward_bankinventory; //!< The amount of bank space this mission rewards
|
||||
};
|
||||
|
||||
namespace CDMissionsTable {
|
||||
class CDMissionsTable : public CDTable<CDMissionsTable> {
|
||||
private:
|
||||
std::vector<CDMissions> entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDMissionsTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDMissions> Query(std::function<bool(CDMissions)> predicate);
|
||||
|
||||
|
||||
@@ -14,12 +14,12 @@ struct CDMovementAIComponent {
|
||||
std::string attachedPath;
|
||||
};
|
||||
|
||||
namespace CDMovementAIComponentTable {
|
||||
class CDMovementAIComponentTable : public CDTable<CDMovementAIComponentTable> {
|
||||
private:
|
||||
std::vector<CDMovementAIComponent> entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDMovementAIComponentTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDMovementAIComponent> Query(std::function<bool(CDMovementAIComponent)> predicate);
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@ struct CDObjectSkills {
|
||||
unsigned int AICombatWeight; //!< ???
|
||||
};
|
||||
|
||||
namespace CDObjectSkillsTable {
|
||||
class CDObjectSkillsTable : public CDTable<CDObjectSkillsTable> {
|
||||
private:
|
||||
std::vector<CDObjectSkills> entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDObjectSkillsTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDObjectSkills> Query(std::function<bool(CDObjectSkills)> predicate);
|
||||
|
||||
|
||||
@@ -20,13 +20,13 @@ struct CDObjects {
|
||||
UNUSED(unsigned int HQ_valid); //!< Probably used for the Nexus HQ database on LEGOUniverse.com
|
||||
};
|
||||
|
||||
namespace CDObjectsTable {
|
||||
class CDObjectsTable : public CDTable<CDObjectsTable> {
|
||||
private:
|
||||
std::map<unsigned int, CDObjects> entries;
|
||||
CDObjects m_default;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDObjectsTable();
|
||||
// Gets an entry by ID
|
||||
const CDObjects& GetByID(unsigned int LOT);
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ struct CDPackageComponent {
|
||||
unsigned int packageType;
|
||||
};
|
||||
|
||||
namespace CDPackageComponentTable {
|
||||
class CDPackageComponentTable : public CDTable<CDPackageComponentTable> {
|
||||
private:
|
||||
std::vector<CDPackageComponent> entries;
|
||||
|
||||
|
||||
@@ -21,9 +21,10 @@ struct CDPhysicsComponent {
|
||||
UNUSED(std::string gravityVolumeAsset);
|
||||
};
|
||||
|
||||
namespace CDPhysicsComponentTable {
|
||||
class CDPhysicsComponentTable : public CDTable<CDPhysicsComponentTable> {
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDPhysicsComponentTable();
|
||||
~CDPhysicsComponentTable();
|
||||
|
||||
static const std::string GetTableName() { return "PhysicsComponent"; };
|
||||
CDPhysicsComponent* GetByID(unsigned int componentID);
|
||||
|
||||
@@ -9,9 +9,9 @@ struct CDPropertyEntranceComponent {
|
||||
std::string groupType;
|
||||
};
|
||||
|
||||
namespace CDPropertyEntranceComponentTable {
|
||||
class CDPropertyEntranceComponentTable : public CDTable<CDPropertyEntranceComponentTable> {
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDPropertyEntranceComponentTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
CDPropertyEntranceComponent GetByID(uint32_t id);
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ struct CDPropertyTemplate {
|
||||
std::string spawnName;
|
||||
};
|
||||
|
||||
namespace CDPropertyTemplateTable {
|
||||
class CDPropertyTemplateTable : public CDTable<CDPropertyTemplateTable> {
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDPropertyTemplateTable();
|
||||
|
||||
static const std::string GetTableName() { return "PropertyTemplate"; };
|
||||
CDPropertyTemplate GetByMapID(uint32_t mapID);
|
||||
|
||||
@@ -10,7 +10,7 @@ struct CDProximityMonitorComponent {
|
||||
bool LoadOnServer;
|
||||
};
|
||||
|
||||
namespace CDProximityMonitorComponentTable {
|
||||
class CDProximityMonitorComponentTable : public CDTable<CDProximityMonitorComponentTable> {
|
||||
private:
|
||||
std::vector<CDProximityMonitorComponent> entries;
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ struct CDRailActivatorComponent {
|
||||
bool showNameBillboard;
|
||||
};
|
||||
|
||||
namespace CDRailActivatorComponentTable {
|
||||
class CDRailActivatorComponentTable : public CDTable<CDRailActivatorComponentTable> {
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDRailActivatorComponentTable();
|
||||
static const std::string GetTableName() { return "RailActivatorComponent"; };
|
||||
[[nodiscard]] CDRailActivatorComponent GetEntryByID(int32_t id) const;
|
||||
[[nodiscard]] std::vector<CDRailActivatorComponent> GetEntries() const;
|
||||
|
||||
@@ -26,12 +26,12 @@ struct CDRarityTable {
|
||||
}
|
||||
};
|
||||
|
||||
namespace CDRarityTableTable {
|
||||
class CDRarityTableTable : public CDTable<CDRarityTableTable> {
|
||||
private:
|
||||
std::vector<CDRarityTable> entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDRarityTableTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDRarityTable> Query(std::function<bool(CDRarityTable)> predicate);
|
||||
|
||||
|
||||
@@ -16,12 +16,12 @@ struct CDRebuildComponent {
|
||||
float time_before_smash; //!< The time before smash
|
||||
};
|
||||
|
||||
namespace CDRebuildComponentTable {
|
||||
class CDRebuildComponentTable : public CDTable<CDRebuildComponentTable> {
|
||||
private:
|
||||
std::vector<CDRebuildComponent> entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDRebuildComponentTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDRebuildComponent> Query(std::function<bool(CDRebuildComponent)> predicate);
|
||||
|
||||
|
||||
@@ -11,9 +11,10 @@ struct CDRewards {
|
||||
int32_t count;
|
||||
};
|
||||
|
||||
namespace CDRewardsTable {
|
||||
class CDRewardsTable : public CDTable<CDRewardsTable> {
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDRewardsTable();
|
||||
~CDRewardsTable();
|
||||
|
||||
static const std::string GetTableName() { return "Rewards"; };
|
||||
std::vector<CDRewards*> GetByLevelID(uint32_t levelID);
|
||||
|
||||
@@ -9,13 +9,13 @@ struct CDScriptComponent {
|
||||
std::string client_script_name; //!< The client script name
|
||||
};
|
||||
|
||||
namespace CDScriptComponentTable {
|
||||
class CDScriptComponentTable : public CDTable<CDScriptComponentTable> {
|
||||
private:
|
||||
std::map<unsigned int, CDScriptComponent> entries;
|
||||
CDScriptComponent m_ToReturnWhenNoneFound;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDScriptComponentTable();
|
||||
// Gets an entry by scriptID
|
||||
const CDScriptComponent& GetByID(unsigned int id);
|
||||
};
|
||||
|
||||
@@ -25,13 +25,13 @@ struct CDSkillBehavior {
|
||||
UNUSED(unsigned int cancelType); //!< The cancel type (?)
|
||||
};
|
||||
|
||||
namespace CDSkillBehaviorTable {
|
||||
class CDSkillBehaviorTable : public CDTable<CDSkillBehaviorTable> {
|
||||
private:
|
||||
std::map<unsigned int, CDSkillBehavior> entries;
|
||||
CDSkillBehavior m_empty;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDSkillBehaviorTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDSkillBehavior> Query(std::function<bool(CDSkillBehavior)> predicate);
|
||||
|
||||
|
||||
@@ -25,6 +25,12 @@
|
||||
#pragma warning (disable : 4244) //Disable double to float conversion warnings
|
||||
#pragma warning (disable : 4715) //Disable "not all control paths return a value"
|
||||
|
||||
template<class Table>
|
||||
class CDTable : public Singleton<Table> {
|
||||
protected:
|
||||
virtual ~CDTable() = default;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class LookupResult {
|
||||
typedef std::pair<T, bool> DataType;
|
||||
|
||||
@@ -11,12 +11,12 @@ struct CDVendorComponent {
|
||||
unsigned int LootMatrixIndex; //!< LootMatrixIndex of the vendor's items
|
||||
};
|
||||
|
||||
namespace CDVendorComponentTable {
|
||||
class CDVendorComponentTable : public CDTable<CDVendorComponentTable> {
|
||||
private:
|
||||
std::vector<CDVendorComponent> entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDVendorComponentTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDVendorComponent> Query(std::function<bool(CDVendorComponent)> predicate);
|
||||
|
||||
|
||||
@@ -33,12 +33,12 @@ struct CDZoneTable {
|
||||
UNUSED(bool mountsAllowed); //!< Whether or not mounts are allowed
|
||||
};
|
||||
|
||||
namespace CDZoneTableTable {
|
||||
class CDZoneTableTable : public CDTable<CDZoneTableTable> {
|
||||
private:
|
||||
std::map<unsigned int, CDZoneTable> m_Entries;
|
||||
|
||||
public:
|
||||
void LoadTableIntoMemory();
|
||||
CDZoneTableTable();
|
||||
|
||||
// Queries the table with a zoneID to find.
|
||||
const CDZoneTable* Query(unsigned int zoneID);
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
|
||||
void ConstructEntity(Entity* entity, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS, bool skipChecks = false);
|
||||
void DestructEntity(Entity* entity, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
|
||||
void SerializeEntity(Entity* entity);
|
||||
virtual void SerializeEntity(Entity* entity);
|
||||
|
||||
void ConstructAllEntities(const SystemAddress& sysAddr);
|
||||
void DestructAllEntities(const SystemAddress& sysAddr);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
struct BehaviorContext;
|
||||
struct BehaviorBranchContext;
|
||||
namespace CDBehaviorParameterTable; {
|
||||
class CDBehaviorParameterTable;
|
||||
|
||||
class Behavior
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
set(DGAME_DCOMPONENTS_SOURCES "BaseCombatAIComponent.cpp"
|
||||
set(DGAME_DCOMPONENTS_SOURCES
|
||||
"BaseCombatAIComponent.cpp"
|
||||
"BouncerComponent.cpp"
|
||||
"BuffComponent.cpp"
|
||||
"BuildBorderComponent.cpp"
|
||||
|
||||
@@ -30,7 +30,7 @@ CharacterComponent::CharacterComponent(Entity* parent, Character* character) : C
|
||||
m_DirtySocialInfo = false;
|
||||
|
||||
m_PvpEnabled = false;
|
||||
m_GMLevel = character->GetGMLevel();
|
||||
m_GMLevel = character != nullptr ? character->GetGMLevel() : eGameMasterLevel::CIVILIAN;
|
||||
|
||||
m_EditorEnabled = false;
|
||||
m_EditorLevel = m_GMLevel;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "EntityManager.h"
|
||||
#include "GameMessages.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "PropertySelectQueryProperty.h"
|
||||
|
||||
/**
|
||||
* Represents the launch pad that's used to select and browse properties
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
set(DGAMETEST_SOURCES
|
||||
"EntityTests.cpp"
|
||||
"GameDependencies.cpp"
|
||||
"EntityTests.cpp"
|
||||
)
|
||||
|
||||
add_subdirectory(dComponentsTests)
|
||||
@@ -13,7 +15,7 @@ file(COPY ${GAMEMESSAGE_TESTBITSTREAMS} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
# Add the executable. Remember to add all tests above this!
|
||||
add_executable(dGameTests ${DGAMETEST_SOURCES})
|
||||
|
||||
target_link_libraries(dGameTests ${COMMON_LIBRARIES} GTest::gtest_main dGame dZoneManager dPhysics Detour Recast tinyxml2 dWorldServer dChatFilter dNavigation)
|
||||
target_link_libraries(dGameTests ${COMMON_LIBRARIES} GTest::gtest_main GTest::gmock dGame dZoneManager dPhysics Detour Recast tinyxml2 dWorldServer dChatFilter dNavigation)
|
||||
|
||||
# Discover the tests
|
||||
gtest_discover_tests(dGameTests)
|
||||
|
||||
250
tests/dGameTests/EntityTests.cpp
Normal file
250
tests/dGameTests/EntityTests.cpp
Normal file
@@ -0,0 +1,250 @@
|
||||
#include "GameDependencies.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "BaseCombatAIComponent.h"
|
||||
#include "BouncerComponent.h"
|
||||
#include "BuffComponent.h"
|
||||
#include "BuildBorderComponent.h"
|
||||
#include "CharacterComponent.h"
|
||||
#include "Component.h"
|
||||
#include "ControllablePhysicsComponent.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "LevelProgressionComponent.h"
|
||||
#include "LUPExhibitComponent.h"
|
||||
#include "MissionComponent.h"
|
||||
#include "MissionOfferComponent.h"
|
||||
#include "ModelComponent.h"
|
||||
#include "ModuleAssemblyComponent.h"
|
||||
#include "MovementAIComponent.h"
|
||||
#include "MovingPlatformComponent.h"
|
||||
#include "PetComponent.h"
|
||||
#include "PhantomPhysicsComponent.h"
|
||||
#include "PlayerForcedMovementComponent.h"
|
||||
#include "PossessableComponent.h"
|
||||
#include "PossessorComponent.h"
|
||||
#include "PropertyComponent.h"
|
||||
#include "PropertyEntranceComponent.h"
|
||||
#include "PropertyManagementComponent.h"
|
||||
#include "PropertyVendorComponent.h"
|
||||
#include "ProximityMonitorComponent.h"
|
||||
#include "RacingControlComponent.h"
|
||||
#include "RailActivatorComponent.h"
|
||||
#include "RebuildComponent.h"
|
||||
#include "RenderComponent.h"
|
||||
#include "RigidbodyPhantomPhysicsComponent.h"
|
||||
#include "RocketLaunchLupComponent.h"
|
||||
#include "RocketLaunchpadControlComponent.h"
|
||||
#include "ScriptedActivityComponent.h"
|
||||
#include "ShootingGalleryComponent.h"
|
||||
#include "SimplePhysicsComponent.h"
|
||||
#include "SkillComponent.h"
|
||||
#include "SoundTriggerComponent.h"
|
||||
#include "SwitchComponent.h"
|
||||
#include "TriggerComponent.h"
|
||||
#include "VehiclePhysicsComponent.h"
|
||||
#include "VendorComponent.h"
|
||||
|
||||
#include "Entity.h"
|
||||
#include "eReplicaPacketType.h"
|
||||
|
||||
class EntityTests : public GameDependenciesTest {
|
||||
protected:
|
||||
struct {
|
||||
BaseCombatAIComponent* baseCombatAIComponent;
|
||||
int32_t combatAiComponentTarget = 0;
|
||||
};
|
||||
BouncerComponent* bouncerComponent;
|
||||
BuffComponent* buffComponent;
|
||||
BuildBorderComponent* buildBorderComponent;
|
||||
CharacterComponent* characterComponent;
|
||||
ControllablePhysicsComponent* controllablePhysicsComponent;
|
||||
DestroyableComponent* destroyableComponent;
|
||||
InventoryComponent* inventoryComponent;
|
||||
LevelProgressionComponent* levelProgressionComponent;
|
||||
LUPExhibitComponent* lUPExhibitComponent;
|
||||
MissionComponent* missionComponent;
|
||||
MissionOfferComponent* missionOfferComponent;
|
||||
ModelComponent* modelComponent;
|
||||
ModuleAssemblyComponent* moduleAssemblyComponent;
|
||||
MovementAIComponent* movementAIComponent;
|
||||
MovingPlatformComponent* movingPlatformComponent;
|
||||
PetComponent* petComponent;
|
||||
PhantomPhysicsComponent* phantomPhysicsComponent;
|
||||
PlayerForcedMovementComponent* playerForcedMovementComponent;
|
||||
PossessableComponent* possessableComponent;
|
||||
PossessorComponent* possessorComponent;
|
||||
PropertyComponent* propertyComponent;
|
||||
PropertyEntranceComponent* propertyEntranceComponent;
|
||||
PropertyManagementComponent* propertyManagementComponent;
|
||||
PropertyVendorComponent* propertyVendorComponent;
|
||||
ProximityMonitorComponent* proximityMonitorComponent;
|
||||
RacingControlComponent* racingControlComponent;
|
||||
RailActivatorComponent* railActivatorComponent;
|
||||
RebuildComponent* rebuildComponent;
|
||||
RenderComponent* renderComponent;
|
||||
RigidbodyPhantomPhysicsComponent* rigidbodyPhantomPhysicsComponent;
|
||||
RocketLaunchLupComponent* rocketLaunchLupComponent;
|
||||
RocketLaunchpadControlComponent* rocketLaunchpadControlComponent;
|
||||
ScriptedActivityComponent* scriptedActivityComponent;
|
||||
ShootingGalleryComponent* shootingGalleryComponent;
|
||||
SimplePhysicsComponent* simplePhysicsComponent;
|
||||
SkillComponent* skillComponent;
|
||||
SoundTriggerComponent* soundTriggerComponent;
|
||||
SwitchComponent* switchComponent;
|
||||
TriggerComponent* triggerComponent;
|
||||
VehiclePhysicsComponent* vehiclePhysicsComponent;
|
||||
VendorComponent* vendorComponent;
|
||||
Entity* testedEntity;
|
||||
void SetUp() override {
|
||||
srand(time(NULL));
|
||||
SetUpDependencies();
|
||||
testedEntity = new Entity(5, info);
|
||||
Game::logger->Log("EntityTests", "starting");
|
||||
bouncerComponent = new BouncerComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "BouncerComponent");
|
||||
buffComponent = new BuffComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "BuffComponent");
|
||||
buildBorderComponent = new BuildBorderComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "BuildBorderComponent");
|
||||
characterComponent = new CharacterComponent(testedEntity, nullptr);
|
||||
Game::logger->Log("EntityTests", "CharacterComponent");
|
||||
controllablePhysicsComponent = new ControllablePhysicsComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "ControllablePhysicsComponent");
|
||||
destroyableComponent = new DestroyableComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "DestroyableComponent");
|
||||
inventoryComponent = new InventoryComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "InventoryComponent");
|
||||
levelProgressionComponent = new LevelProgressionComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "LevelProgressionComponent");
|
||||
lUPExhibitComponent = new LUPExhibitComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "LUPExhibitComponent");
|
||||
missionComponent = new MissionComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "MissionComponent");
|
||||
missionOfferComponent = new MissionOfferComponent(testedEntity, 2345);
|
||||
Game::logger->Log("EntityTests", "MissionOfferComponent");
|
||||
modelComponent = new ModelComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "ModelComponent");
|
||||
moduleAssemblyComponent = new ModuleAssemblyComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "ModuleAssemblyComponent");
|
||||
movementAIComponent = new MovementAIComponent(testedEntity, MovementAIInfo());
|
||||
Game::logger->Log("EntityTests", "MovementAIComponent");
|
||||
movingPlatformComponent = new MovingPlatformComponent(testedEntity, "");
|
||||
Game::logger->Log("EntityTests", "MovingPlatformComponent");
|
||||
petComponent = new PetComponent(testedEntity, 1234);
|
||||
Game::logger->Log("EntityTests", "PetComponent");
|
||||
phantomPhysicsComponent = new PhantomPhysicsComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "PhantomPhysicsComponent");
|
||||
playerForcedMovementComponent = new PlayerForcedMovementComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "PlayerForcedMovementComponent");
|
||||
possessableComponent = new PossessableComponent(testedEntity, 124);
|
||||
Game::logger->Log("EntityTests", "PossessableComponent");
|
||||
possessorComponent = new PossessorComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "PossessorComponent");
|
||||
propertyComponent = new PropertyComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "PropertyComponent");
|
||||
propertyEntranceComponent = new PropertyEntranceComponent(38, testedEntity);
|
||||
Game::logger->Log("EntityTests", "PropertyEntranceComponent");
|
||||
propertyManagementComponent = new PropertyManagementComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "PropertyManagementComponent");
|
||||
propertyVendorComponent = new PropertyVendorComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "PropertyVendorComponent");
|
||||
proximityMonitorComponent = new ProximityMonitorComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "ProximityMonitorComponent");
|
||||
racingControlComponent = new RacingControlComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "RacingControlComponent");
|
||||
railActivatorComponent = new RailActivatorComponent(testedEntity, 4231);
|
||||
Game::logger->Log("EntityTests", "RailActivatorComponent");
|
||||
rebuildComponent = new RebuildComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "RebuildComponent");
|
||||
renderComponent = new RenderComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "RenderComponent");
|
||||
rigidbodyPhantomPhysicsComponent = new RigidbodyPhantomPhysicsComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "RigidbodyPhantomPhysicsComponent");
|
||||
rocketLaunchLupComponent = new RocketLaunchLupComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "RocketLaunchLupComponent");
|
||||
rocketLaunchpadControlComponent = new RocketLaunchpadControlComponent(testedEntity, 5);
|
||||
Game::logger->Log("EntityTests", "RocketLaunchpadControlComponent");
|
||||
scriptedActivityComponent = new ScriptedActivityComponent(testedEntity, 4);
|
||||
Game::logger->Log("EntityTests", "ScriptedActivityComponent");
|
||||
shootingGalleryComponent = new ShootingGalleryComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "ShootingGalleryComponent");
|
||||
simplePhysicsComponent = new SimplePhysicsComponent(3, testedEntity);
|
||||
Game::logger->Log("EntityTests", "SimplePhysicsComponent");
|
||||
skillComponent = new SkillComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "SkillComponent");
|
||||
soundTriggerComponent = new SoundTriggerComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "SoundTriggerComponent");
|
||||
switchComponent = new SwitchComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "SwitchComponent");
|
||||
triggerComponent = new TriggerComponent(testedEntity, "");
|
||||
Game::logger->Log("EntityTests", "TriggerComponent");
|
||||
vehiclePhysicsComponent = new VehiclePhysicsComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "VehiclePhysicsComponent");
|
||||
vendorComponent = new VendorComponent(testedEntity);
|
||||
Game::logger->Log("EntityTests", "VendorComponent");
|
||||
baseCombatAIComponent->SetState(AiState::dead);
|
||||
combatAiComponentTarget = rand();
|
||||
baseCombatAIComponent->SetTarget(combatAiComponentTarget);
|
||||
|
||||
bouncerComponent->SetPetEnabled(true);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
TearDownDependencies();
|
||||
delete baseCombatAIComponent;
|
||||
delete bouncerComponent;
|
||||
delete buffComponent;
|
||||
delete buildBorderComponent;
|
||||
delete characterComponent;
|
||||
delete controllablePhysicsComponent;
|
||||
delete destroyableComponent;
|
||||
delete inventoryComponent;
|
||||
delete levelProgressionComponent;
|
||||
delete lUPExhibitComponent;
|
||||
delete missionComponent;
|
||||
delete missionOfferComponent;
|
||||
delete modelComponent;
|
||||
delete moduleAssemblyComponent;
|
||||
delete movementAIComponent;
|
||||
delete movingPlatformComponent;
|
||||
delete petComponent;
|
||||
delete phantomPhysicsComponent;
|
||||
delete playerForcedMovementComponent;
|
||||
delete possessableComponent;
|
||||
delete possessorComponent;
|
||||
delete propertyComponent;
|
||||
delete propertyEntranceComponent;
|
||||
delete propertyManagementComponent;
|
||||
delete propertyVendorComponent;
|
||||
delete proximityMonitorComponent;
|
||||
delete racingControlComponent;
|
||||
delete railActivatorComponent;
|
||||
delete rebuildComponent;
|
||||
delete renderComponent;
|
||||
delete rigidbodyPhantomPhysicsComponent;
|
||||
delete rocketLaunchLupComponent;
|
||||
delete rocketLaunchpadControlComponent;
|
||||
delete scriptedActivityComponent;
|
||||
delete shootingGalleryComponent;
|
||||
delete simplePhysicsComponent;
|
||||
delete skillComponent;
|
||||
delete soundTriggerComponent;
|
||||
delete switchComponent;
|
||||
delete triggerComponent;
|
||||
delete vehiclePhysicsComponent;
|
||||
delete vendorComponent;
|
||||
operator delete(testedEntity);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(EntityTests, EntityConstructionTest) {
|
||||
CBITSTREAM;
|
||||
testedEntity->WriteComponents(&bitStream, eReplicaPacketType::CONSTRUCTION);
|
||||
}
|
||||
|
||||
TEST_F(EntityTests, EntitySerializationTest) {
|
||||
CBITSTREAM;
|
||||
testedEntity->WriteComponents(&bitStream, eReplicaPacketType::SERIALIZATION);
|
||||
}
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "EntityInfo.h"
|
||||
#include "EntityManager.h"
|
||||
#include "dConfig.h"
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
class dZoneManager;
|
||||
@@ -21,6 +23,11 @@ public:
|
||||
void Send(RakNet::BitStream* bitStream, const SystemAddress& sysAddr, bool broadcast) override { sentBitStream = bitStream; };
|
||||
};
|
||||
|
||||
class EntityManagerMock : public EntityManager {
|
||||
public:
|
||||
void SerializeEntity(Entity* entity) override {};
|
||||
};
|
||||
|
||||
class GameDependenciesTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUpDependencies() {
|
||||
@@ -32,7 +39,7 @@ protected:
|
||||
Game::logger = new dLogger("./testing.log", true, true);
|
||||
Game::server = new dServerMock();
|
||||
Game::config = new dConfig("worldconfig.ini");
|
||||
Game::entityManager = new EntityManager();
|
||||
Game::entityManager = new EntityManagerMock();
|
||||
}
|
||||
|
||||
void TearDownDependencies() {
|
||||
|
||||
Reference in New Issue
Block a user