Fixed memory leak in growth rate library.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2019-12-14 13:42:34 +01:00
parent 649de39571
commit f5a71ca807
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 8 additions and 0 deletions

View File

@ -6,6 +6,8 @@
namespace CreatureLib::Library {
class GrowthRate {
public:
virtual ~GrowthRate() = default;
[[nodiscard]] virtual uint8_t CalculateLevel(uint32_t experience) const = 0;
[[nodiscard]] virtual uint32_t CalculateExperience(uint8_t level) const = 0;
};

View File

@ -12,6 +12,12 @@ namespace CreatureLib::Library {
std::unordered_map<std::string, GrowthRate*> _growthRates;
public:
~GrowthRateLibrary(){
for (auto gr: _growthRates){
delete gr.second;
}
}
[[nodiscard]] uint8_t CalculateLevel(const std::string& growthRate, uint32_t experience) const;
[[nodiscard]] uint32_t CalculateExperience(const std::string& growthRate, uint8_t level) const;