mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-12-21 03:35:05 -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"
|
set(DDATABASE_SOURCES "CDClientDatabase.cpp"
|
||||||
|
"CDClientManager.cpp"
|
||||||
"Database.cpp"
|
"Database.cpp"
|
||||||
"MigrationRunner.cpp")
|
"MigrationRunner.cpp")
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
#include "CDActivitiesTable.h"
|
#include "CDActivitiesTable.h"
|
||||||
|
|
||||||
namespace {
|
CDActivitiesTable::CDActivitiesTable(void) {
|
||||||
std::vector<CDActivities> entries;
|
|
||||||
};
|
|
||||||
|
|
||||||
void CDActivitiesTable::LoadTableIntoMemory() {
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Activities");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Activities");
|
||||||
@@ -17,7 +14,7 @@ void CDActivitiesTable::LoadTableIntoMemory() {
|
|||||||
tableSize.finalize();
|
tableSize.finalize();
|
||||||
|
|
||||||
// Reserve the size
|
// Reserve the size
|
||||||
entries.reserve(size);
|
this->entries.reserve(size);
|
||||||
|
|
||||||
// Now get the data
|
// Now get the data
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Activities");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Activities");
|
||||||
@@ -43,7 +40,7 @@ void CDActivitiesTable::LoadTableIntoMemory() {
|
|||||||
entry.noTeamLootOnDeath = tableData.getIntField("noTeamLootOnDeath", -1);
|
entry.noTeamLootOnDeath = tableData.getIntField("noTeamLootOnDeath", -1);
|
||||||
entry.optionalPercentage = tableData.getFloatField("optionalPercentage", -1.0f);
|
entry.optionalPercentage = tableData.getFloatField("optionalPercentage", -1.0f);
|
||||||
|
|
||||||
entries.push_back(entry);
|
this->entries.push_back(entry);
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,9 +49,14 @@ void CDActivitiesTable::LoadTableIntoMemory() {
|
|||||||
|
|
||||||
std::vector<CDActivities> CDActivitiesTable::Query(std::function<bool(CDActivities)> predicate) {
|
std::vector<CDActivities> CDActivitiesTable::Query(std::function<bool(CDActivities)> predicate) {
|
||||||
|
|
||||||
std::vector<CDActivities> data = cpplinq::from(entries)
|
std::vector<CDActivities> data = cpplinq::from(this->entries)
|
||||||
>> cpplinq::where(predicate)
|
>> cpplinq::where(predicate)
|
||||||
>> cpplinq::to_vector();
|
>> cpplinq::to_vector();
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<CDActivities> CDActivitiesTable::GetEntries(void) const {
|
||||||
|
return this->entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,14 @@ struct CDActivities {
|
|||||||
float optionalPercentage;
|
float optionalPercentage;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDActivitiesTable {
|
class CDActivitiesTable : public CDTable<CDActivitiesTable> {
|
||||||
void LoadTableIntoMemory();
|
private:
|
||||||
|
std::vector<CDActivities> entries;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CDActivitiesTable();
|
||||||
// Queries the table with a custom "where" clause
|
// Queries the table with a custom "where" clause
|
||||||
std::vector<CDActivities> Query(std::function<bool(CDActivities)> predicate);
|
std::vector<CDActivities> Query(std::function<bool(CDActivities)> predicate);
|
||||||
|
|
||||||
|
std::vector<CDActivities> GetEntries(void) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
#include "CDActivityRewardsTable.h"
|
#include "CDActivityRewardsTable.h"
|
||||||
|
|
||||||
namespace {
|
CDActivityRewardsTable::CDActivityRewardsTable(void) {
|
||||||
std::vector<CDActivityRewards> entries;
|
|
||||||
};
|
|
||||||
|
|
||||||
void CDActivityRewardsTable::LoadTableIntoMemory() {
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ActivityRewards");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ActivityRewards");
|
||||||
@@ -17,7 +14,7 @@ void CDActivityRewardsTable::LoadTableIntoMemory() {
|
|||||||
tableSize.finalize();
|
tableSize.finalize();
|
||||||
|
|
||||||
// Reserve the size
|
// Reserve the size
|
||||||
entries.reserve(size);
|
this->entries.reserve(size);
|
||||||
|
|
||||||
// Now get the data
|
// Now get the data
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ActivityRewards");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ActivityRewards");
|
||||||
@@ -31,7 +28,7 @@ void CDActivityRewardsTable::LoadTableIntoMemory() {
|
|||||||
entry.ChallengeRating = tableData.getIntField("ChallengeRating", -1);
|
entry.ChallengeRating = tableData.getIntField("ChallengeRating", -1);
|
||||||
entry.description = tableData.getStringField("description", "");
|
entry.description = tableData.getStringField("description", "");
|
||||||
|
|
||||||
entries.push_back(entry);
|
this->entries.push_back(entry);
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,9 +37,14 @@ void CDActivityRewardsTable::LoadTableIntoMemory() {
|
|||||||
|
|
||||||
std::vector<CDActivityRewards> CDActivityRewardsTable::Query(std::function<bool(CDActivityRewards)> predicate) {
|
std::vector<CDActivityRewards> CDActivityRewardsTable::Query(std::function<bool(CDActivityRewards)> predicate) {
|
||||||
|
|
||||||
std::vector<CDActivityRewards> data = cpplinq::from(entries)
|
std::vector<CDActivityRewards> data = cpplinq::from(this->entries)
|
||||||
>> cpplinq::where(predicate)
|
>> cpplinq::where(predicate)
|
||||||
>> cpplinq::to_vector();
|
>> cpplinq::to_vector();
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<CDActivityRewards> CDActivityRewardsTable::GetEntries(void) const {
|
||||||
|
return this->entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,15 @@ struct CDActivityRewards {
|
|||||||
std::string description; //!< The description
|
std::string description; //!< The description
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDActivityRewardsTable {
|
class CDActivityRewardsTable : public CDTable<CDActivityRewardsTable> {
|
||||||
void LoadTableIntoMemory();
|
private:
|
||||||
|
std::vector<CDActivityRewards> entries;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CDActivityRewardsTable();
|
||||||
// Queries the table with a custom "where" clause
|
// Queries the table with a custom "where" clause
|
||||||
std::vector<CDActivityRewards> Query(std::function<bool(CDActivityRewards)> predicate);
|
std::vector<CDActivityRewards> Query(std::function<bool(CDActivityRewards)> predicate);
|
||||||
|
|
||||||
|
std::vector<CDActivityRewards> GetEntries(void) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,24 +2,7 @@
|
|||||||
#include "GeneralUtils.h"
|
#include "GeneralUtils.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
|
||||||
namespace {
|
bool CDAnimationsTable::CacheData(CppSQLite3Statement& queryToCache) {
|
||||||
/**
|
|
||||||
* 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];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run the query responsible for caching the data.
|
|
||||||
*/
|
|
||||||
bool 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.
|
||||||
if (tableData.eof()) return false;
|
if (tableData.eof()) return false;
|
||||||
@@ -27,23 +10,23 @@ namespace {
|
|||||||
do {
|
do {
|
||||||
std::string animation_type = tableData.getStringField("animation_type", "");
|
std::string animation_type = tableData.getStringField("animation_type", "");
|
||||||
DluAssert(!animation_type.empty());
|
DluAssert(!animation_type.empty());
|
||||||
CDAnimationsTable::AnimationGroupID animationGroupID = tableData.getIntField("animationGroupID", -1);
|
AnimationGroupID animationGroupID = tableData.getIntField("animationGroupID", -1);
|
||||||
DluAssert(animationGroupID != -1);
|
DluAssert(animationGroupID != -1);
|
||||||
|
|
||||||
CDAnimation entry;
|
CDAnimation entry;
|
||||||
entry.animation_name = tableData.getStringField("animation_name", "");
|
entry.animation_name = tableData.getStringField("animation_name", "");
|
||||||
entry.chance_to_play = tableData.getFloatField("chance_to_play", 1.0f);
|
entry.chance_to_play = tableData.getFloatField("chance_to_play", 1.0f);
|
||||||
UNUSED_COLUMN(entry.min_loops = tableData.getIntField("min_loops", 0););
|
UNUSED_COLUMN(entry.min_loops = tableData.getIntField("min_loops", 0);)
|
||||||
UNUSED_COLUMN(entry.max_loops = tableData.getIntField("max_loops", 0););
|
UNUSED_COLUMN(entry.max_loops = tableData.getIntField("max_loops", 0);)
|
||||||
entry.animation_length = tableData.getFloatField("animation_length", 0.0f);
|
entry.animation_length = tableData.getFloatField("animation_length", 0.0f);
|
||||||
UNUSED_COLUMN(entry.hideEquip = tableData.getIntField("hideEquip", 0) == 1;);
|
UNUSED_COLUMN(entry.hideEquip = tableData.getIntField("hideEquip", 0) == 1;)
|
||||||
UNUSED_COLUMN(entry.ignoreUpperBody = tableData.getIntField("ignoreUpperBody", 0) == 1;);
|
UNUSED_COLUMN(entry.ignoreUpperBody = tableData.getIntField("ignoreUpperBody", 0) == 1;)
|
||||||
UNUSED_COLUMN(entry.restartable = tableData.getIntField("restartable", 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.face_animation_name = tableData.getStringField("face_animation_name", "");)
|
||||||
UNUSED_COLUMN(entry.priority = tableData.getFloatField("priority", 0.0f););
|
UNUSED_COLUMN(entry.priority = tableData.getFloatField("priority", 0.0f);)
|
||||||
UNUSED_COLUMN(entry.blendTime = tableData.getFloatField("blendTime", 0.0f););
|
UNUSED_COLUMN(entry.blendTime = tableData.getFloatField("blendTime", 0.0f);)
|
||||||
|
|
||||||
animations[CDAnimationsTable::CDAnimationKey(animation_type, animationGroupID)].push_back(entry);
|
this->animations[CDAnimationKey(animation_type, animationGroupID)].push_back(entry);
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
} while (!tableData.eof());
|
} while (!tableData.eof());
|
||||||
|
|
||||||
@@ -52,16 +35,19 @@ namespace {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void CDAnimationsTable::CacheAnimations(const CDAnimationKey animationKey) {
|
||||||
* Each animation is key'd by its animationName and its animationGroupID. Each
|
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM Animations WHERE animationGroupID = ? and animation_type = ?");
|
||||||
* 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.
|
query.bind(1, static_cast<int32_t>(animationKey.second));
|
||||||
*/
|
query.bind(2, animationKey.first.c_str());
|
||||||
std::map<CDAnimationsTable::CDAnimationKey, std::list<CDAnimation>> animations;
|
// If we received a bad lookup, cache it anyways so we do not run the query again.
|
||||||
};
|
if (!CacheData(query)) {
|
||||||
|
this->animations[animationKey];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CDAnimationsTable::CacheAnimationGroup(AnimationGroupID animationGroupID) {
|
void CDAnimationsTable::CacheAnimationGroup(AnimationGroupID animationGroupID) {
|
||||||
auto animationEntryCached = animations.find(CDAnimationKey("", animationGroupID));
|
auto animationEntryCached = this->animations.find(CDAnimationKey("", animationGroupID));
|
||||||
if (animationEntryCached != animations.end()) {
|
if (animationEntryCached != this->animations.end()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,17 +56,17 @@ void CDAnimationsTable::CacheAnimationGroup(AnimationGroupID animationGroupID) {
|
|||||||
|
|
||||||
// Cache the query so we don't run the query again.
|
// Cache the query so we don't run the query again.
|
||||||
CacheData(query);
|
CacheData(query);
|
||||||
animations[CDAnimationKey("", animationGroupID)];
|
this->animations[CDAnimationKey("", animationGroupID)];
|
||||||
}
|
}
|
||||||
|
|
||||||
CDAnimationLookupResult CDAnimationsTable::GetAnimation(const AnimationID& animationType, const std::string& previousAnimationName, const AnimationGroupID animationGroupID) {
|
CDAnimationLookupResult CDAnimationsTable::GetAnimation(const AnimationID& animationType, const std::string& previousAnimationName, const AnimationGroupID animationGroupID) {
|
||||||
CDAnimationKey animationKey(animationType, animationGroupID);
|
CDAnimationKey animationKey(animationType, animationGroupID);
|
||||||
auto animationEntryCached = animations.find(animationKey);
|
auto animationEntryCached = this->animations.find(animationKey);
|
||||||
if (animationEntryCached == animations.end()) {
|
if (animationEntryCached == this->animations.end()) {
|
||||||
CacheAnimations(animationKey);
|
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 we have only one animation, return it regardless of the chance to play.
|
||||||
if (animationEntry->second.size() == 1) {
|
if (animationEntry->second.size() == 1) {
|
||||||
return CDAnimationLookupResult(animationEntry->second.front());
|
return CDAnimationLookupResult(animationEntry->second.front());
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ struct CDAnimation {
|
|||||||
|
|
||||||
typedef LookupResult<CDAnimation> CDAnimationLookupResult;
|
typedef LookupResult<CDAnimation> CDAnimationLookupResult;
|
||||||
|
|
||||||
namespace CDAnimationsTable {
|
class CDAnimationsTable : public CDTable<CDAnimationsTable> {
|
||||||
typedef int32_t AnimationGroupID;
|
typedef int32_t AnimationGroupID;
|
||||||
typedef std::string AnimationID;
|
typedef std::string AnimationID;
|
||||||
typedef std::pair<std::string, AnimationGroupID> CDAnimationKey;
|
typedef std::pair<std::string, AnimationGroupID> CDAnimationKey;
|
||||||
void LoadTableIntoMemory();
|
public:
|
||||||
/**
|
/**
|
||||||
* Given an animationType and the previousAnimationName played, return the next animationType to play.
|
* Given an animationType and the previousAnimationName played, return the next animationType to play.
|
||||||
* If there are more than 1 animationTypes that can be played, one is selected at random but also does not allow
|
* If there are more than 1 animationTypes that can be played, one is selected at random but also does not allow
|
||||||
@@ -43,4 +43,24 @@ namespace CDAnimationsTable {
|
|||||||
* Cache a full AnimationGroup by its ID.
|
* Cache a full AnimationGroup by its ID.
|
||||||
*/
|
*/
|
||||||
void CacheAnimationGroup(AnimationGroupID animationGroupID);
|
void CacheAnimationGroup(AnimationGroupID animationGroupID);
|
||||||
|
private:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache all animations given a premade key
|
||||||
|
*/
|
||||||
|
void CacheAnimations(const CDAnimationKey animationKey);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the query responsible for caching the data.
|
||||||
|
* @param queryToCache
|
||||||
|
* @return true
|
||||||
|
* @return false
|
||||||
|
*/
|
||||||
|
bool CacheData(CppSQLite3Statement& queryToCache);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Each animation is key'd by its animationName and its animationGroupID. Each
|
||||||
|
* animation has a possible list of animations. This is because there can be animations have a percent chance to play so one is selected at random.
|
||||||
|
*/
|
||||||
|
std::map<CDAnimationKey, std::list<CDAnimation>> animations;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
#include "CDBehaviorParameterTable.h"
|
#include "CDBehaviorParameterTable.h"
|
||||||
#include "GeneralUtils.h"
|
#include "GeneralUtils.h"
|
||||||
|
|
||||||
namespace {
|
CDBehaviorParameterTable::CDBehaviorParameterTable(void) {
|
||||||
std::unordered_map<uint64_t, CDBehaviorParameter> m_Entries;
|
|
||||||
std::unordered_map<std::string, uint32_t> m_ParametersList;
|
|
||||||
};
|
|
||||||
|
|
||||||
void CDBehaviorParameterTable::LoadTableIntoMemory() {
|
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BehaviorParameter");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BehaviorParameter");
|
||||||
uint32_t uniqueParameterId = 0;
|
uint32_t uniqueParameterId = 0;
|
||||||
uint64_t hash = 0;
|
uint64_t hash = 0;
|
||||||
@@ -33,8 +28,8 @@ void CDBehaviorParameterTable::LoadTableIntoMemory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 = m_ParametersList.find(name);
|
auto parameterID = this->m_ParametersList.find(name);
|
||||||
if (parameterID == m_ParametersList.end()) return defaultValue;
|
if (parameterID == this->m_ParametersList.end()) return defaultValue;
|
||||||
|
|
||||||
uint64_t hash = behaviorID;
|
uint64_t hash = behaviorID;
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,13 @@ struct CDBehaviorParameter {
|
|||||||
float value; //!< The value of the behavior template
|
float value; //!< The value of the behavior template
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDBehaviorParameterTable {
|
class CDBehaviorParameterTable : public CDTable<CDBehaviorParameterTable> {
|
||||||
void LoadTableIntoMemory();
|
private:
|
||||||
float GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue = 0.0f);
|
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);
|
std::map<std::string, float> GetParametersByBehaviorID(uint32_t behaviorID);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
#include "CDBehaviorTemplateTable.h"
|
#include "CDBehaviorTemplateTable.h"
|
||||||
|
|
||||||
namespace {
|
CDBehaviorTemplateTable::CDBehaviorTemplateTable(void) {
|
||||||
std::vector<CDBehaviorTemplate> entries;
|
|
||||||
std::unordered_map<uint32_t, CDBehaviorTemplate> entriesMappedByBehaviorID;
|
|
||||||
std::unordered_set<std::string> m_EffectHandles;
|
|
||||||
};
|
|
||||||
|
|
||||||
void CDBehaviorTemplateTable::LoadTableIntoMemory() {
|
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -20,7 +14,7 @@ void CDBehaviorTemplateTable::LoadTableIntoMemory() {
|
|||||||
tableSize.finalize();
|
tableSize.finalize();
|
||||||
|
|
||||||
// Reserve the size
|
// Reserve the size
|
||||||
entries.reserve(size);
|
this->entries.reserve(size);
|
||||||
|
|
||||||
// Now get the data
|
// Now get the data
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BehaviorTemplate");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BehaviorTemplate");
|
||||||
@@ -37,8 +31,8 @@ void CDBehaviorTemplateTable::LoadTableIntoMemory() {
|
|||||||
entry.effectHandle = m_EffectHandles.insert(candidateToAdd).first;
|
entry.effectHandle = m_EffectHandles.insert(candidateToAdd).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
entries.push_back(entry);
|
this->entries.push_back(entry);
|
||||||
entriesMappedByBehaviorID.insert(std::make_pair(entry.behaviorID, entry));
|
this->entriesMappedByBehaviorID.insert(std::make_pair(entry.behaviorID, entry));
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,16 +41,20 @@ void CDBehaviorTemplateTable::LoadTableIntoMemory() {
|
|||||||
|
|
||||||
std::vector<CDBehaviorTemplate> CDBehaviorTemplateTable::Query(std::function<bool(CDBehaviorTemplate)> predicate) {
|
std::vector<CDBehaviorTemplate> CDBehaviorTemplateTable::Query(std::function<bool(CDBehaviorTemplate)> predicate) {
|
||||||
|
|
||||||
std::vector<CDBehaviorTemplate> data = cpplinq::from(entries)
|
std::vector<CDBehaviorTemplate> data = cpplinq::from(this->entries)
|
||||||
>> cpplinq::where(predicate)
|
>> cpplinq::where(predicate)
|
||||||
>> cpplinq::to_vector();
|
>> cpplinq::to_vector();
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<CDBehaviorTemplate> CDBehaviorTemplateTable::GetEntries(void) const {
|
||||||
|
return this->entries;
|
||||||
|
}
|
||||||
|
|
||||||
const CDBehaviorTemplate CDBehaviorTemplateTable::GetByBehaviorID(uint32_t behaviorID) {
|
const CDBehaviorTemplate CDBehaviorTemplateTable::GetByBehaviorID(uint32_t behaviorID) {
|
||||||
auto entry = entriesMappedByBehaviorID.find(behaviorID);
|
auto entry = this->entriesMappedByBehaviorID.find(behaviorID);
|
||||||
if (entry == entriesMappedByBehaviorID.end()) {
|
if (entry == this->entriesMappedByBehaviorID.end()) {
|
||||||
CDBehaviorTemplate entryToReturn;
|
CDBehaviorTemplate entryToReturn;
|
||||||
entryToReturn.behaviorID = 0;
|
entryToReturn.behaviorID = 0;
|
||||||
entryToReturn.effectHandle = m_EffectHandles.end();
|
entryToReturn.effectHandle = m_EffectHandles.end();
|
||||||
|
|||||||
@@ -6,17 +6,24 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
struct CDBehaviorTemplate {
|
struct CDBehaviorTemplate {
|
||||||
uint32_t behaviorID; //!< The Behavior ID
|
unsigned int behaviorID; //!< The Behavior ID
|
||||||
uint32_t templateID; //!< The Template ID (LOT)
|
unsigned int templateID; //!< The Template ID (LOT)
|
||||||
uint32_t effectID; //!< The Effect ID attached
|
unsigned int effectID; //!< The Effect ID attached
|
||||||
std::unordered_set<std::string>::iterator effectHandle; //!< The effect handle
|
std::unordered_set<std::string>::iterator effectHandle; //!< The effect handle
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
namespace CDBehaviorTemplateTable {
|
class CDBehaviorTemplateTable : public CDTable<CDBehaviorTemplateTable> {
|
||||||
void LoadTableIntoMemory();
|
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
|
// Queries the table with a custom "where" clause
|
||||||
std::vector<CDBehaviorTemplate> Query(std::function<bool(CDBehaviorTemplate)> predicate);
|
std::vector<CDBehaviorTemplate> Query(std::function<bool(CDBehaviorTemplate)> predicate);
|
||||||
|
|
||||||
|
std::vector<CDBehaviorTemplate> GetEntries(void) const;
|
||||||
|
|
||||||
const CDBehaviorTemplate GetByBehaviorID(uint32_t behaviorID);
|
const CDBehaviorTemplate GetByBehaviorID(uint32_t behaviorID);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
#include "CDBrickIDTableTable.h"
|
#include "CDBrickIDTableTable.h"
|
||||||
|
|
||||||
namespace {
|
CDBrickIDTableTable::CDBrickIDTableTable(void) {
|
||||||
std::vector<CDBrickIDTable> entries;
|
|
||||||
};
|
|
||||||
|
|
||||||
void CDBrickIDTableTable::LoadTableIntoMemory() {
|
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -18,7 +14,7 @@ void CDBrickIDTableTable::LoadTableIntoMemory() {
|
|||||||
tableSize.finalize();
|
tableSize.finalize();
|
||||||
|
|
||||||
// Reserve the size
|
// Reserve the size
|
||||||
entries.reserve(size);
|
this->entries.reserve(size);
|
||||||
|
|
||||||
// Now get the data
|
// Now get the data
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BrickIDTable");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BrickIDTable");
|
||||||
@@ -27,7 +23,7 @@ void CDBrickIDTableTable::LoadTableIntoMemory() {
|
|||||||
entry.NDObjectID = tableData.getIntField("NDObjectID", -1);
|
entry.NDObjectID = tableData.getIntField("NDObjectID", -1);
|
||||||
entry.LEGOBrickID = tableData.getIntField("LEGOBrickID", -1);
|
entry.LEGOBrickID = tableData.getIntField("LEGOBrickID", -1);
|
||||||
|
|
||||||
entries.push_back(entry);
|
this->entries.push_back(entry);
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,9 +32,14 @@ void CDBrickIDTableTable::LoadTableIntoMemory() {
|
|||||||
|
|
||||||
std::vector<CDBrickIDTable> CDBrickIDTableTable::Query(std::function<bool(CDBrickIDTable)> predicate) {
|
std::vector<CDBrickIDTable> CDBrickIDTableTable::Query(std::function<bool(CDBrickIDTable)> predicate) {
|
||||||
|
|
||||||
std::vector<CDBrickIDTable> data = cpplinq::from(entries)
|
std::vector<CDBrickIDTable> data = cpplinq::from(this->entries)
|
||||||
>> cpplinq::where(predicate)
|
>> cpplinq::where(predicate)
|
||||||
>> cpplinq::to_vector();
|
>> cpplinq::to_vector();
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<CDBrickIDTable> CDBrickIDTableTable::GetEntries(void) const {
|
||||||
|
return this->entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,14 @@ struct CDBrickIDTable {
|
|||||||
|
|
||||||
|
|
||||||
//! BrickIDTable table
|
//! BrickIDTable table
|
||||||
namespace CDBrickIDTableTable {
|
class CDBrickIDTableTable : public CDTable<CDBrickIDTableTable> {
|
||||||
void LoadTableIntoMemory();
|
private:
|
||||||
|
std::vector<CDBrickIDTable> entries;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CDBrickIDTableTable();
|
||||||
// Queries the table with a custom "where" clause
|
// Queries the table with a custom "where" clause
|
||||||
std::vector<CDBrickIDTable> Query(std::function<bool(CDBrickIDTable)> predicate);
|
std::vector<CDBrickIDTable> Query(std::function<bool(CDBrickIDTable)> predicate);
|
||||||
|
|
||||||
|
std::vector<CDBrickIDTable> GetEntries(void) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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
|
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);
|
int32_t GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue = 0);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ struct CDCurrencyTable {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//! CurrencyTable table
|
//! CurrencyTable table
|
||||||
namespace CDCurrencyTableTable {
|
class CDCurrencyTableTable : public CDTable<CDCurrencyTableTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDCurrencyTable> entries;
|
std::vector<CDCurrencyTable> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDCurrencyTableTable();
|
||||||
// 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);
|
||||||
|
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ struct CDDestructibleComponent {
|
|||||||
int difficultyLevel; //!< ???
|
int difficultyLevel; //!< ???
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDDestructibleComponentTable {
|
class CDDestructibleComponentTable : public CDTable<CDDestructibleComponentTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDDestructibleComponent> entries;
|
std::vector<CDDestructibleComponent> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDDestructibleComponentTable();
|
||||||
// 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);
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +1,40 @@
|
|||||||
#include "CDEmoteTable.h"
|
#include "CDEmoteTable.h"
|
||||||
|
|
||||||
namespace {
|
//! Constructor
|
||||||
std::map<int, CDEmoteTable> entries;
|
CDEmoteTableTable::CDEmoteTableTable(void) {
|
||||||
};
|
|
||||||
|
|
||||||
void CDEmoteTableTable::LoadTableIntoMemory() {
|
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Emotes");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Emotes");
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDEmoteTable entry;
|
CDEmoteTable* entry = new CDEmoteTable();
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
CDEmoteTable* CDEmoteTableTable::GetEmote(int id) {
|
//! Destructor
|
||||||
return entries.find(id) != entries.end() ? &entries[id] : nullptr;
|
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;
|
std::string gateVersion;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDEmoteTableTable {
|
class CDEmoteTableTable : public CDTable<CDEmoteTableTable> {
|
||||||
void LoadTableIntoMemory();
|
private:
|
||||||
|
std::map<int, CDEmoteTable*> entries;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CDEmoteTableTable();
|
||||||
|
~CDEmoteTableTable();
|
||||||
// Returns an emote by ID
|
// Returns an emote by ID
|
||||||
CDEmoteTable* GetEmote(int id);
|
CDEmoteTable* GetEmote(int id);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ struct CDFeatureGating {
|
|||||||
std::string description;
|
std::string description;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDFeatureGatingTable {
|
class CDFeatureGatingTable : public CDTable<CDFeatureGatingTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDFeatureGating> entries;
|
std::vector<CDFeatureGating> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDFeatureGatingTable();
|
||||||
// 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);
|
||||||
|
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ struct CDInventoryComponent {
|
|||||||
bool equip; //!< Whether or not to equip the item
|
bool equip; //!< Whether or not to equip the item
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDInventoryComponentTable {
|
class CDInventoryComponentTable : public CDTable<CDInventoryComponentTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDInventoryComponent> entries;
|
std::vector<CDInventoryComponent> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDInventoryComponentTable();
|
||||||
// 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);
|
||||||
|
|
||||||
|
|||||||
@@ -49,12 +49,12 @@ struct CDItemComponent {
|
|||||||
float SellMultiplier; //!< Something to do with early vendors perhaps (but replaced)
|
float SellMultiplier; //!< Something to do with early vendors perhaps (but replaced)
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDItemComponentTable {
|
class CDItemComponentTable : public CDTable<CDItemComponentTable> {
|
||||||
private:
|
private:
|
||||||
std::map<unsigned int, CDItemComponent> entries;
|
std::map<unsigned int, CDItemComponent> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDItemComponentTable();
|
||||||
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
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ struct CDItemSetSkills {
|
|||||||
unsigned int SkillCastType; //!< The skill cast type
|
unsigned int SkillCastType; //!< The skill cast type
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDItemSetSkillsTable {
|
class CDItemSetSkillsTable : public CDTable<CDItemSetSkillsTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDItemSetSkills> entries;
|
std::vector<CDItemSetSkills> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDItemSetSkillsTable();
|
||||||
// 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);
|
||||||
|
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ struct CDItemSets {
|
|||||||
float priority; //!< The priority
|
float priority; //!< The priority
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDItemSetsTable {
|
class CDItemSetsTable : public CDTable<CDItemSetsTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDItemSets> entries;
|
std::vector<CDItemSets> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDItemSetsTable();
|
||||||
// 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);
|
||||||
|
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ struct CDLevelProgressionLookup {
|
|||||||
std::string BehaviorEffect; //!< The behavior effect attached to this
|
std::string BehaviorEffect; //!< The behavior effect attached to this
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDLevelProgressionLookupTable {
|
class CDLevelProgressionLookupTable : public CDTable<CDLevelProgressionLookupTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDLevelProgressionLookup> entries;
|
std::vector<CDLevelProgressionLookup> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDLevelProgressionLookupTable();
|
||||||
// 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);
|
||||||
|
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ struct CDLootMatrix {
|
|||||||
UNUSED(std::string gate_version); //!< The Gate Version
|
UNUSED(std::string gate_version); //!< The Gate Version
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDLootMatrixTable {
|
class CDLootMatrixTable : public CDTable<CDLootMatrixTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDLootMatrix> entries;
|
std::vector<CDLootMatrix> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDLootMatrixTable();
|
||||||
// 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);
|
||||||
|
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ struct CDLootTable {
|
|||||||
unsigned int sortPriority; //!< The sorting priority
|
unsigned int sortPriority; //!< The sorting priority
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDLootTableTable {
|
class CDLootTableTable : public CDTable<CDLootTableTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDLootTable> entries;
|
std::vector<CDLootTable> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDLootTableTable();
|
||||||
// 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);
|
||||||
|
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ struct CDMissionEmail {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
namespace CDMissionEmailTable {
|
class CDMissionEmailTable : public CDTable<CDMissionEmailTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDMissionEmail> entries;
|
std::vector<CDMissionEmail> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDMissionEmailTable();
|
||||||
// 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);
|
||||||
|
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ struct CDMissionNPCComponent {
|
|||||||
std::string gate_version; //!< The gate version
|
std::string gate_version; //!< The gate version
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDMissionNPCComponentTable {
|
class CDMissionNPCComponentTable : public CDTable<CDMissionNPCComponentTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDMissionNPCComponent> entries;
|
std::vector<CDMissionNPCComponent> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDMissionNPCComponentTable();
|
||||||
// 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);
|
||||||
|
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ struct CDMissionTasks {
|
|||||||
UNUSED(std::string gate_version); //!< ???
|
UNUSED(std::string gate_version); //!< ???
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDMissionTasksTable {
|
class CDMissionTasksTable : public CDTable<CDMissionTasksTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDMissionTasks> entries;
|
std::vector<CDMissionTasks> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDMissionTasksTable();
|
||||||
// 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);
|
||||||
|
|
||||||
|
|||||||
@@ -60,12 +60,12 @@ struct CDMissions {
|
|||||||
int reward_bankinventory; //!< The amount of bank space this mission rewards
|
int reward_bankinventory; //!< The amount of bank space this mission rewards
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDMissionsTable {
|
class CDMissionsTable : public CDTable<CDMissionsTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDMissions> entries;
|
std::vector<CDMissions> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDMissionsTable();
|
||||||
// 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);
|
||||||
|
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ struct CDMovementAIComponent {
|
|||||||
std::string attachedPath;
|
std::string attachedPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDMovementAIComponentTable {
|
class CDMovementAIComponentTable : public CDTable<CDMovementAIComponentTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDMovementAIComponent> entries;
|
std::vector<CDMovementAIComponent> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDMovementAIComponentTable();
|
||||||
// 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);
|
||||||
|
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ struct CDObjectSkills {
|
|||||||
unsigned int AICombatWeight; //!< ???
|
unsigned int AICombatWeight; //!< ???
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDObjectSkillsTable {
|
class CDObjectSkillsTable : public CDTable<CDObjectSkillsTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDObjectSkills> entries;
|
std::vector<CDObjectSkills> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDObjectSkillsTable();
|
||||||
// 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);
|
||||||
|
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ struct CDObjects {
|
|||||||
UNUSED(unsigned int HQ_valid); //!< Probably used for the Nexus HQ database on LEGOUniverse.com
|
UNUSED(unsigned int HQ_valid); //!< Probably used for the Nexus HQ database on LEGOUniverse.com
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDObjectsTable {
|
class CDObjectsTable : public CDTable<CDObjectsTable> {
|
||||||
private:
|
private:
|
||||||
std::map<unsigned int, CDObjects> entries;
|
std::map<unsigned int, CDObjects> entries;
|
||||||
CDObjects m_default;
|
CDObjects m_default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDObjectsTable();
|
||||||
// Gets an entry by ID
|
// Gets an entry by ID
|
||||||
const CDObjects& GetByID(unsigned int LOT);
|
const CDObjects& GetByID(unsigned int LOT);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ struct CDPackageComponent {
|
|||||||
unsigned int packageType;
|
unsigned int packageType;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDPackageComponentTable {
|
class CDPackageComponentTable : public CDTable<CDPackageComponentTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDPackageComponent> entries;
|
std::vector<CDPackageComponent> entries;
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,10 @@ struct CDPhysicsComponent {
|
|||||||
UNUSED(std::string gravityVolumeAsset);
|
UNUSED(std::string gravityVolumeAsset);
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDPhysicsComponentTable {
|
class CDPhysicsComponentTable : public CDTable<CDPhysicsComponentTable> {
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDPhysicsComponentTable();
|
||||||
|
~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);
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ struct CDPropertyEntranceComponent {
|
|||||||
std::string groupType;
|
std::string groupType;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDPropertyEntranceComponentTable {
|
class CDPropertyEntranceComponentTable : public CDTable<CDPropertyEntranceComponentTable> {
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDPropertyEntranceComponentTable();
|
||||||
// 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);
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ struct CDPropertyTemplate {
|
|||||||
std::string spawnName;
|
std::string spawnName;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDPropertyTemplateTable {
|
class CDPropertyTemplateTable : public CDTable<CDPropertyTemplateTable> {
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDPropertyTemplateTable();
|
||||||
|
|
||||||
static const std::string GetTableName() { return "PropertyTemplate"; };
|
static const std::string GetTableName() { return "PropertyTemplate"; };
|
||||||
CDPropertyTemplate GetByMapID(uint32_t mapID);
|
CDPropertyTemplate GetByMapID(uint32_t mapID);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ struct CDProximityMonitorComponent {
|
|||||||
bool LoadOnServer;
|
bool LoadOnServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDProximityMonitorComponentTable {
|
class CDProximityMonitorComponentTable : public CDTable<CDProximityMonitorComponentTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDProximityMonitorComponent> entries;
|
std::vector<CDProximityMonitorComponent> entries;
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ struct CDRailActivatorComponent {
|
|||||||
bool showNameBillboard;
|
bool showNameBillboard;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDRailActivatorComponentTable {
|
class CDRailActivatorComponentTable : public CDTable<CDRailActivatorComponentTable> {
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDRailActivatorComponentTable();
|
||||||
static const std::string GetTableName() { return "RailActivatorComponent"; };
|
static const std::string GetTableName() { return "RailActivatorComponent"; };
|
||||||
[[nodiscard]] CDRailActivatorComponent GetEntryByID(int32_t id) const;
|
[[nodiscard]] CDRailActivatorComponent GetEntryByID(int32_t id) const;
|
||||||
[[nodiscard]] std::vector<CDRailActivatorComponent> GetEntries() const;
|
[[nodiscard]] std::vector<CDRailActivatorComponent> GetEntries() const;
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ struct CDRarityTable {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDRarityTableTable {
|
class CDRarityTableTable : public CDTable<CDRarityTableTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDRarityTable> entries;
|
std::vector<CDRarityTable> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDRarityTableTable();
|
||||||
// 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);
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ struct CDRebuildComponent {
|
|||||||
float time_before_smash; //!< The time before smash
|
float time_before_smash; //!< The time before smash
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDRebuildComponentTable {
|
class CDRebuildComponentTable : public CDTable<CDRebuildComponentTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDRebuildComponent> entries;
|
std::vector<CDRebuildComponent> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDRebuildComponentTable();
|
||||||
// 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);
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,10 @@ struct CDRewards {
|
|||||||
int32_t count;
|
int32_t count;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDRewardsTable {
|
class CDRewardsTable : public CDTable<CDRewardsTable> {
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDRewardsTable();
|
||||||
|
~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);
|
||||||
|
|||||||
@@ -9,13 +9,13 @@ struct CDScriptComponent {
|
|||||||
std::string client_script_name; //!< The client script name
|
std::string client_script_name; //!< The client script name
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDScriptComponentTable {
|
class CDScriptComponentTable : public CDTable<CDScriptComponentTable> {
|
||||||
private:
|
private:
|
||||||
std::map<unsigned int, CDScriptComponent> entries;
|
std::map<unsigned int, CDScriptComponent> entries;
|
||||||
CDScriptComponent m_ToReturnWhenNoneFound;
|
CDScriptComponent m_ToReturnWhenNoneFound;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDScriptComponentTable();
|
||||||
// Gets an entry by scriptID
|
// Gets an entry by scriptID
|
||||||
const CDScriptComponent& GetByID(unsigned int id);
|
const CDScriptComponent& GetByID(unsigned int id);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ struct CDSkillBehavior {
|
|||||||
UNUSED(unsigned int cancelType); //!< The cancel type (?)
|
UNUSED(unsigned int cancelType); //!< The cancel type (?)
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDSkillBehaviorTable {
|
class CDSkillBehaviorTable : public CDTable<CDSkillBehaviorTable> {
|
||||||
private:
|
private:
|
||||||
std::map<unsigned int, CDSkillBehavior> entries;
|
std::map<unsigned int, CDSkillBehavior> entries;
|
||||||
CDSkillBehavior m_empty;
|
CDSkillBehavior m_empty;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDSkillBehaviorTable();
|
||||||
// Queries the table with a custom "where" clause
|
// Queries the table with a custom "where" clause
|
||||||
std::vector<CDSkillBehavior> Query(std::function<bool(CDSkillBehavior)> predicate);
|
std::vector<CDSkillBehavior> Query(std::function<bool(CDSkillBehavior)> predicate);
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,12 @@
|
|||||||
#pragma warning (disable : 4244) //Disable double to float conversion warnings
|
#pragma warning (disable : 4244) //Disable double to float conversion warnings
|
||||||
#pragma warning (disable : 4715) //Disable "not all control paths return a value"
|
#pragma warning (disable : 4715) //Disable "not all control paths return a value"
|
||||||
|
|
||||||
|
template<class Table>
|
||||||
|
class CDTable : public Singleton<Table> {
|
||||||
|
protected:
|
||||||
|
virtual ~CDTable() = default;
|
||||||
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class LookupResult {
|
class LookupResult {
|
||||||
typedef std::pair<T, bool> DataType;
|
typedef std::pair<T, bool> DataType;
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ struct CDVendorComponent {
|
|||||||
unsigned int LootMatrixIndex; //!< LootMatrixIndex of the vendor's items
|
unsigned int LootMatrixIndex; //!< LootMatrixIndex of the vendor's items
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDVendorComponentTable {
|
class CDVendorComponentTable : public CDTable<CDVendorComponentTable> {
|
||||||
private:
|
private:
|
||||||
std::vector<CDVendorComponent> entries;
|
std::vector<CDVendorComponent> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDVendorComponentTable();
|
||||||
// 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);
|
||||||
|
|
||||||
|
|||||||
@@ -33,12 +33,12 @@ struct CDZoneTable {
|
|||||||
UNUSED(bool mountsAllowed); //!< Whether or not mounts are allowed
|
UNUSED(bool mountsAllowed); //!< Whether or not mounts are allowed
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace CDZoneTableTable {
|
class CDZoneTableTable : public CDTable<CDZoneTableTable> {
|
||||||
private:
|
private:
|
||||||
std::map<unsigned int, CDZoneTable> m_Entries;
|
std::map<unsigned int, CDZoneTable> m_Entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTableIntoMemory();
|
CDZoneTableTable();
|
||||||
|
|
||||||
// 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);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public:
|
|||||||
|
|
||||||
void ConstructEntity(Entity* entity, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS, bool skipChecks = false);
|
void ConstructEntity(Entity* entity, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS, bool skipChecks = false);
|
||||||
void DestructEntity(Entity* entity, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
|
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 ConstructAllEntities(const SystemAddress& sysAddr);
|
||||||
void DestructAllEntities(const SystemAddress& sysAddr);
|
void DestructAllEntities(const SystemAddress& sysAddr);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
struct BehaviorContext;
|
struct BehaviorContext;
|
||||||
struct BehaviorBranchContext;
|
struct BehaviorBranchContext;
|
||||||
namespace CDBehaviorParameterTable; {
|
class CDBehaviorParameterTable;
|
||||||
|
|
||||||
class Behavior
|
class Behavior
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
set(DGAME_DCOMPONENTS_SOURCES "BaseCombatAIComponent.cpp"
|
set(DGAME_DCOMPONENTS_SOURCES
|
||||||
|
"BaseCombatAIComponent.cpp"
|
||||||
"BouncerComponent.cpp"
|
"BouncerComponent.cpp"
|
||||||
"BuffComponent.cpp"
|
"BuffComponent.cpp"
|
||||||
"BuildBorderComponent.cpp"
|
"BuildBorderComponent.cpp"
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ CharacterComponent::CharacterComponent(Entity* parent, Character* character) : C
|
|||||||
m_DirtySocialInfo = false;
|
m_DirtySocialInfo = false;
|
||||||
|
|
||||||
m_PvpEnabled = false;
|
m_PvpEnabled = false;
|
||||||
m_GMLevel = character->GetGMLevel();
|
m_GMLevel = character != nullptr ? character->GetGMLevel() : eGameMasterLevel::CIVILIAN;
|
||||||
|
|
||||||
m_EditorEnabled = false;
|
m_EditorEnabled = false;
|
||||||
m_EditorLevel = m_GMLevel;
|
m_EditorLevel = m_GMLevel;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "EntityManager.h"
|
#include "EntityManager.h"
|
||||||
#include "GameMessages.h"
|
#include "GameMessages.h"
|
||||||
#include "eReplicaComponentType.h"
|
#include "eReplicaComponentType.h"
|
||||||
|
#include "PropertySelectQueryProperty.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the launch pad that's used to select and browse properties
|
* Represents the launch pad that's used to select and browse properties
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
set(DGAMETEST_SOURCES
|
set(DGAMETEST_SOURCES
|
||||||
|
"EntityTests.cpp"
|
||||||
"GameDependencies.cpp"
|
"GameDependencies.cpp"
|
||||||
|
"EntityTests.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectory(dComponentsTests)
|
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 the executable. Remember to add all tests above this!
|
||||||
add_executable(dGameTests ${DGAMETEST_SOURCES})
|
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
|
# Discover the tests
|
||||||
gtest_discover_tests(dGameTests)
|
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 "EntityInfo.h"
|
||||||
#include "EntityManager.h"
|
#include "EntityManager.h"
|
||||||
#include "dConfig.h"
|
#include "dConfig.h"
|
||||||
|
|
||||||
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
class dZoneManager;
|
class dZoneManager;
|
||||||
@@ -21,6 +23,11 @@ public:
|
|||||||
void Send(RakNet::BitStream* bitStream, const SystemAddress& sysAddr, bool broadcast) override { sentBitStream = bitStream; };
|
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 {
|
class GameDependenciesTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
void SetUpDependencies() {
|
void SetUpDependencies() {
|
||||||
@@ -32,7 +39,7 @@ protected:
|
|||||||
Game::logger = new dLogger("./testing.log", true, true);
|
Game::logger = new dLogger("./testing.log", true, true);
|
||||||
Game::server = new dServerMock();
|
Game::server = new dServerMock();
|
||||||
Game::config = new dConfig("worldconfig.ini");
|
Game::config = new dConfig("worldconfig.ini");
|
||||||
Game::entityManager = new EntityManager();
|
Game::entityManager = new EntityManagerMock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDownDependencies() {
|
void TearDownDependencies() {
|
||||||
|
|||||||
Reference in New Issue
Block a user