fix possible live ranking crash

This commit is contained in:
Beu 2024-08-25 18:42:23 +02:00
parent fba93075b0
commit a3f042e7f7

View File

@ -1331,7 +1331,8 @@ Void UpdateRanking() {
} else { } else {
declare Ident PlayerId = ScoreIdToPlayerId.get(Score.Id, NullId); declare Ident PlayerId = ScoreIdToPlayerId.get(Score.Id, NullId);
if (PlayerId != NullId) { if (PlayerId != NullId) {
declare CSmPlayer Player <=> Players[PlayerId]; declare CSmPlayer Player <=> Players.get(PlayerId, Null);
if (Player != Null) {
PlayerState.CPNb = Player.RaceWaypointTimes.count; PlayerState.CPNb = Player.RaceWaypointTimes.count;
PlayerState.IsNotPlaying = (Player.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned); PlayerState.IsNotPlaying = (Player.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned);
PlayerState.Finished = (Score.PrevRaceTimes.count != 0); PlayerState.Finished = (Score.PrevRaceTimes.count != 0);
@ -1342,6 +1343,7 @@ Void UpdateRanking() {
if (GlobalLastCPTime < PlayerState.LastCPTime) GlobalLastCPTime = PlayerState.LastCPTime; if (GlobalLastCPTime < PlayerState.LastCPTime) GlobalLastCPTime = PlayerState.LastCPTime;
} }
} }
}
if (!Ranking.existskey(PlayerState.CPNb)) Ranking[PlayerState.CPNb] = []; if (!Ranking.existskey(PlayerState.CPNb)) Ranking[PlayerState.CPNb] = [];
if (!Ranking[PlayerState.CPNb].existskey(PlayerState.LastCPTime)) Ranking[PlayerState.CPNb][PlayerState.LastCPTime] = []; if (!Ranking[PlayerState.CPNb].existskey(PlayerState.LastCPTime)) Ranking[PlayerState.CPNb][PlayerState.LastCPTime] = [];
@ -1392,7 +1394,10 @@ Void UpdateRanking() {
PlayerState.InDanger = (Rank >= LostOfLifeRank); PlayerState.InDanger = (Rank >= LostOfLifeRank);
if (FirstPlayer == Null) { if (FirstPlayer == Null) {
FirstPlayer <=> Players[ScoreIdToPlayerId.get(PlayerState.ScoreId, NullId)]; declare Ident FirstPlayerId = ScoreIdToPlayerId.get(PlayerState.ScoreId, NullId);
if (FirstPlayerId != NullId) {
FirstPlayer <=> Players[FirstPlayerId];
}
} }
if (FirstPlayer != Null) { if (FirstPlayer != Null) {