mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-24 14:33:34 +00:00
switch to unordered
This commit is contained in:
parent
6f2d583ca2
commit
0642b4ac55
@ -1,34 +1,21 @@
|
||||
#include "CDScriptComponentTable.h"
|
||||
|
||||
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
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ScriptComponent");
|
||||
while (!tableData.eof()) {
|
||||
CDScriptComponent entry;
|
||||
entry.id = tableData.getIntField("id", -1);
|
||||
uint32_t id = tableData.getIntField("id", -1);
|
||||
entry.script_name = tableData.getStringField("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.finalize();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -4,14 +4,13 @@
|
||||
#include "CDTable.h"
|
||||
|
||||
struct CDScriptComponent {
|
||||
unsigned int id; //!< The component ID
|
||||
std::string script_name; //!< The script name
|
||||
std::string client_script_name; //!< The client script name
|
||||
};
|
||||
|
||||
class CDScriptComponentTable : public CDTable<CDScriptComponentTable> {
|
||||
private:
|
||||
std::map<unsigned int, CDScriptComponent> entries;
|
||||
std::unordered_map<unsigned int, CDScriptComponent> entries;
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
// Gets an entry by scriptID
|
||||
|
@ -1,25 +1,10 @@
|
||||
#include "CDSkillBehaviorTable.h"
|
||||
|
||||
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");
|
||||
while (!tableData.eof()) {
|
||||
CDSkillBehavior entry;
|
||||
entry.skillID = tableData.getIntField("skillID", -1);
|
||||
uint32_t skillID = tableData.getIntField("skillID", -1);
|
||||
UNUSED(entry.locStatus = tableData.getIntField("locStatus", -1));
|
||||
entry.behaviorID = tableData.getIntField("behaviorID", -1);
|
||||
entry.imaginationcost = tableData.getIntField("imaginationcost", -1);
|
||||
@ -39,12 +24,9 @@ void CDSkillBehaviorTable::LoadValuesFromDatabase() {
|
||||
UNUSED(entry.gate_version = tableData.getStringField("gate_version", ""));
|
||||
UNUSED(entry.cancelType = tableData.getIntField("cancelType", -1));
|
||||
|
||||
this->entries.insert(std::make_pair(entry.skillID, entry));
|
||||
//this->entries.push_back(entry);
|
||||
this->entries.insert_or_assign(skillID, entry);
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
const std::optional<CDSkillBehavior> CDSkillBehaviorTable::GetSkillByID(unsigned int skillID) {
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "CDTable.h"
|
||||
|
||||
struct CDSkillBehavior {
|
||||
unsigned int skillID; //!< The Skill ID of the skill
|
||||
UNUSED(unsigned int locStatus); //!< ??
|
||||
unsigned int behaviorID; //!< The Behavior ID of the skill
|
||||
unsigned int imaginationcost; //!< The imagination cost of the skill
|
||||
@ -27,7 +26,7 @@ struct CDSkillBehavior {
|
||||
|
||||
class CDSkillBehaviorTable : public CDTable<CDSkillBehaviorTable> {
|
||||
private:
|
||||
std::map<unsigned int, CDSkillBehavior> entries;
|
||||
std::unordered_map<uint32_t, CDSkillBehavior> entries;
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
|
||||
|
@ -14,8 +14,6 @@ void CDVendorComponentTable::LoadValuesFromDatabase() {
|
||||
this->entries.insert_or_assign(id, entry);
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
const std::optional<CDVendorComponent> CDVendorComponentTable::Query(uint32_t id) {
|
||||
|
@ -12,7 +12,7 @@ struct CDVendorComponent {
|
||||
|
||||
class CDVendorComponentTable : public CDTable<CDVendorComponentTable> {
|
||||
private:
|
||||
std::map<uint32_t, CDVendorComponent> entries;
|
||||
std::unordered_map<uint32_t, CDVendorComponent> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
|
@ -1,18 +1,6 @@
|
||||
#include "CDZoneTableTable.h"
|
||||
|
||||
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
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ZoneTable");
|
||||
while (!tableData.eof()) {
|
||||
@ -48,8 +36,6 @@ void CDZoneTableTable::LoadValuesFromDatabase() {
|
||||
this->m_Entries.insert(std::make_pair(entry.zoneID, entry));
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
//! Queries the table with a zoneID to find.
|
||||
|
@ -34,7 +34,7 @@ struct CDZoneTable {
|
||||
|
||||
class CDZoneTableTable : public CDTable<CDZoneTableTable> {
|
||||
private:
|
||||
std::map<unsigned int, CDZoneTable> m_Entries;
|
||||
std::unordered_map<uint32_t, CDZoneTable> m_Entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
|
Loading…
Reference in New Issue
Block a user