Skip to content

Commit b0f6a1c

Browse files
Added fix for teams not taking team side swap orders into consideration in overtime
1 parent a1830f7 commit b0f6a1c

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<Company>Source Engine Discord</Company>
1616
<Copyright>© 2014 EHVAG, 2020 Source Engine Discord and contributors</Copyright>
1717
<Product>SourceEngine.Demo</Product>
18-
<Version>2.0.6</Version>
18+
<Version>2.0.7</Version>
1919
</PropertyGroup>
2020

2121
<PropertyGroup Label="Package Metadata">

src/SourceEngine.Demo.Stats/DemoProcessor.cs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ public GeneralroundsStats GetGeneralRoundsStats(ProcessedData processedData, Dic
10111011
string reason = string.Empty;
10121012
string half = string.Empty;
10131013
bool isOvertime = ((switchSides.Count() >= 2) && (i >= switchSides.ElementAt(1).RoundBeforeSwitch)) ? true : false;
1014-
int overtimeNum = 0;
1014+
int overtimeCount = 0;
10151015
double roundLength = processedData.RoundLengthValues.ElementAt(i);
10161016

10171017
// determines which half / side it is
@@ -1022,9 +1022,9 @@ public GeneralroundsStats GetGeneralRoundsStats(ProcessedData processedData, Dic
10221022
int roundsPerOT = roundsPerOTHalf * 2;
10231023

10241024
int roundsIntoOT = (i + 1) - lastNormalTimeRound;
1025-
overtimeNum = (int)Math.Ceiling((double)roundsIntoOT / roundsPerOT);
1025+
overtimeCount = (int)Math.Ceiling((double)roundsIntoOT / roundsPerOT);
10261026

1027-
double currentOTHalf = (int)Math.Ceiling((double)roundsIntoOT / roundsPerOTHalf);
1027+
int currentOTHalf = (int)Math.Ceiling((double)roundsIntoOT / roundsPerOTHalf);
10281028
half = currentOTHalf % 2 == 1 ? "First" : "Second";
10291029
}
10301030
else
@@ -1033,7 +1033,7 @@ public GeneralroundsStats GetGeneralRoundsStats(ProcessedData processedData, Dic
10331033
}
10341034

10351035
// total rounds calculation
1036-
if (half == "First")
1036+
if (GetIfTeamSwapOrdersAreNormalOrderByHalfAndOvertimeCount(half, overtimeCount))
10371037
{
10381038
if (roundsWonTeams.ElementAt(i).ToString() == "Terrorist")
10391039
{
@@ -1044,7 +1044,7 @@ public GeneralroundsStats GetGeneralRoundsStats(ProcessedData processedData, Dic
10441044
totalRoundsWonTeamBeta++;
10451045
}
10461046
}
1047-
else if (half == "Second")
1047+
else
10481048
{
10491049
if (roundsWonTeams.ElementAt(i).ToString() == "Terrorist")
10501050
{
@@ -1098,15 +1098,15 @@ public GeneralroundsStats GetGeneralRoundsStats(ProcessedData processedData, Dic
10981098
player.SteamID = (player.SteamID == 0) ? GetSteamIdByPlayerName(playerNames, player.Name) : player.SteamID;
10991099
}
11001100

1101-
int playerCountTeamA = (currentRoundTeams != null) ? (half == "First" ? currentRoundTeams.Terrorists.Count() : currentRoundTeams.CounterTerrorists.Count()) : 0;
1102-
int playerCountTeamB = (currentRoundTeams != null) ? (half == "First" ? currentRoundTeams.CounterTerrorists.Count() : currentRoundTeams.Terrorists.Count()) : 0;
1101+
int playerCountTeamA = (currentRoundTeams != null) ? (GetIfTeamSwapOrdersAreNormalOrderByHalfAndOvertimeCount(half, overtimeCount) ? currentRoundTeams.Terrorists.Count() : currentRoundTeams.CounterTerrorists.Count()) : 0;
1102+
int playerCountTeamB = (currentRoundTeams != null) ? (GetIfTeamSwapOrdersAreNormalOrderByHalfAndOvertimeCount(half, overtimeCount) ? currentRoundTeams.CounterTerrorists.Count() : currentRoundTeams.Terrorists.Count()) : 0;
11031103

11041104
// equip values
11051105
var teamEquipValues = processedData.TeamEquipmentValues.Count() >= i ? processedData.TeamEquipmentValues.ElementAt(i) : null;
1106-
int equipValueTeamA = (teamEquipValues != null) ? (half == "First" ? teamEquipValues.TEquipValue : teamEquipValues.CTEquipValue) : 0;
1107-
int equipValueTeamB = (teamEquipValues != null) ? (half == "First" ? teamEquipValues.CTEquipValue : teamEquipValues.TEquipValue) : 0;
1108-
int expenditureTeamA = (teamEquipValues != null) ? (half == "First" ? teamEquipValues.TExpenditure : teamEquipValues.CTExpenditure) : 0;
1109-
int expenditureTeamB = (teamEquipValues != null) ? (half == "First" ? teamEquipValues.CTExpenditure : teamEquipValues.TExpenditure) : 0;
1106+
int equipValueTeamA = (teamEquipValues != null) ? (GetIfTeamSwapOrdersAreNormalOrderByHalfAndOvertimeCount(half, overtimeCount) ? teamEquipValues.TEquipValue : teamEquipValues.CTEquipValue) : 0;
1107+
int equipValueTeamB = (teamEquipValues != null) ? (GetIfTeamSwapOrdersAreNormalOrderByHalfAndOvertimeCount(half, overtimeCount) ? teamEquipValues.CTEquipValue : teamEquipValues.TEquipValue) : 0;
1108+
int expenditureTeamA = (teamEquipValues != null) ? (GetIfTeamSwapOrdersAreNormalOrderByHalfAndOvertimeCount(half, overtimeCount) ? teamEquipValues.TExpenditure : teamEquipValues.CTExpenditure) : 0;
1109+
int expenditureTeamB = (teamEquipValues != null) ? (GetIfTeamSwapOrdersAreNormalOrderByHalfAndOvertimeCount(half, overtimeCount) ? teamEquipValues.CTExpenditure : teamEquipValues.TExpenditure) : 0;
11101110

11111111
// bombsite planted/exploded/defused at
11121112
string bombsite = null;
@@ -1230,7 +1230,7 @@ public GeneralroundsStats GetGeneralRoundsStats(ProcessedData processedData, Dic
12301230
{
12311231
Round = i + 1,
12321232
Half = half,
1233-
Overtime = overtimeNum,
1233+
Overtime = overtimeCount,
12341234
Length = roundLength,
12351235
Winners = roundsWonTeams[i].ToString(),
12361236
WinMethod = reason,
@@ -2019,6 +2019,11 @@ public HostagePickedUp GenerateNewHostagePickedUp(HostageRescued hostageRescued)
20192019
};
20202020
}
20212021

2022+
public bool GetIfTeamSwapOrdersAreNormalOrderByHalfAndOvertimeCount(string half, int overtimeCount)
2023+
{
2024+
return (half == "First" && overtimeCount % 2 == 0) || (half == "Second" && overtimeCount % 2 == 1); // the team playing T Side first switches each OT for example, this checks the OT count for swaps
2025+
}
2026+
20222027
public static int? GetMinRoundsForWin(string testType)
20232028
{
20242029
string gamemode = testType.ToLower();

0 commit comments

Comments
 (0)