Fixed Segfault when overriding talent.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
fa5184ad77
commit
670abd7229
|
@ -171,9 +171,11 @@ void Battling::Creature::Heal(uint32_t amount, bool canRevive) {
|
||||||
|
|
||||||
void Battling::Creature::OverrideActiveTalent(const ArbUt::StringView& talent) {
|
void Battling::Creature::OverrideActiveTalent(const ArbUt::StringView& talent) {
|
||||||
_hasOverridenTalent = true;
|
_hasOverridenTalent = true;
|
||||||
|
if (_activeTalent != nullptr) {
|
||||||
_activeTalent->OnRemove();
|
_activeTalent->OnRemove();
|
||||||
_overridenTalentName = talent;
|
|
||||||
_activeTalent.reset(this->_library->LoadScript(ScriptCategory::Talent, talent));
|
_activeTalent.reset(this->_library->LoadScript(ScriptCategory::Talent, talent));
|
||||||
|
}
|
||||||
|
_overridenTalentName = talent;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::unordered_set<uint8_t>& Battling::Creature::GetTypes() const noexcept { return _types; }
|
const std::unordered_set<uint8_t>& Battling::Creature::GetTypes() const noexcept { return _types; }
|
||||||
|
|
|
@ -46,4 +46,12 @@ TEST_CASE("Increase creature stat boost", "[Library]") {
|
||||||
delete creature;
|
delete creature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Override Creature talent", "[Library]") {
|
||||||
|
auto library = TestLibrary::Get();
|
||||||
|
auto creature = CreateCreature(library, "testSpecies1"_cnc, 1).Create();
|
||||||
|
creature->OverrideActiveTalent("foobar");
|
||||||
|
REQUIRE(creature->GetActiveTalent() == "foobar");
|
||||||
|
delete creature;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue