Skip to content

Commit 8bb2455

Browse files
committed
Correctly set winning team
Gets rid of simple score check which could be equal. Checks game match winner instead (fixes #14)
1 parent bd9f535 commit 8bb2455

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

AutoReplayUploader/AutoReplayUploaderPlugin.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,20 @@ string AutoReplayUploaderPlugin::SetReplayName(ServerWrapper& server, ReplaySocc
420420
// Get Team scores
421421
match.Team0Score = soccarReplay.GetTeam0Score();
422422
match.Team1Score = soccarReplay.GetTeam1Score();
423+
424+
if (auto matchWinner = server.GetMatchWinner(); !matchWinner.IsNull())
425+
{
426+
match.WinningTeam = matchWinner.GetTeamIndex();
427+
}
428+
else if (auto gameWinner = server.GetGameWinner(); !gameWinner.IsNull())
429+
{
430+
match.WinningTeam = gameWinner.GetTeamIndex();
431+
}
432+
else
433+
{
434+
match.WinningTeam = match.Team0Score > match.Team1Score ? 0 : 1;
435+
}
436+
423437

424438
// Get current Sequence number
425439
auto seq = *templateSequence;

Uploader/Match.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Match
1717

1818
int Team0Score;
1919
int Team1Score;
20-
20+
int WinningTeam;
2121
Match();
2222
~Match();
2323
};

Uploader/Player.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Player::~Player()
88
{
99
}
1010

11-
bool Player::WonMatch(int team0Score, int team1Score)
11+
bool Player::WonMatch(int winningTeam)
1212
{
13-
return Team == 0 ? team0Score > team1Score : team1Score > team0Score;
13+
return Team == winningTeam;
1414
}

Uploader/Player.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ class Player
2121
Player();
2222
~Player();
2323

24-
bool WonMatch(int team0Score, int team1Score);
24+
bool WonMatch(int winningTeam);
2525
};

Uploader/Replay.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ string ApplyNameTemplate(string& nameTemplate, Match& match, int* matchIndex)
6363
min.insert(min.begin(), 2 - min.length(), '0');
6464

6565
// Calculate Win/Loss string
66-
auto won = match.PrimaryPlayer.WonMatch(match.Team0Score, match.Team1Score);
66+
auto won = match.PrimaryPlayer.WonMatch(match.WinningTeam);
6767
auto winloss = won ? string("Win") : string("Loss");
6868
auto wl = won ? string("W") : string("L");
6969

0 commit comments

Comments
 (0)