use reference instead of pointer for cdclient data

This commit is contained in:
jadebenn
2024-01-05 14:50:49 -06:00
parent c575fd9a6c
commit 384083ea18
4 changed files with 55 additions and 59 deletions

View File

@@ -28,7 +28,8 @@ void CDPetComponentTable::LoadValuesFromDatabase() {
}
CDPetComponent* CDPetComponentTable::GetByID(unsigned int componentID) {
CDPetComponent& CDPetComponentTable::GetByID(unsigned int componentID) {
auto itr = m_entries.find(componentID);
return itr != m_entries.end() ? &itr->second : nullptr;
if (itr == m_entries.end()) throw std::exception(); // TODO: Use a default set of values instead?
return itr->second;
}

View File

@@ -25,7 +25,7 @@ public:
void LoadValuesFromDatabase();
static const std::string GetTableName() { return "PetComponent"; };
CDPetComponent* GetByID(unsigned int componentID);
CDPetComponent& GetByID(unsigned int componentID);
private:
std::map<unsigned int, CDPetComponent> m_entries;