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; }
|
||||
|
||||
void Battling::Creature::OnFaint() {
|
||||
AssertNotNull(_battle)
|
||||
AssertNotNull(_side)
|
||||
// HOOK: On Faint
|
||||
if (_battle != nullptr) {
|
||||
_battle->TriggerEventListener<FaintEvent>(this);
|
||||
|
@ -148,7 +150,7 @@ void Battling::Creature::Damage(uint32_t damage, Battling::DamageSource source)
|
|||
}
|
||||
_currentHealth = newHealth;
|
||||
|
||||
if (IsFainted() && damage > 0) {
|
||||
if (IsFainted() && damage > 0 && battle != nullptr) {
|
||||
OnFaint();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue