Skip to content

Commit

Permalink
Analytics: Add old team value to team change events
Browse files Browse the repository at this point in the history
  • Loading branch information
Sejsel committed Jul 8, 2024
1 parent 0a25257 commit 2c47094
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions ArcdpsLogManager/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This is the full changelog of the arcdps Log Manager.
- Exact arcdps build is now shown in the Statistics tabs; requires arcdps 2024-06-14 or newer.
- Added old weapon set to AgentWeaponSwapEvent; requires arcdps 2024-06-27 or newer.
- Added CrowdControlEvent (crowd control against non-defiant enemies); requires arcdps 2024-06-27 or newer.
- Added old team ids to TeamChangeEvent; requires arcdps 2024-06-12 or newer.

## Log Manager v1.11.1

Expand Down
6 changes: 5 additions & 1 deletion EVTCAnalytics/Events/AgentEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,13 @@ public class FacingChangeEvent(long time, Agent agent, float x, float y)
/// <br />
/// Teams affect hostility of targets.
/// </summary>
public class TeamChangeEvent(long time, Agent agent, ulong newTeamId) : AgentEvent(time, agent)
public class TeamChangeEvent(long time, Agent agent, ulong newTeamId, int? oldTeamId) : AgentEvent(time, agent)
{
public ulong NewTeamId { get; } = newTeamId;
/// <remarks>
/// Introduced in EVTC20240612. May be null before.
/// </remarks>
public int? OldTeamId { get; } = oldTeamId;
}

/// <summary>
Expand Down
13 changes: 10 additions & 3 deletions EVTCAnalytics/Processing/LogProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,10 @@ Skill GetSkillByIdOrAdd(uint id)
state.SkillsById.Add(id, newSkill);
return newSkill;
}

bool isOldWeaponSetAvailable = string.Compare(state.EvtcVersion, "EVTC20240627", StringComparison.OrdinalIgnoreCase) >= 0;
bool isCommanderAvailable = string.Compare(state.EvtcVersion, "EVTC20220823", StringComparison.OrdinalIgnoreCase) >= 0;
bool isOldTeamAvailable = string.Compare(state.EvtcVersion, "EVTC20240612", StringComparison.OrdinalIgnoreCase) >= 0;

if (item.IsStateChange != StateChange.Normal)
{
Expand Down Expand Up @@ -991,7 +995,6 @@ static WeaponSet WeaponSetFromId(long id)
}

WeaponSet newWeaponSet = WeaponSetFromId((long) item.DstAgent);
bool isOldWeaponSetAvailable = string.Compare(state.EvtcVersion, "EVTC20240627", StringComparison.OrdinalIgnoreCase) >= 0;
WeaponSet? oldWeaponSet = isOldWeaponSetAvailable ? WeaponSetFromId(item.Value) : null;

return new AgentWeaponSwapEvent(item.Time, GetAgentByAddress(item.SrcAgent), newWeaponSet, oldWeaponSet);
Expand Down Expand Up @@ -1037,7 +1040,12 @@ static WeaponSet WeaponSetFromId(long id)
return new FacingChangeEvent(item.Time, GetAgentByAddress(item.SrcAgent), x, y);
}
case StateChange.TeamChange:
return new TeamChangeEvent(item.Time, GetAgentByAddress(item.SrcAgent), item.DstAgent);
int? oldTeam = isOldTeamAvailable switch
{
true => item.Value,
false => null,
};
return new TeamChangeEvent(item.Time, GetAgentByAddress(item.SrcAgent), item.DstAgent, oldTeam);
case StateChange.Targetable:
{
var agent = GetAgentByAddress(item.SrcAgent);
Expand Down Expand Up @@ -1093,7 +1101,6 @@ static WeaponSet WeaponSetFromId(long id)
}

// Added in aug.23.2022
bool isCommanderAvailable = string.Compare(state.EvtcVersion, "EVTC20220823", StringComparison.OrdinalIgnoreCase) >= 0;
bool? isCommander = isCommanderAvailable switch
{
true => item.Buff != 0,
Expand Down

0 comments on commit 2c47094

Please sign in to comment.