moved adding new score entry to separate function
authorHolger Schemel <info@artsoft.org>
Sat, 24 Apr 2021 22:57:43 +0000 (00:57 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 1 May 2021 13:38:30 +0000 (15:38 +0200)
src/game.c

index 5a88750f40b867bf3a08459b40dd05a6b99aa7e9..21b4b82bdbf0e316e821ffe87122152b86f29fe6 100644 (file)
@@ -5041,14 +5041,12 @@ void GameEnd(void)
   }
 }
 
-int NewHighScore(int level_nr)
+static int addScoreEntry(void)
 {
   int i, l;
   int position = -1;
   boolean one_score_entry_per_name = !program.many_scores_per_name;
 
-  LoadScore(level_nr);
-
   if (strEqual(setup.player_name, EMPTY_PLAYER_NAME) ||
       game.score_final < scores.entry[MAX_SCORE_ENTRIES - 1].score)
     return -1;
@@ -5111,6 +5109,15 @@ int NewHighScore(int level_nr)
       break;   // player already there with a higher score
   }
 
+  return position;
+}
+
+int NewHighScore(int level_nr)
+{
+  LoadScore(level_nr);
+
+  int position = addScoreEntry();
+
   if (position >= 0)
   {
     SaveScoreTape(level_nr);