Fixed memory leak in growth rate library.
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
649de39571
commit
f5a71ca807
|
@ -6,6 +6,8 @@
|
||||||
namespace CreatureLib::Library {
|
namespace CreatureLib::Library {
|
||||||
class GrowthRate {
|
class GrowthRate {
|
||||||
public:
|
public:
|
||||||
|
virtual ~GrowthRate() = default;
|
||||||
|
|
||||||
[[nodiscard]] virtual uint8_t CalculateLevel(uint32_t experience) const = 0;
|
[[nodiscard]] virtual uint8_t CalculateLevel(uint32_t experience) const = 0;
|
||||||
[[nodiscard]] virtual uint32_t CalculateExperience(uint8_t level) const = 0;
|
[[nodiscard]] virtual uint32_t CalculateExperience(uint8_t level) const = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,6 +12,12 @@ namespace CreatureLib::Library {
|
||||||
std::unordered_map<std::string, GrowthRate*> _growthRates;
|
std::unordered_map<std::string, GrowthRate*> _growthRates;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
~GrowthRateLibrary(){
|
||||||
|
for (auto gr: _growthRates){
|
||||||
|
delete gr.second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] uint8_t CalculateLevel(const std::string& growthRate, uint32_t experience) const;
|
[[nodiscard]] uint8_t CalculateLevel(const std::string& growthRate, uint32_t experience) const;
|
||||||
[[nodiscard]] uint32_t CalculateExperience(const std::string& growthRate, uint8_t level) const;
|
[[nodiscard]] uint32_t CalculateExperience(const std::string& growthRate, uint8_t level) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue