Core/Threat: Fix a potential crash that would occur in specific edge cases of AI being a bit naughty.

(cherry picked from commit 1847555c8c)
This commit is contained in:
Treeston
2018-01-15 15:42:41 +01:00
committed by Shauren
parent 08ac27d959
commit 56fcd8ba1d
2 changed files with 5 additions and 5 deletions

View File

@@ -201,7 +201,7 @@ bool CombatManager::SetInCombatWith(Unit* who)
NotifyAICombat(_owner, who);
if (needOtherAI)
NotifyAICombat(who, _owner);
return true;
return IsInCombatWith(who);
}
bool CombatManager::IsInCombatWith(ObjectGuid const& guid) const

View File

@@ -363,6 +363,10 @@ void ThreatManager::AddThreat(Unit* target, float amount, SpellInfo const* spell
}
}
// ensure we're in combat (threat implies combat!)
if (!_owner->GetCombatManager().SetInCombatWith(target)) // if this returns false, we're not actually in combat, and thus cannot have threat!
return; // typical causes: bad scripts trying to add threat to GMs, dead targets etc
// ok, now we actually apply threat
// check if we already have an entry - if we do, just increase threat for that entry and we're done
auto it = _myThreatListEntries.find(target->GetGUID());
@@ -372,10 +376,6 @@ void ThreatManager::AddThreat(Unit* target, float amount, SpellInfo const* spell
return;
}
// otherwise, ensure we're in combat (threat implies combat!)
if (!_owner->GetCombatManager().SetInCombatWith(target)) // if this returns false, we're not actually in combat, and thus cannot have threat!
return; // typical causes: bad scripts trying to add threat to GMs, dead targets etc
// ok, we're now in combat - create the threat list reference and push it to the respective managers
ThreatReference* ref = new ThreatReference(this, target, amount);
PutThreatListRef(target->GetGUID(), ref);