2021-12-05 17:54:36 +00:00
|
|
|
#include "CDVendorComponentTable.h"
|
|
|
|
|
2023-07-25 08:26:52 +00:00
|
|
|
void CDVendorComponentTable::LoadValuesFromDatabase() {
|
2021-12-05 17:54:36 +00:00
|
|
|
// 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);
|
2023-01-07 09:48:59 +00:00
|
|
|
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);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-07-26 04:29:06 +00:00
|
|
|
this->entries.insert_or_assign(id, entry);
|
2021-12-05 17:54:36 +00:00
|
|
|
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;
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|