Add more assertions to prevent segfaults.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-08-02 09:52:11 +02:00
parent 1b9da9a721
commit d55a9e8494
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 3 additions and 1 deletions

View File

@ -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();
} }
} }