DarkflameServer/dDatabase/Tables/CDVendorComponentTable.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
892 B
C++
Raw Normal View History

#include "CDVendorComponentTable.h"
void CDVendorComponentTable::LoadValuesFromDatabase() {
// Now get the data
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM VendorComponent");
while (!tableData.eof()) {
CDVendorComponent entry;
2023-07-26 04:29:06 +00:00
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);
2023-07-26 04:29:06 +00:00
this->entries.insert_or_assign(id, entry);
tableData.nextRow();
}
tableData.finalize();
}
2023-07-26 04:29:06 +00:00
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;
}