Core/Threat: Fix taunt logic relying on unspecified behavior by unordered boost heap iterators. Use ordered iterators instead, this is cheap for our use case anyway. This will make taunt behave consistently again.

Port From (https://github.com/TrinityCore/TrinityCore/commit/74cdf260e1e37d54ac1ce2045f05a2e50f7eceaa)
This commit is contained in:
hondacrx
2021-08-09 10:27:17 -04:00
parent d6dd7acd28
commit 37fd6936fd
+7 -17
View File
@@ -330,24 +330,14 @@ namespace Game.Combat
int index = 0;
ThreatReference highest = _sortedThreatList[index];
if (!highest.IsOnline())
if (!highest.IsAvailable())
return;
if (highest.GetTauntState() != 0) // might need to skip this - new max could be one of the preceding elements (heap property) since there is only one taunt element
if (highest.IsTaunting() && (++index) != _sortedThreatList.Count - 1) // might need to skip this - max threat could be the preceding element (there is only one taunt element)
{
if ((++index) != _sortedThreatList.Count - 1)
{
ThreatReference a = _sortedThreatList[index];
if (a.IsOnline() && a.GetThreat() > highest.GetThreat())
highest = a;
if ((++index) != _sortedThreatList.Count)
{
ThreatReference aa = _sortedThreatList[index];
if (aa.IsOnline() && aa.GetThreat() > highest.GetThreat())
highest = aa;
}
}
ThreatReference a = _sortedThreatList[index];
if (a.IsAvailable() && a.GetThreat() > highest.GetThreat())
highest = a;
}
AddThreat(target, highest.GetThreat() - GetThreat(target, true), null, true, true);
@@ -364,7 +354,7 @@ namespace Game.Combat
if (refe == null)
continue;
if (!refe.IsOnline())
if (!refe.IsAvailable())
continue;
tauntRef = refe;
@@ -656,7 +646,7 @@ namespace Game.Combat
_sortedThreatList.Remove(refe);
_sortedThreatList.Sort();
if (sendRemove && refe.IsOnline())
if (sendRemove && refe.IsAvailable())
SendRemoveToClients(refe.GetVictim());
}