When setting variant of species with the same name of already existing variant, delete previous variant.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-02-09 12:04:59 +01:00
parent 3f57051219
commit 80708040a4
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 7 additions and 1 deletions

View File

@ -40,7 +40,13 @@ namespace CreatureLib::Library {
[[nodiscard]] Gender GetRandomGender(Core::Random& rand) const; [[nodiscard]] Gender GetRandomGender(Core::Random& rand) const;
[[nodiscard]] const std::string& GetName() const; [[nodiscard]] const std::string& GetName() const;
void SetVariant(const std::string& name, const SpeciesVariant* variant) { _variants.insert({name, variant}); } void SetVariant(const std::string& name, const SpeciesVariant* variant) {
auto find = _variants.find(name);
if (find != _variants.end()) {
delete find->second;
}
_variants[name] = variant;
}
}; };
} }