moved adding new score entry to separate function
[rocksndiamonds.git] / src / game.c
index 05de29db43be435e1cfbedca18e76af34bbc95ee..21b4b82bdbf0e316e821ffe87122152b86f29fe6 100644 (file)
@@ -1106,7 +1106,7 @@ void ContinueMoving(int, int);
 void Bang(int, int);
 void InitMovDir(int, int);
 void InitAmoebaNr(int, int);
-int NewHiScore(int);
+int NewHighScore(int);
 
 void TestIfGoodThingHitsBadThing(int, int, int);
 void TestIfBadThingHitsGoodThing(int, int, int);
@@ -5019,7 +5019,7 @@ void GameEnd(void)
     }
   }
 
-  highlight_position = NewHiScore(last_level_nr);
+  highlight_position = NewHighScore(last_level_nr);
 
   if (highlight_position >= 0 && setup.show_scores_after_game)
   {
@@ -5041,14 +5041,12 @@ void GameEnd(void)
   }
 }
 
-int NewHiScore(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 NewHiScore(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);