Skip to content

Commit

Permalink
Analytics: Do not form minion cycles in old logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Sejsel committed Aug 5, 2019
1 parent 453aa8c commit 63f930d
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions EVTCAnalytics/LogProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,21 +287,42 @@ private void AssignAgentMasters(ParsedLog log, IReadOnlyCollection<Agent> agents
}
}

Agent master = null;
foreach (var agent in agents)
if (minion != null && minion.Master == null)
{
if (!(agent is Gadget) && agent.Id == combatItem.SrcMasterId &&
agent.IsWithinAwareTime(combatItem.Time))
Agent master = null;
foreach (var agent in agents)
{
master = agent;
break;
if (!(agent is Gadget) && agent.Id == combatItem.SrcMasterId &&
agent.IsWithinAwareTime(combatItem.Time))
{
master = agent;
break;
}
}
}

if (minion != null && master != null && minion.Master == null)
{
minion.Master = master;
master.MinionList.Add(minion);
if (master != null)
{
bool inCycle = false;
var masterParent = master;
while (masterParent != null)
{
if (masterParent == minion)
{
// A cycle is present in the minion hierarchy, this minion would end up as
// a transitive minion of itself, which could cause infinite looping.
// This is common in very old logs where minion data is somewhat weird.
inCycle = true;
break;
}
masterParent = masterParent.Master;
}

if (!inCycle)
{
minion.Master = master;
master.MinionList.Add(minion);
}
}
}
}
}
Expand Down

0 comments on commit 63f930d

Please sign in to comment.