mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-01-05 16:13:51 -06:00
Compare commits
1 Commits
cdcinstanc
...
ZoneInstan
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04a97e618b |
@@ -97,56 +97,15 @@ make_directory(${CMAKE_BINARY_DIR}/logs)
|
|||||||
|
|
||||||
# Copy resource files on first build
|
# Copy resource files on first build
|
||||||
set(RESOURCE_FILES "sharedconfig.ini" "authconfig.ini" "chatconfig.ini" "worldconfig.ini" "masterconfig.ini" "blacklist.dcf")
|
set(RESOURCE_FILES "sharedconfig.ini" "authconfig.ini" "chatconfig.ini" "worldconfig.ini" "masterconfig.ini" "blacklist.dcf")
|
||||||
message(STATUS "Checking resource file integrity")
|
|
||||||
foreach(resource_file ${RESOURCE_FILES})
|
foreach(resource_file ${RESOURCE_FILES})
|
||||||
set(file_size 0)
|
if (NOT EXISTS ${PROJECT_BINARY_DIR}/${resource_file})
|
||||||
if (EXISTS ${PROJECT_BINARY_DIR}/${resource_file})
|
|
||||||
file(SIZE ${PROJECT_BINARY_DIR}/${resource_file} file_size)
|
|
||||||
endif()
|
|
||||||
if (${file_size} EQUAL 0)
|
|
||||||
configure_file(
|
configure_file(
|
||||||
${CMAKE_SOURCE_DIR}/resources/${resource_file} ${PROJECT_BINARY_DIR}/${resource_file}
|
${CMAKE_SOURCE_DIR}/resources/${resource_file} ${PROJECT_BINARY_DIR}/${resource_file}
|
||||||
COPYONLY
|
COPYONLY
|
||||||
)
|
)
|
||||||
message(STATUS "Moved " ${resource_file} " to project binary directory")
|
message("Moved ${resource_file} to project binary directory")
|
||||||
elseif (resource_file MATCHES ".ini")
|
|
||||||
message(STATUS "Checking " ${resource_file} " for missing config options")
|
|
||||||
file(READ ${PROJECT_BINARY_DIR}/${resource_file} current_file_contents)
|
|
||||||
string(REPLACE "\\\n" "" current_file_contents ${current_file_contents})
|
|
||||||
string(REPLACE "\n" ";" current_file_contents ${current_file_contents})
|
|
||||||
set(parsed_current_file_contents "")
|
|
||||||
# Remove comment lines so they do not interfere with the variable parsing
|
|
||||||
foreach (line ${current_file_contents})
|
|
||||||
string(FIND ${line} "#" is_comment)
|
|
||||||
if (NOT ${is_comment} EQUAL 0)
|
|
||||||
string(APPEND parsed_current_file_contents ${line})
|
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
file(READ ${CMAKE_SOURCE_DIR}/resources/${resource_file} depot_file_contents)
|
|
||||||
string(REPLACE "\\\n" "" depot_file_contents ${depot_file_contents})
|
|
||||||
string(REPLACE "\n" ";" depot_file_contents ${depot_file_contents})
|
|
||||||
set(line_to_add "")
|
|
||||||
foreach (line ${depot_file_contents})
|
|
||||||
string(FIND ${line} "#" is_comment)
|
|
||||||
if (NOT ${is_comment} EQUAL 0)
|
|
||||||
string(REPLACE "=" ";" line_split ${line})
|
|
||||||
list(GET line_split 0 variable_name)
|
|
||||||
if (NOT ${parsed_current_file_contents} MATCHES ${variable_name})
|
|
||||||
message(STATUS "Adding missing config option " ${variable_name} " to " ${resource_file})
|
|
||||||
set(line_to_add ${line_to_add} ${line})
|
|
||||||
foreach (line_to_append ${line_to_add})
|
|
||||||
file(APPEND ${PROJECT_BINARY_DIR}/${resource_file} "\n" ${line_to_append})
|
|
||||||
endforeach()
|
|
||||||
file(APPEND ${PROJECT_BINARY_DIR}/${resource_file} "\n")
|
|
||||||
endif()
|
|
||||||
set(line_to_add "")
|
|
||||||
else()
|
|
||||||
set(line_to_add ${line_to_add} ${line})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
message(STATUS "Resource file integrity check complete")
|
|
||||||
|
|
||||||
# Copy navmesh data on first build and extract it
|
# Copy navmesh data on first build and extract it
|
||||||
if (NOT EXISTS ${PROJECT_BINARY_DIR}/navmeshes/)
|
if (NOT EXISTS ${PROJECT_BINARY_DIR}/navmeshes/)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
PROJECT_VERSION_MAJOR=1
|
PROJECT_VERSION_MAJOR=1
|
||||||
PROJECT_VERSION_MINOR=1
|
PROJECT_VERSION_MINOR=0
|
||||||
PROJECT_VERSION_PATCH=0
|
PROJECT_VERSION_PATCH=4
|
||||||
# LICENSE
|
# LICENSE
|
||||||
LICENSE=AGPL-3.0
|
LICENSE=AGPL-3.0
|
||||||
# The network version.
|
# The network version.
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ namespace Game {
|
|||||||
dServer* server = nullptr;
|
dServer* server = nullptr;
|
||||||
dConfig* config = nullptr;
|
dConfig* config = nullptr;
|
||||||
bool shouldShutdown = false;
|
bool shouldShutdown = false;
|
||||||
std::mt19937 randomEngine;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dLogger* SetupLogger();
|
dLogger* SetupLogger();
|
||||||
@@ -84,8 +83,6 @@ int main(int argc, char** argv) {
|
|||||||
delete res;
|
delete res;
|
||||||
delete stmt;
|
delete stmt;
|
||||||
|
|
||||||
Game::randomEngine = std::mt19937(time(0));
|
|
||||||
|
|
||||||
//It's safe to pass 'localhost' here, as the IP is only used as the external IP.
|
//It's safe to pass 'localhost' here, as the IP is only used as the external IP.
|
||||||
uint32_t maxClients = 50;
|
uint32_t maxClients = 50;
|
||||||
uint32_t ourPort = 1001; //LU client is hardcoded to use this for auth port, so I'm making it the default.
|
uint32_t ourPort = 1001; //LU client is hardcoded to use this for auth port, so I'm making it the default.
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ class dConfig;
|
|||||||
class RakPeerInterface;
|
class RakPeerInterface;
|
||||||
class AssetManager;
|
class AssetManager;
|
||||||
struct SystemAddress;
|
struct SystemAddress;
|
||||||
class EntityManager;
|
|
||||||
class dZoneManager;
|
|
||||||
|
|
||||||
namespace Game {
|
namespace Game {
|
||||||
extern dLogger* logger;
|
extern dLogger* logger;
|
||||||
@@ -24,6 +22,4 @@ namespace Game {
|
|||||||
extern AssetManager* assetManager;
|
extern AssetManager* assetManager;
|
||||||
extern SystemAddress chatSysAddr;
|
extern SystemAddress chatSysAddr;
|
||||||
extern bool shouldShutdown;
|
extern bool shouldShutdown;
|
||||||
extern EntityManager* entityManager;
|
|
||||||
extern dZoneManager* zoneManager;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,6 +111,29 @@ namespace GeneralUtils {
|
|||||||
*/
|
*/
|
||||||
bool CheckBit(int64_t value, uint32_t index);
|
bool CheckBit(int64_t value, uint32_t index);
|
||||||
|
|
||||||
|
// MARK: Random Number Generation
|
||||||
|
|
||||||
|
//! Generates a random number
|
||||||
|
/*!
|
||||||
|
\param min The minimum the generate from
|
||||||
|
\param max The maximum to generate to
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
inline T GenerateRandomNumber(std::size_t min, std::size_t max) {
|
||||||
|
// Make sure it is a numeric type
|
||||||
|
static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type");
|
||||||
|
|
||||||
|
if constexpr (std::is_integral_v<T>) { // constexpr only necessary on first statement
|
||||||
|
std::uniform_int_distribution<T> distribution(min, max);
|
||||||
|
return distribution(Game::randomEngine);
|
||||||
|
} else if (std::is_floating_point_v<T>) {
|
||||||
|
std::uniform_real_distribution<T> distribution(min, max);
|
||||||
|
return distribution(Game::randomEngine);
|
||||||
|
}
|
||||||
|
|
||||||
|
return T();
|
||||||
|
}
|
||||||
|
|
||||||
bool ReplaceInString(std::string& str, const std::string& from, const std::string& to);
|
bool ReplaceInString(std::string& str, const std::string& from, const std::string& to);
|
||||||
|
|
||||||
std::u16string ReadWString(RakNet::BitStream* inStream);
|
std::u16string ReadWString(RakNet::BitStream* inStream);
|
||||||
@@ -200,42 +223,4 @@ namespace GeneralUtils {
|
|||||||
std::hash<T> h;
|
std::hash<T> h;
|
||||||
s ^= h(v) + 0x9e3779b9 + (s << 6) + (s >> 2);
|
s ^= h(v) + 0x9e3779b9 + (s << 6) + (s >> 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Random Number Generation
|
|
||||||
|
|
||||||
//! Generates a random number
|
|
||||||
/*!
|
|
||||||
\param min The minimum the generate from
|
|
||||||
\param max The maximum to generate to
|
|
||||||
*/
|
|
||||||
template <typename T>
|
|
||||||
inline T GenerateRandomNumber(std::size_t min, std::size_t max) {
|
|
||||||
// Make sure it is a numeric type
|
|
||||||
static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type");
|
|
||||||
|
|
||||||
if constexpr (std::is_integral_v<T>) { // constexpr only necessary on first statement
|
|
||||||
std::uniform_int_distribution<T> distribution(min, max);
|
|
||||||
return distribution(Game::randomEngine);
|
|
||||||
} else if (std::is_floating_point_v<T>) {
|
|
||||||
std::uniform_real_distribution<T> distribution(min, max);
|
|
||||||
return distribution(Game::randomEngine);
|
|
||||||
}
|
|
||||||
|
|
||||||
return T();
|
|
||||||
}
|
|
||||||
|
|
||||||
// on Windows we need to undef these or else they conflict with our numeric limits calls
|
|
||||||
// DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS
|
|
||||||
#ifdef _WIN32
|
|
||||||
#undef min
|
|
||||||
#undef max
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline T GenerateRandomNumber() {
|
|
||||||
// Make sure it is a numeric type
|
|
||||||
static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type");
|
|
||||||
|
|
||||||
return GenerateRandomNumber<T>(std::numeric_limits<T>::min(), std::numeric_limits<T>::max());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,14 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
// Enable this to cache all entries in each table for fast access, comes with more memory cost
|
||||||
|
//#define CDCLIENT_CACHE_ALL
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\file CDClientDatabase.hpp
|
||||||
|
\brief An interface between the CDClient.sqlite file and the server
|
||||||
|
*/
|
||||||
|
|
||||||
//! The CDClient Database namespace
|
//! The CDClient Database namespace
|
||||||
namespace CDClientDatabase {
|
namespace CDClientDatabase {
|
||||||
|
|
||||||
|
|||||||
@@ -38,53 +38,43 @@
|
|||||||
#include "CDFeatureGatingTable.h"
|
#include "CDFeatureGatingTable.h"
|
||||||
#include "CDRailActivatorComponent.h"
|
#include "CDRailActivatorComponent.h"
|
||||||
|
|
||||||
// Uncomment this to cache the full cdclient database into memory. This will make the server load faster, but will use more memory.
|
|
||||||
// A vanilla CDClient takes about 46MB of memory + the regular world data.
|
|
||||||
// #define CDCLIENT_CACHE_ALL
|
|
||||||
|
|
||||||
#ifdef CDCLIENT_CACHE_ALL
|
|
||||||
#define CDCLIENT_DONT_CACHE_TABLE(x) x
|
|
||||||
#else
|
|
||||||
#define CDCLIENT_DONT_CACHE_TABLE(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CDClientManager::CDClientManager() {
|
CDClientManager::CDClientManager() {
|
||||||
CDActivityRewardsTable::Instance().LoadValuesFromDatabase();
|
CDActivityRewardsTable::Instance();
|
||||||
CDActivitiesTable::Instance().LoadValuesFromDatabase();
|
CDAnimationsTable::Instance();
|
||||||
CDCLIENT_DONT_CACHE_TABLE(CDAnimationsTable::Instance().LoadValuesFromDatabase());
|
CDBehaviorParameterTable::Instance();
|
||||||
CDBehaviorParameterTable::Instance().LoadValuesFromDatabase();
|
CDBehaviorTemplateTable::Instance();
|
||||||
CDBehaviorTemplateTable::Instance().LoadValuesFromDatabase();
|
CDComponentsRegistryTable::Instance();
|
||||||
CDBrickIDTableTable::Instance().LoadValuesFromDatabase();
|
CDCurrencyTableTable::Instance();
|
||||||
CDComponentsRegistryTable::Instance().LoadValuesFromDatabase();
|
CDDestructibleComponentTable::Instance();
|
||||||
CDCurrencyTableTable::Instance().LoadValuesFromDatabase();
|
CDEmoteTableTable::Instance();
|
||||||
CDDestructibleComponentTable::Instance().LoadValuesFromDatabase();
|
CDInventoryComponentTable::Instance();
|
||||||
CDEmoteTableTable::Instance().LoadValuesFromDatabase();
|
CDItemComponentTable::Instance();
|
||||||
CDFeatureGatingTable::Instance().LoadValuesFromDatabase();
|
CDItemSetsTable::Instance();
|
||||||
CDInventoryComponentTable::Instance().LoadValuesFromDatabase();
|
CDItemSetSkillsTable::Instance();
|
||||||
CDCLIENT_DONT_CACHE_TABLE(CDItemComponentTable::Instance().LoadValuesFromDatabase());
|
CDLevelProgressionLookupTable::Instance();
|
||||||
CDItemSetSkillsTable::Instance().LoadValuesFromDatabase();
|
CDLootMatrixTable::Instance();
|
||||||
CDItemSetsTable::Instance().LoadValuesFromDatabase();
|
CDLootTableTable::Instance();
|
||||||
CDLevelProgressionLookupTable::Instance().LoadValuesFromDatabase();
|
CDMissionNPCComponentTable::Instance();
|
||||||
CDLootMatrixTable::Instance().LoadValuesFromDatabase();
|
CDMissionTasksTable::Instance();
|
||||||
CDLootTableTable::Instance().LoadValuesFromDatabase();
|
CDMissionsTable::Instance();
|
||||||
CDMissionEmailTable::Instance().LoadValuesFromDatabase();
|
CDObjectSkillsTable::Instance();
|
||||||
CDMissionNPCComponentTable::Instance().LoadValuesFromDatabase();
|
CDObjectsTable::Instance();
|
||||||
CDMissionTasksTable::Instance().LoadValuesFromDatabase();
|
CDPhysicsComponentTable::Instance();
|
||||||
CDMissionsTable::Instance().LoadValuesFromDatabase();
|
CDRebuildComponentTable::Instance();
|
||||||
CDMovementAIComponentTable::Instance().LoadValuesFromDatabase();
|
CDScriptComponentTable::Instance();
|
||||||
CDObjectSkillsTable::Instance().LoadValuesFromDatabase();
|
CDSkillBehaviorTable::Instance();
|
||||||
CDCLIENT_DONT_CACHE_TABLE(CDObjectsTable::Instance().LoadValuesFromDatabase());
|
CDZoneTableTable::Instance();
|
||||||
CDPhysicsComponentTable::Instance().LoadValuesFromDatabase();
|
CDVendorComponentTable::Instance();
|
||||||
CDPackageComponentTable::Instance().LoadValuesFromDatabase();
|
CDActivitiesTable::Instance();
|
||||||
CDProximityMonitorComponentTable::Instance().LoadValuesFromDatabase();
|
CDPackageComponentTable::Instance();
|
||||||
CDPropertyEntranceComponentTable::Instance().LoadValuesFromDatabase();
|
CDProximityMonitorComponentTable::Instance();
|
||||||
CDPropertyTemplateTable::Instance().LoadValuesFromDatabase();
|
CDMovementAIComponentTable::Instance();
|
||||||
CDRailActivatorComponentTable::Instance().LoadValuesFromDatabase();
|
CDBrickIDTableTable::Instance();
|
||||||
CDRarityTableTable::Instance().LoadValuesFromDatabase();
|
CDRarityTableTable::Instance();
|
||||||
CDRebuildComponentTable::Instance().LoadValuesFromDatabase();
|
CDMissionEmailTable::Instance();
|
||||||
CDRewardsTable::Instance().LoadValuesFromDatabase();
|
CDRewardsTable::Instance();
|
||||||
CDScriptComponentTable::Instance().LoadValuesFromDatabase();
|
CDPropertyEntranceComponentTable::Instance();
|
||||||
CDSkillBehaviorTable::Instance().LoadValuesFromDatabase();
|
CDPropertyTemplateTable::Instance();
|
||||||
CDVendorComponentTable::Instance().LoadValuesFromDatabase();
|
CDFeatureGatingTable::Instance();
|
||||||
CDZoneTableTable::Instance().LoadValuesFromDatabase();
|
CDRailActivatorComponentTable::Instance();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "CDActivitiesTable.h"
|
#include "CDActivitiesTable.h"
|
||||||
|
|
||||||
void CDActivitiesTable::LoadValuesFromDatabase() {
|
CDActivitiesTable::CDActivitiesTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Activities");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Activities");
|
||||||
@@ -54,3 +55,8 @@ std::vector<CDActivities> CDActivitiesTable::Query(std::function<bool(CDActiviti
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<CDActivities> CDActivitiesTable::GetEntries(void) const {
|
||||||
|
return this->entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,10 +30,9 @@ private:
|
|||||||
std::vector<CDActivities> entries;
|
std::vector<CDActivities> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
const std::vector<CDActivities>& GetEntries() const { return this->entries; }
|
std::vector<CDActivities> GetEntries(void) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "CDActivityRewardsTable.h"
|
#include "CDActivityRewardsTable.h"
|
||||||
|
|
||||||
void CDActivityRewardsTable::LoadValuesFromDatabase() {
|
CDActivityRewardsTable::CDActivityRewardsTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -43,3 +43,8 @@ std::vector<CDActivityRewards> CDActivityRewardsTable::Query(std::function<bool(
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<CDActivityRewards> CDActivityRewardsTable::GetEntries(void) const {
|
||||||
|
return this->entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ private:
|
|||||||
std::vector<CDActivityRewards> entries;
|
std::vector<CDActivityRewards> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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() const;
|
std::vector<CDActivityRewards> GetEntries(void) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,35 +2,6 @@
|
|||||||
#include "GeneralUtils.h"
|
#include "GeneralUtils.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
|
||||||
|
|
||||||
void CDAnimationsTable::LoadValuesFromDatabase() {
|
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Animations");
|
|
||||||
while (!tableData.eof()) {
|
|
||||||
std::string animation_type = tableData.getStringField("animation_type", "");
|
|
||||||
DluAssert(!animation_type.empty());
|
|
||||||
AnimationGroupID animationGroupID = tableData.getIntField("animationGroupID", -1);
|
|
||||||
DluAssert(animationGroupID != -1);
|
|
||||||
|
|
||||||
CDAnimation entry;
|
|
||||||
entry.animation_name = tableData.getStringField("animation_name", "");
|
|
||||||
entry.chance_to_play = tableData.getFloatField("chance_to_play", 1.0f);
|
|
||||||
UNUSED_COLUMN(entry.min_loops = tableData.getIntField("min_loops", 0);)
|
|
||||||
UNUSED_COLUMN(entry.max_loops = tableData.getIntField("max_loops", 0);)
|
|
||||||
entry.animation_length = tableData.getFloatField("animation_length", 0.0f);
|
|
||||||
UNUSED_COLUMN(entry.hideEquip = tableData.getIntField("hideEquip", 0) == 1;)
|
|
||||||
UNUSED_COLUMN(entry.ignoreUpperBody = tableData.getIntField("ignoreUpperBody", 0) == 1;)
|
|
||||||
UNUSED_COLUMN(entry.restartable = tableData.getIntField("restartable", 0) == 1;)
|
|
||||||
UNUSED_COLUMN(entry.face_animation_name = tableData.getStringField("face_animation_name", "");)
|
|
||||||
UNUSED_COLUMN(entry.priority = tableData.getFloatField("priority", 0.0f);)
|
|
||||||
UNUSED_COLUMN(entry.blendTime = tableData.getFloatField("blendTime", 0.0f);)
|
|
||||||
|
|
||||||
this->animations[CDAnimationKey(animation_type, animationGroupID)].push_back(entry);
|
|
||||||
tableData.nextRow();
|
|
||||||
}
|
|
||||||
|
|
||||||
tableData.finalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CDAnimationsTable::CacheData(CppSQLite3Statement& queryToCache) {
|
bool CDAnimationsTable::CacheData(CppSQLite3Statement& queryToCache) {
|
||||||
auto tableData = queryToCache.execQuery();
|
auto tableData = queryToCache.execQuery();
|
||||||
// If we received a bad lookup, cache it anyways so we do not run the query again.
|
// If we received a bad lookup, cache it anyways so we do not run the query again.
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ class CDAnimationsTable : public CDTable<CDAnimationsTable> {
|
|||||||
typedef std::string AnimationID;
|
typedef std::string AnimationID;
|
||||||
typedef std::pair<std::string, AnimationGroupID> CDAnimationKey;
|
typedef std::pair<std::string, AnimationGroupID> CDAnimationKey;
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
|
||||||
/**
|
/**
|
||||||
* Given an animationType and the previousAnimationName played, return the next animationType to play.
|
* Given an animationType and the previousAnimationName played, return the next animationType to play.
|
||||||
* If there are more than 1 animationTypes that can be played, one is selected at random but also does not allow
|
* If there are more than 1 animationTypes that can be played, one is selected at random but also does not allow
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "CDBehaviorParameterTable.h"
|
#include "CDBehaviorParameterTable.h"
|
||||||
#include "GeneralUtils.h"
|
#include "GeneralUtils.h"
|
||||||
|
|
||||||
void CDBehaviorParameterTable::LoadValuesFromDatabase() {
|
CDBehaviorParameterTable::CDBehaviorParameterTable(void) {
|
||||||
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;
|
||||||
@@ -53,3 +53,4 @@ std::map<std::string, float> CDBehaviorParameterTable::GetParametersByBehaviorID
|
|||||||
}
|
}
|
||||||
return returnInfo;
|
return returnInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ private:
|
|||||||
std::unordered_map<uint64_t, CDBehaviorParameter> m_Entries;
|
std::unordered_map<uint64_t, CDBehaviorParameter> m_Entries;
|
||||||
std::unordered_map<std::string, uint32_t> m_ParametersList;
|
std::unordered_map<std::string, uint32_t> m_ParametersList;
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
CDBehaviorParameterTable();
|
||||||
|
|
||||||
float GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue = 0);
|
float GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue = 0);
|
||||||
|
|
||||||
std::map<std::string, float> GetParametersByBehaviorID(uint32_t behaviorID);
|
std::map<std::string, float> GetParametersByBehaviorID(uint32_t behaviorID);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "CDBehaviorTemplateTable.h"
|
#include "CDBehaviorTemplateTable.h"
|
||||||
|
|
||||||
void CDBehaviorTemplateTable::LoadValuesFromDatabase() {
|
CDBehaviorTemplateTable::CDBehaviorTemplateTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -48,7 +48,7 @@ std::vector<CDBehaviorTemplate> CDBehaviorTemplateTable::Query(std::function<boo
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<CDBehaviorTemplate>& CDBehaviorTemplateTable::GetEntries() const {
|
std::vector<CDBehaviorTemplate> CDBehaviorTemplateTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,3 +64,4 @@ const CDBehaviorTemplate CDBehaviorTemplateTable::GetByBehaviorID(uint32_t behav
|
|||||||
return entry->second;
|
return entry->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,12 +19,11 @@ private:
|
|||||||
std::unordered_map<uint32_t, CDBehaviorTemplate> entriesMappedByBehaviorID;
|
std::unordered_map<uint32_t, CDBehaviorTemplate> entriesMappedByBehaviorID;
|
||||||
std::unordered_set<std::string> m_EffectHandles;
|
std::unordered_set<std::string> m_EffectHandles;
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
const std::vector<CDBehaviorTemplate>& GetEntries(void) const;
|
std::vector<CDBehaviorTemplate> GetEntries(void) const;
|
||||||
|
|
||||||
const CDBehaviorTemplate GetByBehaviorID(uint32_t behaviorID);
|
const CDBehaviorTemplate GetByBehaviorID(uint32_t behaviorID);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "CDBrickIDTableTable.h"
|
#include "CDBrickIDTableTable.h"
|
||||||
|
|
||||||
void CDBrickIDTableTable::LoadValuesFromDatabase() {
|
CDBrickIDTableTable::CDBrickIDTableTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -39,7 +39,7 @@ std::vector<CDBrickIDTable> CDBrickIDTableTable::Query(std::function<bool(CDBric
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<CDBrickIDTable>& CDBrickIDTableTable::GetEntries() const {
|
std::vector<CDBrickIDTable> CDBrickIDTableTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ private:
|
|||||||
std::vector<CDBrickIDTable> entries;
|
std::vector<CDBrickIDTable> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
const std::vector<CDBrickIDTable>& GetEntries() const;
|
std::vector<CDBrickIDTable> GetEntries(void) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,25 @@
|
|||||||
#include "CDComponentsRegistryTable.h"
|
#include "CDComponentsRegistryTable.h"
|
||||||
#include "eReplicaComponentType.h"
|
#include "eReplicaComponentType.h"
|
||||||
|
|
||||||
void CDComponentsRegistryTable::LoadValuesFromDatabase() {
|
#define CDCLIENT_CACHE_ALL
|
||||||
|
|
||||||
|
CDComponentsRegistryTable::CDComponentsRegistryTable(void) {
|
||||||
|
|
||||||
|
#ifdef CDCLIENT_CACHE_ALL
|
||||||
|
// First, get the size of the table
|
||||||
|
unsigned int size = 0;
|
||||||
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ComponentsRegistry");
|
||||||
|
while (!tableSize.eof()) {
|
||||||
|
size = tableSize.getIntField(0, 0);
|
||||||
|
|
||||||
|
tableSize.nextRow();
|
||||||
|
}
|
||||||
|
|
||||||
|
tableSize.finalize();
|
||||||
|
|
||||||
|
// Reserve the size
|
||||||
|
//this->entries.reserve(size);
|
||||||
|
|
||||||
// Now get the data
|
// Now get the data
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ComponentsRegistry");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ComponentsRegistry");
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
@@ -16,35 +34,60 @@ void CDComponentsRegistryTable::LoadValuesFromDatabase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tableData.finalize();
|
tableData.finalize();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue) {
|
int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue) {
|
||||||
auto iter = mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id));
|
const auto& iter = this->mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id));
|
||||||
|
|
||||||
if (iter == this->mappedEntries.end()) {
|
if (iter == this->mappedEntries.end()) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return iter->second;
|
return iter->second;
|
||||||
// Now get the data
|
|
||||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM ComponentsRegistry WHERE id = ? AND component_type = ?;");
|
|
||||||
query.bind(1, static_cast<int32_t>(id));
|
|
||||||
query.bind(2, static_cast<int32_t>(componentType));
|
|
||||||
|
|
||||||
auto tableData = query.execQuery();
|
#ifndef CDCLIENT_CACHE_ALL
|
||||||
|
// Now get the data
|
||||||
|
std::stringstream query;
|
||||||
|
|
||||||
|
query << "SELECT * FROM ComponentsRegistry WHERE id = " << std::to_string(id);
|
||||||
|
|
||||||
|
auto tableData = CDClientDatabase::ExecuteQuery(query.str());
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDComponentsRegistry entry;
|
CDComponentsRegistry entry;
|
||||||
entry.id = tableData.getIntField("id", -1);
|
entry.id = tableData.getIntField("id", -1);
|
||||||
entry.component_type = static_cast<eReplicaComponentType>(tableData.getIntField("component_type", 0));
|
entry.component_type = tableData.getIntField("component_type", -1);
|
||||||
entry.component_id = tableData.getIntField("component_id", -1);
|
entry.component_id = tableData.getIntField("component_id", -1);
|
||||||
|
|
||||||
this->mappedEntries.insert_or_assign(((uint64_t)entry.component_type) << 32 | ((uint64_t)entry.id), entry.component_id);
|
//this->entries.push_back(entry);
|
||||||
|
|
||||||
|
//Darwin's stuff:
|
||||||
|
const auto& it = this->mappedEntries.find(entry.id);
|
||||||
|
if (it != mappedEntries.end()) {
|
||||||
|
const auto& iter = it->second.find(entry.component_type);
|
||||||
|
if (iter == it->second.end()) {
|
||||||
|
it->second.insert(std::make_pair(entry.component_type, entry.component_id));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::map<unsigned int, unsigned int> map;
|
||||||
|
map.insert(std::make_pair(entry.component_type, entry.component_id));
|
||||||
|
this->mappedEntries.insert(std::make_pair(entry.id, map));
|
||||||
|
}
|
||||||
|
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
iter = this->mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id));
|
tableData.finalize();
|
||||||
|
|
||||||
return iter == this->mappedEntries.end() ? defaultValue : iter->second;
|
const auto& it2 = this->mappedEntries.find(id);
|
||||||
|
if (it2 != mappedEntries.end()) {
|
||||||
|
const auto& iter = it2->second.find(componentType);
|
||||||
|
if (iter != it2->second.end()) {
|
||||||
|
return iter->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultValue;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,6 @@ private:
|
|||||||
std::map<uint64_t, uint32_t> mappedEntries; //id, component_type, component_id
|
std::map<uint64_t, uint32_t> mappedEntries; //id, component_type, component_id
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "CDCurrencyTableTable.h"
|
#include "CDCurrencyTableTable.h"
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
void CDCurrencyTableTable::LoadValuesFromDatabase() {
|
CDCurrencyTableTable::CDCurrencyTableTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -43,7 +43,7 @@ std::vector<CDCurrencyTable> CDCurrencyTableTable::Query(std::function<bool(CDCu
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<CDCurrencyTable>& CDCurrencyTableTable::GetEntries() const {
|
std::vector<CDCurrencyTable> CDCurrencyTableTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ private:
|
|||||||
std::vector<CDCurrencyTable> entries;
|
std::vector<CDCurrencyTable> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
const std::vector<CDCurrencyTable>& GetEntries() const;
|
std::vector<CDCurrencyTable> GetEntries(void) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#include "CDDestructibleComponentTable.h"
|
#include "CDDestructibleComponentTable.h"
|
||||||
|
|
||||||
void CDDestructibleComponentTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDDestructibleComponentTable::CDDestructibleComponentTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM DestructibleComponent");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM DestructibleComponent");
|
||||||
@@ -50,7 +52,7 @@ std::vector<CDDestructibleComponent> CDDestructibleComponentTable::Query(std::fu
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<CDDestructibleComponent>& CDDestructibleComponentTable::GetEntries() const {
|
std::vector<CDDestructibleComponent> CDDestructibleComponentTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ private:
|
|||||||
std::vector<CDDestructibleComponent> entries;
|
std::vector<CDDestructibleComponent> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
const std::vector<CDDestructibleComponent>& GetEntries(void) const;
|
std::vector<CDDestructibleComponent> GetEntries(void) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,26 +1,40 @@
|
|||||||
#include "CDEmoteTable.h"
|
#include "CDEmoteTable.h"
|
||||||
|
|
||||||
void CDEmoteTableTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDEmoteTableTable::CDEmoteTableTable(void) {
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Emotes");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Emotes");
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDEmoteTable entry;
|
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
|
||||||
auto itr = entries.find(id);
|
CDEmoteTableTable::~CDEmoteTableTable(void) {
|
||||||
return itr != entries.end() ? &itr->second : nullptr;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,10 +28,11 @@ struct CDEmoteTable {
|
|||||||
|
|
||||||
class CDEmoteTableTable : public CDTable<CDEmoteTableTable> {
|
class CDEmoteTableTable : public CDTable<CDEmoteTableTable> {
|
||||||
private:
|
private:
|
||||||
std::map<int, CDEmoteTable> entries;
|
std::map<int, CDEmoteTable*> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
CDEmoteTableTable();
|
||||||
|
~CDEmoteTableTable();
|
||||||
// Returns an emote by ID
|
// Returns an emote by ID
|
||||||
CDEmoteTable* GetEmote(int id);
|
CDEmoteTable* GetEmote(int id);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "CDFeatureGatingTable.h"
|
#include "CDFeatureGatingTable.h"
|
||||||
|
|
||||||
void CDFeatureGatingTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDFeatureGatingTable::CDFeatureGatingTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -52,7 +53,7 @@ bool CDFeatureGatingTable::FeatureUnlocked(const std::string& feature) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<CDFeatureGating>& CDFeatureGatingTable::GetEntries() const {
|
std::vector<CDFeatureGating> CDFeatureGatingTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,11 @@ private:
|
|||||||
std::vector<CDFeatureGating> entries;
|
std::vector<CDFeatureGating> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
bool FeatureUnlocked(const std::string& feature) const;
|
bool FeatureUnlocked(const std::string& feature) const;
|
||||||
|
|
||||||
const std::vector<CDFeatureGating>& GetEntries(void) const;
|
std::vector<CDFeatureGating> GetEntries(void) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "CDInventoryComponentTable.h"
|
#include "CDInventoryComponentTable.h"
|
||||||
|
|
||||||
void CDInventoryComponentTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDInventoryComponentTable::CDInventoryComponentTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -41,7 +42,7 @@ std::vector<CDInventoryComponent> CDInventoryComponentTable::Query(std::function
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<CDInventoryComponent>& CDInventoryComponentTable::GetEntries() const {
|
std::vector<CDInventoryComponent> CDInventoryComponentTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ private:
|
|||||||
std::vector<CDInventoryComponent> entries;
|
std::vector<CDInventoryComponent> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
const std::vector<CDInventoryComponent>& GetEntries() const;
|
std::vector<CDInventoryComponent> GetEntries(void) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,7 +3,11 @@
|
|||||||
|
|
||||||
CDItemComponent CDItemComponentTable::Default = {};
|
CDItemComponent CDItemComponentTable::Default = {};
|
||||||
|
|
||||||
void CDItemComponentTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDItemComponentTable::CDItemComponentTable(void) {
|
||||||
|
Default = CDItemComponent();
|
||||||
|
|
||||||
|
#ifdef CDCLIENT_CACHE_ALL
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ItemComponent");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ItemComponent");
|
||||||
@@ -51,13 +55,13 @@ void CDItemComponentTable::LoadValuesFromDatabase() {
|
|||||||
entry.currencyLOT = tableData.getIntField("currencyLOT", -1);
|
entry.currencyLOT = tableData.getIntField("currencyLOT", -1);
|
||||||
entry.altCurrencyCost = tableData.getIntField("altCurrencyCost", -1);
|
entry.altCurrencyCost = tableData.getIntField("altCurrencyCost", -1);
|
||||||
entry.subItems = tableData.getStringField("subItems", "");
|
entry.subItems = tableData.getStringField("subItems", "");
|
||||||
UNUSED_COLUMN(entry.audioEventUse = tableData.getStringField("audioEventUse", ""));
|
entry.audioEventUse = tableData.getStringField("audioEventUse", "");
|
||||||
entry.noEquipAnimation = tableData.getIntField("noEquipAnimation", -1) == 1 ? true : false;
|
entry.noEquipAnimation = tableData.getIntField("noEquipAnimation", -1) == 1 ? true : false;
|
||||||
entry.commendationLOT = tableData.getIntField("commendationLOT", -1);
|
entry.commendationLOT = tableData.getIntField("commendationLOT", -1);
|
||||||
entry.commendationCost = tableData.getIntField("commendationCost", -1);
|
entry.commendationCost = tableData.getIntField("commendationCost", -1);
|
||||||
UNUSED_COLUMN(entry.audioEquipMetaEventSet = tableData.getStringField("audioEquipMetaEventSet", ""));
|
entry.audioEquipMetaEventSet = tableData.getStringField("audioEquipMetaEventSet", "");
|
||||||
entry.currencyCosts = tableData.getStringField("currencyCosts", "");
|
entry.currencyCosts = tableData.getStringField("currencyCosts", "");
|
||||||
UNUSED_COLUMN(entry.ingredientInfo = tableData.getStringField("ingredientInfo", ""));
|
entry.ingredientInfo = tableData.getStringField("ingredientInfo", "");
|
||||||
entry.locStatus = tableData.getIntField("locStatus", -1);
|
entry.locStatus = tableData.getIntField("locStatus", -1);
|
||||||
entry.forgeType = tableData.getIntField("forgeType", -1);
|
entry.forgeType = tableData.getIntField("forgeType", -1);
|
||||||
entry.SellMultiplier = tableData.getFloatField("SellMultiplier", -1.0f);
|
entry.SellMultiplier = tableData.getFloatField("SellMultiplier", -1.0f);
|
||||||
@@ -67,6 +71,7 @@ void CDItemComponentTable::LoadValuesFromDatabase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tableData.finalize();
|
tableData.finalize();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int skillID) {
|
const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int skillID) {
|
||||||
@@ -75,10 +80,12 @@ const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int s
|
|||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM ItemComponent WHERE id = ?;");
|
#ifndef CDCLIENT_CACHE_ALL
|
||||||
query.bind(1, static_cast<int32_t>(skillID));
|
std::stringstream query;
|
||||||
|
|
||||||
auto tableData = query.execQuery();
|
query << "SELECT * FROM ItemComponent WHERE id = " << std::to_string(skillID);
|
||||||
|
|
||||||
|
auto tableData = CDClientDatabase::ExecuteQuery(query.str());
|
||||||
if (tableData.eof()) {
|
if (tableData.eof()) {
|
||||||
entries.insert(std::make_pair(skillID, Default));
|
entries.insert(std::make_pair(skillID, Default));
|
||||||
return Default;
|
return Default;
|
||||||
@@ -137,6 +144,7 @@ const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int s
|
|||||||
if (it2 != this->entries.end()) {
|
if (it2 != this->entries.end()) {
|
||||||
return it2->second;
|
return it2->second;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return Default;
|
return Default;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ private:
|
|||||||
std::map<unsigned int, CDItemComponent> entries;
|
std::map<unsigned int, CDItemComponent> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "CDItemSetSkillsTable.h"
|
#include "CDItemSetSkillsTable.h"
|
||||||
|
|
||||||
void CDItemSetSkillsTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDItemSetSkillsTable::CDItemSetSkillsTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -40,7 +41,7 @@ std::vector<CDItemSetSkills> CDItemSetSkillsTable::Query(std::function<bool(CDIt
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<CDItemSetSkills>& CDItemSetSkillsTable::GetEntries() const {
|
std::vector<CDItemSetSkills> CDItemSetSkillsTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ private:
|
|||||||
std::vector<CDItemSetSkills> entries;
|
std::vector<CDItemSetSkills> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
const std::vector<CDItemSetSkills>& GetEntries() const;
|
std::vector<CDItemSetSkills> GetEntries(void) const;
|
||||||
|
|
||||||
std::vector<CDItemSetSkills> GetBySkillID(unsigned int SkillSetID);
|
std::vector<CDItemSetSkills> GetBySkillID(unsigned int SkillSetID);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "CDItemSetsTable.h"
|
#include "CDItemSetsTable.h"
|
||||||
|
|
||||||
void CDItemSetsTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDItemSetsTable::CDItemSetsTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -52,7 +53,7 @@ std::vector<CDItemSets> CDItemSetsTable::Query(std::function<bool(CDItemSets)> p
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<CDItemSets>& CDItemSetsTable::GetEntries() const {
|
std::vector<CDItemSets> CDItemSetsTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ private:
|
|||||||
std::vector<CDItemSets> entries;
|
std::vector<CDItemSets> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
const std::vector<CDItemSets>& GetEntries(void) const;
|
std::vector<CDItemSets> GetEntries(void) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "CDLevelProgressionLookupTable.h"
|
#include "CDLevelProgressionLookupTable.h"
|
||||||
|
|
||||||
void CDLevelProgressionLookupTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDLevelProgressionLookupTable::CDLevelProgressionLookupTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -31,6 +32,7 @@ void CDLevelProgressionLookupTable::LoadValuesFromDatabase() {
|
|||||||
tableData.finalize();
|
tableData.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Queries the table with a custom "where" clause
|
||||||
std::vector<CDLevelProgressionLookup> CDLevelProgressionLookupTable::Query(std::function<bool(CDLevelProgressionLookup)> predicate) {
|
std::vector<CDLevelProgressionLookup> CDLevelProgressionLookupTable::Query(std::function<bool(CDLevelProgressionLookup)> predicate) {
|
||||||
|
|
||||||
std::vector<CDLevelProgressionLookup> data = cpplinq::from(this->entries)
|
std::vector<CDLevelProgressionLookup> data = cpplinq::from(this->entries)
|
||||||
@@ -40,7 +42,8 @@ std::vector<CDLevelProgressionLookup> CDLevelProgressionLookupTable::Query(std::
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<CDLevelProgressionLookup>& CDLevelProgressionLookupTable::GetEntries() const {
|
//! Gets all the entries in the table
|
||||||
|
std::vector<CDLevelProgressionLookup> CDLevelProgressionLookupTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ private:
|
|||||||
std::vector<CDLevelProgressionLookup> entries;
|
std::vector<CDLevelProgressionLookup> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
const std::vector<CDLevelProgressionLookup>& GetEntries() const;
|
// Gets all the entries in the table
|
||||||
|
std::vector<CDLevelProgressionLookup> GetEntries(void) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "CDLootMatrixTable.h"
|
#include "CDLootMatrixTable.h"
|
||||||
|
|
||||||
void CDLootMatrixTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDLootMatrixTable::CDLootMatrixTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -46,7 +47,7 @@ std::vector<CDLootMatrix> CDLootMatrixTable::Query(std::function<bool(CDLootMatr
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<CDLootMatrix>& CDLootMatrixTable::GetEntries() const {
|
const std::vector<CDLootMatrix>& CDLootMatrixTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ private:
|
|||||||
std::vector<CDLootMatrix> entries;
|
std::vector<CDLootMatrix> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
const std::vector<CDLootMatrix>& GetEntries() const;
|
const std::vector<CDLootMatrix>& GetEntries(void) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "CDLootTableTable.h"
|
#include "CDLootTableTable.h"
|
||||||
|
|
||||||
void CDLootTableTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDLootTableTable::CDLootTableTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -45,7 +46,7 @@ std::vector<CDLootTable> CDLootTableTable::Query(std::function<bool(CDLootTable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Gets all the entries in the table
|
//! Gets all the entries in the table
|
||||||
const std::vector<CDLootTable>& CDLootTableTable::GetEntries() const {
|
const std::vector<CDLootTable>& CDLootTableTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ private:
|
|||||||
std::vector<CDLootTable> entries;
|
std::vector<CDLootTable> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
const std::vector<CDLootTable>& GetEntries() const;
|
const std::vector<CDLootTable>& GetEntries(void) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "CDMissionEmailTable.h"
|
#include "CDMissionEmailTable.h"
|
||||||
|
|
||||||
void CDMissionEmailTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDMissionEmailTable::CDMissionEmailTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -47,7 +48,7 @@ std::vector<CDMissionEmail> CDMissionEmailTable::Query(std::function<bool(CDMiss
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Gets all the entries in the table
|
//! Gets all the entries in the table
|
||||||
const std::vector<CDMissionEmail>& CDMissionEmailTable::GetEntries() const {
|
std::vector<CDMissionEmail> CDMissionEmailTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ private:
|
|||||||
std::vector<CDMissionEmail> entries;
|
std::vector<CDMissionEmail> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
const std::vector<CDMissionEmail>& GetEntries() const;
|
std::vector<CDMissionEmail> GetEntries(void) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "CDMissionNPCComponentTable.h"
|
#include "CDMissionNPCComponentTable.h"
|
||||||
|
|
||||||
void CDMissionNPCComponentTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDMissionNPCComponentTable::CDMissionNPCComponentTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -44,7 +45,7 @@ std::vector<CDMissionNPCComponent> CDMissionNPCComponentTable::Query(std::functi
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Gets all the entries in the table
|
//! Gets all the entries in the table
|
||||||
const std::vector<CDMissionNPCComponent>& CDMissionNPCComponentTable::GetEntries() const {
|
std::vector<CDMissionNPCComponent> CDMissionNPCComponentTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ private:
|
|||||||
std::vector<CDMissionNPCComponent> entries;
|
std::vector<CDMissionNPCComponent> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
// Gets all the entries in the table
|
// Gets all the entries in the table
|
||||||
const std::vector<CDMissionNPCComponent>& GetEntries() const;
|
std::vector<CDMissionNPCComponent> GetEntries(void) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "CDMissionTasksTable.h"
|
#include "CDMissionTasksTable.h"
|
||||||
|
|
||||||
void CDMissionTasksTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDMissionTasksTable::CDMissionTasksTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -55,14 +56,16 @@ std::vector<CDMissionTasks*> CDMissionTasksTable::GetByMissionID(uint32_t missio
|
|||||||
|
|
||||||
for (auto& entry : this->entries) {
|
for (auto& entry : this->entries) {
|
||||||
if (entry.id == missionID) {
|
if (entry.id == missionID) {
|
||||||
tasks.push_back(&entry);
|
CDMissionTasks* task = const_cast<CDMissionTasks*>(&entry);
|
||||||
|
|
||||||
|
tasks.push_back(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return tasks;
|
return tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<CDMissionTasks>& CDMissionTasksTable::GetEntries() const {
|
const std::vector<CDMissionTasks>& CDMissionTasksTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,12 +24,12 @@ private:
|
|||||||
std::vector<CDMissionTasks> entries;
|
std::vector<CDMissionTasks> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
std::vector<CDMissionTasks*> GetByMissionID(uint32_t missionID);
|
std::vector<CDMissionTasks*> GetByMissionID(uint32_t missionID);
|
||||||
|
|
||||||
const std::vector<CDMissionTasks>& GetEntries() const;
|
const std::vector<CDMissionTasks>& GetEntries(void) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
CDMissions CDMissionsTable::Default = {};
|
CDMissions CDMissionsTable::Default = {};
|
||||||
|
|
||||||
void CDMissionsTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDMissionsTable::CDMissionsTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
|
|||||||
@@ -65,12 +65,12 @@ private:
|
|||||||
std::vector<CDMissions> entries;
|
std::vector<CDMissions> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
// Gets all the entries in the table
|
// Gets all the entries in the table
|
||||||
const std::vector<CDMissions>& GetEntries() const;
|
const std::vector<CDMissions>& GetEntries(void) const;
|
||||||
|
|
||||||
const CDMissions* GetPtrByMissionID(uint32_t missionID) const;
|
const CDMissions* GetPtrByMissionID(uint32_t missionID) const;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "CDMovementAIComponentTable.h"
|
#include "CDMovementAIComponentTable.h"
|
||||||
|
|
||||||
void CDMovementAIComponentTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDMovementAIComponentTable::CDMovementAIComponentTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -36,6 +37,7 @@ void CDMovementAIComponentTable::LoadValuesFromDatabase() {
|
|||||||
tableData.finalize();
|
tableData.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Queries the table with a custom "where" clause
|
||||||
std::vector<CDMovementAIComponent> CDMovementAIComponentTable::Query(std::function<bool(CDMovementAIComponent)> predicate) {
|
std::vector<CDMovementAIComponent> CDMovementAIComponentTable::Query(std::function<bool(CDMovementAIComponent)> predicate) {
|
||||||
|
|
||||||
std::vector<CDMovementAIComponent> data = cpplinq::from(this->entries)
|
std::vector<CDMovementAIComponent> data = cpplinq::from(this->entries)
|
||||||
@@ -45,7 +47,8 @@ std::vector<CDMovementAIComponent> CDMovementAIComponentTable::Query(std::functi
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<CDMovementAIComponent>& CDMovementAIComponentTable::GetEntries(void) const {
|
//! Gets all the entries in the table
|
||||||
|
std::vector<CDMovementAIComponent> CDMovementAIComponentTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ private:
|
|||||||
std::vector<CDMovementAIComponent> entries;
|
std::vector<CDMovementAIComponent> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
// Gets all the entries in the table
|
// Gets all the entries in the table
|
||||||
const std::vector<CDMovementAIComponent>& GetEntries() const;
|
std::vector<CDMovementAIComponent> GetEntries(void) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "CDObjectSkillsTable.h"
|
#include "CDObjectSkillsTable.h"
|
||||||
|
|
||||||
void CDObjectSkillsTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDObjectSkillsTable::CDObjectSkillsTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -32,6 +33,7 @@ void CDObjectSkillsTable::LoadValuesFromDatabase() {
|
|||||||
tableData.finalize();
|
tableData.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Queries the table with a custom "where" clause
|
||||||
std::vector<CDObjectSkills> CDObjectSkillsTable::Query(std::function<bool(CDObjectSkills)> predicate) {
|
std::vector<CDObjectSkills> CDObjectSkillsTable::Query(std::function<bool(CDObjectSkills)> predicate) {
|
||||||
|
|
||||||
std::vector<CDObjectSkills> data = cpplinq::from(this->entries)
|
std::vector<CDObjectSkills> data = cpplinq::from(this->entries)
|
||||||
@@ -41,6 +43,7 @@ std::vector<CDObjectSkills> CDObjectSkillsTable::Query(std::function<bool(CDObje
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<CDObjectSkills>& CDObjectSkillsTable::GetEntries() const {
|
//! Gets all the entries in the table
|
||||||
|
std::vector<CDObjectSkills> CDObjectSkillsTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ private:
|
|||||||
std::vector<CDObjectSkills> entries;
|
std::vector<CDObjectSkills> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
// Gets all the entries in the table
|
// Gets all the entries in the table
|
||||||
const std::vector<CDObjectSkills>& GetEntries() const;
|
std::vector<CDObjectSkills> GetEntries(void) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#include "CDObjectsTable.h"
|
#include "CDObjectsTable.h"
|
||||||
|
|
||||||
void CDObjectsTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDObjectsTable::CDObjectsTable(void) {
|
||||||
|
#ifdef CDCLIENT_CACHE_ALL
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Objects");
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Objects");
|
||||||
@@ -18,24 +20,25 @@ void CDObjectsTable::LoadValuesFromDatabase() {
|
|||||||
CDObjects entry;
|
CDObjects entry;
|
||||||
entry.id = tableData.getIntField("id", -1);
|
entry.id = tableData.getIntField("id", -1);
|
||||||
entry.name = tableData.getStringField("name", "");
|
entry.name = tableData.getStringField("name", "");
|
||||||
UNUSED_COLUMN(entry.placeable = tableData.getIntField("placeable", -1);)
|
entry.placeable = tableData.getIntField("placeable", -1);
|
||||||
entry.type = tableData.getStringField("type", "");
|
entry.type = tableData.getStringField("type", "");
|
||||||
UNUSED_COLUMN(entry.description = tableData.getStringField("description", "");)
|
entry.description = tableData.getStringField("description", "");
|
||||||
UNUSED_COLUMN(entry.localize = tableData.getIntField("localize", -1);)
|
entry.localize = tableData.getIntField("localize", -1);
|
||||||
UNUSED_COLUMN(entry.npcTemplateID = tableData.getIntField("npcTemplateID", -1);)
|
entry.npcTemplateID = tableData.getIntField("npcTemplateID", -1);
|
||||||
UNUSED_COLUMN(entry.displayName = tableData.getStringField("displayName", "");)
|
entry.displayName = tableData.getStringField("displayName", "");
|
||||||
entry.interactionDistance = tableData.getFloatField("interactionDistance", -1.0f);
|
entry.interactionDistance = tableData.getFloatField("interactionDistance", -1.0f);
|
||||||
UNUSED_COLUMN(entry.nametag = tableData.getIntField("nametag", -1);)
|
entry.nametag = tableData.getIntField("nametag", -1);
|
||||||
UNUSED_COLUMN(entry._internalNotes = tableData.getStringField("_internalNotes", "");)
|
entry._internalNotes = tableData.getStringField("_internalNotes", "");
|
||||||
UNUSED_COLUMN(entry.locStatus = tableData.getIntField("locStatus", -1);)
|
entry.locStatus = tableData.getIntField("locStatus", -1);
|
||||||
UNUSED_COLUMN(entry.gate_version = tableData.getStringField("gate_version", "");)
|
entry.gate_version = tableData.getStringField("gate_version", "");
|
||||||
UNUSED_COLUMN(entry.HQ_valid = tableData.getIntField("HQ_valid", -1);)
|
entry.HQ_valid = tableData.getIntField("HQ_valid", -1);
|
||||||
|
|
||||||
this->entries.insert(std::make_pair(entry.id, entry));
|
this->entries.insert(std::make_pair(entry.id, entry));
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
tableData.finalize();
|
tableData.finalize();
|
||||||
|
#endif
|
||||||
|
|
||||||
m_default.id = 0;
|
m_default.id = 0;
|
||||||
}
|
}
|
||||||
@@ -46,10 +49,12 @@ const CDObjects& CDObjectsTable::GetByID(unsigned int LOT) {
|
|||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM Objects WHERE id = ?;");
|
#ifndef CDCLIENT_CACHE_ALL
|
||||||
query.bind(1, static_cast<int32_t>(LOT));
|
std::stringstream query;
|
||||||
|
|
||||||
auto tableData = query.execQuery();
|
query << "SELECT * FROM Objects WHERE id = " << std::to_string(LOT);
|
||||||
|
|
||||||
|
auto tableData = CDClientDatabase::ExecuteQuery(query.str());
|
||||||
if (tableData.eof()) {
|
if (tableData.eof()) {
|
||||||
this->entries.insert(std::make_pair(LOT, m_default));
|
this->entries.insert(std::make_pair(LOT, m_default));
|
||||||
return m_default;
|
return m_default;
|
||||||
@@ -83,6 +88,7 @@ const CDObjects& CDObjectsTable::GetByID(unsigned int LOT) {
|
|||||||
if (it2 != entries.end()) {
|
if (it2 != entries.end()) {
|
||||||
return it2->second;
|
return it2->second;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return m_default;
|
return m_default;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ private:
|
|||||||
CDObjects m_default;
|
CDObjects m_default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
CDObjectsTable();
|
||||||
// Gets an entry by ID
|
// Gets an entry by ID
|
||||||
const CDObjects& GetByID(unsigned int LOT);
|
const CDObjects& GetByID(unsigned int LOT);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "CDPackageComponentTable.h"
|
#include "CDPackageComponentTable.h"
|
||||||
|
|
||||||
void CDPackageComponentTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDPackageComponentTable::CDPackageComponentTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -42,7 +43,7 @@ std::vector<CDPackageComponent> CDPackageComponentTable::Query(std::function<boo
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Gets all the entries in the table
|
//! Gets all the entries in the table
|
||||||
const std::vector<CDPackageComponent>& CDPackageComponentTable::GetEntries() const {
|
std::vector<CDPackageComponent> CDPackageComponentTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ private:
|
|||||||
std::vector<CDPackageComponent> entries;
|
std::vector<CDPackageComponent> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
CDPackageComponentTable(void);
|
||||||
// Queries the table with a custom "where" clause
|
// Queries the table with a custom "where" clause
|
||||||
std::vector<CDPackageComponent> Query(std::function<bool(CDPackageComponent)> predicate);
|
std::vector<CDPackageComponent> Query(std::function<bool(CDPackageComponent)> predicate);
|
||||||
|
|
||||||
const std::vector<CDPackageComponent>& GetEntries() const;
|
std::vector<CDPackageComponent> GetEntries(void) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,35 +1,46 @@
|
|||||||
#include "CDPhysicsComponentTable.h"
|
#include "CDPhysicsComponentTable.h"
|
||||||
|
|
||||||
void CDPhysicsComponentTable::LoadValuesFromDatabase() {
|
CDPhysicsComponentTable::CDPhysicsComponentTable(void) {
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PhysicsComponent");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PhysicsComponent");
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDPhysicsComponent entry;
|
CDPhysicsComponent* entry = new CDPhysicsComponent();
|
||||||
entry.id = tableData.getIntField("id", -1);
|
entry->id = tableData.getIntField("id", -1);
|
||||||
entry.bStatic = tableData.getIntField("static", -1) != 0;
|
entry->bStatic = tableData.getIntField("static", -1) != 0;
|
||||||
entry.physicsAsset = tableData.getStringField("physics_asset", "");
|
entry->physicsAsset = tableData.getStringField("physics_asset", "");
|
||||||
UNUSED(entry->jump = tableData.getIntField("jump", -1) != 0);
|
UNUSED(entry->jump = tableData.getIntField("jump", -1) != 0);
|
||||||
UNUSED(entry->doublejump = tableData.getIntField("doublejump", -1) != 0);
|
UNUSED(entry->doublejump = tableData.getIntField("doublejump", -1) != 0);
|
||||||
entry.speed = tableData.getFloatField("speed", -1);
|
entry->speed = tableData.getFloatField("speed", -1);
|
||||||
UNUSED(entry->rotSpeed = tableData.getFloatField("rotSpeed", -1));
|
UNUSED(entry->rotSpeed = tableData.getFloatField("rotSpeed", -1));
|
||||||
entry.playerHeight = tableData.getFloatField("playerHeight");
|
entry->playerHeight = tableData.getFloatField("playerHeight");
|
||||||
entry.playerRadius = tableData.getFloatField("playerRadius");
|
entry->playerRadius = tableData.getFloatField("playerRadius");
|
||||||
entry.pcShapeType = tableData.getIntField("pcShapeType");
|
entry->pcShapeType = tableData.getIntField("pcShapeType");
|
||||||
entry.collisionGroup = tableData.getIntField("collisionGroup");
|
entry->collisionGroup = tableData.getIntField("collisionGroup");
|
||||||
UNUSED(entry->airSpeed = tableData.getFloatField("airSpeed"));
|
UNUSED(entry->airSpeed = tableData.getFloatField("airSpeed"));
|
||||||
UNUSED(entry->boundaryAsset = tableData.getStringField("boundaryAsset"));
|
UNUSED(entry->boundaryAsset = tableData.getStringField("boundaryAsset"));
|
||||||
UNUSED(entry->jumpAirSpeed = tableData.getFloatField("jumpAirSpeed"));
|
UNUSED(entry->jumpAirSpeed = tableData.getFloatField("jumpAirSpeed"));
|
||||||
UNUSED(entry->friction = tableData.getFloatField("friction"));
|
UNUSED(entry->friction = tableData.getFloatField("friction"));
|
||||||
UNUSED(entry->gravityVolumeAsset = tableData.getStringField("gravityVolumeAsset"));
|
UNUSED(entry->gravityVolumeAsset = tableData.getStringField("gravityVolumeAsset"));
|
||||||
|
|
||||||
m_entries.insert(std::make_pair(entry.id, entry));
|
m_entries.insert(std::make_pair(entry->id, entry));
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
tableData.finalize();
|
tableData.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
CDPhysicsComponent* CDPhysicsComponentTable::GetByID(unsigned int componentID) {
|
CDPhysicsComponentTable::~CDPhysicsComponentTable() {
|
||||||
auto itr = m_entries.find(componentID);
|
for (auto e : m_entries) {
|
||||||
return itr != m_entries.end() ? &itr->second : nullptr;
|
if (e.second) delete e.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_entries.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
CDPhysicsComponent* CDPhysicsComponentTable::GetByID(unsigned int componentID) {
|
||||||
|
for (auto e : m_entries) {
|
||||||
|
if (e.first == componentID) return e.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,11 +23,12 @@ struct CDPhysicsComponent {
|
|||||||
|
|
||||||
class CDPhysicsComponentTable : public CDTable<CDPhysicsComponentTable> {
|
class CDPhysicsComponentTable : public CDTable<CDPhysicsComponentTable> {
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<unsigned int, CDPhysicsComponent> m_entries;
|
std::map<unsigned int, CDPhysicsComponent*> m_entries;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
#include "CDPropertyEntranceComponentTable.h"
|
#include "CDPropertyEntranceComponentTable.h"
|
||||||
|
|
||||||
void CDPropertyEntranceComponentTable::LoadValuesFromDatabase() {
|
CDPropertyEntranceComponentTable::CDPropertyEntranceComponentTable() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ struct CDPropertyEntranceComponent {
|
|||||||
|
|
||||||
class CDPropertyEntranceComponentTable : public CDTable<CDPropertyEntranceComponentTable> {
|
class CDPropertyEntranceComponentTable : public CDTable<CDPropertyEntranceComponentTable> {
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|
||||||
// Gets all the entries in the table
|
// Gets all the entries in the table
|
||||||
[[nodiscard]] const std::vector<CDPropertyEntranceComponent>& GetEntries() const { return entries; }
|
[[nodiscard]] std::vector<CDPropertyEntranceComponent> GetEntries() const { return entries; }
|
||||||
private:
|
private:
|
||||||
std::vector<CDPropertyEntranceComponent> entries{};
|
std::vector<CDPropertyEntranceComponent> entries{};
|
||||||
CDPropertyEntranceComponent defaultEntry{};
|
CDPropertyEntranceComponent defaultEntry{};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "CDPropertyTemplateTable.h"
|
#include "CDPropertyTemplateTable.h"
|
||||||
|
|
||||||
void CDPropertyTemplateTable::LoadValuesFromDatabase() {
|
CDPropertyTemplateTable::CDPropertyTemplateTable() {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ struct CDPropertyTemplate {
|
|||||||
|
|
||||||
class CDPropertyTemplateTable : public CDTable<CDPropertyTemplateTable> {
|
class CDPropertyTemplateTable : public CDTable<CDPropertyTemplateTable> {
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "CDProximityMonitorComponentTable.h"
|
#include "CDProximityMonitorComponentTable.h"
|
||||||
|
|
||||||
void CDProximityMonitorComponentTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDProximityMonitorComponentTable::CDProximityMonitorComponentTable(void) {
|
||||||
|
|
||||||
// First, get the size of the table
|
// First, get the size of the table
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
@@ -32,6 +33,7 @@ void CDProximityMonitorComponentTable::LoadValuesFromDatabase() {
|
|||||||
tableData.finalize();
|
tableData.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Queries the table with a custom "where" clause
|
||||||
std::vector<CDProximityMonitorComponent> CDProximityMonitorComponentTable::Query(std::function<bool(CDProximityMonitorComponent)> predicate) {
|
std::vector<CDProximityMonitorComponent> CDProximityMonitorComponentTable::Query(std::function<bool(CDProximityMonitorComponent)> predicate) {
|
||||||
|
|
||||||
std::vector<CDProximityMonitorComponent> data = cpplinq::from(this->entries)
|
std::vector<CDProximityMonitorComponent> data = cpplinq::from(this->entries)
|
||||||
@@ -41,7 +43,8 @@ std::vector<CDProximityMonitorComponent> CDProximityMonitorComponentTable::Query
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<CDProximityMonitorComponent>& CDProximityMonitorComponentTable::GetEntries() const {
|
//! Gets all the entries in the table
|
||||||
|
std::vector<CDProximityMonitorComponent> CDProximityMonitorComponentTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ private:
|
|||||||
std::vector<CDProximityMonitorComponent> entries;
|
std::vector<CDProximityMonitorComponent> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
CDProximityMonitorComponentTable(void);
|
||||||
//! Queries the table with a custom "where" clause
|
//! Queries the table with a custom "where" clause
|
||||||
std::vector<CDProximityMonitorComponent> Query(std::function<bool(CDProximityMonitorComponent)> predicate);
|
std::vector<CDProximityMonitorComponent> Query(std::function<bool(CDProximityMonitorComponent)> predicate);
|
||||||
|
|
||||||
const std::vector<CDProximityMonitorComponent>& GetEntries() const;
|
std::vector<CDProximityMonitorComponent> GetEntries(void) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "CDRailActivatorComponent.h"
|
#include "CDRailActivatorComponent.h"
|
||||||
#include "GeneralUtils.h"
|
#include "GeneralUtils.h"
|
||||||
|
|
||||||
void CDRailActivatorComponentTable::LoadValuesFromDatabase() {
|
CDRailActivatorComponentTable::CDRailActivatorComponentTable() {
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM RailActivatorComponent;");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM RailActivatorComponent;");
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDRailActivatorComponent entry;
|
CDRailActivatorComponent entry;
|
||||||
@@ -52,7 +52,7 @@ CDRailActivatorComponent CDRailActivatorComponentTable::GetEntryByID(int32_t id)
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<CDRailActivatorComponent>& CDRailActivatorComponentTable::GetEntries() const {
|
std::vector<CDRailActivatorComponent> CDRailActivatorComponentTable::GetEntries() const {
|
||||||
return m_Entries;
|
return m_Entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ struct CDRailActivatorComponent {
|
|||||||
|
|
||||||
class CDRailActivatorComponentTable : public CDTable<CDRailActivatorComponentTable> {
|
class CDRailActivatorComponentTable : public CDTable<CDRailActivatorComponentTable> {
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
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]] const std::vector<CDRailActivatorComponent>& GetEntries() const;
|
[[nodiscard]] std::vector<CDRailActivatorComponent> GetEntries() const;
|
||||||
private:
|
private:
|
||||||
static std::pair<uint32_t, std::u16string> EffectPairFromString(std::string& str);
|
static std::pair<uint32_t, std::u16string> EffectPairFromString(std::string& str);
|
||||||
std::vector<CDRailActivatorComponent> m_Entries{};
|
std::vector<CDRailActivatorComponent> m_Entries{};
|
||||||
|
|||||||
@@ -1,16 +1,32 @@
|
|||||||
#include "CDRarityTableTable.h"
|
#include "CDRarityTableTable.h"
|
||||||
|
|
||||||
void CDRarityTableTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDRarityTableTable::CDRarityTableTable(void) {
|
||||||
|
|
||||||
|
// First, get the size of the table
|
||||||
|
unsigned int size = 0;
|
||||||
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM RarityTable");
|
||||||
|
while (!tableSize.eof()) {
|
||||||
|
size = tableSize.getIntField(0, 0);
|
||||||
|
|
||||||
|
tableSize.nextRow();
|
||||||
|
}
|
||||||
|
|
||||||
|
tableSize.finalize();
|
||||||
|
|
||||||
|
// Reserve the size
|
||||||
|
this->entries.reserve(size);
|
||||||
|
|
||||||
// Now get the data
|
// Now get the data
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM RarityTable");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM RarityTable");
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDRarityTable entry;
|
CDRarityTable entry;
|
||||||
uint32_t id = tableData.getIntField("id", -1);
|
entry.id = tableData.getIntField("id", -1);
|
||||||
entry.randmax = tableData.getFloatField("randmax", -1);
|
entry.randmax = tableData.getFloatField("randmax", -1);
|
||||||
entry.rarity = tableData.getIntField("rarity", -1);
|
entry.rarity = tableData.getIntField("rarity", -1);
|
||||||
entry.RarityTableIndex = tableData.getIntField("RarityTableIndex", -1);
|
entry.RarityTableIndex = tableData.getIntField("RarityTableIndex", -1);
|
||||||
|
|
||||||
this->entries.insert_or_assign(id, entry);
|
this->entries.push_back(entry);
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,7 +34,17 @@ void CDRarityTableTable::LoadValuesFromDatabase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Queries the table with a custom "where" clause
|
//! Queries the table with a custom "where" clause
|
||||||
const std::optional<CDRarityTable> CDRarityTableTable::Get(uint32_t id) {
|
std::vector<CDRarityTable> CDRarityTableTable::Query(std::function<bool(CDRarityTable)> predicate) {
|
||||||
auto it = this->entries.find(id);
|
|
||||||
return it != this->entries.end() ? std::make_optional(it->second) : std::nullopt;
|
std::vector<CDRarityTable> data = cpplinq::from(this->entries)
|
||||||
|
>> cpplinq::where(predicate)
|
||||||
|
>> cpplinq::to_vector();
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Gets all the entries in the table
|
||||||
|
const std::vector<CDRarityTable>& CDRarityTableTable::GetEntries(void) const {
|
||||||
|
return this->entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,11 +28,13 @@ struct CDRarityTable {
|
|||||||
|
|
||||||
class CDRarityTableTable : public CDTable<CDRarityTableTable> {
|
class CDRarityTableTable : public CDTable<CDRarityTableTable> {
|
||||||
private:
|
private:
|
||||||
std::unordered_map<uint32_t, CDRarityTable> entries;
|
std::vector<CDRarityTable> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
CDRarityTableTable();
|
||||||
// Queries the table with a custom "where" clause
|
// Queries the table with a custom "where" clause
|
||||||
const std::optional<CDRarityTable> Get(uint32_t predicate);
|
std::vector<CDRarityTable> Query(std::function<bool(CDRarityTable)> predicate);
|
||||||
|
|
||||||
|
const std::vector<CDRarityTable>& GetEntries() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,27 @@
|
|||||||
#include "CDRebuildComponentTable.h"
|
#include "CDRebuildComponentTable.h"
|
||||||
|
|
||||||
void CDRebuildComponentTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDRebuildComponentTable::CDRebuildComponentTable(void) {
|
||||||
|
|
||||||
|
// First, get the size of the table
|
||||||
|
unsigned int size = 0;
|
||||||
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM RebuildComponent");
|
||||||
|
while (!tableSize.eof()) {
|
||||||
|
size = tableSize.getIntField(0, 0);
|
||||||
|
|
||||||
|
tableSize.nextRow();
|
||||||
|
}
|
||||||
|
|
||||||
|
tableSize.finalize();
|
||||||
|
|
||||||
|
// Reserve the size
|
||||||
|
this->entries.reserve(size);
|
||||||
|
|
||||||
// Now get the data
|
// Now get the data
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM RebuildComponent");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM RebuildComponent");
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDRebuildComponent entry;
|
CDRebuildComponent entry;
|
||||||
uint32_t id = tableData.getIntField("id", -1);
|
entry.id = tableData.getIntField("id", -1);
|
||||||
entry.reset_time = tableData.getFloatField("reset_time", -1.0f);
|
entry.reset_time = tableData.getFloatField("reset_time", -1.0f);
|
||||||
entry.complete_time = tableData.getFloatField("complete_time", -1.0f);
|
entry.complete_time = tableData.getFloatField("complete_time", -1.0f);
|
||||||
entry.take_imagination = tableData.getIntField("take_imagination", -1);
|
entry.take_imagination = tableData.getIntField("take_imagination", -1);
|
||||||
@@ -16,12 +32,25 @@ void CDRebuildComponentTable::LoadValuesFromDatabase() {
|
|||||||
entry.post_imagination_cost = tableData.getIntField("post_imagination_cost", -1);
|
entry.post_imagination_cost = tableData.getIntField("post_imagination_cost", -1);
|
||||||
entry.time_before_smash = tableData.getFloatField("time_before_smash", -1.0f);
|
entry.time_before_smash = tableData.getFloatField("time_before_smash", -1.0f);
|
||||||
|
|
||||||
this->entries.insert_or_assign(id, entry);
|
this->entries.push_back(entry);
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tableData.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::optional<CDRebuildComponent> CDRebuildComponentTable::Get(uint32_t componentId) {
|
//! Queries the table with a custom "where" clause
|
||||||
auto it = this->entries.find(componentId);
|
std::vector<CDRebuildComponent> CDRebuildComponentTable::Query(std::function<bool(CDRebuildComponent)> predicate) {
|
||||||
return it != this->entries.end() ? std::make_optional(it->second) : std::nullopt;
|
|
||||||
|
std::vector<CDRebuildComponent> data = cpplinq::from(this->entries)
|
||||||
|
>> cpplinq::where(predicate)
|
||||||
|
>> cpplinq::to_vector();
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Gets all the entries in the table
|
||||||
|
std::vector<CDRebuildComponent> CDRebuildComponentTable::GetEntries(void) const {
|
||||||
|
return this->entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDRebuildComponent {
|
struct CDRebuildComponent {
|
||||||
|
unsigned int id; //!< The component Id
|
||||||
float reset_time; //!< The reset time
|
float reset_time; //!< The reset time
|
||||||
float complete_time; //!< The complete time
|
float complete_time; //!< The complete time
|
||||||
unsigned int take_imagination; //!< The amount of imagination it costs
|
unsigned int take_imagination; //!< The amount of imagination it costs
|
||||||
@@ -17,11 +18,13 @@ struct CDRebuildComponent {
|
|||||||
|
|
||||||
class CDRebuildComponentTable : public CDTable<CDRebuildComponentTable> {
|
class CDRebuildComponentTable : public CDTable<CDRebuildComponentTable> {
|
||||||
private:
|
private:
|
||||||
std::unordered_map<uint32_t, CDRebuildComponent> entries;
|
std::vector<CDRebuildComponent> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
CDRebuildComponentTable();
|
||||||
// Queries the table with a custom "where" clause
|
// Queries the table with a custom "where" clause
|
||||||
const std::optional<CDRebuildComponent> Get(uint32_t componentId);
|
std::vector<CDRebuildComponent> Query(std::function<bool(CDRebuildComponent)> predicate);
|
||||||
|
|
||||||
|
std::vector<CDRebuildComponent> GetEntries() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,35 @@
|
|||||||
#include "CDRewardsTable.h"
|
#include "CDRewardsTable.h"
|
||||||
|
|
||||||
void CDRewardsTable::LoadValuesFromDatabase() {
|
CDRewardsTable::CDRewardsTable(void) {
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Rewards");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Rewards");
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDRewards entry;
|
CDRewards* entry = new CDRewards();
|
||||||
uint32_t id = tableData.getIntField("id", -1);
|
entry->id = tableData.getIntField("id", -1);
|
||||||
entry.levelID = tableData.getIntField("LevelID", -1);
|
entry->levelID = tableData.getIntField("LevelID", -1);
|
||||||
entry.missionID = tableData.getIntField("MissionID", -1);
|
entry->missionID = tableData.getIntField("MissionID", -1);
|
||||||
entry.rewardType = tableData.getIntField("RewardType", -1);
|
entry->rewardType = tableData.getIntField("RewardType", -1);
|
||||||
entry.value = tableData.getIntField("value", -1);
|
entry->value = tableData.getIntField("value", -1);
|
||||||
entry.count = tableData.getIntField("count", -1);
|
entry->count = tableData.getIntField("count", -1);
|
||||||
|
|
||||||
m_entries.push_back(entry);
|
m_entries.insert(std::make_pair(entry->id, entry));
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
tableData.finalize();
|
tableData.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CDRewards> CDRewardsTable::GetByLevelID(uint32_t levelID) {
|
CDRewardsTable::~CDRewardsTable(void) {
|
||||||
std::vector<CDRewards> result;
|
for (auto e : m_entries) {
|
||||||
for (const auto& levelData : m_entries) {
|
if (e.second) delete e.second;
|
||||||
if (levelData.levelID == levelID) result.push_back(levelData);
|
}
|
||||||
|
|
||||||
|
m_entries.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<CDRewards*> CDRewardsTable::GetByLevelID(uint32_t levelID) {
|
||||||
|
std::vector<CDRewards*> result{};
|
||||||
|
for (const auto& e : m_entries) {
|
||||||
|
if (e.second->levelID == levelID) result.push_back(e.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
struct CDRewards {
|
struct CDRewards {
|
||||||
|
int32_t id;
|
||||||
int32_t levelID;
|
int32_t levelID;
|
||||||
int32_t missionID;
|
int32_t missionID;
|
||||||
int32_t rewardType;
|
int32_t rewardType;
|
||||||
@@ -12,8 +13,12 @@ struct CDRewards {
|
|||||||
|
|
||||||
class CDRewardsTable : public CDTable<CDRewardsTable> {
|
class CDRewardsTable : public CDTable<CDRewardsTable> {
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
CDRewardsTable();
|
||||||
std::vector<CDRewards> GetByLevelID(uint32_t levelID);
|
~CDRewardsTable();
|
||||||
|
|
||||||
|
static const std::string GetTableName() { return "Rewards"; };
|
||||||
|
std::vector<CDRewards*> GetByLevelID(uint32_t levelID);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<CDRewards> m_entries;
|
std::map<uint32_t, CDRewards*> m_entries;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,21 +1,40 @@
|
|||||||
#include "CDScriptComponentTable.h"
|
#include "CDScriptComponentTable.h"
|
||||||
|
|
||||||
void CDScriptComponentTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDScriptComponentTable::CDScriptComponentTable(void) {
|
||||||
|
|
||||||
|
// First, get the size of the table
|
||||||
|
unsigned int size = 0;
|
||||||
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ScriptComponent");
|
||||||
|
while (!tableSize.eof()) {
|
||||||
|
size = tableSize.getIntField(0, 0);
|
||||||
|
|
||||||
|
tableSize.nextRow();
|
||||||
|
}
|
||||||
|
|
||||||
|
tableSize.finalize();
|
||||||
|
|
||||||
// Now get the data
|
// Now get the data
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ScriptComponent");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ScriptComponent");
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDScriptComponent entry;
|
CDScriptComponent entry;
|
||||||
uint32_t id = tableData.getIntField("id", -1);
|
entry.id = tableData.getIntField("id", -1);
|
||||||
entry.script_name = tableData.getStringField("script_name", "");
|
entry.script_name = tableData.getStringField("script_name", "");
|
||||||
entry.client_script_name = tableData.getStringField("client_script_name", "");
|
entry.client_script_name = tableData.getStringField("client_script_name", "");
|
||||||
|
|
||||||
this->entries.insert_or_assign(id, entry);
|
this->entries.insert(std::make_pair(entry.id, entry));
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tableData.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::optional<CDScriptComponent> CDScriptComponentTable::GetByID(unsigned int id) {
|
const CDScriptComponent& CDScriptComponentTable::GetByID(unsigned int id) {
|
||||||
auto it = this->entries.find(id);
|
std::map<unsigned int, CDScriptComponent>::iterator it = this->entries.find(id);
|
||||||
return (it != this->entries.end()) ? std::make_optional<CDScriptComponent>(it->second) : std::nullopt;
|
if (it != this->entries.end()) {
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_ToReturnWhenNoneFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,16 +4,19 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDScriptComponent {
|
struct CDScriptComponent {
|
||||||
|
unsigned int id; //!< The component ID
|
||||||
std::string script_name; //!< The script name
|
std::string script_name; //!< The script name
|
||||||
std::string client_script_name; //!< The client script name
|
std::string client_script_name; //!< The client script name
|
||||||
};
|
};
|
||||||
|
|
||||||
class CDScriptComponentTable : public CDTable<CDScriptComponentTable> {
|
class CDScriptComponentTable : public CDTable<CDScriptComponentTable> {
|
||||||
private:
|
private:
|
||||||
std::unordered_map<unsigned int, CDScriptComponent> entries;
|
std::map<unsigned int, CDScriptComponent> entries;
|
||||||
|
CDScriptComponent m_ToReturnWhenNoneFound;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
CDScriptComponentTable();
|
||||||
// Gets an entry by scriptID
|
// Gets an entry by scriptID
|
||||||
const std::optional<CDScriptComponent> GetByID(unsigned int id);
|
const CDScriptComponent& GetByID(unsigned int id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,29 @@
|
|||||||
#include "CDSkillBehaviorTable.h"
|
#include "CDSkillBehaviorTable.h"
|
||||||
|
//#include "Logger.hpp"
|
||||||
|
|
||||||
void CDSkillBehaviorTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDSkillBehaviorTable::CDSkillBehaviorTable(void) {
|
||||||
|
m_empty = CDSkillBehavior();
|
||||||
|
|
||||||
|
// First, get the size of the table
|
||||||
|
unsigned int size = 0;
|
||||||
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM SkillBehavior");
|
||||||
|
while (!tableSize.eof()) {
|
||||||
|
size = tableSize.getIntField(0, 0);
|
||||||
|
|
||||||
|
tableSize.nextRow();
|
||||||
|
}
|
||||||
|
|
||||||
|
tableSize.finalize();
|
||||||
|
|
||||||
|
// Reserve the size
|
||||||
|
//this->entries.reserve(size);
|
||||||
|
|
||||||
|
// Now get the data
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM SkillBehavior");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM SkillBehavior");
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDSkillBehavior entry;
|
CDSkillBehavior entry;
|
||||||
uint32_t skillID = tableData.getIntField("skillID", -1);
|
entry.skillID = tableData.getIntField("skillID", -1);
|
||||||
UNUSED(entry.locStatus = tableData.getIntField("locStatus", -1));
|
UNUSED(entry.locStatus = tableData.getIntField("locStatus", -1));
|
||||||
entry.behaviorID = tableData.getIntField("behaviorID", -1);
|
entry.behaviorID = tableData.getIntField("behaviorID", -1);
|
||||||
entry.imaginationcost = tableData.getIntField("imaginationcost", -1);
|
entry.imaginationcost = tableData.getIntField("imaginationcost", -1);
|
||||||
@@ -24,13 +43,27 @@ void CDSkillBehaviorTable::LoadValuesFromDatabase() {
|
|||||||
UNUSED(entry.gate_version = tableData.getStringField("gate_version", ""));
|
UNUSED(entry.gate_version = tableData.getStringField("gate_version", ""));
|
||||||
UNUSED(entry.cancelType = tableData.getIntField("cancelType", -1));
|
UNUSED(entry.cancelType = tableData.getIntField("cancelType", -1));
|
||||||
|
|
||||||
this->entries.insert_or_assign(skillID, entry);
|
this->entries.insert(std::make_pair(entry.skillID, entry));
|
||||||
|
//this->entries.push_back(entry);
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tableData.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::optional<CDSkillBehavior> CDSkillBehaviorTable::GetSkillByID(unsigned int skillID) {
|
//! Queries the table with a custom "where" clause
|
||||||
auto it = this->entries.find(skillID);
|
std::vector<CDSkillBehavior> CDSkillBehaviorTable::Query(std::function<bool(CDSkillBehavior)> predicate) {
|
||||||
return it != this->entries.end() ? std::make_optional(it->second) : std::nullopt;
|
std::vector<CDSkillBehavior> data; //So MSVC shuts up
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Gets an entry by ID
|
||||||
|
const CDSkillBehavior& CDSkillBehaviorTable::GetSkillByID(unsigned int skillID) {
|
||||||
|
std::map<unsigned int, CDSkillBehavior>::iterator it = this->entries.find(skillID);
|
||||||
|
if (it != this->entries.end()) {
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDSkillBehavior {
|
struct CDSkillBehavior {
|
||||||
|
unsigned int skillID; //!< The Skill ID of the skill
|
||||||
UNUSED(unsigned int locStatus); //!< ??
|
UNUSED(unsigned int locStatus); //!< ??
|
||||||
unsigned int behaviorID; //!< The Behavior ID of the skill
|
unsigned int behaviorID; //!< The Behavior ID of the skill
|
||||||
unsigned int imaginationcost; //!< The imagination cost of the skill
|
unsigned int imaginationcost; //!< The imagination cost of the skill
|
||||||
@@ -26,11 +27,15 @@ struct CDSkillBehavior {
|
|||||||
|
|
||||||
class CDSkillBehaviorTable : public CDTable<CDSkillBehaviorTable> {
|
class CDSkillBehaviorTable : public CDTable<CDSkillBehaviorTable> {
|
||||||
private:
|
private:
|
||||||
std::unordered_map<uint32_t, CDSkillBehavior> entries;
|
std::map<unsigned int, CDSkillBehavior> entries;
|
||||||
|
CDSkillBehavior m_empty;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
CDSkillBehaviorTable();
|
||||||
|
// Queries the table with a custom "where" clause
|
||||||
|
std::vector<CDSkillBehavior> Query(std::function<bool(CDSkillBehavior)> predicate);
|
||||||
|
|
||||||
// Gets an entry by skillID
|
// Gets an entry by skillID
|
||||||
const std::optional<CDSkillBehavior> GetSkillByID(unsigned int skillID);
|
const CDSkillBehavior& GetSkillByID(unsigned int skillID);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include "DluAssert.h"
|
#include "DluAssert.h"
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <optional>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|||||||
@@ -1,22 +1,51 @@
|
|||||||
#include "CDVendorComponentTable.h"
|
#include "CDVendorComponentTable.h"
|
||||||
|
|
||||||
void CDVendorComponentTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDVendorComponentTable::CDVendorComponentTable(void) {
|
||||||
|
|
||||||
|
// First, get the size of the table
|
||||||
|
unsigned int size = 0;
|
||||||
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM VendorComponent");
|
||||||
|
while (!tableSize.eof()) {
|
||||||
|
size = tableSize.getIntField(0, 0);
|
||||||
|
|
||||||
|
tableSize.nextRow();
|
||||||
|
}
|
||||||
|
|
||||||
|
tableSize.finalize();
|
||||||
|
|
||||||
|
// Reserve the size
|
||||||
|
this->entries.reserve(size);
|
||||||
|
|
||||||
// Now get the data
|
// Now get the data
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM VendorComponent");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM VendorComponent");
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDVendorComponent entry;
|
CDVendorComponent entry;
|
||||||
uint32_t id = tableData.getIntField("id", -1);
|
entry.id = tableData.getIntField("id", -1);
|
||||||
entry.buyScalar = tableData.getFloatField("buyScalar", -1.0f);
|
entry.buyScalar = tableData.getFloatField("buyScalar", -1.0f);
|
||||||
entry.sellScalar = tableData.getFloatField("sellScalar", -1.0f);
|
entry.sellScalar = tableData.getFloatField("sellScalar", -1.0f);
|
||||||
entry.refreshTimeSeconds = tableData.getFloatField("refreshTimeSeconds", -1.0f);
|
entry.refreshTimeSeconds = tableData.getFloatField("refreshTimeSeconds", -1.0f);
|
||||||
entry.LootMatrixIndex = tableData.getIntField("LootMatrixIndex", -1);
|
entry.LootMatrixIndex = tableData.getIntField("LootMatrixIndex", -1);
|
||||||
|
|
||||||
this->entries.insert_or_assign(id, entry);
|
this->entries.push_back(entry);
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tableData.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::optional<CDVendorComponent> CDVendorComponentTable::Query(uint32_t id) {
|
//! Queries the table with a custom "where" clause
|
||||||
const auto& iter = entries.find(id);
|
std::vector<CDVendorComponent> CDVendorComponentTable::Query(std::function<bool(CDVendorComponent)> predicate) {
|
||||||
return iter != entries.end() ? std::make_optional(iter->second) : std::nullopt;
|
|
||||||
|
std::vector<CDVendorComponent> data = cpplinq::from(this->entries)
|
||||||
|
>> cpplinq::where(predicate)
|
||||||
|
>> cpplinq::to_vector();
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Gets all the entries in the table
|
||||||
|
std::vector<CDVendorComponent> CDVendorComponentTable::GetEntries(void) const {
|
||||||
|
return this->entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDVendorComponent {
|
struct CDVendorComponent {
|
||||||
|
unsigned int id; //!< The Component ID
|
||||||
float buyScalar; //!< Buy Scalar (what does that mean?)
|
float buyScalar; //!< Buy Scalar (what does that mean?)
|
||||||
float sellScalar; //!< Sell Scalar (what does that mean?)
|
float sellScalar; //!< Sell Scalar (what does that mean?)
|
||||||
float refreshTimeSeconds; //!< The refresh time
|
float refreshTimeSeconds; //!< The refresh time
|
||||||
@@ -12,11 +13,13 @@ struct CDVendorComponent {
|
|||||||
|
|
||||||
class CDVendorComponentTable : public CDTable<CDVendorComponentTable> {
|
class CDVendorComponentTable : public CDTable<CDVendorComponentTable> {
|
||||||
private:
|
private:
|
||||||
std::unordered_map<uint32_t, CDVendorComponent> entries;
|
std::vector<CDVendorComponent> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
CDVendorComponentTable();
|
||||||
// Queries the table with a custom "where" clause
|
// Queries the table with a custom "where" clause
|
||||||
const std::optional<CDVendorComponent> Query(uint32_t id);
|
std::vector<CDVendorComponent> Query(std::function<bool(CDVendorComponent)> predicate);
|
||||||
|
|
||||||
|
std::vector<CDVendorComponent> GetEntries(void) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,19 @@
|
|||||||
#include "CDZoneTableTable.h"
|
#include "CDZoneTableTable.h"
|
||||||
|
|
||||||
void CDZoneTableTable::LoadValuesFromDatabase() {
|
//! Constructor
|
||||||
|
CDZoneTableTable::CDZoneTableTable(void) {
|
||||||
|
|
||||||
|
// First, get the size of the table
|
||||||
|
unsigned int size = 0;
|
||||||
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ZoneTable");
|
||||||
|
while (!tableSize.eof()) {
|
||||||
|
size = tableSize.getIntField(0, 0);
|
||||||
|
|
||||||
|
tableSize.nextRow();
|
||||||
|
}
|
||||||
|
|
||||||
|
tableSize.finalize();
|
||||||
|
|
||||||
// Now get the data
|
// Now get the data
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ZoneTable");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ZoneTable");
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
@@ -36,11 +49,18 @@ void CDZoneTableTable::LoadValuesFromDatabase() {
|
|||||||
this->m_Entries.insert(std::make_pair(entry.zoneID, entry));
|
this->m_Entries.insert(std::make_pair(entry.zoneID, entry));
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tableData.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Queries the table with a zoneID to find.
|
//! Queries the table with a zoneID to find.
|
||||||
const std::optional<CDZoneTable> CDZoneTableTable::Query(unsigned int zoneID) {
|
const CDZoneTable* CDZoneTableTable::Query(unsigned int zoneID) {
|
||||||
const auto& iter = m_Entries.find(zoneID);
|
const auto& iter = m_Entries.find(zoneID);
|
||||||
return iter != m_Entries.end() ? std::make_optional(iter->second) : std::nullopt;
|
|
||||||
|
if (iter != m_Entries.end()) {
|
||||||
|
return &iter->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
// Custom Classes
|
||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
struct CDZoneTable {
|
struct CDZoneTable {
|
||||||
@@ -34,11 +35,11 @@ struct CDZoneTable {
|
|||||||
|
|
||||||
class CDZoneTableTable : public CDTable<CDZoneTableTable> {
|
class CDZoneTableTable : public CDTable<CDZoneTableTable> {
|
||||||
private:
|
private:
|
||||||
std::unordered_map<uint32_t, CDZoneTable> m_Entries;
|
std::map<unsigned int, CDZoneTable> m_Entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
CDZoneTableTable();
|
||||||
|
|
||||||
// Queries the table with a zoneID to find.
|
// Queries the table with a zoneID to find.
|
||||||
const std::optional<CDZoneTable> Query(unsigned int zoneID);
|
const CDZoneTable* Query(unsigned int zoneID);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ void Character::DoQuickXMLDataParse() {
|
|||||||
//To try and fix the AG landing into:
|
//To try and fix the AG landing into:
|
||||||
if (m_ZoneID == 1000 && Game::server->GetZoneID() == 1100) {
|
if (m_ZoneID == 1000 && Game::server->GetZoneID() == 1100) {
|
||||||
//sneakily insert our position:
|
//sneakily insert our position:
|
||||||
auto pos = Game::zoneManager->GetZone()->GetSpawnPos();
|
auto pos = dZoneManager::Instance()->GetZone()->GetSpawnPos();
|
||||||
character->SetAttribute("lzx", pos.x);
|
character->SetAttribute("lzx", pos.x);
|
||||||
character->SetAttribute("lzy", pos.y);
|
character->SetAttribute("lzy", pos.y);
|
||||||
character->SetAttribute("lzz", pos.z);
|
character->SetAttribute("lzz", pos.z);
|
||||||
@@ -290,13 +290,13 @@ void Character::DoQuickXMLDataParse() {
|
|||||||
|
|
||||||
void Character::UnlockEmote(int emoteID) {
|
void Character::UnlockEmote(int emoteID) {
|
||||||
m_UnlockedEmotes.push_back(emoteID);
|
m_UnlockedEmotes.push_back(emoteID);
|
||||||
GameMessages::SendSetEmoteLockState(Game::entityManager->GetEntity(m_ObjectID), false, emoteID);
|
GameMessages::SendSetEmoteLockState(EntityManager::Instance()->GetEntity(m_ObjectID), false, emoteID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Character::SetBuildMode(bool buildMode) {
|
void Character::SetBuildMode(bool buildMode) {
|
||||||
m_BuildMode = buildMode;
|
m_BuildMode = buildMode;
|
||||||
|
|
||||||
auto* controller = Game::zoneManager->GetZoneControlObject();
|
auto* controller = dZoneManager::Instance()->GetZoneControlObject();
|
||||||
|
|
||||||
controller->OnFireEventServerSide(m_OurEntity, buildMode ? "OnBuildModeEnter" : "OnBuildModeLeave");
|
controller->OnFireEventServerSide(m_OurEntity, buildMode ? "OnBuildModeEnter" : "OnBuildModeLeave");
|
||||||
}
|
}
|
||||||
@@ -312,7 +312,7 @@ void Character::SaveXMLToDatabase() {
|
|||||||
character->SetAttribute("gm", static_cast<uint32_t>(m_GMLevel));
|
character->SetAttribute("gm", static_cast<uint32_t>(m_GMLevel));
|
||||||
character->SetAttribute("cc", m_Coins);
|
character->SetAttribute("cc", m_Coins);
|
||||||
|
|
||||||
auto zoneInfo = Game::zoneManager->GetZone()->GetZoneID();
|
auto zoneInfo = dZoneManager::Instance()->GetZone()->GetZoneID();
|
||||||
// lzid garbage, binary concat of zoneID, zoneInstance and zoneClone
|
// lzid garbage, binary concat of zoneID, zoneInstance and zoneClone
|
||||||
if (zoneInfo.GetMapID() != 0 && zoneInfo.GetCloneID() == 0) {
|
if (zoneInfo.GetMapID() != 0 && zoneInfo.GetCloneID() == 0) {
|
||||||
uint64_t lzidConcat = zoneInfo.GetCloneID();
|
uint64_t lzidConcat = zoneInfo.GetCloneID();
|
||||||
@@ -424,7 +424,7 @@ void Character::SetPlayerFlag(const uint32_t flagId, const bool value) {
|
|||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
// Update the mission component:
|
// Update the mission component:
|
||||||
auto* player = Game::entityManager->GetEntity(m_ObjectID);
|
auto* player = EntityManager::Instance()->GetEntity(m_ObjectID);
|
||||||
|
|
||||||
if (player != nullptr) {
|
if (player != nullptr) {
|
||||||
auto* missionComponent = player->GetComponent<MissionComponent>();
|
auto* missionComponent = player->GetComponent<MissionComponent>();
|
||||||
@@ -602,7 +602,7 @@ void Character::SetCoins(int64_t newCoins, eLootSourceType lootSource) {
|
|||||||
|
|
||||||
m_Coins = newCoins;
|
m_Coins = newCoins;
|
||||||
|
|
||||||
GameMessages::SendSetCurrency(Game::entityManager->GetEntity(m_ObjectID), m_Coins, 0, 0, 0, 0, true, lootSource);
|
GameMessages::SendSetCurrency(EntityManager::Instance()->GetEntity(m_ObjectID), m_Coins, 0, 0, 0, 0, true, lootSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Character::HasBeenToWorld(LWOMAPID mapID) const {
|
bool Character::HasBeenToWorld(LWOMAPID mapID) const {
|
||||||
|
|||||||
@@ -263,17 +263,17 @@ void Entity::Initialize() {
|
|||||||
NiQuaternion rot;
|
NiQuaternion rot;
|
||||||
|
|
||||||
const auto& targetSceneName = m_Character->GetTargetScene();
|
const auto& targetSceneName = m_Character->GetTargetScene();
|
||||||
auto* targetScene = Game::entityManager->GetSpawnPointEntity(targetSceneName);
|
auto* targetScene = EntityManager::Instance()->GetSpawnPointEntity(targetSceneName);
|
||||||
|
|
||||||
if (m_Character->HasBeenToWorld(mapID) && targetSceneName.empty()) {
|
if (m_Character->HasBeenToWorld(mapID) && targetSceneName.empty()) {
|
||||||
pos = m_Character->GetRespawnPoint(mapID);
|
pos = m_Character->GetRespawnPoint(mapID);
|
||||||
rot = Game::zoneManager->GetZone()->GetSpawnRot();
|
rot = dZoneManager::Instance()->GetZone()->GetSpawnRot();
|
||||||
} else if (targetScene != nullptr) {
|
} else if (targetScene != nullptr) {
|
||||||
pos = targetScene->GetPosition();
|
pos = targetScene->GetPosition();
|
||||||
rot = targetScene->GetRotation();
|
rot = targetScene->GetRotation();
|
||||||
} else {
|
} else {
|
||||||
pos = Game::zoneManager->GetZone()->GetSpawnPos();
|
pos = dZoneManager::Instance()->GetZone()->GetSpawnPos();
|
||||||
rot = Game::zoneManager->GetZone()->GetSpawnRot();
|
rot = dZoneManager::Instance()->GetZone()->GetSpawnRot();
|
||||||
}
|
}
|
||||||
|
|
||||||
controllablePhysics->SetPosition(pos);
|
controllablePhysics->SetPosition(pos);
|
||||||
@@ -463,11 +463,9 @@ void Entity::Initialize() {
|
|||||||
if (scriptComponentID > 0 || m_Character) {
|
if (scriptComponentID > 0 || m_Character) {
|
||||||
std::string clientScriptName;
|
std::string clientScriptName;
|
||||||
if (!m_Character) {
|
if (!m_Character) {
|
||||||
auto scriptCompData = scriptCompTable->GetByID(scriptComponentID);
|
CDScriptComponent scriptCompData = scriptCompTable->GetByID(scriptComponentID);
|
||||||
if (scriptCompData) {
|
scriptName = scriptCompData.script_name;
|
||||||
scriptName = scriptCompData->script_name;
|
clientScriptName = scriptCompData.client_script_name;
|
||||||
clientScriptName = scriptCompData->client_script_name;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
scriptName = "";
|
scriptName = "";
|
||||||
}
|
}
|
||||||
@@ -506,19 +504,18 @@ void Entity::Initialize() {
|
|||||||
|
|
||||||
// ZoneControl script
|
// ZoneControl script
|
||||||
if (m_TemplateID == 2365) {
|
if (m_TemplateID == 2365) {
|
||||||
auto* zoneTable = CDClientManager::Instance().GetTable<CDZoneTableTable>();
|
CDZoneTableTable* zoneTable = CDClientManager::Instance().GetTable<CDZoneTableTable>();
|
||||||
const auto zoneID = Game::zoneManager->GetZoneID();
|
const auto zoneID = dZoneManager::Instance()->GetZoneID();
|
||||||
auto zoneData = zoneTable->Query(zoneID.GetMapID());
|
const CDZoneTable* zoneData = zoneTable->Query(zoneID.GetMapID());
|
||||||
|
|
||||||
if (zoneData) {
|
if (zoneData != nullptr) {
|
||||||
int zoneScriptID = zoneData->scriptID;
|
int zoneScriptID = zoneData->scriptID;
|
||||||
auto zoneScriptData = scriptCompTable->GetByID(zoneScriptID);
|
CDScriptComponent zoneScriptData = scriptCompTable->GetByID(zoneScriptID);
|
||||||
if (zoneScriptData) {
|
|
||||||
ScriptComponent* comp = new ScriptComponent(this, zoneScriptData->script_name, true);
|
ScriptComponent* comp = new ScriptComponent(this, zoneScriptData.script_name, true);
|
||||||
m_Components.insert(std::make_pair(eReplicaComponentType::SCRIPT, comp));
|
m_Components.insert(std::make_pair(eReplicaComponentType::SCRIPT, comp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SKILL, -1) != -1 || m_Character) {
|
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SKILL, -1) != -1 || m_Character) {
|
||||||
SkillComponent* comp = new SkillComponent(this);
|
SkillComponent* comp = new SkillComponent(this);
|
||||||
@@ -536,17 +533,17 @@ void Entity::Initialize() {
|
|||||||
m_Components.insert(std::make_pair(eReplicaComponentType::QUICK_BUILD, comp));
|
m_Components.insert(std::make_pair(eReplicaComponentType::QUICK_BUILD, comp));
|
||||||
|
|
||||||
CDRebuildComponentTable* rebCompTable = CDClientManager::Instance().GetTable<CDRebuildComponentTable>();
|
CDRebuildComponentTable* rebCompTable = CDClientManager::Instance().GetTable<CDRebuildComponentTable>();
|
||||||
auto rebCompData = rebCompTable->Get(rebuildComponentID);
|
std::vector<CDRebuildComponent> rebCompData = rebCompTable->Query([=](CDRebuildComponent entry) { return (entry.id == rebuildComponentID); });
|
||||||
|
|
||||||
if (rebCompData) {
|
if (rebCompData.size() > 0) {
|
||||||
comp->SetResetTime(rebCompData->reset_time);
|
comp->SetResetTime(rebCompData[0].reset_time);
|
||||||
comp->SetCompleteTime(rebCompData->complete_time);
|
comp->SetCompleteTime(rebCompData[0].complete_time);
|
||||||
comp->SetTakeImagination(rebCompData->take_imagination);
|
comp->SetTakeImagination(rebCompData[0].take_imagination);
|
||||||
comp->SetInterruptible(rebCompData->interruptible);
|
comp->SetInterruptible(rebCompData[0].interruptible);
|
||||||
comp->SetSelfActivator(rebCompData->self_activator);
|
comp->SetSelfActivator(rebCompData[0].self_activator);
|
||||||
comp->SetActivityId(rebCompData->activityID);
|
comp->SetActivityId(rebCompData[0].activityID);
|
||||||
comp->SetPostImaginationCost(rebCompData->post_imagination_cost);
|
comp->SetPostImaginationCost(rebCompData[0].post_imagination_cost);
|
||||||
comp->SetTimeBeforeSmash(rebCompData->time_before_smash);
|
comp->SetTimeBeforeSmash(rebCompData[0].time_before_smash);
|
||||||
|
|
||||||
const auto rebuildResetTime = GetVar<float>(u"rebuild_reset_time");
|
const auto rebuildResetTime = GetVar<float>(u"rebuild_reset_time");
|
||||||
|
|
||||||
@@ -694,7 +691,7 @@ void Entity::Initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string pathName = GetVarAsString(u"attached_path");
|
std::string pathName = GetVarAsString(u"attached_path");
|
||||||
const Path* path = Game::zoneManager->GetZone()->GetPath(pathName);
|
const Path* path = dZoneManager::Instance()->GetZone()->GetPath(pathName);
|
||||||
|
|
||||||
//Check to see if we have an attached path and add the appropiate component to handle it:
|
//Check to see if we have an attached path and add the appropiate component to handle it:
|
||||||
if (path){
|
if (path){
|
||||||
@@ -738,7 +735,7 @@ void Entity::Initialize() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!m_Character && Game::entityManager->GetGhostingEnabled()) {
|
if (!m_Character && EntityManager::Instance()->GetGhostingEnabled()) {
|
||||||
// Don't ghost what is likely large scene elements
|
// Don't ghost what is likely large scene elements
|
||||||
if (HasComponent(eReplicaComponentType::SIMPLE_PHYSICS) && HasComponent(eReplicaComponentType::RENDER) && (m_Components.size() == 2 || (HasComponent(eReplicaComponentType::TRIGGER) && m_Components.size() == 3))) {
|
if (HasComponent(eReplicaComponentType::SIMPLE_PHYSICS) && HasComponent(eReplicaComponentType::RENDER) && (m_Components.size() == 2 || (HasComponent(eReplicaComponentType::TRIGGER) && m_Components.size() == 3))) {
|
||||||
goto no_ghosting;
|
goto no_ghosting;
|
||||||
@@ -1287,12 +1284,12 @@ void Entity::Update(const float deltaTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_ShouldDestroyAfterUpdate) {
|
if (m_ShouldDestroyAfterUpdate) {
|
||||||
Game::entityManager->DestroyEntity(this->GetObjectID());
|
EntityManager::Instance()->DestroyEntity(this->GetObjectID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnCollisionProximity(LWOOBJID otherEntity, const std::string& proxName, const std::string& status) {
|
void Entity::OnCollisionProximity(LWOOBJID otherEntity, const std::string& proxName, const std::string& status) {
|
||||||
Entity* other = Game::entityManager->GetEntity(otherEntity);
|
Entity* other = EntityManager::Instance()->GetEntity(otherEntity);
|
||||||
if (!other) return;
|
if (!other) return;
|
||||||
|
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
||||||
@@ -1306,7 +1303,7 @@ void Entity::OnCollisionProximity(LWOOBJID otherEntity, const std::string& proxN
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnCollisionPhantom(const LWOOBJID otherEntity) {
|
void Entity::OnCollisionPhantom(const LWOOBJID otherEntity) {
|
||||||
auto* other = Game::entityManager->GetEntity(otherEntity);
|
auto* other = EntityManager::Instance()->GetEntity(otherEntity);
|
||||||
if (!other) return;
|
if (!other) return;
|
||||||
|
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
||||||
@@ -1353,7 +1350,7 @@ void Entity::OnCollisionPhantom(const LWOOBJID otherEntity) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnCollisionLeavePhantom(const LWOOBJID otherEntity) {
|
void Entity::OnCollisionLeavePhantom(const LWOOBJID otherEntity) {
|
||||||
auto* other = Game::entityManager->GetEntity(otherEntity);
|
auto* other = EntityManager::Instance()->GetEntity(otherEntity);
|
||||||
if (!other) return;
|
if (!other) return;
|
||||||
|
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
||||||
@@ -1507,13 +1504,13 @@ void Entity::Smash(const LWOOBJID source, const eKillType killType, const std::u
|
|||||||
|
|
||||||
auto* destroyableComponent = GetComponent<DestroyableComponent>();
|
auto* destroyableComponent = GetComponent<DestroyableComponent>();
|
||||||
if (destroyableComponent == nullptr) {
|
if (destroyableComponent == nullptr) {
|
||||||
Kill(Game::entityManager->GetEntity(source));
|
Kill(EntityManager::Instance()->GetEntity(source));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto* possessorComponent = GetComponent<PossessorComponent>();
|
auto* possessorComponent = GetComponent<PossessorComponent>();
|
||||||
if (possessorComponent) {
|
if (possessorComponent) {
|
||||||
if (possessorComponent->GetPossessable() != LWOOBJID_EMPTY) {
|
if (possessorComponent->GetPossessable() != LWOOBJID_EMPTY) {
|
||||||
auto* mount = Game::entityManager->GetEntity(possessorComponent->GetPossessable());
|
auto* mount = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
|
||||||
if (mount) possessorComponent->Dismount(mount, true);
|
if (mount) possessorComponent->Dismount(mount, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1541,20 +1538,20 @@ void Entity::Kill(Entity* murderer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!IsPlayer()) {
|
if (!IsPlayer()) {
|
||||||
Game::entityManager->DestroyEntity(this);
|
EntityManager::Instance()->DestroyEntity(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& grpNameQBShowBricks = GetVar<std::string>(u"grpNameQBShowBricks");
|
const auto& grpNameQBShowBricks = GetVar<std::string>(u"grpNameQBShowBricks");
|
||||||
|
|
||||||
if (!grpNameQBShowBricks.empty()) {
|
if (!grpNameQBShowBricks.empty()) {
|
||||||
auto spawners = Game::zoneManager->GetSpawnersByName(grpNameQBShowBricks);
|
auto spawners = dZoneManager::Instance()->GetSpawnersByName(grpNameQBShowBricks);
|
||||||
|
|
||||||
Spawner* spawner = nullptr;
|
Spawner* spawner = nullptr;
|
||||||
|
|
||||||
if (!spawners.empty()) {
|
if (!spawners.empty()) {
|
||||||
spawner = spawners[0];
|
spawner = spawners[0];
|
||||||
} else {
|
} else {
|
||||||
spawners = Game::zoneManager->GetSpawnersInGroup(grpNameQBShowBricks);
|
spawners = dZoneManager::Instance()->GetSpawnersInGroup(grpNameQBShowBricks);
|
||||||
|
|
||||||
if (!spawners.empty()) {
|
if (!spawners.empty()) {
|
||||||
spawner = spawners[0];
|
spawner = spawners[0];
|
||||||
@@ -1631,9 +1628,9 @@ void Entity::PickupItem(const LWOOBJID& objectID) {
|
|||||||
std::vector<CDObjectSkills> skills = skillsTable->Query([=](CDObjectSkills entry) {return (entry.objectTemplate == p.second.lot); });
|
std::vector<CDObjectSkills> skills = skillsTable->Query([=](CDObjectSkills entry) {return (entry.objectTemplate == p.second.lot); });
|
||||||
for (CDObjectSkills skill : skills) {
|
for (CDObjectSkills skill : skills) {
|
||||||
CDSkillBehaviorTable* skillBehTable = CDClientManager::Instance().GetTable<CDSkillBehaviorTable>();
|
CDSkillBehaviorTable* skillBehTable = CDClientManager::Instance().GetTable<CDSkillBehaviorTable>();
|
||||||
auto behaviorData = skillBehTable->GetSkillByID(skill.skillID);
|
CDSkillBehavior behaviorData = skillBehTable->GetSkillByID(skill.skillID);
|
||||||
if (!behaviorData) continue;
|
|
||||||
SkillComponent::HandleUnmanaged(behaviorData->behaviorID, GetObjectID());
|
SkillComponent::HandleUnmanaged(behaviorData.behaviorID, GetObjectID());
|
||||||
|
|
||||||
auto* missionComponent = GetComponent<MissionComponent>();
|
auto* missionComponent = GetComponent<MissionComponent>();
|
||||||
|
|
||||||
@@ -1722,7 +1719,7 @@ void Entity::CancelCallbackTimers() {
|
|||||||
|
|
||||||
void Entity::ScheduleKillAfterUpdate(Entity* murderer) {
|
void Entity::ScheduleKillAfterUpdate(Entity* murderer) {
|
||||||
//if (m_Info.spawner) m_Info.spawner->ScheduleKill(this);
|
//if (m_Info.spawner) m_Info.spawner->ScheduleKill(this);
|
||||||
Game::entityManager->ScheduleForKill(this);
|
EntityManager::Instance()->ScheduleForKill(this);
|
||||||
|
|
||||||
if (murderer) m_ScheduleKiller = murderer;
|
if (murderer) m_ScheduleKiller = murderer;
|
||||||
}
|
}
|
||||||
@@ -1766,7 +1763,7 @@ void Entity::TriggerEvent(eTriggerEventType event, Entity* optionalTarget) {
|
|||||||
|
|
||||||
Entity* Entity::GetOwner() const {
|
Entity* Entity::GetOwner() const {
|
||||||
if (m_OwnerOverride != LWOOBJID_EMPTY) {
|
if (m_OwnerOverride != LWOOBJID_EMPTY) {
|
||||||
auto* other = Game::entityManager->GetEntity(m_OwnerOverride);
|
auto* other = EntityManager::Instance()->GetEntity(m_OwnerOverride);
|
||||||
|
|
||||||
if (other != nullptr) {
|
if (other != nullptr) {
|
||||||
return other->GetOwner();
|
return other->GetOwner();
|
||||||
@@ -1910,7 +1907,7 @@ void Entity::SetPosition(NiPoint3 position) {
|
|||||||
vehicel->SetPosition(position);
|
vehicel->SetPosition(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::entityManager->SerializeEntity(this);
|
EntityManager::Instance()->SerializeEntity(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::SetRotation(NiQuaternion rotation) {
|
void Entity::SetRotation(NiQuaternion rotation) {
|
||||||
@@ -1938,7 +1935,7 @@ void Entity::SetRotation(NiQuaternion rotation) {
|
|||||||
vehicel->SetRotation(rotation);
|
vehicel->SetRotation(rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::entityManager->SerializeEntity(this);
|
EntityManager::Instance()->SerializeEntity(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entity::GetBoolean(const std::u16string& name) const {
|
bool Entity::GetBoolean(const std::u16string& name) const {
|
||||||
@@ -1990,7 +1987,7 @@ std::vector<LWOOBJID>& Entity::GetTargetsInPhantom() {
|
|||||||
for (auto i = 0u; i < m_TargetsInPhantom.size(); ++i) {
|
for (auto i = 0u; i < m_TargetsInPhantom.size(); ++i) {
|
||||||
const auto id = m_TargetsInPhantom.at(i);
|
const auto id = m_TargetsInPhantom.at(i);
|
||||||
|
|
||||||
auto* entity = Game::entityManager->GetEntity(id);
|
auto* entity = EntityManager::Instance()->GetEntity(id);
|
||||||
|
|
||||||
if (entity == nullptr) {
|
if (entity == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
#include "eReplicaComponentType.h"
|
#include "eReplicaComponentType.h"
|
||||||
#include "eReplicaPacketType.h"
|
#include "eReplicaPacketType.h"
|
||||||
|
|
||||||
|
EntityManager* EntityManager::m_Address = nullptr;
|
||||||
|
|
||||||
// Configure which zones have ghosting disabled, mostly small worlds.
|
// Configure which zones have ghosting disabled, mostly small worlds.
|
||||||
std::vector<LWOMAPID> EntityManager::m_GhostingExcludedZones = {
|
std::vector<LWOMAPID> EntityManager::m_GhostingExcludedZones = {
|
||||||
// Small zones
|
// Small zones
|
||||||
@@ -60,7 +62,7 @@ void EntityManager::Initialize() {
|
|||||||
m_GhostingEnabled = std::find(
|
m_GhostingEnabled = std::find(
|
||||||
m_GhostingExcludedZones.begin(),
|
m_GhostingExcludedZones.begin(),
|
||||||
m_GhostingExcludedZones.end(),
|
m_GhostingExcludedZones.end(),
|
||||||
Game::zoneManager->GetZoneID().GetMapID()
|
dZoneManager::Instance()->GetZoneID().GetMapID()
|
||||||
) == m_GhostingExcludedZones.end();
|
) == m_GhostingExcludedZones.end();
|
||||||
|
|
||||||
// grab hardcore mode settings and load them with sane defaults
|
// grab hardcore mode settings and load them with sane defaults
|
||||||
@@ -75,7 +77,10 @@ void EntityManager::Initialize() {
|
|||||||
|
|
||||||
// If cloneID is not zero, then hardcore mode is disabled
|
// If cloneID is not zero, then hardcore mode is disabled
|
||||||
// aka minigames and props
|
// aka minigames and props
|
||||||
if (Game::zoneManager->GetZoneID().GetCloneID() != 0) m_HardcoreMode = false;
|
if (dZoneManager::Instance()->GetZoneID().GetCloneID() != 0) m_HardcoreMode = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityManager::~EntityManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity* EntityManager::CreateEntity(EntityInfo info, User* user, Entity* parentEntity, const bool controller, const LWOOBJID explicitId) {
|
Entity* EntityManager::CreateEntity(EntityInfo info, User* user, Entity* parentEntity, const bool controller, const LWOOBJID explicitId) {
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
#ifndef ENTITYMANAGER_H
|
#ifndef ENTITYMANAGER_H
|
||||||
#define ENTITYMANAGER_H
|
#define ENTITYMANAGER_H
|
||||||
|
|
||||||
|
#include "dCommonVars.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "dCommonVars.h"
|
|
||||||
|
|
||||||
class Entity;
|
class Entity;
|
||||||
class EntityInfo;
|
class EntityInfo;
|
||||||
class Player;
|
class Player;
|
||||||
@@ -18,8 +17,19 @@ struct SystemAddress;
|
|||||||
|
|
||||||
class EntityManager {
|
class EntityManager {
|
||||||
public:
|
public:
|
||||||
|
static EntityManager* Instance() {
|
||||||
|
if (!m_Address) {
|
||||||
|
m_Address = new EntityManager();
|
||||||
|
m_Address->Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_Address;
|
||||||
|
}
|
||||||
|
|
||||||
void Initialize();
|
void Initialize();
|
||||||
|
|
||||||
|
~EntityManager();
|
||||||
|
|
||||||
void UpdateEntities(float deltaTime);
|
void UpdateEntities(float deltaTime);
|
||||||
Entity* CreateEntity(EntityInfo info, User* user = nullptr, Entity* parentEntity = nullptr, bool controller = false, LWOOBJID explicitId = LWOOBJID_EMPTY);
|
Entity* CreateEntity(EntityInfo info, User* user = nullptr, Entity* parentEntity = nullptr, bool controller = false, LWOOBJID explicitId = LWOOBJID_EMPTY);
|
||||||
void DestroyEntity(const LWOOBJID& objectID);
|
void DestroyEntity(const LWOOBJID& objectID);
|
||||||
@@ -79,6 +89,7 @@ private:
|
|||||||
void KillEntities();
|
void KillEntities();
|
||||||
void DeleteEntities();
|
void DeleteEntities();
|
||||||
|
|
||||||
|
static EntityManager* m_Address; //For singleton method
|
||||||
static std::vector<LWOMAPID> m_GhostingExcludedZones;
|
static std::vector<LWOMAPID> m_GhostingExcludedZones;
|
||||||
static std::vector<LOT> m_GhostingExcludedLOTs;
|
static std::vector<LOT> m_GhostingExcludedLOTs;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
#include "LeaderboardManager.h"
|
#include "LeaderboardManager.h"
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "Database.h"
|
#include "Database.h"
|
||||||
#include "EntityManager.h"
|
#include "EntityManager.h"
|
||||||
#include "Character.h"
|
#include "Character.h"
|
||||||
@@ -13,400 +10,461 @@
|
|||||||
#include "CDClientManager.h"
|
#include "CDClientManager.h"
|
||||||
#include "GeneralUtils.h"
|
#include "GeneralUtils.h"
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
#include "LDFFormat.h"
|
|
||||||
#include "DluAssert.h"
|
|
||||||
|
|
||||||
#include "CDActivitiesTable.h"
|
#include "CDActivitiesTable.h"
|
||||||
#include "Metrics.hpp"
|
|
||||||
|
|
||||||
namespace LeaderboardManager {
|
Leaderboard::Leaderboard(uint32_t gameID, uint32_t infoType, bool weekly, std::vector<LeaderboardEntry> entries,
|
||||||
std::map<GameID, Leaderboard::Type> leaderboardCache;
|
LWOOBJID relatedPlayer, LeaderboardType leaderboardType) {
|
||||||
}
|
this->relatedPlayer = relatedPlayer;
|
||||||
|
|
||||||
Leaderboard::Leaderboard(const GameID gameID, const Leaderboard::InfoType infoType, const bool weekly, LWOOBJID relatedPlayer, const Leaderboard::Type leaderboardType) {
|
|
||||||
this->gameID = gameID;
|
this->gameID = gameID;
|
||||||
this->weekly = weekly;
|
this->weekly = weekly;
|
||||||
this->infoType = infoType;
|
this->infoType = infoType;
|
||||||
|
this->entries = std::move(entries);
|
||||||
this->leaderboardType = leaderboardType;
|
this->leaderboardType = leaderboardType;
|
||||||
this->relatedPlayer = relatedPlayer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Leaderboard::~Leaderboard() {
|
std::u16string Leaderboard::ToString() const {
|
||||||
Clear();
|
std::string leaderboard;
|
||||||
|
|
||||||
|
leaderboard += "ADO.Result=7:1\n";
|
||||||
|
leaderboard += "Result.Count=1:1\n";
|
||||||
|
leaderboard += "Result[0].Index=0:RowNumber\n";
|
||||||
|
leaderboard += "Result[0].RowCount=1:" + std::to_string(entries.size()) + "\n";
|
||||||
|
|
||||||
|
auto index = 0;
|
||||||
|
for (const auto& entry : entries) {
|
||||||
|
leaderboard += "Result[0].Row[" + std::to_string(index) + "].LastPlayed=8:" + std::to_string(entry.lastPlayed) + "\n";
|
||||||
|
leaderboard += "Result[0].Row[" + std::to_string(index) + "].CharacterID=8:" + std::to_string(entry.playerID) + "\n";
|
||||||
|
leaderboard += "Result[0].Row[" + std::to_string(index) + "].NumPlayed=1:1\n";
|
||||||
|
leaderboard += "Result[0].Row[" + std::to_string(index) + "].RowNumber=8:" + std::to_string(entry.placement) + "\n";
|
||||||
|
leaderboard += "Result[0].Row[" + std::to_string(index) + "].Time=1:" + std::to_string(entry.time) + "\n";
|
||||||
|
|
||||||
|
// Only these minigames have a points system
|
||||||
|
if (leaderboardType == Survival || leaderboardType == ShootingGallery) {
|
||||||
|
leaderboard += "Result[0].Row[" + std::to_string(index) + "].Points=1:" + std::to_string(entry.score) + "\n";
|
||||||
|
} else if (leaderboardType == SurvivalNS) {
|
||||||
|
leaderboard += "Result[0].Row[" + std::to_string(index) + "].Wave=1:" + std::to_string(entry.score) + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Leaderboard::Clear() {
|
leaderboard += "Result[0].Row[" + std::to_string(index) + "].name=0:" + entry.playerName + "\n";
|
||||||
for (auto& entry : entries) for (auto ldfData : entry) delete ldfData;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void WriteLeaderboardRow(std::ostringstream& leaderboard, const uint32_t& index, LDFBaseData* data) {
|
return GeneralUtils::UTF8ToUTF16(leaderboard);
|
||||||
leaderboard << "\nResult[0].Row[" << index << "]." << data->GetString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Leaderboard::Serialize(RakNet::BitStream* bitStream) const {
|
std::vector<LeaderboardEntry> Leaderboard::GetEntries() {
|
||||||
bitStream->Write(gameID);
|
return entries;
|
||||||
bitStream->Write(infoType);
|
|
||||||
|
|
||||||
std::ostringstream leaderboard;
|
|
||||||
|
|
||||||
leaderboard << "ADO.Result=7:1"; // Unused in 1.10.64, but is in captures
|
|
||||||
leaderboard << "\nResult.Count=1:1"; // number of results, always 1
|
|
||||||
if (!this->entries.empty()) leaderboard << "\nResult[0].Index=0:RowNumber"; // "Primary key". Live doesn't include this if there are no entries.
|
|
||||||
leaderboard << "\nResult[0].RowCount=1:" << entries.size();
|
|
||||||
|
|
||||||
int32_t rowNumber = 0;
|
|
||||||
for (auto& entry : entries) {
|
|
||||||
for (auto* data : entry) {
|
|
||||||
WriteLeaderboardRow(leaderboard, rowNumber, data);
|
|
||||||
}
|
|
||||||
rowNumber++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serialize the thing to a BitStream
|
uint32_t Leaderboard::GetGameID() const {
|
||||||
uint32_t leaderboardSize = leaderboard.tellp();
|
return gameID;
|
||||||
bitStream->Write<uint32_t>(leaderboardSize);
|
|
||||||
// Doing this all in 1 call so there is no possbility of a dangling pointer.
|
|
||||||
bitStream->WriteAlignedBytes(reinterpret_cast<const unsigned char*>(GeneralUtils::ASCIIToUTF16(leaderboard.str()).c_str()), leaderboardSize * sizeof(char16_t));
|
|
||||||
if (leaderboardSize > 0) bitStream->Write<uint16_t>(0);
|
|
||||||
bitStream->Write0();
|
|
||||||
bitStream->Write0();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Leaderboard::QueryToLdf(std::unique_ptr<sql::ResultSet>& rows) {
|
uint32_t Leaderboard::GetInfoType() const {
|
||||||
Clear();
|
return infoType;
|
||||||
if (rows->rowsCount() == 0) return;
|
|
||||||
|
|
||||||
this->entries.reserve(rows->rowsCount());
|
|
||||||
while (rows->next()) {
|
|
||||||
constexpr int32_t MAX_NUM_DATA_PER_ROW = 9;
|
|
||||||
this->entries.push_back(std::vector<LDFBaseData*>());
|
|
||||||
auto& entry = this->entries.back();
|
|
||||||
entry.reserve(MAX_NUM_DATA_PER_ROW);
|
|
||||||
entry.push_back(new LDFData<uint64_t>(u"CharacterID", rows->getInt("character_id")));
|
|
||||||
entry.push_back(new LDFData<uint64_t>(u"LastPlayed", rows->getUInt64("lastPlayed")));
|
|
||||||
entry.push_back(new LDFData<int32_t>(u"NumPlayed", rows->getInt("timesPlayed")));
|
|
||||||
entry.push_back(new LDFData<std::u16string>(u"name", GeneralUtils::ASCIIToUTF16(rows->getString("name").c_str())));
|
|
||||||
entry.push_back(new LDFData<uint64_t>(u"RowNumber", rows->getInt("ranking")));
|
|
||||||
switch (leaderboardType) {
|
|
||||||
case Type::ShootingGallery:
|
|
||||||
entry.push_back(new LDFData<int32_t>(u"Score", rows->getInt("primaryScore")));
|
|
||||||
// Score:1
|
|
||||||
entry.push_back(new LDFData<int32_t>(u"Streak", rows->getInt("secondaryScore")));
|
|
||||||
// Streak:1
|
|
||||||
entry.push_back(new LDFData<float>(u"HitPercentage", (rows->getInt("tertiaryScore") / 100.0f)));
|
|
||||||
// HitPercentage:3 between 0 and 1
|
|
||||||
break;
|
|
||||||
case Type::Racing:
|
|
||||||
entry.push_back(new LDFData<float>(u"BestTime", rows->getDouble("primaryScore")));
|
|
||||||
// BestLapTime:3
|
|
||||||
entry.push_back(new LDFData<float>(u"BestLapTime", rows->getDouble("secondaryScore")));
|
|
||||||
// BestTime:3
|
|
||||||
entry.push_back(new LDFData<int32_t>(u"License", 1));
|
|
||||||
// License:1 - 1 if player has completed mission 637 and 0 otherwise
|
|
||||||
entry.push_back(new LDFData<int32_t>(u"NumWins", rows->getInt("numWins")));
|
|
||||||
// NumWins:1
|
|
||||||
break;
|
|
||||||
case Type::UnusedLeaderboard4:
|
|
||||||
entry.push_back(new LDFData<int32_t>(u"Points", rows->getInt("primaryScore")));
|
|
||||||
// Points:1
|
|
||||||
break;
|
|
||||||
case Type::MonumentRace:
|
|
||||||
entry.push_back(new LDFData<int32_t>(u"Time", rows->getInt("primaryScore")));
|
|
||||||
// Time:1(?)
|
|
||||||
break;
|
|
||||||
case Type::FootRace:
|
|
||||||
entry.push_back(new LDFData<int32_t>(u"Time", rows->getInt("primaryScore")));
|
|
||||||
// Time:1
|
|
||||||
break;
|
|
||||||
case Type::Survival:
|
|
||||||
entry.push_back(new LDFData<int32_t>(u"Points", rows->getInt("primaryScore")));
|
|
||||||
// Points:1
|
|
||||||
entry.push_back(new LDFData<int32_t>(u"Time", rows->getInt("secondaryScore")));
|
|
||||||
// Time:1
|
|
||||||
break;
|
|
||||||
case Type::SurvivalNS:
|
|
||||||
entry.push_back(new LDFData<int32_t>(u"Wave", rows->getInt("primaryScore")));
|
|
||||||
// Wave:1
|
|
||||||
entry.push_back(new LDFData<int32_t>(u"Time", rows->getInt("secondaryScore")));
|
|
||||||
// Time:1
|
|
||||||
break;
|
|
||||||
case Type::Donations:
|
|
||||||
entry.push_back(new LDFData<int32_t>(u"Points", rows->getInt("primaryScore")));
|
|
||||||
// Score:1
|
|
||||||
break;
|
|
||||||
case Type::None:
|
|
||||||
// This type is included here simply to resolve a compiler warning on mac about unused enum types
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string_view Leaderboard::GetOrdering(Leaderboard::Type leaderboardType) {
|
void Leaderboard::Send(LWOOBJID targetID) const {
|
||||||
// Use a switch case and return desc for all 3 columns if higher is better and asc if lower is better
|
auto* player = EntityManager::Instance()->GetEntity(relatedPlayer);
|
||||||
switch (leaderboardType) {
|
|
||||||
case Type::Racing:
|
|
||||||
case Type::MonumentRace:
|
|
||||||
return "primaryScore ASC, secondaryScore ASC, tertiaryScore ASC";
|
|
||||||
case Type::Survival:
|
|
||||||
return Game::config->GetValue("classic_survival_scoring") == "1" ?
|
|
||||||
"secondaryScore DESC, primaryScore DESC, tertiaryScore DESC" :
|
|
||||||
"primaryScore DESC, secondaryScore DESC, tertiaryScore DESC";
|
|
||||||
case Type::SurvivalNS:
|
|
||||||
return "primaryScore DESC, secondaryScore ASC, tertiaryScore DESC";
|
|
||||||
case Type::ShootingGallery:
|
|
||||||
case Type::FootRace:
|
|
||||||
case Type::UnusedLeaderboard4:
|
|
||||||
case Type::Donations:
|
|
||||||
case Type::None:
|
|
||||||
default:
|
|
||||||
return "primaryScore DESC, secondaryScore DESC, tertiaryScore DESC";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Leaderboard::SetupLeaderboard(bool weekly, uint32_t resultStart, uint32_t resultEnd) {
|
|
||||||
resultStart++;
|
|
||||||
resultEnd++;
|
|
||||||
// We need everything except 1 column so i'm selecting * from leaderboard
|
|
||||||
const std::string queryBase =
|
|
||||||
R"QUERY(
|
|
||||||
WITH leaderboardsRanked AS (
|
|
||||||
SELECT leaderboard.*, charinfo.name,
|
|
||||||
RANK() OVER
|
|
||||||
(
|
|
||||||
ORDER BY %s, UNIX_TIMESTAMP(last_played) ASC, id DESC
|
|
||||||
) AS ranking
|
|
||||||
FROM leaderboard JOIN charinfo on charinfo.id = leaderboard.character_id
|
|
||||||
WHERE game_id = ? %s
|
|
||||||
),
|
|
||||||
myStanding AS (
|
|
||||||
SELECT
|
|
||||||
ranking as myRank
|
|
||||||
FROM leaderboardsRanked
|
|
||||||
WHERE id = ?
|
|
||||||
),
|
|
||||||
lowestRanking AS (
|
|
||||||
SELECT MAX(ranking) AS lowestRank
|
|
||||||
FROM leaderboardsRanked
|
|
||||||
)
|
|
||||||
SELECT leaderboardsRanked.*, character_id, UNIX_TIMESTAMP(last_played) as lastPlayed, leaderboardsRanked.name, leaderboardsRanked.ranking FROM leaderboardsRanked, myStanding, lowestRanking
|
|
||||||
WHERE leaderboardsRanked.ranking
|
|
||||||
BETWEEN
|
|
||||||
LEAST(GREATEST(CAST(myRank AS SIGNED) - 5, %i), lowestRanking.lowestRank - 9)
|
|
||||||
AND
|
|
||||||
LEAST(GREATEST(myRank + 5, %i), lowestRanking.lowestRank)
|
|
||||||
ORDER BY ranking ASC;
|
|
||||||
)QUERY";
|
|
||||||
|
|
||||||
std::string friendsFilter =
|
|
||||||
R"QUERY(
|
|
||||||
AND (
|
|
||||||
character_id IN (
|
|
||||||
SELECT fr.requested_player FROM (
|
|
||||||
SELECT CASE
|
|
||||||
WHEN player_id = ? THEN friend_id
|
|
||||||
WHEN friend_id = ? THEN player_id
|
|
||||||
END AS requested_player
|
|
||||||
FROM friends
|
|
||||||
) AS fr
|
|
||||||
JOIN charinfo AS ci
|
|
||||||
ON ci.id = fr.requested_player
|
|
||||||
WHERE fr.requested_player IS NOT NULL
|
|
||||||
)
|
|
||||||
OR character_id = ?
|
|
||||||
)
|
|
||||||
)QUERY";
|
|
||||||
|
|
||||||
std::string weeklyFilter = " AND UNIX_TIMESTAMP(last_played) BETWEEN UNIX_TIMESTAMP(date_sub(now(),INTERVAL 1 WEEK)) AND UNIX_TIMESTAMP(now()) ";
|
|
||||||
|
|
||||||
std::string filter;
|
|
||||||
// Setup our filter based on the query type
|
|
||||||
if (this->infoType == InfoType::Friends) filter += friendsFilter;
|
|
||||||
if (this->weekly) filter += weeklyFilter;
|
|
||||||
const auto orderBase = GetOrdering(this->leaderboardType);
|
|
||||||
|
|
||||||
// For top query, we want to just rank all scores, but for all others we need the scores around a specific player
|
|
||||||
std::string baseLookup;
|
|
||||||
if (this->infoType == InfoType::Top) {
|
|
||||||
baseLookup = "SELECT id, last_played FROM leaderboard WHERE game_id = ? " + (this->weekly ? weeklyFilter : std::string("")) + " ORDER BY ";
|
|
||||||
baseLookup += orderBase.data();
|
|
||||||
} else {
|
|
||||||
baseLookup = "SELECT id, last_played FROM leaderboard WHERE game_id = ? " + (this->weekly ? weeklyFilter : std::string("")) + " AND character_id = ";
|
|
||||||
baseLookup += std::to_string(static_cast<uint32_t>(this->relatedPlayer));
|
|
||||||
}
|
|
||||||
baseLookup += " LIMIT 1";
|
|
||||||
Game::logger->LogDebug("LeaderboardManager", "query is %s", baseLookup.c_str());
|
|
||||||
std::unique_ptr<sql::PreparedStatement> baseQuery(Database::CreatePreppedStmt(baseLookup));
|
|
||||||
baseQuery->setInt(1, this->gameID);
|
|
||||||
std::unique_ptr<sql::ResultSet> baseResult(baseQuery->executeQuery());
|
|
||||||
|
|
||||||
if (!baseResult->next()) return; // In this case, there are no entries in the leaderboard for this game.
|
|
||||||
|
|
||||||
uint32_t relatedPlayerLeaderboardId = baseResult->getInt("id");
|
|
||||||
|
|
||||||
// Create and execute the actual save here. Using a heap allocated buffer to avoid stack overflow
|
|
||||||
constexpr uint16_t STRING_LENGTH = 4096;
|
|
||||||
std::unique_ptr<char[]> lookupBuffer = std::make_unique<char[]>(STRING_LENGTH);
|
|
||||||
int32_t res = snprintf(lookupBuffer.get(), STRING_LENGTH, queryBase.c_str(), orderBase.data(), filter.c_str(), resultStart, resultEnd);
|
|
||||||
DluAssert(res != -1);
|
|
||||||
std::unique_ptr<sql::PreparedStatement> query(Database::CreatePreppedStmt(lookupBuffer.get()));
|
|
||||||
Game::logger->LogDebug("LeaderboardManager", "Query is %s vars are %i %i %i", lookupBuffer.get(), this->gameID, this->relatedPlayer, relatedPlayerLeaderboardId);
|
|
||||||
query->setInt(1, this->gameID);
|
|
||||||
if (this->infoType == InfoType::Friends) {
|
|
||||||
query->setInt(2, this->relatedPlayer);
|
|
||||||
query->setInt(3, this->relatedPlayer);
|
|
||||||
query->setInt(4, this->relatedPlayer);
|
|
||||||
query->setInt(5, relatedPlayerLeaderboardId);
|
|
||||||
} else {
|
|
||||||
query->setInt(2, relatedPlayerLeaderboardId);
|
|
||||||
}
|
|
||||||
std::unique_ptr<sql::ResultSet> result(query->executeQuery());
|
|
||||||
QueryToLdf(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Leaderboard::Send(const LWOOBJID targetID) const {
|
|
||||||
auto* player = Game::entityManager->GetEntity(relatedPlayer);
|
|
||||||
if (player != nullptr) {
|
if (player != nullptr) {
|
||||||
GameMessages::SendActivitySummaryLeaderboardData(targetID, this, player->GetSystemAddress());
|
GameMessages::SendActivitySummaryLeaderboardData(targetID, this, player->GetSystemAddress());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FormatInsert(const Leaderboard::Type& type, const Score& score, const bool useUpdate) {
|
void LeaderboardManager::SaveScore(LWOOBJID playerID, uint32_t gameID, uint32_t score, uint32_t time) {
|
||||||
std::string insertStatement;
|
const auto* player = EntityManager::Instance()->GetEntity(playerID);
|
||||||
if (useUpdate) {
|
if (player == nullptr)
|
||||||
insertStatement =
|
return;
|
||||||
R"QUERY(
|
|
||||||
UPDATE leaderboard
|
|
||||||
SET primaryScore = %f, secondaryScore = %f, tertiaryScore = %f,
|
|
||||||
timesPlayed = timesPlayed + 1 WHERE character_id = ? AND game_id = ?;
|
|
||||||
)QUERY";
|
|
||||||
} else {
|
|
||||||
insertStatement =
|
|
||||||
R"QUERY(
|
|
||||||
INSERT leaderboard SET
|
|
||||||
primaryScore = %f, secondaryScore = %f, tertiaryScore = %f,
|
|
||||||
character_id = ?, game_id = ?;
|
|
||||||
)QUERY";
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr uint16_t STRING_LENGTH = 400;
|
auto* character = player->GetCharacter();
|
||||||
// Then fill in our score
|
if (character == nullptr)
|
||||||
char finishedQuery[STRING_LENGTH];
|
return;
|
||||||
int32_t res = snprintf(finishedQuery, STRING_LENGTH, insertStatement.c_str(), score.GetPrimaryScore(), score.GetSecondaryScore(), score.GetTertiaryScore());
|
|
||||||
DluAssert(res != -1);
|
|
||||||
return finishedQuery;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LeaderboardManager::SaveScore(const LWOOBJID& playerID, const GameID activityId, const float primaryScore, const float secondaryScore, const float tertiaryScore) {
|
auto* select = Database::CreatePreppedStmt("SELECT time, score FROM leaderboard WHERE character_id = ? AND game_id = ?;");
|
||||||
const Leaderboard::Type leaderboardType = GetLeaderboardType(activityId);
|
|
||||||
auto* lookup = "SELECT * FROM leaderboard WHERE character_id = ? AND game_id = ?;";
|
|
||||||
|
|
||||||
std::unique_ptr<sql::PreparedStatement> query(Database::CreatePreppedStmt(lookup));
|
select->setUInt64(1, character->GetID());
|
||||||
query->setInt(1, playerID);
|
select->setInt(2, gameID);
|
||||||
query->setInt(2, activityId);
|
|
||||||
std::unique_ptr<sql::ResultSet> myScoreResult(query->executeQuery());
|
auto any = false;
|
||||||
|
auto* result = select->executeQuery();
|
||||||
|
auto leaderboardType = GetLeaderboardType(gameID);
|
||||||
|
|
||||||
|
// Check if the new score is a high score
|
||||||
|
while (result->next()) {
|
||||||
|
any = true;
|
||||||
|
|
||||||
|
const auto storedTime = result->getInt(1);
|
||||||
|
const auto storedScore = result->getInt(2);
|
||||||
|
auto highscore = true;
|
||||||
|
bool classicSurvivalScoring = Game::config->GetValue("classic_survival_scoring") == "1";
|
||||||
|
|
||||||
std::string saveQuery("UPDATE leaderboard SET timesPlayed = timesPlayed + 1 WHERE character_id = ? AND game_id = ?;");
|
|
||||||
Score newScore(primaryScore, secondaryScore, tertiaryScore);
|
|
||||||
if (myScoreResult->next()) {
|
|
||||||
Score oldScore;
|
|
||||||
bool lowerScoreBetter = false;
|
|
||||||
switch (leaderboardType) {
|
switch (leaderboardType) {
|
||||||
// Higher score better
|
case ShootingGallery:
|
||||||
case Leaderboard::Type::ShootingGallery: {
|
if (score <= storedScore)
|
||||||
oldScore.SetPrimaryScore(myScoreResult->getInt("primaryScore"));
|
highscore = false;
|
||||||
oldScore.SetSecondaryScore(myScoreResult->getInt("secondaryScore"));
|
|
||||||
oldScore.SetTertiaryScore(myScoreResult->getInt("tertiaryScore"));
|
|
||||||
break;
|
break;
|
||||||
}
|
case Racing:
|
||||||
case Leaderboard::Type::FootRace: {
|
if (time >= storedTime)
|
||||||
oldScore.SetPrimaryScore(myScoreResult->getInt("primaryScore"));
|
highscore = false;
|
||||||
break;
|
break;
|
||||||
}
|
case MonumentRace:
|
||||||
case Leaderboard::Type::Survival: {
|
if (time >= storedTime)
|
||||||
oldScore.SetPrimaryScore(myScoreResult->getInt("primaryScore"));
|
highscore = false;
|
||||||
oldScore.SetSecondaryScore(myScoreResult->getInt("secondaryScore"));
|
|
||||||
break;
|
break;
|
||||||
}
|
case FootRace:
|
||||||
case Leaderboard::Type::SurvivalNS: {
|
if (time <= storedTime)
|
||||||
oldScore.SetPrimaryScore(myScoreResult->getInt("primaryScore"));
|
highscore = false;
|
||||||
oldScore.SetSecondaryScore(myScoreResult->getInt("secondaryScore"));
|
|
||||||
break;
|
break;
|
||||||
|
case Survival:
|
||||||
|
if (classicSurvivalScoring) {
|
||||||
|
if (time <= storedTime) { // Based on time (LU live)
|
||||||
|
highscore = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (score <= storedScore) // Based on score (DLU)
|
||||||
|
highscore = false;
|
||||||
}
|
}
|
||||||
case Leaderboard::Type::UnusedLeaderboard4:
|
|
||||||
case Leaderboard::Type::Donations: {
|
|
||||||
oldScore.SetPrimaryScore(myScoreResult->getInt("primaryScore"));
|
|
||||||
break;
|
break;
|
||||||
}
|
case SurvivalNS:
|
||||||
case Leaderboard::Type::Racing: {
|
if (!(score > storedScore || (time < storedTime && score >= storedScore)))
|
||||||
oldScore.SetPrimaryScore(myScoreResult->getInt("primaryScore"));
|
highscore = false;
|
||||||
oldScore.SetSecondaryScore(myScoreResult->getInt("secondaryScore"));
|
|
||||||
|
|
||||||
// For wins we dont care about the score, just the time, so zero out the tertiary.
|
|
||||||
// Wins are updated later.
|
|
||||||
oldScore.SetTertiaryScore(0);
|
|
||||||
newScore.SetTertiaryScore(0);
|
|
||||||
lowerScoreBetter = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case Leaderboard::Type::MonumentRace: {
|
|
||||||
oldScore.SetPrimaryScore(myScoreResult->getInt("primaryScore"));
|
|
||||||
lowerScoreBetter = true;
|
|
||||||
// Do score checking here
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Leaderboard::Type::None:
|
|
||||||
default:
|
default:
|
||||||
Game::logger->Log("LeaderboardManager", "Unknown leaderboard type %i for game %i. Cannot save score!", leaderboardType, activityId);
|
highscore = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!highscore) {
|
||||||
|
delete select;
|
||||||
|
delete result;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool newHighScore = lowerScoreBetter ? newScore < oldScore : newScore > oldScore;
|
|
||||||
// Nimbus station has a weird leaderboard where we need a custom scoring system
|
|
||||||
if (leaderboardType == Leaderboard::Type::SurvivalNS) {
|
|
||||||
newHighScore = newScore.GetPrimaryScore() > oldScore.GetPrimaryScore() ||
|
|
||||||
(newScore.GetPrimaryScore() == oldScore.GetPrimaryScore() && newScore.GetSecondaryScore() < oldScore.GetSecondaryScore());
|
|
||||||
} else if (leaderboardType == Leaderboard::Type::Survival && Game::config->GetValue("classic_survival_scoring") == "1") {
|
|
||||||
Score oldScoreFlipped(oldScore.GetSecondaryScore(), oldScore.GetPrimaryScore());
|
|
||||||
Score newScoreFlipped(newScore.GetSecondaryScore(), newScore.GetPrimaryScore());
|
|
||||||
newHighScore = newScoreFlipped > oldScoreFlipped;
|
|
||||||
}
|
|
||||||
if (newHighScore) {
|
|
||||||
saveQuery = FormatInsert(leaderboardType, newScore, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete select;
|
||||||
|
delete result;
|
||||||
|
|
||||||
|
if (any) {
|
||||||
|
auto* statement = Database::CreatePreppedStmt("UPDATE leaderboard SET time = ?, score = ?, last_played=SYSDATE() WHERE character_id = ? AND game_id = ?;");
|
||||||
|
statement->setInt(1, time);
|
||||||
|
statement->setInt(2, score);
|
||||||
|
statement->setUInt64(3, character->GetID());
|
||||||
|
statement->setInt(4, gameID);
|
||||||
|
statement->execute();
|
||||||
|
|
||||||
|
delete statement;
|
||||||
} else {
|
} else {
|
||||||
saveQuery = FormatInsert(leaderboardType, newScore, false);
|
// Note: last_played will be set to SYSDATE() by default when inserting into leaderboard
|
||||||
}
|
auto* statement = Database::CreatePreppedStmt("INSERT INTO leaderboard (character_id, game_id, time, score) VALUES (?, ?, ?, ?);");
|
||||||
Game::logger->Log("LeaderboardManager", "save query %s %i %i", saveQuery.c_str(), playerID, activityId);
|
statement->setUInt64(1, character->GetID());
|
||||||
std::unique_ptr<sql::PreparedStatement> saveStatement(Database::CreatePreppedStmt(saveQuery));
|
statement->setInt(2, gameID);
|
||||||
saveStatement->setInt(1, playerID);
|
statement->setInt(3, time);
|
||||||
saveStatement->setInt(2, activityId);
|
statement->setInt(4, score);
|
||||||
saveStatement->execute();
|
statement->execute();
|
||||||
|
|
||||||
// track wins separately
|
delete statement;
|
||||||
if (leaderboardType == Leaderboard::Type::Racing && tertiaryScore != 0.0f) {
|
|
||||||
std::unique_ptr<sql::PreparedStatement> winUpdate(Database::CreatePreppedStmt("UPDATE leaderboard SET numWins = numWins + 1 WHERE character_id = ? AND game_id = ?;"));
|
|
||||||
winUpdate->setInt(1, playerID);
|
|
||||||
winUpdate->setInt(2, activityId);
|
|
||||||
winUpdate->execute();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LeaderboardManager::SendLeaderboard(const GameID gameID, const Leaderboard::InfoType infoType, const bool weekly, const LWOOBJID playerID, const LWOOBJID targetID, const uint32_t resultStart, const uint32_t resultEnd) {
|
Leaderboard* LeaderboardManager::GetLeaderboard(uint32_t gameID, InfoType infoType, bool weekly, LWOOBJID playerID) {
|
||||||
Leaderboard leaderboard(gameID, infoType, weekly, playerID, GetLeaderboardType(gameID));
|
auto leaderboardType = GetLeaderboardType(gameID);
|
||||||
leaderboard.SetupLeaderboard(weekly, resultStart, resultEnd);
|
|
||||||
leaderboard.Send(targetID);
|
std::string query;
|
||||||
|
bool classicSurvivalScoring = Game::config->GetValue("classic_survival_scoring") == "1";
|
||||||
|
switch (infoType) {
|
||||||
|
case InfoType::Standings:
|
||||||
|
switch (leaderboardType) {
|
||||||
|
case ShootingGallery:
|
||||||
|
query = standingsScoreQuery; // Shooting gallery is based on the highest score.
|
||||||
|
break;
|
||||||
|
case FootRace:
|
||||||
|
query = standingsTimeQuery; // The higher your time, the better for FootRace.
|
||||||
|
break;
|
||||||
|
case Survival:
|
||||||
|
query = classicSurvivalScoring ? standingsTimeQuery : standingsScoreQuery;
|
||||||
|
break;
|
||||||
|
case SurvivalNS:
|
||||||
|
query = standingsScoreQueryAsc; // BoNS is scored by highest wave (score) first, then time.
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
query = standingsTimeQueryAsc; // MonumentRace and Racing are based on the shortest time.
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case InfoType::Friends:
|
||||||
|
switch (leaderboardType) {
|
||||||
|
case ShootingGallery:
|
||||||
|
query = friendsScoreQuery; // Shooting gallery is based on the highest score.
|
||||||
|
break;
|
||||||
|
case FootRace:
|
||||||
|
query = friendsTimeQuery; // The higher your time, the better for FootRace.
|
||||||
|
break;
|
||||||
|
case Survival:
|
||||||
|
query = classicSurvivalScoring ? friendsTimeQuery : friendsScoreQuery;
|
||||||
|
break;
|
||||||
|
case SurvivalNS:
|
||||||
|
query = friendsScoreQueryAsc; // BoNS is scored by highest wave (score) first, then time.
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
query = friendsTimeQueryAsc; // MonumentRace and Racing are based on the shortest time.
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
switch (leaderboardType) {
|
||||||
|
case ShootingGallery:
|
||||||
|
query = topPlayersScoreQuery; // Shooting gallery is based on the highest score.
|
||||||
|
break;
|
||||||
|
case FootRace:
|
||||||
|
query = topPlayersTimeQuery; // The higher your time, the better for FootRace.
|
||||||
|
break;
|
||||||
|
case Survival:
|
||||||
|
query = classicSurvivalScoring ? topPlayersTimeQuery : topPlayersScoreQuery;
|
||||||
|
break;
|
||||||
|
case SurvivalNS:
|
||||||
|
query = topPlayersScoreQueryAsc; // BoNS is scored by highest wave (score) first, then time.
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
query = topPlayersTimeQueryAsc; // MonumentRace and Racing are based on the shortest time.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Leaderboard::Type LeaderboardManager::GetLeaderboardType(const GameID gameID) {
|
auto* statement = Database::CreatePreppedStmt(query);
|
||||||
auto lookup = leaderboardCache.find(gameID);
|
statement->setUInt(1, gameID);
|
||||||
if (lookup != leaderboardCache.end()) return lookup->second;
|
|
||||||
|
|
||||||
|
// Only the standings and friends leaderboards require the character ID to be set
|
||||||
|
if (infoType == Standings || infoType == Friends) {
|
||||||
|
auto characterID = 0;
|
||||||
|
|
||||||
|
const auto* player = EntityManager::Instance()->GetEntity(playerID);
|
||||||
|
if (player != nullptr) {
|
||||||
|
auto* character = player->GetCharacter();
|
||||||
|
if (character != nullptr)
|
||||||
|
characterID = character->GetID();
|
||||||
|
}
|
||||||
|
|
||||||
|
statement->setUInt64(2, characterID);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto* res = statement->executeQuery();
|
||||||
|
|
||||||
|
std::vector<LeaderboardEntry> entries{};
|
||||||
|
|
||||||
|
uint32_t index = 0;
|
||||||
|
while (res->next()) {
|
||||||
|
LeaderboardEntry entry;
|
||||||
|
entry.playerID = res->getUInt64(4);
|
||||||
|
entry.playerName = res->getString(5);
|
||||||
|
entry.time = res->getUInt(1);
|
||||||
|
entry.score = res->getUInt(2);
|
||||||
|
entry.placement = res->getUInt(3);
|
||||||
|
entry.lastPlayed = res->getUInt(6);
|
||||||
|
|
||||||
|
entries.push_back(entry);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete res;
|
||||||
|
delete statement;
|
||||||
|
|
||||||
|
return new Leaderboard(gameID, infoType, weekly, entries, playerID, leaderboardType);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LeaderboardManager::SendLeaderboard(uint32_t gameID, InfoType infoType, bool weekly, LWOOBJID targetID,
|
||||||
|
LWOOBJID playerID) {
|
||||||
|
const auto* leaderboard = LeaderboardManager::GetLeaderboard(gameID, infoType, weekly, playerID);
|
||||||
|
leaderboard->Send(targetID);
|
||||||
|
delete leaderboard;
|
||||||
|
}
|
||||||
|
|
||||||
|
LeaderboardType LeaderboardManager::GetLeaderboardType(uint32_t gameID) {
|
||||||
auto* activitiesTable = CDClientManager::Instance().GetTable<CDActivitiesTable>();
|
auto* activitiesTable = CDClientManager::Instance().GetTable<CDActivitiesTable>();
|
||||||
std::vector<CDActivities> activities = activitiesTable->Query([gameID](const CDActivities& entry) {
|
std::vector<CDActivities> activities = activitiesTable->Query([=](const CDActivities& entry) {
|
||||||
return entry.ActivityID == gameID;
|
return (entry.ActivityID == gameID);
|
||||||
});
|
});
|
||||||
auto type = !activities.empty() ? static_cast<Leaderboard::Type>(activities.at(0).leaderboardType) : Leaderboard::Type::None;
|
|
||||||
leaderboardCache.insert_or_assign(gameID, type);
|
for (const auto& activity : activities) {
|
||||||
return type;
|
return static_cast<LeaderboardType>(activity.leaderboardType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return LeaderboardType::None;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string LeaderboardManager::topPlayersScoreQuery =
|
||||||
|
"WITH leaderboard_vales AS ( "
|
||||||
|
" SELECT l.time, l.score, UNIX_TIMESTAMP(l.last_played) last_played, c.name, c.id, "
|
||||||
|
"RANK() OVER ( ORDER BY l.score DESC, l.time DESC, last_played ) leaderboard_rank "
|
||||||
|
" FROM leaderboard l "
|
||||||
|
"INNER JOIN charinfo c ON l.character_id = c.id "
|
||||||
|
"WHERE l.game_id = ? "
|
||||||
|
"ORDER BY leaderboard_rank) "
|
||||||
|
"SELECT time, score, leaderboard_rank, id, name, last_played "
|
||||||
|
"FROM leaderboard_vales LIMIT 11;";
|
||||||
|
|
||||||
|
const std::string LeaderboardManager::friendsScoreQuery =
|
||||||
|
"WITH leaderboard_vales AS ( "
|
||||||
|
" SELECT l.time, l.score, UNIX_TIMESTAMP(l.last_played) last_played, c.name, c.id, f.friend_id, f.player_id, "
|
||||||
|
" RANK() OVER ( ORDER BY l.score DESC, l.time DESC, last_played ) leaderboard_rank "
|
||||||
|
" FROM leaderboard l "
|
||||||
|
" INNER JOIN charinfo c ON l.character_id = c.id "
|
||||||
|
" INNER JOIN friends f ON f.player_id = c.id "
|
||||||
|
" WHERE l.game_id = ? "
|
||||||
|
" ORDER BY leaderboard_rank), "
|
||||||
|
" personal_values AS ( "
|
||||||
|
" SELECT id as related_player_id, "
|
||||||
|
" GREATEST(CAST(leaderboard_rank AS SIGNED) - 5, 1) AS min_rank, "
|
||||||
|
" GREATEST(leaderboard_rank + 5, 11) AS max_rank "
|
||||||
|
" FROM leaderboard_vales WHERE leaderboard_vales.id = ? LIMIT 1) "
|
||||||
|
"SELECT time, score, leaderboard_rank, id, name, last_played "
|
||||||
|
"FROM leaderboard_vales, personal_values "
|
||||||
|
"WHERE leaderboard_rank BETWEEN min_rank AND max_rank AND (player_id = related_player_id OR friend_id = related_player_id);";
|
||||||
|
|
||||||
|
const std::string LeaderboardManager::standingsScoreQuery =
|
||||||
|
"WITH leaderboard_vales AS ( "
|
||||||
|
" SELECT l.time, l.score, UNIX_TIMESTAMP(l.last_played) last_played, c.name, c.id, "
|
||||||
|
" RANK() OVER ( ORDER BY l.score DESC, l.time DESC, last_played ) leaderboard_rank "
|
||||||
|
" FROM leaderboard l "
|
||||||
|
" INNER JOIN charinfo c ON l.character_id = c.id "
|
||||||
|
" WHERE l.game_id = ? "
|
||||||
|
" ORDER BY leaderboard_rank), "
|
||||||
|
"personal_values AS ( "
|
||||||
|
" SELECT GREATEST(CAST(leaderboard_rank AS SIGNED) - 5, 1) AS min_rank, "
|
||||||
|
" GREATEST(leaderboard_rank + 5, 11) AS max_rank "
|
||||||
|
" FROM leaderboard_vales WHERE id = ? LIMIT 1) "
|
||||||
|
"SELECT time, score, leaderboard_rank, id, name, last_played "
|
||||||
|
"FROM leaderboard_vales, personal_values "
|
||||||
|
"WHERE leaderboard_rank BETWEEN min_rank AND max_rank;";
|
||||||
|
|
||||||
|
const std::string LeaderboardManager::topPlayersScoreQueryAsc =
|
||||||
|
"WITH leaderboard_vales AS ( "
|
||||||
|
" SELECT l.time, l.score, UNIX_TIMESTAMP(l.last_played) last_played, c.name, c.id, "
|
||||||
|
"RANK() OVER ( ORDER BY l.score DESC, l.time ASC, last_played ) leaderboard_rank "
|
||||||
|
" FROM leaderboard l "
|
||||||
|
"INNER JOIN charinfo c ON l.character_id = c.id "
|
||||||
|
"WHERE l.game_id = ? "
|
||||||
|
"ORDER BY leaderboard_rank) "
|
||||||
|
"SELECT time, score, leaderboard_rank, id, name, last_played "
|
||||||
|
"FROM leaderboard_vales LIMIT 11;";
|
||||||
|
|
||||||
|
const std::string LeaderboardManager::friendsScoreQueryAsc =
|
||||||
|
"WITH leaderboard_vales AS ( "
|
||||||
|
" SELECT l.time, l.score, UNIX_TIMESTAMP(l.last_played) last_played, c.name, c.id, f.friend_id, f.player_id, "
|
||||||
|
" RANK() OVER ( ORDER BY l.score DESC, l.time ASC, last_played ) leaderboard_rank "
|
||||||
|
" FROM leaderboard l "
|
||||||
|
" INNER JOIN charinfo c ON l.character_id = c.id "
|
||||||
|
" INNER JOIN friends f ON f.player_id = c.id "
|
||||||
|
" WHERE l.game_id = ? "
|
||||||
|
" ORDER BY leaderboard_rank), "
|
||||||
|
" personal_values AS ( "
|
||||||
|
" SELECT id as related_player_id, "
|
||||||
|
" GREATEST(CAST(leaderboard_rank AS SIGNED) - 5, 1) AS min_rank, "
|
||||||
|
" GREATEST(leaderboard_rank + 5, 11) AS max_rank "
|
||||||
|
" FROM leaderboard_vales WHERE leaderboard_vales.id = ? LIMIT 1) "
|
||||||
|
"SELECT time, score, leaderboard_rank, id, name, last_played "
|
||||||
|
"FROM leaderboard_vales, personal_values "
|
||||||
|
"WHERE leaderboard_rank BETWEEN min_rank AND max_rank AND (player_id = related_player_id OR friend_id = related_player_id);";
|
||||||
|
|
||||||
|
const std::string LeaderboardManager::standingsScoreQueryAsc =
|
||||||
|
"WITH leaderboard_vales AS ( "
|
||||||
|
" SELECT l.time, l.score, UNIX_TIMESTAMP(l.last_played) last_played, c.name, c.id, "
|
||||||
|
" RANK() OVER ( ORDER BY l.score DESC, l.time ASC, last_played ) leaderboard_rank "
|
||||||
|
" FROM leaderboard l "
|
||||||
|
" INNER JOIN charinfo c ON l.character_id = c.id "
|
||||||
|
" WHERE l.game_id = ? "
|
||||||
|
" ORDER BY leaderboard_rank), "
|
||||||
|
"personal_values AS ( "
|
||||||
|
" SELECT GREATEST(CAST(leaderboard_rank AS SIGNED) - 5, 1) AS min_rank, "
|
||||||
|
" GREATEST(leaderboard_rank + 5, 11) AS max_rank "
|
||||||
|
" FROM leaderboard_vales WHERE id = ? LIMIT 1) "
|
||||||
|
"SELECT time, score, leaderboard_rank, id, name, last_played "
|
||||||
|
"FROM leaderboard_vales, personal_values "
|
||||||
|
"WHERE leaderboard_rank BETWEEN min_rank AND max_rank;";
|
||||||
|
|
||||||
|
const std::string LeaderboardManager::topPlayersTimeQuery =
|
||||||
|
"WITH leaderboard_vales AS ( "
|
||||||
|
" SELECT l.time, l.score, UNIX_TIMESTAMP(l.last_played) last_played, c.name, c.id, "
|
||||||
|
"RANK() OVER ( ORDER BY l.time DESC, l.score DESC, last_played ) leaderboard_rank "
|
||||||
|
" FROM leaderboard l "
|
||||||
|
"INNER JOIN charinfo c ON l.character_id = c.id "
|
||||||
|
"WHERE l.game_id = ? "
|
||||||
|
"ORDER BY leaderboard_rank) "
|
||||||
|
"SELECT time, score, leaderboard_rank, id, name, last_played "
|
||||||
|
"FROM leaderboard_vales LIMIT 11;";
|
||||||
|
|
||||||
|
const std::string LeaderboardManager::friendsTimeQuery =
|
||||||
|
"WITH leaderboard_vales AS ( "
|
||||||
|
" SELECT l.time, l.score, UNIX_TIMESTAMP(l.last_played) last_played, c.name, c.id, f.friend_id, f.player_id, "
|
||||||
|
" RANK() OVER ( ORDER BY l.time DESC, l.score DESC, last_played ) leaderboard_rank "
|
||||||
|
" FROM leaderboard l "
|
||||||
|
" INNER JOIN charinfo c ON l.character_id = c.id "
|
||||||
|
" INNER JOIN friends f ON f.player_id = c.id "
|
||||||
|
" WHERE l.game_id = ? "
|
||||||
|
" ORDER BY leaderboard_rank), "
|
||||||
|
" personal_values AS ( "
|
||||||
|
" SELECT id as related_player_id, "
|
||||||
|
" GREATEST(CAST(leaderboard_rank AS SIGNED) - 5, 1) AS min_rank, "
|
||||||
|
" GREATEST(leaderboard_rank + 5, 11) AS max_rank "
|
||||||
|
" FROM leaderboard_vales WHERE leaderboard_vales.id = ? LIMIT 1) "
|
||||||
|
"SELECT time, score, leaderboard_rank, id, name, last_played "
|
||||||
|
"FROM leaderboard_vales, personal_values "
|
||||||
|
"WHERE leaderboard_rank BETWEEN min_rank AND max_rank AND (player_id = related_player_id OR friend_id = related_player_id);";
|
||||||
|
|
||||||
|
const std::string LeaderboardManager::standingsTimeQuery =
|
||||||
|
"WITH leaderboard_vales AS ( "
|
||||||
|
" SELECT l.time, l.score, UNIX_TIMESTAMP(l.last_played) last_played, c.name, c.id, "
|
||||||
|
" RANK() OVER ( ORDER BY l.time DESC, l.score DESC, last_played ) leaderboard_rank "
|
||||||
|
" FROM leaderboard l "
|
||||||
|
" INNER JOIN charinfo c ON l.character_id = c.id "
|
||||||
|
" WHERE l.game_id = ? "
|
||||||
|
" ORDER BY leaderboard_rank), "
|
||||||
|
"personal_values AS ( "
|
||||||
|
" SELECT GREATEST(CAST(leaderboard_rank AS SIGNED) - 5, 1) AS min_rank, "
|
||||||
|
" GREATEST(leaderboard_rank + 5, 11) AS max_rank "
|
||||||
|
" FROM leaderboard_vales WHERE id = ? LIMIT 1) "
|
||||||
|
"SELECT time, score, leaderboard_rank, id, name, last_played "
|
||||||
|
"FROM leaderboard_vales, personal_values "
|
||||||
|
"WHERE leaderboard_rank BETWEEN min_rank AND max_rank;";
|
||||||
|
|
||||||
|
const std::string LeaderboardManager::topPlayersTimeQueryAsc =
|
||||||
|
"WITH leaderboard_vales AS ( "
|
||||||
|
" SELECT l.time, l.score, UNIX_TIMESTAMP(l.last_played) last_played, c.name, c.id, "
|
||||||
|
"RANK() OVER ( ORDER BY l.time ASC, l.score DESC, last_played ) leaderboard_rank "
|
||||||
|
" FROM leaderboard l "
|
||||||
|
"INNER JOIN charinfo c ON l.character_id = c.id "
|
||||||
|
"WHERE l.game_id = ? "
|
||||||
|
"ORDER BY leaderboard_rank) "
|
||||||
|
"SELECT time, score, leaderboard_rank, id, name, last_played "
|
||||||
|
"FROM leaderboard_vales LIMIT 11;";
|
||||||
|
|
||||||
|
const std::string LeaderboardManager::friendsTimeQueryAsc =
|
||||||
|
"WITH leaderboard_vales AS ( "
|
||||||
|
" SELECT l.time, l.score, UNIX_TIMESTAMP(l.last_played) last_played, c.name, c.id, f.friend_id, f.player_id, "
|
||||||
|
" RANK() OVER ( ORDER BY l.time ASC, l.score DESC, last_played ) leaderboard_rank "
|
||||||
|
" FROM leaderboard l "
|
||||||
|
" INNER JOIN charinfo c ON l.character_id = c.id "
|
||||||
|
" INNER JOIN friends f ON f.player_id = c.id "
|
||||||
|
" WHERE l.game_id = ? "
|
||||||
|
" ORDER BY leaderboard_rank), "
|
||||||
|
" personal_values AS ( "
|
||||||
|
" SELECT id as related_player_id, "
|
||||||
|
" GREATEST(CAST(leaderboard_rank AS SIGNED) - 5, 1) AS min_rank, "
|
||||||
|
" GREATEST(leaderboard_rank + 5, 11) AS max_rank "
|
||||||
|
" FROM leaderboard_vales WHERE leaderboard_vales.id = ? LIMIT 1) "
|
||||||
|
"SELECT time, score, leaderboard_rank, id, name, last_played "
|
||||||
|
"FROM leaderboard_vales, personal_values "
|
||||||
|
"WHERE leaderboard_rank BETWEEN min_rank AND max_rank AND (player_id = related_player_id OR friend_id = related_player_id);";
|
||||||
|
|
||||||
|
const std::string LeaderboardManager::standingsTimeQueryAsc =
|
||||||
|
"WITH leaderboard_vales AS ( "
|
||||||
|
" SELECT l.time, l.score, UNIX_TIMESTAMP(l.last_played) last_played, c.name, c.id, "
|
||||||
|
" RANK() OVER ( ORDER BY l.time ASC, l.score DESC, last_played ) leaderboard_rank "
|
||||||
|
" FROM leaderboard l "
|
||||||
|
" INNER JOIN charinfo c ON l.character_id = c.id "
|
||||||
|
" WHERE l.game_id = ? "
|
||||||
|
" ORDER BY leaderboard_rank), "
|
||||||
|
"personal_values AS ( "
|
||||||
|
" SELECT GREATEST(CAST(leaderboard_rank AS SIGNED) - 5, 1) AS min_rank, "
|
||||||
|
" GREATEST(leaderboard_rank + 5, 11) AS max_rank "
|
||||||
|
" FROM leaderboard_vales WHERE id = ? LIMIT 1) "
|
||||||
|
"SELECT time, score, leaderboard_rank, id, name, last_played "
|
||||||
|
"FROM leaderboard_vales, personal_values "
|
||||||
|
"WHERE leaderboard_rank BETWEEN min_rank AND max_rank;";
|
||||||
|
|||||||
@@ -1,134 +1,80 @@
|
|||||||
#ifndef __LEADERBOARDMANAGER__H__
|
#pragma once
|
||||||
#define __LEADERBOARDMANAGER__H__
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
|
||||||
#include <string_view>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <climits>
|
||||||
#include "Singleton.h"
|
|
||||||
#include "dCommonVars.h"
|
#include "dCommonVars.h"
|
||||||
#include "LDFFormat.h"
|
|
||||||
|
|
||||||
namespace sql {
|
struct LeaderboardEntry {
|
||||||
class ResultSet;
|
uint64_t playerID;
|
||||||
|
std::string playerName;
|
||||||
|
uint32_t time;
|
||||||
|
uint32_t score;
|
||||||
|
uint32_t placement;
|
||||||
|
time_t lastPlayed;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace RakNet {
|
|
||||||
class BitStream;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Score {
|
|
||||||
public:
|
|
||||||
Score() {
|
|
||||||
primaryScore = 0;
|
|
||||||
secondaryScore = 0;
|
|
||||||
tertiaryScore = 0;
|
|
||||||
}
|
|
||||||
Score(const float primaryScore, const float secondaryScore = 0, const float tertiaryScore = 0) {
|
|
||||||
this->primaryScore = primaryScore;
|
|
||||||
this->secondaryScore = secondaryScore;
|
|
||||||
this->tertiaryScore = tertiaryScore;
|
|
||||||
}
|
|
||||||
bool operator<(const Score& rhs) const {
|
|
||||||
return primaryScore < rhs.primaryScore || (primaryScore == rhs.primaryScore && secondaryScore < rhs.secondaryScore) || (primaryScore == rhs.primaryScore && secondaryScore == rhs.secondaryScore && tertiaryScore < rhs.tertiaryScore);
|
|
||||||
}
|
|
||||||
bool operator>(const Score& rhs) const {
|
|
||||||
return primaryScore > rhs.primaryScore || (primaryScore == rhs.primaryScore && secondaryScore > rhs.secondaryScore) || (primaryScore == rhs.primaryScore && secondaryScore == rhs.secondaryScore && tertiaryScore > rhs.tertiaryScore);
|
|
||||||
}
|
|
||||||
void SetPrimaryScore(const float score) { primaryScore = score; }
|
|
||||||
float GetPrimaryScore() const { return primaryScore; }
|
|
||||||
|
|
||||||
void SetSecondaryScore(const float score) { secondaryScore = score; }
|
|
||||||
float GetSecondaryScore() const { return secondaryScore; }
|
|
||||||
|
|
||||||
void SetTertiaryScore(const float score) { tertiaryScore = score; }
|
|
||||||
float GetTertiaryScore() const { return tertiaryScore; }
|
|
||||||
private:
|
|
||||||
float primaryScore;
|
|
||||||
float secondaryScore;
|
|
||||||
float tertiaryScore;
|
|
||||||
};
|
|
||||||
|
|
||||||
using GameID = uint32_t;
|
|
||||||
|
|
||||||
class Leaderboard {
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Enums for leaderboards
|
|
||||||
enum InfoType : uint32_t {
|
enum InfoType : uint32_t {
|
||||||
Top, // Top 11 all time players
|
Top, // Top 11 all time players
|
||||||
MyStanding, // Ranking of the current player
|
Standings, // Ranking of the current player
|
||||||
Friends // Ranking between friends
|
Friends // Ranking between friends
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Type : uint32_t {
|
enum LeaderboardType : uint32_t {
|
||||||
ShootingGallery,
|
ShootingGallery,
|
||||||
Racing,
|
Racing,
|
||||||
MonumentRace,
|
MonumentRace,
|
||||||
FootRace,
|
FootRace,
|
||||||
UnusedLeaderboard4, // There is no 4 defined anywhere in the cdclient, but it takes a Score.
|
Survival = 5,
|
||||||
Survival,
|
SurvivalNS = 6,
|
||||||
SurvivalNS,
|
None = UINT_MAX
|
||||||
Donations,
|
|
||||||
None
|
|
||||||
};
|
};
|
||||||
Leaderboard() = delete;
|
|
||||||
Leaderboard(const GameID gameID, const Leaderboard::InfoType infoType, const bool weekly, LWOOBJID relatedPlayer, const Leaderboard::Type = None);
|
|
||||||
|
|
||||||
~Leaderboard();
|
class Leaderboard {
|
||||||
|
public:
|
||||||
/**
|
Leaderboard(uint32_t gameID, uint32_t infoType, bool weekly, std::vector<LeaderboardEntry> entries,
|
||||||
* @brief Resets the leaderboard state and frees its allocated memory
|
LWOOBJID relatedPlayer = LWOOBJID_EMPTY, LeaderboardType = None);
|
||||||
*
|
std::vector<LeaderboardEntry> GetEntries();
|
||||||
*/
|
[[nodiscard]] std::u16string ToString() const;
|
||||||
void Clear();
|
[[nodiscard]] uint32_t GetGameID() const;
|
||||||
|
[[nodiscard]] uint32_t GetInfoType() const;
|
||||||
/**
|
void Send(LWOOBJID targetID) const;
|
||||||
* Serialize the Leaderboard to a BitStream
|
|
||||||
*
|
|
||||||
* Expensive! Leaderboards are very string intensive so be wary of performatnce calling this method.
|
|
||||||
*/
|
|
||||||
void Serialize(RakNet::BitStream* bitStream) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the leaderboard from the database based on the associated gameID
|
|
||||||
*
|
|
||||||
* @param resultStart The index to start the leaderboard at. Zero indexed.
|
|
||||||
* @param resultEnd The index to end the leaderboard at. Zero indexed.
|
|
||||||
*/
|
|
||||||
void SetupLeaderboard(bool weekly, uint32_t resultStart = 0, uint32_t resultEnd = 10);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends the leaderboard to the client specified by targetID.
|
|
||||||
*/
|
|
||||||
void Send(const LWOOBJID targetID) const;
|
|
||||||
|
|
||||||
// Helper function to get the columns, ordering and insert format for a leaderboard
|
|
||||||
static const std::string_view GetOrdering(Type leaderboardType);
|
|
||||||
private:
|
private:
|
||||||
// Takes the resulting query from a leaderboard lookup and converts it to the LDF we need
|
std::vector<LeaderboardEntry> entries{};
|
||||||
// to send it to a client.
|
|
||||||
void QueryToLdf(std::unique_ptr<sql::ResultSet>& rows);
|
|
||||||
|
|
||||||
using LeaderboardEntry = std::vector<LDFBaseData*>;
|
|
||||||
using LeaderboardEntries = std::vector<LeaderboardEntry>;
|
|
||||||
|
|
||||||
LeaderboardEntries entries;
|
|
||||||
LWOOBJID relatedPlayer;
|
LWOOBJID relatedPlayer;
|
||||||
GameID gameID;
|
uint32_t gameID;
|
||||||
InfoType infoType;
|
uint32_t infoType;
|
||||||
Leaderboard::Type leaderboardType;
|
LeaderboardType leaderboardType;
|
||||||
bool weekly;
|
bool weekly;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace LeaderboardManager {
|
class LeaderboardManager {
|
||||||
void SendLeaderboard(const GameID gameID, const Leaderboard::InfoType infoType, const bool weekly, const LWOOBJID playerID, const LWOOBJID targetID, const uint32_t resultStart = 0, const uint32_t resultEnd = 10);
|
public:
|
||||||
|
static LeaderboardManager* Instance() {
|
||||||
|
if (address == nullptr)
|
||||||
|
address = new LeaderboardManager;
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
static void SendLeaderboard(uint32_t gameID, InfoType infoType, bool weekly, LWOOBJID targetID,
|
||||||
|
LWOOBJID playerID = LWOOBJID_EMPTY);
|
||||||
|
static Leaderboard* GetLeaderboard(uint32_t gameID, InfoType infoType, bool weekly, LWOOBJID playerID = LWOOBJID_EMPTY);
|
||||||
|
static void SaveScore(LWOOBJID playerID, uint32_t gameID, uint32_t score, uint32_t time);
|
||||||
|
static LeaderboardType GetLeaderboardType(uint32_t gameID);
|
||||||
|
private:
|
||||||
|
static LeaderboardManager* address;
|
||||||
|
|
||||||
void SaveScore(const LWOOBJID& playerID, const GameID activityId, const float primaryScore, const float secondaryScore = 0, const float tertiaryScore = 0);
|
// Modified 12/12/2021: Existing queries were renamed to be more descriptive.
|
||||||
|
static const std::string topPlayersScoreQuery;
|
||||||
|
static const std::string friendsScoreQuery;
|
||||||
|
static const std::string standingsScoreQuery;
|
||||||
|
static const std::string topPlayersScoreQueryAsc;
|
||||||
|
static const std::string friendsScoreQueryAsc;
|
||||||
|
static const std::string standingsScoreQueryAsc;
|
||||||
|
|
||||||
Leaderboard::Type GetLeaderboardType(const GameID gameID);
|
// Added 12/12/2021: Queries dictated by time are needed for certain minigames.
|
||||||
extern std::map<GameID, Leaderboard::Type> leaderboardCache;
|
static const std::string topPlayersTimeQuery;
|
||||||
|
static const std::string friendsTimeQuery;
|
||||||
|
static const std::string standingsTimeQuery;
|
||||||
|
static const std::string topPlayersTimeQueryAsc;
|
||||||
|
static const std::string friendsTimeQueryAsc;
|
||||||
|
static const std::string standingsTimeQueryAsc;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //!__LEADERBOARDMANAGER__H__
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ void Player::SetSystemAddress(const SystemAddress& value) {
|
|||||||
void Player::SetRespawnPos(const NiPoint3 position) {
|
void Player::SetRespawnPos(const NiPoint3 position) {
|
||||||
m_respawnPos = position;
|
m_respawnPos = position;
|
||||||
|
|
||||||
m_Character->SetRespawnPoint(Game::zoneManager->GetZone()->GetWorldID(), position);
|
m_Character->SetRespawnPoint(dZoneManager::Instance()->GetZone()->GetWorldID(), position);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SetRespawnRot(const NiQuaternion rotation) {
|
void Player::SetRespawnRot(const NiQuaternion rotation) {
|
||||||
@@ -85,7 +85,7 @@ void Player::SendToZone(LWOMAPID zoneId, LWOCLONEID cloneId) {
|
|||||||
const auto objid = GetObjectID();
|
const auto objid = GetObjectID();
|
||||||
|
|
||||||
ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, zoneId, cloneId, false, [objid](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) {
|
ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, zoneId, cloneId, false, [objid](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) {
|
||||||
auto* entity = Game::entityManager->GetEntity(objid);
|
auto* entity = EntityManager::Instance()->GetEntity(objid);
|
||||||
|
|
||||||
if (entity == nullptr) {
|
if (entity == nullptr) {
|
||||||
return;
|
return;
|
||||||
@@ -108,7 +108,7 @@ void Player::SendToZone(LWOMAPID zoneId, LWOCLONEID cloneId) {
|
|||||||
|
|
||||||
WorldPackets::SendTransferToWorld(sysAddr, serverIP, serverPort, mythranShift);
|
WorldPackets::SendTransferToWorld(sysAddr, serverIP, serverPort, mythranShift);
|
||||||
|
|
||||||
Game::entityManager->DestructEntity(entity);
|
EntityManager::Instance()->DestructEntity(entity);
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -135,13 +135,13 @@ void Player::RemoveLimboConstruction(LWOOBJID objectId) {
|
|||||||
|
|
||||||
void Player::ConstructLimboEntities() {
|
void Player::ConstructLimboEntities() {
|
||||||
for (const auto objectId : m_LimboConstructions) {
|
for (const auto objectId : m_LimboConstructions) {
|
||||||
auto* entity = Game::entityManager->GetEntity(objectId);
|
auto* entity = EntityManager::Instance()->GetEntity(objectId);
|
||||||
|
|
||||||
if (entity == nullptr) {
|
if (entity == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::entityManager->ConstructEntity(entity, m_SystemAddress);
|
EntityManager::Instance()->ConstructEntity(entity, m_SystemAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_LimboConstructions.clear();
|
m_LimboConstructions.clear();
|
||||||
@@ -224,7 +224,7 @@ Player* Player::GetPlayer(const SystemAddress& sysAddr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player* Player::GetPlayer(const std::string& name) {
|
Player* Player::GetPlayer(const std::string& name) {
|
||||||
const auto characters = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::CHARACTER);
|
const auto characters = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::CHARACTER);
|
||||||
|
|
||||||
for (auto* character : characters) {
|
for (auto* character : characters) {
|
||||||
if (!character->IsPlayer()) continue;
|
if (!character->IsPlayer()) continue;
|
||||||
@@ -269,7 +269,7 @@ Player::~Player() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* entity = Game::entityManager->GetGhostCandidate(id);
|
auto* entity = EntityManager::Instance()->GetGhostCandidate(id);
|
||||||
|
|
||||||
if (entity != nullptr) {
|
if (entity != nullptr) {
|
||||||
entity->SetObservers(entity->GetObservers() - 1);
|
entity->SetObservers(entity->GetObservers() - 1);
|
||||||
@@ -285,12 +285,12 @@ Player::~Player() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (IsPlayer()) {
|
if (IsPlayer()) {
|
||||||
Entity* zoneControl = Game::entityManager->GetZoneControlEntity();
|
Entity* zoneControl = EntityManager::Instance()->GetZoneControlEntity();
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) {
|
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) {
|
||||||
script->OnPlayerExit(zoneControl, this);
|
script->OnPlayerExit(zoneControl, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Entity*> scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
|
std::vector<Entity*> scriptedActs = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
|
||||||
for (Entity* scriptEntity : scriptedActs) {
|
for (Entity* scriptEntity : scriptedActs) {
|
||||||
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
|
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) {
|
for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) {
|
||||||
|
|||||||
@@ -40,11 +40,11 @@ LWOOBJID Trade::GetParticipantB() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Entity* Trade::GetParticipantAEntity() const {
|
Entity* Trade::GetParticipantAEntity() const {
|
||||||
return Game::entityManager->GetEntity(m_ParticipantA);
|
return EntityManager::Instance()->GetEntity(m_ParticipantA);
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity* Trade::GetParticipantBEntity() const {
|
Entity* Trade::GetParticipantBEntity() const {
|
||||||
return Game::entityManager->GetEntity(m_ParticipantB);
|
return EntityManager::Instance()->GetEntity(m_ParticipantB);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trade::SetCoins(LWOOBJID participant, uint64_t coins) {
|
void Trade::SetCoins(LWOOBJID participant, uint64_t coins) {
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ void UserManager::RequestCharacterList(const SystemAddress& sysAddr) {
|
|||||||
skillComponent->Reset();
|
skillComponent->Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::entityManager->DestroyEntity(chars[i]->GetEntity());
|
EntityManager::Instance()->DestroyEntity(chars[i]->GetEntity());
|
||||||
|
|
||||||
chars[i]->SaveXMLToDatabase();
|
chars[i]->SaveXMLToDatabase();
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ void AirMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitS
|
|||||||
|
|
||||||
auto* behavior = CreateBehavior(behaviorId);
|
auto* behavior = CreateBehavior(behaviorId);
|
||||||
|
|
||||||
if (Game::entityManager->GetEntity(target) != nullptr) {
|
if (EntityManager::Instance()->GetEntity(target) != nullptr) {
|
||||||
branch.target = target;
|
branch.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
|
|
||||||
void ApplyBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
void ApplyBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
auto* entity = Game::entityManager->GetEntity(branch.target == LWOOBJID_EMPTY ? context->originator : branch.target);
|
auto* entity = EntityManager::Instance()->GetEntity(branch.target == LWOOBJID_EMPTY ? context->originator : branch.target);
|
||||||
|
|
||||||
if (entity == nullptr) return;
|
if (entity == nullptr) return;
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ void ApplyBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ApplyBuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
void ApplyBuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
||||||
auto* entity = Game::entityManager->GetEntity(branch.target);
|
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
if (entity == nullptr) return;
|
if (entity == nullptr) return;
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* b
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
auto* self = Game::entityManager->GetEntity(context->caster);
|
auto* self = EntityManager::Instance()->GetEntity(context->caster);
|
||||||
if (self == nullptr) {
|
if (self == nullptr) {
|
||||||
Game::logger->Log("AreaOfEffectBehavior", "Invalid self for (%llu)!", context->originator);
|
Game::logger->Log("AreaOfEffectBehavior", "Invalid self for (%llu)!", context->originator);
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
|
|||||||
|
|
||||||
std::vector<Entity*> targets;
|
std::vector<Entity*> targets;
|
||||||
|
|
||||||
auto* presetTarget = Game::entityManager->GetEntity(branch.target);
|
auto* presetTarget = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
if (presetTarget != nullptr) {
|
if (presetTarget != nullptr) {
|
||||||
if (this->m_radius * this->m_radius >= Vector3::DistanceSquared(reference, presetTarget->GetPosition())) {
|
if (this->m_radius * this->m_radius >= Vector3::DistanceSquared(reference, presetTarget->GetPosition())) {
|
||||||
@@ -75,7 +75,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
|
|||||||
|
|
||||||
// Gets all of the valid targets, passing in if should target enemies and friends
|
// Gets all of the valid targets, passing in if should target enemies and friends
|
||||||
for (auto validTarget : context->GetValidTargets(m_ignoreFaction, includeFaction, m_TargetSelf == 1, m_targetEnemy == 1, m_targetFriend == 1)) {
|
for (auto validTarget : context->GetValidTargets(m_ignoreFaction, includeFaction, m_TargetSelf == 1, m_targetEnemy == 1, m_targetFriend == 1)) {
|
||||||
auto* entity = Game::entityManager->GetEntity(validTarget);
|
auto* entity = EntityManager::Instance()->GetEntity(validTarget);
|
||||||
|
|
||||||
if (entity == nullptr) {
|
if (entity == nullptr) {
|
||||||
Game::logger->Log("AreaOfEffectBehavior", "Invalid target (%llu) for (%llu)!", validTarget, context->originator);
|
Game::logger->Log("AreaOfEffectBehavior", "Invalid target (%llu) for (%llu)!", validTarget, context->originator);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
void BasicAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
void BasicAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
if (context->unmanaged) {
|
if (context->unmanaged) {
|
||||||
auto* entity = Game::entityManager->GetEntity(branch.target);
|
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||||
if (destroyableComponent != nullptr) {
|
if (destroyableComponent != nullptr) {
|
||||||
@@ -38,7 +38,7 @@ void BasicAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
auto* targetEntity = Game::entityManager->GetEntity(branch.target);
|
auto* targetEntity = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
if (!targetEntity) {
|
if (!targetEntity) {
|
||||||
Game::logger->Log("BasicAttackBehavior", "Target targetEntity %llu not found.", branch.target);
|
Game::logger->Log("BasicAttackBehavior", "Target targetEntity %llu not found.", branch.target);
|
||||||
return;
|
return;
|
||||||
@@ -61,7 +61,7 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit
|
|||||||
|
|
||||||
if (isBlocked) {
|
if (isBlocked) {
|
||||||
destroyableComponent->SetAttacksToBlock(std::min(destroyableComponent->GetAttacksToBlock() - 1, 0U));
|
destroyableComponent->SetAttacksToBlock(std::min(destroyableComponent->GetAttacksToBlock() - 1, 0U));
|
||||||
Game::entityManager->SerializeEntity(targetEntity);
|
EntityManager::Instance()->SerializeEntity(targetEntity);
|
||||||
this->m_OnFailBlocked->Handle(context, bitStream, branch);
|
this->m_OnFailBlocked->Handle(context, bitStream, branch);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -155,7 +155,7 @@ void BasicAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream*
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
auto* targetEntity = Game::entityManager->GetEntity(branch.target);
|
auto* targetEntity = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
if (!targetEntity) {
|
if (!targetEntity) {
|
||||||
Game::logger->Log("BasicAttackBehavior", "Target entity %llu is null!", branch.target);
|
Game::logger->Log("BasicAttackBehavior", "Target entity %llu is null!", branch.target);
|
||||||
return;
|
return;
|
||||||
@@ -173,7 +173,7 @@ void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet
|
|||||||
|
|
||||||
if (isBlocking) {
|
if (isBlocking) {
|
||||||
destroyableComponent->SetAttacksToBlock(destroyableComponent->GetAttacksToBlock() - 1);
|
destroyableComponent->SetAttacksToBlock(destroyableComponent->GetAttacksToBlock() - 1);
|
||||||
Game::entityManager->SerializeEntity(targetEntity);
|
EntityManager::Instance()->SerializeEntity(targetEntity);
|
||||||
this->m_OnFailBlocked->Calculate(context, bitStream, branch);
|
this->m_OnFailBlocked->Calculate(context, bitStream, branch);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ BehaviorTemplates Behavior::GetBehaviorTemplate(const uint32_t behaviorId) {
|
|||||||
|
|
||||||
// For use with enemies, to display the correct damage animations on the players
|
// For use with enemies, to display the correct damage animations on the players
|
||||||
void Behavior::PlayFx(std::u16string type, const LWOOBJID target, const LWOOBJID secondary) {
|
void Behavior::PlayFx(std::u16string type, const LWOOBJID target, const LWOOBJID secondary) {
|
||||||
auto* targetEntity = Game::entityManager->GetEntity(target);
|
auto* targetEntity = EntityManager::Instance()->GetEntity(target);
|
||||||
|
|
||||||
if (targetEntity == nullptr) {
|
if (targetEntity == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ BehaviorEndEntry::BehaviorEndEntry() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t BehaviorContext::GetUniqueSkillId() const {
|
uint32_t BehaviorContext::GetUniqueSkillId() const {
|
||||||
auto* entity = Game::entityManager->GetEntity(this->originator);
|
auto* entity = EntityManager::Instance()->GetEntity(this->originator);
|
||||||
|
|
||||||
if (entity == nullptr) {
|
if (entity == nullptr) {
|
||||||
Game::logger->Log("BehaviorContext", "Invalid entity for (%llu)!", this->originator);
|
Game::logger->Log("BehaviorContext", "Invalid entity for (%llu)!", this->originator);
|
||||||
@@ -94,11 +94,11 @@ void BehaviorContext::ScheduleUpdate(const LWOOBJID id) {
|
|||||||
|
|
||||||
void BehaviorContext::ExecuteUpdates() {
|
void BehaviorContext::ExecuteUpdates() {
|
||||||
for (const auto& id : this->scheduledUpdates) {
|
for (const auto& id : this->scheduledUpdates) {
|
||||||
auto* entity = Game::entityManager->GetEntity(id);
|
auto* entity = EntityManager::Instance()->GetEntity(id);
|
||||||
|
|
||||||
if (entity == nullptr) continue;
|
if (entity == nullptr) continue;
|
||||||
|
|
||||||
Game::entityManager->SerializeEntity(entity);
|
EntityManager::Instance()->SerializeEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->scheduledUpdates.clear();
|
this->scheduledUpdates.clear();
|
||||||
@@ -308,7 +308,7 @@ void BehaviorContext::Reset() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<LWOOBJID> BehaviorContext::GetValidTargets(int32_t ignoreFaction, int32_t includeFaction, bool targetSelf, bool targetEnemy, bool targetFriend) const {
|
std::vector<LWOOBJID> BehaviorContext::GetValidTargets(int32_t ignoreFaction, int32_t includeFaction, bool targetSelf, bool targetEnemy, bool targetFriend) const {
|
||||||
auto* entity = Game::entityManager->GetEntity(this->caster);
|
auto* entity = EntityManager::Instance()->GetEntity(this->caster);
|
||||||
|
|
||||||
std::vector<LWOOBJID> targets;
|
std::vector<LWOOBJID> targets;
|
||||||
|
|
||||||
@@ -320,7 +320,7 @@ std::vector<LWOOBJID> BehaviorContext::GetValidTargets(int32_t ignoreFaction, in
|
|||||||
|
|
||||||
if (!ignoreFaction && !includeFaction) {
|
if (!ignoreFaction && !includeFaction) {
|
||||||
for (auto entry : entity->GetTargetsInPhantom()) {
|
for (auto entry : entity->GetTargetsInPhantom()) {
|
||||||
auto* instance = Game::entityManager->GetEntity(entry);
|
auto* instance = EntityManager::Instance()->GetEntity(entry);
|
||||||
|
|
||||||
if (instance == nullptr) {
|
if (instance == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
@@ -336,7 +336,7 @@ std::vector<LWOOBJID> BehaviorContext::GetValidTargets(int32_t ignoreFaction, in
|
|||||||
return targets;
|
return targets;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto entities = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS);
|
auto entities = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS);
|
||||||
for (auto* candidate : entities) {
|
for (auto* candidate : entities) {
|
||||||
const auto id = candidate->GetObjectID();
|
const auto id = candidate->GetObjectID();
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
void BlockBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
void BlockBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
const auto target = context->originator;
|
const auto target = context->originator;
|
||||||
|
|
||||||
auto* entity = Game::entityManager->GetEntity(target);
|
auto* entity = EntityManager::Instance()->GetEntity(target);
|
||||||
|
|
||||||
if (entity == nullptr) {
|
if (entity == nullptr) {
|
||||||
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target);
|
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target);
|
||||||
@@ -40,7 +40,7 @@ void BlockBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitSt
|
|||||||
void BlockBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
void BlockBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
||||||
const auto target = context->originator;
|
const auto target = context->originator;
|
||||||
|
|
||||||
auto* entity = Game::entityManager->GetEntity(target);
|
auto* entity = EntityManager::Instance()->GetEntity(target);
|
||||||
|
|
||||||
if (entity == nullptr) {
|
if (entity == nullptr) {
|
||||||
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target);
|
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user