mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-26 15:33:34 +00:00
25 lines
892 B
C++
25 lines
892 B
C++
#include "CDVendorComponentTable.h"
|
|
|
|
void CDVendorComponentTable::LoadValuesFromDatabase() {
|
|
// Now get the data
|
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM VendorComponent");
|
|
while (!tableData.eof()) {
|
|
CDVendorComponent entry;
|
|
uint32_t id = tableData.getIntField("id", -1);
|
|
entry.buyScalar = tableData.getFloatField("buyScalar", -1.0f);
|
|
entry.sellScalar = tableData.getFloatField("sellScalar", -1.0f);
|
|
entry.refreshTimeSeconds = tableData.getFloatField("refreshTimeSeconds", -1.0f);
|
|
entry.LootMatrixIndex = tableData.getIntField("LootMatrixIndex", -1);
|
|
|
|
this->entries.insert_or_assign(id, entry);
|
|
tableData.nextRow();
|
|
}
|
|
|
|
tableData.finalize();
|
|
}
|
|
|
|
const std::optional<CDVendorComponent> CDVendorComponentTable::Query(uint32_t id) {
|
|
const auto& iter = entries.find(id);
|
|
return iter != entries.end() ? std::make_optional(iter->second) : std::nullopt;
|
|
}
|