Fix "Draw bug" when a player leave

This commit is contained in:
Beu 2022-03-08 19:21:28 +01:00
parent 66dfad0b14
commit 59457baa44

View File

@ -287,6 +287,7 @@ if (!MapIsCompatible) {
} }
Race::Start(Player, PlayerLM , StartTime); Race::Start(Player, PlayerLM , StartTime);
AccountIdsOfPlayers.add(Player.User.WebServicesUserId); AccountIdsOfPlayers.add(Player.User.WebServicesUserId);
MalusQueue[Player.User.WebServicesUserId] = GetNewMalus(C_Malus_Reset);
} }
Net_NBPlayers = AccountIdsOfPlayers.count; Net_NBPlayers = AccountIdsOfPlayers.count;
@ -527,20 +528,30 @@ if (Round_ForceEndRound || Round_SkipPauseRound) {
} }
} else { } else {
Map_ValidRoundsNb += 1; Map_ValidRoundsNb += 1;
Scores::SetPlayerWinner(Scores::GetBestPlayer(Race::C_Sort_RoundPoints));
Race::SortScores(Race::C_Sort_TotalPoints); declare CSmScore WinnerScore <=> Scores::GetBestPlayer(Race::C_Sort_RoundPoints);
Scores::EndRound(); if (WinnerScore == Null) {
UIManager.UIAll.BigMessageSound = CUIConfig::EUISound::EndRound; foreach (Score in Scores) {
UIManager.UIAll.BigMessageSoundVariant = 0; if (Score.BestRaceTimes.count <= 0 && AccountIdsOfPlayers.exists(Score.User.WebServicesUserId)) {
WinnerScore <=> Score;
break;
}
}
}
Scores::SetPlayerWinner(WinnerScore);
declare Text Message = _("|Match|Draw"); declare Text Message = _("|Match|Draw");
declare CSmScore WinnerScore <=> Scores::GetBestPlayer(Race::C_Sort_RoundPoints);
if (WinnerScore != Null) { if (WinnerScore != Null) {
Message = TL::Compose(_("$<%1$> wins the match!"), Tools::GetNameWithClubTag(WinnerScore.User)); // TODO CHeck why display draw when someone leave Message = TL::Compose(_("$<%1$> wins the match!"), Tools::GetNameWithClubTag(WinnerScore.User)); // TODO CHeck why display draw when someone leave
} }
UIManager.UIAll.BigMessageSound = CUIConfig::EUISound::EndRound;
UIManager.UIAll.BigMessageSoundVariant = 0;
UIManager.UIAll.BigMessage = Message; UIManager.UIAll.BigMessage = Message;
Scores::EndRound();
Race::SortScores(Race::C_Sort_TotalPoints);
MB_Sleep(5000); MB_Sleep(5000);
UIManager.UIAll.BigMessage = ""; UIManager.UIAll.BigMessage = "";
UIManager.UIAll.ScoreTableVisibility = CUIConfig::EVisibility::ForcedVisible; UIManager.UIAll.ScoreTableVisibility = CUIConfig::EVisibility::ForcedVisible;