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,15 +1331,17 @@ 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);
PlayerState.CPNb = Player.RaceWaypointTimes.count; if (Player != Null) {
PlayerState.IsNotPlaying = (Player.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned); PlayerState.CPNb = Player.RaceWaypointTimes.count;
PlayerState.Finished = (Score.PrevRaceTimes.count != 0); PlayerState.IsNotPlaying = (Player.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned);
PlayerState.Finished = (Score.PrevRaceTimes.count != 0);
if (PlayerState.CPNb > 0) {
PlayerState.LastCPTime = Player.RaceWaypointTimes[-1]; if (PlayerState.CPNb > 0) {
PlayerState.LastCPTime = Player.RaceWaypointTimes[-1];
}
if (GlobalLastCPTime < PlayerState.LastCPTime) GlobalLastCPTime = PlayerState.LastCPTime;
} }
if (GlobalLastCPTime < PlayerState.LastCPTime) GlobalLastCPTime = 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) {