Check whether a battle has been set when calling Damage function.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-02-02 12:34:02 +01:00
parent bb9b9609a6
commit fc5826edb1
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 4 additions and 1 deletions

View File

@ -101,7 +101,10 @@ void Battling::Creature::Damage(uint32_t damage, Battling::DamageSource source)
}
// HOOK: On Damage
auto newHealth = _currentHealth - damage;
this->GetBattle()->TriggerEventListener(new DamageEvent(this, source, _currentHealth, newHealth));
auto battle = this->GetBattle();
if (battle != nullptr) {
battle->TriggerEventListener(new DamageEvent(this, source, _currentHealth, newHealth));
}
_currentHealth = newHealth;
if (IsFainted() && damage > 0) {