2021-12-05 17:54:36 +00:00
|
|
|
#include "CDZoneTableTable.h"
|
|
|
|
|
2023-08-11 04:27:40 +00:00
|
|
|
void CDZoneTableTable::LoadValuesFromDatabase() {
|
2022-07-28 13:39:57 +00:00
|
|
|
|
|
|
|
// First, get the size of the table
|
2024-01-09 07:54:14 +00:00
|
|
|
uint32_t size = 0;
|
2022-07-28 13:39:57 +00:00
|
|
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ZoneTable");
|
|
|
|
while (!tableSize.eof()) {
|
|
|
|
size = tableSize.getIntField(0, 0);
|
|
|
|
|
|
|
|
tableSize.nextRow();
|
|
|
|
}
|
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
tableSize.finalize();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
|
|
|
// Now get the data
|
|
|
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ZoneTable");
|
|
|
|
while (!tableData.eof()) {
|
|
|
|
CDZoneTable entry;
|
2023-01-07 09:48:59 +00:00
|
|
|
entry.zoneID = tableData.getIntField("zoneID", -1);
|
|
|
|
entry.locStatus = tableData.getIntField("locStatus", -1);
|
|
|
|
entry.zoneName = tableData.getStringField("zoneName", "");
|
|
|
|
entry.scriptID = tableData.getIntField("scriptID", -1);
|
|
|
|
entry.ghostdistance_min = tableData.getFloatField("ghostdistance_min", -1.0f);
|
|
|
|
entry.ghostdistance = tableData.getFloatField("ghostdistance", -1.0f);
|
|
|
|
entry.population_soft_cap = tableData.getIntField("population_soft_cap", -1);
|
|
|
|
entry.population_hard_cap = tableData.getIntField("population_hard_cap", -1);
|
|
|
|
UNUSED(entry.DisplayDescription = tableData.getStringField("DisplayDescription", ""));
|
|
|
|
UNUSED(entry.mapFolder = tableData.getStringField("mapFolder", ""));
|
|
|
|
entry.smashableMinDistance = tableData.getFloatField("smashableMinDistance", -1.0f);
|
|
|
|
entry.smashableMaxDistance = tableData.getFloatField("smashableMaxDistance", -1.0f);
|
|
|
|
UNUSED(entry.mixerProgram = tableData.getStringField("mixerProgram", ""));
|
|
|
|
UNUSED(entry.clientPhysicsFramerate = tableData.getStringField("clientPhysicsFramerate", ""));
|
2023-11-14 13:02:17 +00:00
|
|
|
entry.serverPhysicsFramerate = tableData.getStringField("serverPhysicsFramerate", "");
|
2023-01-07 09:48:59 +00:00
|
|
|
entry.zoneControlTemplate = tableData.getIntField("zoneControlTemplate", -1);
|
|
|
|
entry.widthInChunks = tableData.getIntField("widthInChunks", -1);
|
|
|
|
entry.heightInChunks = tableData.getIntField("heightInChunks", -1);
|
|
|
|
entry.petsAllowed = tableData.getIntField("petsAllowed", -1) == 1 ? true : false;
|
|
|
|
entry.localize = tableData.getIntField("localize", -1) == 1 ? true : false;
|
|
|
|
entry.fZoneWeight = tableData.getFloatField("fZoneWeight", -1.0f);
|
|
|
|
UNUSED(entry.thumbnail = tableData.getStringField("thumbnail", ""));
|
|
|
|
entry.PlayerLoseCoinsOnDeath = tableData.getIntField("PlayerLoseCoinsOnDeath", -1) == 1 ? true : false;
|
2023-11-14 13:02:17 +00:00
|
|
|
entry.disableSaveLoc = tableData.getIntField("disableSaveLoc", -1) == 1 ? true : false;
|
2023-01-07 09:48:59 +00:00
|
|
|
entry.teamRadius = tableData.getFloatField("teamRadius", -1.0f);
|
|
|
|
UNUSED(entry.gate_version = tableData.getStringField("gate_version", ""));
|
2023-11-14 13:02:17 +00:00
|
|
|
entry.mountsAllowed = tableData.getIntField("mountsAllowed", -1) == 1 ? true : false;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
this->m_Entries.insert(std::make_pair(entry.zoneID, entry));
|
2022-07-28 13:39:57 +00:00
|
|
|
tableData.nextRow();
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
tableData.finalize();
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Queries the table with a zoneID to find.
|
2024-01-09 07:54:14 +00:00
|
|
|
const CDZoneTable* CDZoneTableTable::Query(uint32_t zoneID) {
|
2022-07-28 13:39:57 +00:00
|
|
|
const auto& iter = m_Entries.find(zoneID);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (iter != m_Entries.end()) {
|
|
|
|
return &iter->second;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
return nullptr;
|
2022-07-28 13:39:57 +00:00
|
|
|
}
|
2023-01-07 09:48:59 +00:00
|
|
|
|