mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-05-23 07:12:24 +00:00
switch to unordered
This commit is contained in:
parent
6f2d583ca2
commit
0642b4ac55
@ -1,34 +1,21 @@
|
|||||||
#include "CDScriptComponentTable.h"
|
#include "CDScriptComponentTable.h"
|
||||||
|
|
||||||
void CDScriptComponentTable::LoadValuesFromDatabase() {
|
void CDScriptComponentTable::LoadValuesFromDatabase() {
|
||||||
// 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;
|
||||||
entry.id = tableData.getIntField("id", -1);
|
uint32_t 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(std::make_pair(entry.id, entry));
|
this->entries.insert_or_assign(id, entry);
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
tableData.finalize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::optional<CDScriptComponent> CDScriptComponentTable::GetByID(unsigned int id) {
|
const std::optional<CDScriptComponent> CDScriptComponentTable::GetByID(unsigned int id) {
|
||||||
std::map<unsigned int, CDScriptComponent>::iterator it = this->entries.find(id);
|
auto it = this->entries.find(id);
|
||||||
return (it != this->entries.end()) ? std::make_optional<CDScriptComponent>(it->second) : std::nullopt;
|
return (it != this->entries.end()) ? std::make_optional<CDScriptComponent>(it->second) : std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,14 +4,13 @@
|
|||||||
#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::map<unsigned int, CDScriptComponent> entries;
|
std::unordered_map<unsigned int, CDScriptComponent> entries;
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
void LoadValuesFromDatabase();
|
||||||
// Gets an entry by scriptID
|
// Gets an entry by scriptID
|
||||||
|
@ -1,25 +1,10 @@
|
|||||||
#include "CDSkillBehaviorTable.h"
|
#include "CDSkillBehaviorTable.h"
|
||||||
|
|
||||||
void CDSkillBehaviorTable::LoadValuesFromDatabase() {
|
void CDSkillBehaviorTable::LoadValuesFromDatabase() {
|
||||||
// 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;
|
||||||
entry.skillID = tableData.getIntField("skillID", -1);
|
uint32_t 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);
|
||||||
@ -39,12 +24,9 @@ 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(std::make_pair(entry.skillID, entry));
|
this->entries.insert_or_assign(skillID, entry);
|
||||||
//this->entries.push_back(entry);
|
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
tableData.finalize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::optional<CDSkillBehavior> CDSkillBehaviorTable::GetSkillByID(unsigned int skillID) {
|
const std::optional<CDSkillBehavior> CDSkillBehaviorTable::GetSkillByID(unsigned int skillID) {
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#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
|
||||||
@ -27,7 +26,7 @@ struct CDSkillBehavior {
|
|||||||
|
|
||||||
class CDSkillBehaviorTable : public CDTable<CDSkillBehaviorTable> {
|
class CDSkillBehaviorTable : public CDTable<CDSkillBehaviorTable> {
|
||||||
private:
|
private:
|
||||||
std::map<unsigned int, CDSkillBehavior> entries;
|
std::unordered_map<uint32_t, CDSkillBehavior> entries;
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
void LoadValuesFromDatabase();
|
||||||
|
|
||||||
|
@ -14,8 +14,6 @@ void CDVendorComponentTable::LoadValuesFromDatabase() {
|
|||||||
this->entries.insert_or_assign(id, entry);
|
this->entries.insert_or_assign(id, entry);
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
tableData.finalize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::optional<CDVendorComponent> CDVendorComponentTable::Query(uint32_t id) {
|
const std::optional<CDVendorComponent> CDVendorComponentTable::Query(uint32_t id) {
|
||||||
|
@ -12,7 +12,7 @@ struct CDVendorComponent {
|
|||||||
|
|
||||||
class CDVendorComponentTable : public CDTable<CDVendorComponentTable> {
|
class CDVendorComponentTable : public CDTable<CDVendorComponentTable> {
|
||||||
private:
|
private:
|
||||||
std::map<uint32_t, CDVendorComponent> entries;
|
std::unordered_map<uint32_t, CDVendorComponent> entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
void LoadValuesFromDatabase();
|
||||||
|
@ -1,18 +1,6 @@
|
|||||||
#include "CDZoneTableTable.h"
|
#include "CDZoneTableTable.h"
|
||||||
|
|
||||||
void CDZoneTableTable::LoadValuesFromDatabase() {
|
void CDZoneTableTable::LoadValuesFromDatabase() {
|
||||||
|
|
||||||
// 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()) {
|
||||||
@ -48,8 +36,6 @@ 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.
|
||||||
|
@ -34,7 +34,7 @@ struct CDZoneTable {
|
|||||||
|
|
||||||
class CDZoneTableTable : public CDTable<CDZoneTableTable> {
|
class CDZoneTableTable : public CDTable<CDZoneTableTable> {
|
||||||
private:
|
private:
|
||||||
std::map<unsigned int, CDZoneTable> m_Entries;
|
std::unordered_map<uint32_t, CDZoneTable> m_Entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
void LoadValuesFromDatabase();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user