From: Holger Schemel Date: Wed, 11 May 2022 08:27:44 +0000 (+0200) Subject: added showing score even if not added to local score file X-Git-Tag: 4.3.2.2~35 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=2fd4947ab48cc80c2a5b38f26e207635f5d40cf3;p=rocksndiamonds.git 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. --- 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;