From b4ae37046341bd74a32ee9e3f473d1d58e5efe6b Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 20 Mar 2021 11:04:05 +0100 Subject: [PATCH] moved converting score to time from high score screen to score file loader --- src/files.c | 22 ++++++++++++++++++++++ src/screens.c | 7 ------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/files.c b/src/files.c index 104ecb4d..1909cbec 100644 --- a/src/files.c +++ b/src/files.c @@ -8451,6 +8451,25 @@ static void LoadScore_OLD(int nr) fclose(file); } +static void ConvertScore_OLD(void) +{ + // only convert score to time for levels that rate playing time over score + if (!level.rate_time_over_score) + return; + + // convert old score to playing time for score-less levels (like Supaplex) + int time_final_max = 999; + int i; + + for (i = 0; i < MAX_SCORE_ENTRIES; i++) + { + int score = scores.entry[i].score; + + if (score > 0 && score < time_final_max) + scores.entry[i].time = (time_final_max - score - 1) * FRAMES_PER_SECOND; + } +} + static int LoadScore_VERS(File *file, int chunk_size, struct ScoreInfo *scores) { scores->file_version = getFileVersion(file); @@ -8580,6 +8599,9 @@ void LoadScore(int nr) { // score files from versions before 4.2.4.0 without chunk structure LoadScore_OLD(nr); + + // convert score to time, if possible (mainly for Supaplex levels) + ConvertScore_OLD(); } else { diff --git a/src/screens.c b/src/screens.c index c23f7ce6..8e4fb8c9 100644 --- a/src/screens.c +++ b/src/screens.c @@ -5079,14 +5079,7 @@ static char *getHallOfFameScoreText(int nr) return int2str(scores.entry[nr].time, 5); static char score_text[10]; - int time_final_max = 999; int time_seconds = scores.entry[nr].time / FRAMES_PER_SECOND; - int score = scores.entry[nr].score; - - // convert old score file entries without playing time - if (time_seconds == 0 && score > 0 && score < time_final_max) - time_seconds = time_final_max - score - 1; - int mm = (time_seconds / 60) % 60; int ss = (time_seconds % 60); -- 2.34.1