From 2fd4947ab48cc80c2a5b38f26e207635f5d40cf3 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 11 May 2022 10:27:44 +0200 Subject: [PATCH] added showing score even if not added to local score file This fixes a special case: If a score was not added to the local score file (because all entries in the local score file have a better score, and there are no free slots in the local score file anymore), the hall of fame was completely skipped before. This was handled differently to a score that was still not under the best 100 ranks on the high score server for that level, but that was written to the local score file (either because it was not full yet, or because it was better than the last entry in the local score file). This fix adds showing the score (with a rank of "???" on the last list position, as usual) even if it was not written to the local score file. --- src/files.c | 4 ++++ src/game.c | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/files.c b/src/files.c index b0e376d2..d72bcfae 100644 --- a/src/files.c +++ b/src/files.c @@ -9326,6 +9326,7 @@ void SaveServerScoreFromFile(int nr, boolean tape_saved, void LoadLocalAndServerScore(int nr, boolean download_score) { int last_added_local = scores.last_added_local; + boolean force_last_added = scores.force_last_added; // needed if only showing server scores setScoreInfoToDefaults(); @@ -9345,6 +9346,9 @@ void LoadLocalAndServerScore(int nr, boolean download_score) // merge local scores with scores from server MergeServerScore(); } + + if (force_last_added) + scores.force_last_added = force_last_added; } diff --git a/src/game.c b/src/game.c index 1c33d10b..ca2fa98e 100644 --- a/src/game.c +++ b/src/game.c @@ -5151,7 +5151,8 @@ static int addScoreEntry(struct ScoreInfo *list, struct ScoreEntry *new_entry, } } - return -1; + // special case: new score is beyond the last high score list position + return MAX_SCORE_ENTRIES; } void NewHighScore(int level_nr, boolean tape_saved) @@ -5169,6 +5170,19 @@ void NewHighScore(int level_nr, boolean tape_saved) scores.last_added = addScoreEntry(&scores, &new_entry, one_per_name); + if (scores.last_added >= MAX_SCORE_ENTRIES) + { + scores.last_added = MAX_SCORE_ENTRIES - 1; + scores.force_last_added = TRUE; + + scores.entry[scores.last_added] = new_entry; + + // store last added local score entry (before merging server scores) + scores.last_added_local = scores.last_added; + + return; + } + if (scores.last_added < 0) return; -- 2.34.1