Minimize get_level usage outside of ball/set and ball/level
authorparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Wed, 18 Aug 2010 01:00:44 +0000 (01:00 +0000)
committerparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Wed, 18 Aug 2010 01:00:44 +0000 (01:00 +0000)
git-svn-id: https://s.snth.net/svn/neverball/trunk@3254 78b8d119-cf0a-0410-b17c-f493084dd1d7

ball/level.c
ball/level.h
ball/st_goal.c
ball/st_start.c

index b319ad7..dec1327 100644 (file)
@@ -236,6 +236,11 @@ const char *level_msg(int i)
     return "";
 }
 
+const struct score *level_score(int i, int s)
+{
+    return level_exists(i) ? &get_level(i)->scores[s] : NULL;
+}
+
 /*---------------------------------------------------------------------------*/
 
 int level_score_update(int level,
index 359389f..496f715 100644 (file)
@@ -65,6 +65,8 @@ const char *level_file(int);
 const char *level_name(int);
 const char *level_msg (int);
 
+const struct score *level_score(int, int);
+
 /*---------------------------------------------------------------------------*/
 
 int  level_score_update (int, int, int, int *, int *, int *);
index 9d4ff2e..d346172 100644 (file)
@@ -117,9 +117,8 @@ static int goal_enter(void)
 
     int id, jd, kd, ld, md;
 
-    const struct level *l = get_level(curr_level());
-
     int high = progress_lvl_high();
+    int level = curr_level();
 
     if (new_name)
     {
@@ -242,9 +241,9 @@ static int goal_enter(void)
 
     }
 
-    set_score_board(&l->scores[SCORE_MOST_COINS],  progress_coin_rank(),
-                    &l->scores[SCORE_BEST_TIMES],  progress_time_rank(),
-                    &l->scores[SCORE_FAST_UNLOCK], progress_goal_rank());
+    set_score_board(level_score(level, SCORE_MOST_COINS),  progress_coin_rank(),
+                    level_score(level, SCORE_BEST_TIMES),  progress_time_rank(),
+                    level_score(level, SCORE_FAST_UNLOCK), progress_goal_rank());
 
     audio_music_fade_out(2.0f);
 
index 102d1ce..192f8e6 100644 (file)
@@ -74,9 +74,9 @@ static void start_over_level(int i)
     {
         gui_set_image(shot_id, level_shot(i));
 
-        set_score_board(&get_level(i)->scores[SCORE_MOST_COINS],  -1,
-                        &get_level(i)->scores[SCORE_BEST_TIMES],  -1,
-                        &get_level(i)->scores[SCORE_FAST_UNLOCK], -1);
+        set_score_board(level_score(i, SCORE_MOST_COINS),  -1,
+                        level_score(i, SCORE_BEST_TIMES),  -1,
+                        level_score(i, SCORE_FAST_UNLOCK), -1);
 
         if (file_id)
             gui_set_label(file_id, level_file(i));