Core/Threat: Fix a potential crash that would occur in specific edge cases of AI being a bit naughty.
Port From (https://github.com/TrinityCore/TrinityCore/commit/56fcd8ba1dc33e00ff6f98704764dcdebd838fd3)
This commit is contained in:
@@ -146,7 +146,8 @@ namespace Game.Combat
|
|||||||
NotifyAICombat(_owner, who);
|
NotifyAICombat(_owner, who);
|
||||||
if (needOtherAI)
|
if (needOtherAI)
|
||||||
NotifyAICombat(who, _owner);
|
NotifyAICombat(who, _owner);
|
||||||
return true;
|
|
||||||
|
return IsInCombatWith(who);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsInCombatWith(ObjectGuid guid)
|
public bool IsInCombatWith(ObjectGuid guid)
|
||||||
|
|||||||
@@ -285,6 +285,10 @@ namespace Game.Combat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
// 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
|
// check if we already have an entry - if we do, just increase threat for that entry and we're done
|
||||||
var targetRefe = _myThreatListEntries.LookupByKey(target.GetGUID());
|
var targetRefe = _myThreatListEntries.LookupByKey(target.GetGUID());
|
||||||
@@ -294,10 +298,6 @@ namespace Game.Combat
|
|||||||
return;
|
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
|
// ok, we're now in combat - create the threat list reference and push it to the respective managers
|
||||||
ThreatReference newRefe = new(this, target, amount);
|
ThreatReference newRefe = new(this, target, amount);
|
||||||
PutThreatListRef(target.GetGUID(), newRefe);
|
PutThreatListRef(target.GetGUID(), newRefe);
|
||||||
|
|||||||
Reference in New Issue
Block a user