When setting variant of species with the same name of already existing variant, delete previous variant.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
3f57051219
commit
80708040a4
|
@ -40,7 +40,13 @@ namespace CreatureLib::Library {
|
|||
[[nodiscard]] Gender GetRandomGender(Core::Random& rand) 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;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue