From 15b63f3cbdb6943829c0067a46c0a9f6c00c0392 Mon Sep 17 00:00:00 2001 From: dongresource Date: Wed, 2 Dec 2020 23:32:38 +0100 Subject: [PATCH] Fix regression with a disconnect check in MobManager::combatStep() --- src/MobManager.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/MobManager.cpp b/src/MobManager.cpp index 150e4b1..a2718be 100644 --- a/src/MobManager.cpp +++ b/src/MobManager.cpp @@ -488,11 +488,19 @@ void MobManager::deadStep(Mob *mob, time_t currTime) { void MobManager::combatStep(Mob *mob, time_t currTime) { assert(mob->target != nullptr); + // lose aggro if the player lost connection + if (PlayerManager::players.find(mob->target) == PlayerManager::players.end()) { + mob->target = nullptr; + mob->state = MobState::RETREAT; + if (!aggroCheck(mob, currTime)) + clearDebuff(mob); + return; + } + Player *plr = PlayerManager::getPlayer(mob->target); - // Lose aggro if the player lost connection, became invulnerable or died + // lose aggro if the player became invulnerable or died if (plr->HP <= 0 - || PlayerManager::players.find(mob->target) == PlayerManager::players.end() || (plr->iSpecialState & CN_SPECIAL_STATE_FLAG__INVULNERABLE)) { mob->target = nullptr; mob->state = MobState::RETREAT;