From a3f042e7f781ee8af3d53794ee6fdff31656dbb8 Mon Sep 17 00:00:00 2001 From: beu Date: Sun, 25 Aug 2024 18:42:23 +0200 Subject: [PATCH] fix possible live ranking crash --- TM_MultiLivesKnockout.Script.txt | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/TM_MultiLivesKnockout.Script.txt b/TM_MultiLivesKnockout.Script.txt index 1138940..ad12652 100644 --- a/TM_MultiLivesKnockout.Script.txt +++ b/TM_MultiLivesKnockout.Script.txt @@ -1331,15 +1331,17 @@ Void UpdateRanking() { } else { declare Ident PlayerId = ScoreIdToPlayerId.get(Score.Id, NullId); if (PlayerId != NullId) { - declare CSmPlayer Player <=> Players[PlayerId]; - PlayerState.CPNb = Player.RaceWaypointTimes.count; - PlayerState.IsNotPlaying = (Player.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned); - PlayerState.Finished = (Score.PrevRaceTimes.count != 0); - - if (PlayerState.CPNb > 0) { - PlayerState.LastCPTime = Player.RaceWaypointTimes[-1]; + declare CSmPlayer Player <=> Players.get(PlayerId, Null); + if (Player != Null) { + PlayerState.CPNb = Player.RaceWaypointTimes.count; + PlayerState.IsNotPlaying = (Player.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned); + PlayerState.Finished = (Score.PrevRaceTimes.count != 0); + + 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); 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) {