mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-23 05:57:20 +00:00
7671cc6865
* CDClient cleanup and optimization - Use static function to get table name - Remove unused GetName function - Replace above function with a static GetTableName function - Remove verbose comments - Remove verbose initializers - Remove need to specify table name when getting a table by name - Remove unused typedef for mac and linux * Re-add unused table Convert tables to singletons - Convert all CDClient tables to singletons - Move Singleton.h to dCommon - Reduce header clutter in CDClientManager
38 lines
1009 B
C++
38 lines
1009 B
C++
#include "CDRewardsTable.h"
|
|
|
|
CDRewardsTable::CDRewardsTable(void) {
|
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Rewards");
|
|
while (!tableData.eof()) {
|
|
CDRewards* entry = new CDRewards();
|
|
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);
|
|
|
|
m_entries.insert(std::make_pair(entry->id, entry));
|
|
tableData.nextRow();
|
|
}
|
|
|
|
tableData.finalize();
|
|
}
|
|
|
|
CDRewardsTable::~CDRewardsTable(void) {
|
|
for (auto e : m_entries) {
|
|
if (e.second) delete e.second;
|
|
}
|
|
|
|
m_entries.clear();
|
|
}
|
|
|
|
std::vector<CDRewards*> CDRewardsTable::GetByLevelID(uint32_t levelID) {
|
|
std::vector<CDRewards*> result{};
|
|
for (const auto& e : m_entries) {
|
|
if (e.second->levelID == levelID) result.push_back(e.second);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|