2021-12-05 17:54:36 +00:00
|
|
|
#include "CDRarityTableTable.h"
|
|
|
|
|
2023-08-11 04:27:40 +00:00
|
|
|
void CDRarityTableTable::LoadValuesFromDatabase() {
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
// First, get the size of the table
|
|
|
|
unsigned int size = 0;
|
|
|
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM RarityTable");
|
|
|
|
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
|
|
|
|
|
|
|
// Reserve the size
|
|
|
|
this->entries.reserve(size);
|
|
|
|
|
|
|
|
// Now get the data
|
2023-10-09 20:33:22 +00:00
|
|
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM RarityTable order by randmax desc;");
|
2022-07-28 13:39:57 +00:00
|
|
|
while (!tableData.eof()) {
|
2023-10-09 20:33:22 +00:00
|
|
|
uint32_t rarityTableIndex = tableData.getIntField("RarityTableIndex", -1);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
CDRarityTable entry;
|
2023-01-07 09:48:59 +00:00
|
|
|
entry.randmax = tableData.getFloatField("randmax", -1);
|
|
|
|
entry.rarity = tableData.getIntField("rarity", -1);
|
2023-10-09 20:33:22 +00:00
|
|
|
entries[rarityTableIndex].push_back(entry);
|
2022-07-28 13:39:57 +00:00
|
|
|
tableData.nextRow();
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2023-10-09 20:33:22 +00:00
|
|
|
const std::vector<CDRarityTable>& CDRarityTableTable::GetRarityTable(uint32_t id) {
|
|
|
|
return entries[id];
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|