Fix regression with a disconnect check in MobManager::combatStep()

This commit is contained in:
dongresource 2020-12-02 23:32:38 +01:00
parent ce1a5a7664
commit 15b63f3cbd

View File

@ -488,11 +488,19 @@ void MobManager::deadStep(Mob *mob, time_t currTime) {
void MobManager::combatStep(Mob *mob, time_t currTime) { void MobManager::combatStep(Mob *mob, time_t currTime) {
assert(mob->target != nullptr); 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); 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 if (plr->HP <= 0
|| PlayerManager::players.find(mob->target) == PlayerManager::players.end()
|| (plr->iSpecialState & CN_SPECIAL_STATE_FLAG__INVULNERABLE)) { || (plr->iSpecialState & CN_SPECIAL_STATE_FLAG__INVULNERABLE)) {
mob->target = nullptr; mob->target = nullptr;
mob->state = MobState::RETREAT; mob->state = MobState::RETREAT;