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

This commit is contained in:
Deukhoofd committed 2020-08-02 09:52:11 +02:00
1 parent 1b9da9a721
commit d55a9e8494
1 file changed
+3 -1
+3 -1
View File
@@ -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();
}
}