Add more assertions to prevent segfaults.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
1b9da9a721
commit
d55a9e8494
|
@ -122,6 +122,8 @@ const ArbUt::BorrowedPtr<CreatureLib::Battling::BattleSide>& Battling::Creature:
|
||||||
bool Battling::Creature::IsFainted() const noexcept { return this->_currentHealth == 0; }
|
bool Battling::Creature::IsFainted() const noexcept { return this->_currentHealth == 0; }
|
||||||
|
|
||||||
void Battling::Creature::OnFaint() {
|
void Battling::Creature::OnFaint() {
|
||||||
|
AssertNotNull(_battle)
|
||||||
|
AssertNotNull(_side)
|
||||||
// HOOK: On Faint
|
// HOOK: On Faint
|
||||||
if (_battle != nullptr) {
|
if (_battle != nullptr) {
|
||||||
_battle->TriggerEventListener<FaintEvent>(this);
|
_battle->TriggerEventListener<FaintEvent>(this);
|
||||||
|
@ -148,7 +150,7 @@ void Battling::Creature::Damage(uint32_t damage, Battling::DamageSource source)
|
||||||
}
|
}
|
||||||
_currentHealth = newHealth;
|
_currentHealth = newHealth;
|
||||||
|
|
||||||
if (IsFainted() && damage > 0) {
|
if (IsFainted() && damage > 0 && battle != nullptr) {
|
||||||
OnFaint();
|
OnFaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue