Make GrowthRate library be key based on uint32, instead of on the ConstString, to save memory.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
#include "GrowthRateLibrary.hpp"
|
||||
#include <algorithm>
|
||||
#include "../../Core/Exceptions/CreatureException.hpp"
|
||||
|
||||
uint8_t CreatureLib::Library::GrowthRateLibrary::CalculateLevel(const Arbutils::CaseInsensitiveConstString& growthRate,
|
||||
uint8_t CreatureLib::Library::GrowthRateLibrary::CalculateLevel(const ConstString& growthRate,
|
||||
uint32_t experience) const {
|
||||
auto find = _growthRates.find(growthRate);
|
||||
if (find == _growthRates.end()) {
|
||||
@@ -11,16 +10,36 @@ uint8_t CreatureLib::Library::GrowthRateLibrary::CalculateLevel(const Arbutils::
|
||||
return find->second->CalculateLevel(experience);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
CreatureLib::Library::GrowthRateLibrary::CalculateExperience(const Arbutils::CaseInsensitiveConstString& growthRate,
|
||||
uint8_t level) const {
|
||||
uint8_t CreatureLib::Library::GrowthRateLibrary::CalculateLevel(uint32_t hash, uint32_t experience) const {
|
||||
auto find = _growthRates.find(hash);
|
||||
if (find == _growthRates.end()) {
|
||||
throw CreatureException("Invalid growth rate was requested.");
|
||||
}
|
||||
return find->second->CalculateLevel(experience);
|
||||
}
|
||||
|
||||
uint32_t CreatureLib::Library::GrowthRateLibrary::CalculateExperience(const ConstString& growthRate,
|
||||
uint8_t level) const {
|
||||
auto find = _growthRates.find(growthRate);
|
||||
if (find == _growthRates.end()) {
|
||||
throw CreatureException("Invalid growth rate was requested.");
|
||||
}
|
||||
return find->second->CalculateExperience(level);
|
||||
}
|
||||
void CreatureLib::Library::GrowthRateLibrary::AddGrowthRate(const Arbutils::CaseInsensitiveConstString& name,
|
||||
|
||||
uint32_t CreatureLib::Library::GrowthRateLibrary::CalculateExperience(uint32_t hash, uint8_t level) const {
|
||||
auto find = _growthRates.find(hash);
|
||||
if (find == _growthRates.end()) {
|
||||
throw CreatureException("Invalid growth rate was requested.");
|
||||
}
|
||||
return find->second->CalculateExperience(level);
|
||||
}
|
||||
|
||||
void CreatureLib::Library::GrowthRateLibrary::AddGrowthRate(const ConstString& name,
|
||||
CreatureLib::Library::GrowthRate* rate) {
|
||||
_growthRates.insert({name, rate});
|
||||
}
|
||||
|
||||
void CreatureLib::Library::GrowthRateLibrary::AddGrowthRate(uint32_t hash, CreatureLib::Library::GrowthRate* rate) {
|
||||
_growthRates.insert({hash, rate});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user