diff --git a/src/Library/GrowthRates/GrowthRateLibrary.cpp b/src/Library/GrowthRates/GrowthRateLibrary.cpp index 0d582ea..7b3be6e 100644 --- a/src/Library/GrowthRates/GrowthRateLibrary.cpp +++ b/src/Library/GrowthRates/GrowthRateLibrary.cpp @@ -37,9 +37,9 @@ uint32_t CreatureLib::Library::GrowthRateLibrary::CalculateExperience(uint32_t h void CreatureLib::Library::GrowthRateLibrary::AddGrowthRate(const ConstString& name, CreatureLib::Library::GrowthRate* rate) { - _growthRates.insert({name, rate}); + _growthRates.insert({name, std::unique_ptr(rate)}); } void CreatureLib::Library::GrowthRateLibrary::AddGrowthRate(uint32_t hash, CreatureLib::Library::GrowthRate* rate) { - _growthRates.insert({hash, rate}); + _growthRates.insert({hash, std::unique_ptr(rate)}); } diff --git a/src/Library/GrowthRates/GrowthRateLibrary.hpp b/src/Library/GrowthRates/GrowthRateLibrary.hpp index de74d93..27f3e9d 100644 --- a/src/Library/GrowthRates/GrowthRateLibrary.hpp +++ b/src/Library/GrowthRates/GrowthRateLibrary.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include "GrowthRate.hpp" @@ -12,17 +13,13 @@ using ConstString = Arbutils::CaseInsensitiveConstString; namespace CreatureLib::Library { class GrowthRateLibrary { private: - std::unordered_map _growthRates; + std::unordered_map> _growthRates; public: GrowthRateLibrary(size_t initialCapacity = 10) - : _growthRates(std::unordered_map(initialCapacity)) {} + : _growthRates(std::unordered_map>(initialCapacity)) {} - virtual ~GrowthRateLibrary() { - for (auto gr : _growthRates) { - delete gr.second; - } - } + virtual ~GrowthRateLibrary() = default; [[nodiscard]] uint8_t CalculateLevel(const ConstString& growthRate, uint32_t experience) const; [[nodiscard]] uint8_t CalculateLevel(uint32_t hash, uint32_t experience) const;