DarkflameServer/dDatabase/CDClientDatabase/CDClientTables/CDRewardsTable.cpp

31 lines
900 B
C++
Raw Permalink Normal View History

#include "CDRewardsTable.h"
void CDRewardsTable::LoadValuesFromDatabase() {
2022-07-28 13:39:57 +00:00
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Rewards");
auto& entries = GetEntriesMutable();
2022-07-28 13:39:57 +00:00
while (!tableData.eof()) {
CDRewards entry;
entry.id = tableData.getIntField("id", -1);
entry.levelID = tableData.getIntField("LevelID", -1);
entry.missionID = tableData.getIntField("MissionID", -1);
entry.rewardType = tableData.getIntField("RewardType", -1);
entry.value = tableData.getIntField("value", -1);
entry.count = tableData.getIntField("count", -1);
entries.insert(std::make_pair(entry.id, entry));
2022-07-28 13:39:57 +00:00
tableData.nextRow();
}
tableData.finalize();
}
std::vector<CDRewards> CDRewardsTable::GetByLevelID(uint32_t levelID) {
std::vector<CDRewards> result{};
for (const auto& e : GetEntries()) {
if (e.second.levelID == levelID) result.push_back(e.second);
2022-07-28 13:39:57 +00:00
}
return result;
}