mirror of
https://github.com/DarwinAnim8or/DarkflameServerNostalgiaMax.git
synced 2025-12-21 05:19:36 -06:00
Fixed dDatabase
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "CDBehaviorParameterTable.h"
|
||||
#include "GeneralUtils.h"
|
||||
//Generated by xmlDb2dDatabaseGenerator on 2022-03-04 00:23:32.881145
|
||||
//DO NOT EDIT THIS FILE MANUALLY!
|
||||
|
||||
@@ -11,20 +12,33 @@ CDBehaviorParameterTable::CDBehaviorParameterTable() {
|
||||
}
|
||||
|
||||
tableSize.finalize();
|
||||
this->m_entries.reserve(size);
|
||||
//this->m_Entries.reserve(size);
|
||||
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BehaviorParameter");
|
||||
/*auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BehaviorParameter");
|
||||
while (!tableData.eof()) {
|
||||
CDBehaviorParameter entry;
|
||||
entry.behaviorID = tableData.getIntField(0, int{});
|
||||
entry.parameterID = tableData.getStringField(1, std::string{}.c_str());
|
||||
entry.value = tableData.getFloatField(2, float{});
|
||||
entry._internalSkillID = tableData.getIntField(3, int{});
|
||||
this->m_entries.push_back(entry);
|
||||
|
||||
//Check if we have an entry with this ID:
|
||||
auto it = m_entries.find(entry.behaviorID);
|
||||
if (it != m_entries.end()) {
|
||||
it->second.insert(std::make_pair(entry.parameterID, entry.value));
|
||||
} else {
|
||||
//Otherwise, insert it:
|
||||
m_entries.insert(std::make_pair(entry.behaviorID, std::map<std::string, float>()));
|
||||
auto jit = m_entries.find(entry.behaviorID);
|
||||
|
||||
//Add our value as well:
|
||||
jit->second.insert(std::make_pair(entry.parameterID, entry.value));
|
||||
}
|
||||
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
tableData.finalize();*/
|
||||
}
|
||||
|
||||
CDBehaviorParameterTable::~CDBehaviorParameterTable() {
|
||||
@@ -34,14 +48,50 @@ std::string CDBehaviorParameterTable::GetName(void) const {
|
||||
return "BehaviorParameter";
|
||||
}
|
||||
|
||||
std::vector<CDBehaviorParameter> CDBehaviorParameterTable::Query(std::function<bool(CDBehaviorParameter)> predicate) {
|
||||
std::vector<CDBehaviorParameter> data = cpplinq::from(this->m_entries)
|
||||
>> cpplinq::where(predicate)
|
||||
>> cpplinq::to_vector();
|
||||
float CDBehaviorParameterTable::GetEntry(const uint32_t behaviorID, const std::string& name, const float defaultValue) {
|
||||
size_t hash = 0;
|
||||
GeneralUtils::hash_combine(hash, behaviorID);
|
||||
GeneralUtils::hash_combine(hash, name);
|
||||
|
||||
return data;
|
||||
}
|
||||
// Search for specific parameter
|
||||
const auto& it = m_Entries.find(hash);
|
||||
if (it != m_Entries.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
std::vector<CDBehaviorParameter> CDBehaviorParameterTable::GetEntries(void) const {
|
||||
return this->m_entries;
|
||||
}
|
||||
// Check if this behavior has already been checked
|
||||
const auto& itChecked = m_Entries.find(behaviorID);
|
||||
if (itChecked != m_Entries.end()) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
#ifndef CDCLIENT_CACHE_ALL
|
||||
std::stringstream query;
|
||||
|
||||
query << "SELECT parameterID, value FROM BehaviorParameter WHERE behaviorID = " << std::to_string(behaviorID);
|
||||
|
||||
auto tableData = CDClientDatabase::ExecuteQuery(query.str());
|
||||
|
||||
m_Entries.insert_or_assign(behaviorID, 0);
|
||||
|
||||
while (!tableData.eof()) {
|
||||
const std::string parameterID = tableData.getStringField(0, "");
|
||||
const float value = tableData.getFloatField(1, 0);
|
||||
|
||||
size_t parameterHash = 0;
|
||||
GeneralUtils::hash_combine(parameterHash, behaviorID);
|
||||
GeneralUtils::hash_combine(parameterHash, parameterID);
|
||||
|
||||
m_Entries.insert_or_assign(parameterHash, value);
|
||||
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
const auto& it2 = m_Entries.find(hash);
|
||||
if (it2 != m_Entries.end()) {
|
||||
return it2->second;
|
||||
}
|
||||
#endif
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
@@ -13,12 +13,15 @@ struct CDBehaviorParameter {
|
||||
|
||||
class CDBehaviorParameterTable : public CDTable {
|
||||
private:
|
||||
std::vector<CDBehaviorParameter> m_entries;
|
||||
std::map<size_t, float> m_Entries;
|
||||
|
||||
public:
|
||||
CDBehaviorParameterTable();
|
||||
~CDBehaviorParameterTable();
|
||||
std::string GetName(void) const override;
|
||||
|
||||
std::vector<CDBehaviorParameter> Query(std::function<bool(CDBehaviorParameter)> predicate);
|
||||
std::vector<CDBehaviorParameter> GetEntries(void) const;
|
||||
std::vector<CDBehaviorParameter> Query(std::function<bool(CDBehaviorParameter)> predicate);
|
||||
//std::vector<CDBehaviorParameter> GetEntries(void) const;
|
||||
|
||||
float GetEntry(const uint32_t behaviorID, const std::string& name, const float defaultValue = 0);
|
||||
};
|
||||
|
||||
@@ -1,46 +1,128 @@
|
||||
#include "CDComponentsRegistryTable.h"
|
||||
//Generated by xmlDb2dDatabaseGenerator on 2022-03-04 00:23:32.923033
|
||||
//DO NOT EDIT THIS FILE MANUALLY!
|
||||
|
||||
CDComponentsRegistryTable::CDComponentsRegistryTable() {
|
||||
#define CDCLIENT_CACHE_ALL
|
||||
|
||||
//! Constructor
|
||||
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()) {
|
||||
while (!tableSize.eof()) {
|
||||
size = tableSize.getIntField(0, 0);
|
||||
|
||||
tableSize.nextRow();
|
||||
}
|
||||
|
||||
tableSize.finalize();
|
||||
this->m_entries.reserve(size);
|
||||
|
||||
// Reserve the size
|
||||
//this->entries.reserve(size);
|
||||
|
||||
// Now get the data
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ComponentsRegistry");
|
||||
while (!tableData.eof()) {
|
||||
CDComponentsRegistry entry;
|
||||
entry.id = tableData.getIntField(0, int{});
|
||||
entry.component_type = tableData.getIntField(1, int{});
|
||||
entry.component_id = tableData.getIntField(2, int{});
|
||||
this->m_entries.push_back(entry);
|
||||
entry.id = tableData.getIntField(0, -1);
|
||||
entry.component_type = tableData.getIntField(1, -1);
|
||||
entry.component_id = tableData.getIntField(2, -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.finalize();
|
||||
#endif
|
||||
}
|
||||
|
||||
CDComponentsRegistryTable::~CDComponentsRegistryTable() {
|
||||
}
|
||||
//! Destructor
|
||||
CDComponentsRegistryTable::~CDComponentsRegistryTable(void) {}
|
||||
|
||||
//! Returns the table's name
|
||||
std::string CDComponentsRegistryTable::GetName(void) const {
|
||||
return "ComponentsRegistry";
|
||||
}
|
||||
|
||||
std::vector<CDComponentsRegistry> CDComponentsRegistryTable::Query(std::function<bool(CDComponentsRegistry)> predicate) {
|
||||
std::vector<CDComponentsRegistry> data = cpplinq::from(this->m_entries)
|
||||
>> cpplinq::where(predicate)
|
||||
>> cpplinq::to_vector();
|
||||
int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, uint32_t componentType, int32_t defaultValue) {
|
||||
const auto& iter = this->mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id));
|
||||
|
||||
return data;
|
||||
}
|
||||
if (iter == this->mappedEntries.end()) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
std::vector<CDComponentsRegistry> CDComponentsRegistryTable::GetEntries(void) const {
|
||||
return this->m_entries;
|
||||
}
|
||||
return iter->second;
|
||||
|
||||
/*
|
||||
const auto& it = this->mappedEntries.find(id);
|
||||
if (it != mappedEntries.end()) {
|
||||
const auto& iter = it->second.find(componentType);
|
||||
if (iter != it->second.end()) {
|
||||
return iter->second;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#ifndef CDCLIENT_CACHE_ALL
|
||||
// Now get the data
|
||||
std::stringstream query;
|
||||
|
||||
query << "SELECT * FROM ComponentsRegistry WHERE id = " << std::to_string(id);
|
||||
|
||||
auto tableData = CDClientDatabase::ExecuteQuery(query.str());
|
||||
while (!tableData.eof()) {
|
||||
CDComponentsRegistry entry;
|
||||
entry.id = tableData.getIntField(0, -1);
|
||||
entry.component_type = tableData.getIntField(1, -1);
|
||||
entry.component_id = tableData.getIntField(2, -1);
|
||||
|
||||
//this->entries.push_back(entry);
|
||||
|
||||
//Darwin's stuff:
|
||||
const auto& it = this->mappedEntries.find(entry.id);
|
||||
if (it != mappedEntries.end()) {
|
||||
const auto& iter = it->second.find(entry.component_type);
|
||||
if (iter == it->second.end()) {
|
||||
it->second.insert(std::make_pair(entry.component_type, entry.component_id));
|
||||
}
|
||||
} else {
|
||||
std::map<unsigned int, unsigned int> map;
|
||||
map.insert(std::make_pair(entry.component_type, entry.component_id));
|
||||
this->mappedEntries.insert(std::make_pair(entry.id, map));
|
||||
}
|
||||
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
|
||||
const auto& it2 = this->mappedEntries.find(id);
|
||||
if (it2 != mappedEntries.end()) {
|
||||
const auto& iter = it2->second.find(componentType);
|
||||
if (iter != it2->second.end()) {
|
||||
return iter->second;
|
||||
}
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
#endif
|
||||
}
|
||||
@@ -1,23 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
// Custom Classes
|
||||
#include "CDTable.h"
|
||||
|
||||
//Generated by xmlDb2dDatabaseGenerator on 2022-03-04 00:23:32.922038
|
||||
//DO NOT EDIT THIS FILE MANUALLY!
|
||||
/*!
|
||||
\file CDComponentsRegistryTable.hpp
|
||||
\brief Contains data for the ComponentsRegistry table
|
||||
*/
|
||||
|
||||
//! ComponentsRegistry Entry Struct
|
||||
struct CDComponentsRegistry {
|
||||
int id;
|
||||
int component_type;
|
||||
int component_id;
|
||||
unsigned int id; //!< The LOT is used as the ID
|
||||
unsigned int component_type; //!< See ComponentTypes enum for values
|
||||
unsigned int component_id; //!< The ID used within the component's table (0 may either mean it's non-networked, or that the ID is actually 0
|
||||
};
|
||||
|
||||
|
||||
//! ComponentsRegistry table
|
||||
class CDComponentsRegistryTable : public CDTable {
|
||||
private:
|
||||
std::vector<CDComponentsRegistry> m_entries;
|
||||
public:
|
||||
CDComponentsRegistryTable();
|
||||
~CDComponentsRegistryTable();
|
||||
std::string GetName(void) const override;
|
||||
//std::vector<CDComponentsRegistry> entries;
|
||||
std::map<uint64_t, uint32_t> mappedEntries; //id, component_type, component_id
|
||||
|
||||
std::vector<CDComponentsRegistry> Query(std::function<bool(CDComponentsRegistry)> predicate);
|
||||
std::vector<CDComponentsRegistry> GetEntries(void) const;
|
||||
};
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
CDComponentsRegistryTable(void);
|
||||
|
||||
//! Destructor
|
||||
~CDComponentsRegistryTable(void);
|
||||
|
||||
//! Returns the table's name
|
||||
/*!
|
||||
\return The table name
|
||||
*/
|
||||
std::string GetName(void) const override;
|
||||
|
||||
int32_t GetByIDAndType(uint32_t id, uint32_t componentType, int32_t defaultValue = 0);
|
||||
};
|
||||
@@ -5,9 +5,9 @@
|
||||
//DO NOT EDIT THIS FILE MANUALLY!
|
||||
|
||||
struct CDInventoryComponent {
|
||||
int id;
|
||||
unsigned int id;
|
||||
int itemid;
|
||||
int count;
|
||||
unsigned int count;
|
||||
bool equip;
|
||||
};
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
//Generated by xmlDb2dDatabaseGenerator on 2022-03-04 00:23:32.999829
|
||||
//DO NOT EDIT THIS FILE MANUALLY!
|
||||
|
||||
CDItemComponent CDItemComponentTable::Default = {};
|
||||
|
||||
CDItemComponentTable::CDItemComponentTable() {
|
||||
unsigned int size = 0;
|
||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ItemComponent");
|
||||
@@ -11,7 +13,7 @@ CDItemComponentTable::CDItemComponentTable() {
|
||||
}
|
||||
|
||||
tableSize.finalize();
|
||||
this->m_entries.reserve(size);
|
||||
//this->m_entries.reserve(size);
|
||||
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ItemComponent");
|
||||
while (!tableData.eof()) {
|
||||
@@ -47,7 +49,7 @@ CDItemComponentTable::CDItemComponentTable() {
|
||||
entry.delResIndex = tableData.getIntField(28, int{});
|
||||
entry.currencyLOT = tableData.getIntField(29, int{});
|
||||
entry.altCurrencyCost = tableData.getIntField(30, int{});
|
||||
this->m_entries.push_back(entry);
|
||||
//this->m_entries.push_back(entry);
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
@@ -61,14 +63,11 @@ std::string CDItemComponentTable::GetName(void) const {
|
||||
return "ItemComponent";
|
||||
}
|
||||
|
||||
std::vector<CDItemComponent> CDItemComponentTable::Query(std::function<bool(CDItemComponent)> predicate) {
|
||||
std::vector<CDItemComponent> data = cpplinq::from(this->m_entries)
|
||||
>> cpplinq::where(predicate)
|
||||
>> cpplinq::to_vector();
|
||||
const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int skillID) {
|
||||
const auto& it = this->entries.find(skillID);
|
||||
if (it != this->entries.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
std::vector<CDItemComponent> CDItemComponentTable::GetEntries(void) const {
|
||||
return this->m_entries;
|
||||
}
|
||||
return Default;
|
||||
}
|
||||
@@ -40,12 +40,12 @@ struct CDItemComponent {
|
||||
|
||||
class CDItemComponentTable : public CDTable {
|
||||
private:
|
||||
std::vector<CDItemComponent> m_entries;
|
||||
std::map<unsigned int, CDItemComponent> entries;
|
||||
public:
|
||||
CDItemComponentTable();
|
||||
~CDItemComponentTable();
|
||||
std::string GetName(void) const override;
|
||||
|
||||
std::vector<CDItemComponent> Query(std::function<bool(CDItemComponent)> predicate);
|
||||
std::vector<CDItemComponent> GetEntries(void) const;
|
||||
static CDItemComponent Default;
|
||||
const CDItemComponent& GetItemComponentByID(unsigned int skillID);
|
||||
};
|
||||
|
||||
@@ -52,3 +52,17 @@ std::vector<CDMissionTasks> CDMissionTasksTable::Query(std::function<bool(CDMiss
|
||||
std::vector<CDMissionTasks> CDMissionTasksTable::GetEntries(void) const {
|
||||
return this->m_entries;
|
||||
}
|
||||
|
||||
std::vector<CDMissionTasks*> CDMissionTasksTable::GetByMissionID(uint32_t missionID) {
|
||||
std::vector<CDMissionTasks*> tasks;
|
||||
|
||||
for (auto& entry : this->m_entries) {
|
||||
if (entry.id == missionID) {
|
||||
CDMissionTasks* task = const_cast<CDMissionTasks*>(&entry);
|
||||
|
||||
tasks.push_back(task);
|
||||
}
|
||||
}
|
||||
|
||||
return tasks;
|
||||
}
|
||||
@@ -26,6 +26,8 @@ public:
|
||||
~CDMissionTasksTable();
|
||||
std::string GetName(void) const override;
|
||||
|
||||
std::vector<CDMissionTasks> Query(std::function<bool(CDMissionTasks)> predicate);
|
||||
std::vector<CDMissionTasks> Query(std::function<bool(CDMissionTasks)> predicate);
|
||||
std::vector<CDMissionTasks> GetEntries(void) const;
|
||||
|
||||
std::vector<CDMissionTasks*> GetByMissionID(uint32_t missionID);
|
||||
};
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
//Generated by xmlDb2dDatabaseGenerator on 2022-03-04 00:23:33.212261
|
||||
//DO NOT EDIT THIS FILE MANUALLY!
|
||||
|
||||
CDMissions CDMissionsTable::Default = {};
|
||||
|
||||
CDMissionsTable::CDMissionsTable() {
|
||||
unsigned int size = 0;
|
||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Missions");
|
||||
@@ -83,3 +85,27 @@ std::vector<CDMissions> CDMissionsTable::Query(std::function<bool(CDMissions)> p
|
||||
std::vector<CDMissions> CDMissionsTable::GetEntries(void) const {
|
||||
return this->m_entries;
|
||||
}
|
||||
|
||||
const CDMissions* CDMissionsTable::GetPtrByMissionID(uint32_t missionID) const {
|
||||
for (const auto& entry : m_entries) {
|
||||
if (entry.id == missionID) {
|
||||
return const_cast<CDMissions*>(&entry);
|
||||
}
|
||||
}
|
||||
|
||||
return &Default;
|
||||
}
|
||||
|
||||
const CDMissions& CDMissionsTable::GetByMissionID(uint32_t missionID, bool& found) const {
|
||||
for (const auto& entry : m_entries) {
|
||||
if (entry.id == missionID) {
|
||||
found = true;
|
||||
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
||||
found = false;
|
||||
|
||||
return Default;
|
||||
}
|
||||
@@ -57,6 +57,11 @@ public:
|
||||
~CDMissionsTable();
|
||||
std::string GetName(void) const override;
|
||||
|
||||
std::vector<CDMissions> Query(std::function<bool(CDMissions)> predicate);
|
||||
std::vector<CDMissions> Query(std::function<bool(CDMissions)> predicate);
|
||||
std::vector<CDMissions> GetEntries(void) const;
|
||||
|
||||
const CDMissions* GetPtrByMissionID(uint32_t missionID) const;
|
||||
|
||||
const CDMissions& GetByMissionID(uint32_t missionID, bool& found) const;
|
||||
static CDMissions Default;
|
||||
};
|
||||
|
||||
@@ -27,6 +27,7 @@ CDObjectsTable::CDObjectsTable() {
|
||||
entry.interactionDistance = tableData.getFloatField(8, float{});
|
||||
entry.nametag = tableData.getIntField(9, bool{});
|
||||
this->m_entries.push_back(entry);
|
||||
this->m_mappedEntries.insert(std::make_pair(entry.id, entry));
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
@@ -51,3 +52,12 @@ std::vector<CDObjects> CDObjectsTable::Query(std::function<bool(CDObjects)> pred
|
||||
std::vector<CDObjects> CDObjectsTable::GetEntries(void) const {
|
||||
return this->m_entries;
|
||||
}
|
||||
|
||||
CDObjects CDObjectsTable::GetByID(unsigned int lot) {
|
||||
const auto& it = this->m_mappedEntries.find(lot);
|
||||
if (it != this->m_mappedEntries.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return m_default;
|
||||
}
|
||||
@@ -20,6 +20,9 @@ struct CDObjects {
|
||||
class CDObjectsTable : public CDTable {
|
||||
private:
|
||||
std::vector<CDObjects> m_entries;
|
||||
std::map<int, CDObjects> m_mappedEntries;
|
||||
CDObjects m_default{};
|
||||
|
||||
public:
|
||||
CDObjectsTable();
|
||||
~CDObjectsTable();
|
||||
@@ -27,4 +30,6 @@ public:
|
||||
|
||||
std::vector<CDObjects> Query(std::function<bool(CDObjects)> predicate);
|
||||
std::vector<CDObjects> GetEntries(void) const;
|
||||
|
||||
CDObjects GetByID(unsigned int lot);
|
||||
};
|
||||
|
||||
@@ -32,6 +32,7 @@ CDPhysicsComponentTable::CDPhysicsComponentTable() {
|
||||
entry.jumpAirSpeed = tableData.getFloatField(13, float{});
|
||||
entry.friction = tableData.getFloatField(14, float{});
|
||||
this->m_entries.push_back(entry);
|
||||
m_mappedEntities.insert(std::make_pair(entry.id, entry));
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
@@ -56,3 +57,11 @@ std::vector<CDPhysicsComponent> CDPhysicsComponentTable::Query(std::function<boo
|
||||
std::vector<CDPhysicsComponent> CDPhysicsComponentTable::GetEntries(void) const {
|
||||
return this->m_entries;
|
||||
}
|
||||
|
||||
CDPhysicsComponent* CDPhysicsComponentTable::GetByID(unsigned int ID) {
|
||||
for (auto e : m_mappedEntities) {
|
||||
if (e.first == ID) return &e.second;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@@ -25,11 +25,15 @@ struct CDPhysicsComponent {
|
||||
class CDPhysicsComponentTable : public CDTable {
|
||||
private:
|
||||
std::vector<CDPhysicsComponent> m_entries;
|
||||
std::map<int, CDPhysicsComponent> m_mappedEntities;
|
||||
|
||||
public:
|
||||
CDPhysicsComponentTable();
|
||||
~CDPhysicsComponentTable();
|
||||
std::string GetName(void) const override;
|
||||
|
||||
std::vector<CDPhysicsComponent> Query(std::function<bool(CDPhysicsComponent)> predicate);
|
||||
std::vector<CDPhysicsComponent> Query(std::function<bool(CDPhysicsComponent)> predicate);
|
||||
std::vector<CDPhysicsComponent> GetEntries(void) const;
|
||||
|
||||
CDPhysicsComponent* GetByID(unsigned int ID);
|
||||
};
|
||||
|
||||
@@ -19,6 +19,7 @@ CDScriptComponentTable::CDScriptComponentTable() {
|
||||
entry.id = tableData.getIntField(0, int{});
|
||||
entry.script_name = tableData.getStringField(1, std::string{}.c_str());
|
||||
entry.client_script_name = tableData.getStringField(2, std::string{}.c_str());
|
||||
this->entries.insert(std::make_pair(entry.id, entry));
|
||||
this->m_entries.push_back(entry);
|
||||
tableData.nextRow();
|
||||
}
|
||||
@@ -44,3 +45,12 @@ std::vector<CDScriptComponent> CDScriptComponentTable::Query(std::function<bool(
|
||||
std::vector<CDScriptComponent> CDScriptComponentTable::GetEntries(void) const {
|
||||
return this->m_entries;
|
||||
}
|
||||
|
||||
const CDScriptComponent& CDScriptComponentTable::GetByID(int id) {
|
||||
std::map<int, CDScriptComponent>::iterator it = this->entries.find(id);
|
||||
if (it != this->entries.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return m_default;
|
||||
}
|
||||
@@ -13,11 +13,17 @@ struct CDScriptComponent {
|
||||
class CDScriptComponentTable : public CDTable {
|
||||
private:
|
||||
std::vector<CDScriptComponent> m_entries;
|
||||
std::map<int, CDScriptComponent> entries;
|
||||
|
||||
CDScriptComponent m_default{};
|
||||
|
||||
public:
|
||||
CDScriptComponentTable();
|
||||
~CDScriptComponentTable();
|
||||
std::string GetName(void) const override;
|
||||
|
||||
std::vector<CDScriptComponent> Query(std::function<bool(CDScriptComponent)> predicate);
|
||||
std::vector<CDScriptComponent> Query(std::function<bool(CDScriptComponent)> predicate);
|
||||
std::vector<CDScriptComponent> GetEntries(void) const;
|
||||
|
||||
const CDScriptComponent& GetByID(int id);
|
||||
};
|
||||
|
||||
@@ -37,6 +37,7 @@ CDSkillBehaviorTable::CDSkillBehaviorTable() {
|
||||
entry.damageUI = tableData.getIntField(18, int{});
|
||||
entry.descriptionUI = tableData.getStringField(19, std::string{}.c_str());
|
||||
this->m_entries.push_back(entry);
|
||||
this->entries.insert(std::make_pair(entry.skillID, entry));
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
@@ -61,3 +62,12 @@ std::vector<CDSkillBehavior> CDSkillBehaviorTable::Query(std::function<bool(CDSk
|
||||
std::vector<CDSkillBehavior> CDSkillBehaviorTable::GetEntries(void) const {
|
||||
return this->m_entries;
|
||||
}
|
||||
|
||||
CDSkillBehavior CDSkillBehaviorTable::GetSkillByID(int id) {
|
||||
const auto& it = this->entries.find(id);
|
||||
if (it != this->entries.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return m_default;
|
||||
}
|
||||
@@ -30,11 +30,17 @@ struct CDSkillBehavior {
|
||||
class CDSkillBehaviorTable : public CDTable {
|
||||
private:
|
||||
std::vector<CDSkillBehavior> m_entries;
|
||||
std::map<int, CDSkillBehavior> entries;
|
||||
|
||||
CDSkillBehavior m_default{};
|
||||
|
||||
public:
|
||||
CDSkillBehaviorTable();
|
||||
~CDSkillBehaviorTable();
|
||||
std::string GetName(void) const override;
|
||||
|
||||
std::vector<CDSkillBehavior> Query(std::function<bool(CDSkillBehavior)> predicate);
|
||||
std::vector<CDSkillBehavior> Query(std::function<bool(CDSkillBehavior)> predicate);
|
||||
std::vector<CDSkillBehavior> GetEntries(void) const;
|
||||
|
||||
CDSkillBehavior GetSkillByID(int id);
|
||||
};
|
||||
|
||||
@@ -11,7 +11,6 @@ CDZoneTableTable::CDZoneTableTable() {
|
||||
}
|
||||
|
||||
tableSize.finalize();
|
||||
this->m_entries.reserve(size);
|
||||
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ZoneTable");
|
||||
while (!tableData.eof()) {
|
||||
@@ -30,7 +29,7 @@ CDZoneTableTable::CDZoneTableTable() {
|
||||
entry.clientPhysicsFramerate = tableData.getStringField(11, std::string{}.c_str());
|
||||
entry.serverPhysicsFramerate = tableData.getStringField(12, std::string{}.c_str());
|
||||
entry.zoneControlTemplate = tableData.getIntField(13, int{});
|
||||
this->m_entries.push_back(entry);
|
||||
this->m_Entries.insert(std::make_pair(entry.zoneID, entry));
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
@@ -44,14 +43,12 @@ std::string CDZoneTableTable::GetName(void) const {
|
||||
return "ZoneTable";
|
||||
}
|
||||
|
||||
std::vector<CDZoneTable> CDZoneTableTable::Query(std::function<bool(CDZoneTable)> predicate) {
|
||||
std::vector<CDZoneTable> data = cpplinq::from(this->m_entries)
|
||||
>> cpplinq::where(predicate)
|
||||
>> cpplinq::to_vector();
|
||||
const CDZoneTable* CDZoneTableTable::Query(unsigned int zoneID) {
|
||||
const auto& iter = m_Entries.find(zoneID);
|
||||
|
||||
return data;
|
||||
}
|
||||
if (iter != m_Entries.end()) {
|
||||
return &iter->second;
|
||||
}
|
||||
|
||||
std::vector<CDZoneTable> CDZoneTableTable::GetEntries(void) const {
|
||||
return this->m_entries;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -23,12 +23,12 @@ struct CDZoneTable {
|
||||
|
||||
class CDZoneTableTable : public CDTable {
|
||||
private:
|
||||
std::vector<CDZoneTable> m_entries;
|
||||
std::map<unsigned int, CDZoneTable> m_Entries;
|
||||
|
||||
public:
|
||||
CDZoneTableTable();
|
||||
~CDZoneTableTable();
|
||||
std::string GetName(void) const override;
|
||||
|
||||
std::vector<CDZoneTable> Query(std::function<bool(CDZoneTable)> predicate);
|
||||
std::vector<CDZoneTable> GetEntries(void) const;
|
||||
const CDZoneTable* Query(unsigned int zoneID);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user