House keeping.
authorparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Sun, 30 Dec 2007 19:13:57 +0000 (19:13 +0000)
committerparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Sun, 30 Dec 2007 19:13:57 +0000 (19:13 +0000)
git-svn-id: https://s.snth.net/svn/neverball/trunk@1331 78b8d119-cf0a-0410-b17c-f493084dd1d7

ball/level.c
ball/levels.h
ball/set.c
ball/st_goal.c
ball/st_level.c

index 983cde2..d0eb873 100644 (file)
@@ -209,6 +209,7 @@ int level_play(const struct level *l, int m)
 
     lg->win = lg->dead = lg->unlock = 0;
     lg->next_level = NULL;
+    lg->bonus = lg->bonusid = 0;
 
     return demo_play_init(USER_REPLAY_FILE, lg->level, lg);
 }
index 6514a04..47160c7 100644 (file)
@@ -16,7 +16,7 @@ struct level_game
     int balls;         /* live count */
     int times;         /* time total */
     int bonus;         /* is a bonus level message needed? */
-    int bonusid;         /* which bonus level? */
+    int bonusid;       /* which bonus level? */
 
     /* Once a level is finished */
     int status;        /* status ending */
index e4c494d..874d133 100644 (file)
@@ -310,7 +310,6 @@ static void set_load_levels(void)
 {
     FILE *fin;
 
-    struct level_game *lg = curr_lg();
     struct level *l;
 
     char buf[MAXSTR];
@@ -362,7 +361,6 @@ static void set_load_levels(void)
     }
 
     assert(i == set_v[set].count);
-    lg->bonus = lg->bonusid = 0; /* initialize bonus values */
 }
 
 void set_goto(int i)
@@ -493,19 +491,24 @@ void set_finish_level(struct level_game *lg, const char *player)
     if (lg->status == GAME_GOAL)
     {
         /* Identify the following level */
+
         nl = next_level(ln);
+
         if (nl != NULL)
         {
-            /* skip bonuses if unlocked in any mode */
+            /* Skip bonuses if unlocked in any mode */
+
             if (nl->is_bonus)
             {
-                if(lg->mode == MODE_CHALLENGE && nl->is_locked > 0)
+                if (lg->mode == MODE_CHALLENGE && nl->is_locked)
                 {
-                    lg->bonus = 1; /* Show GUI message */
-                    nl->is_locked = 0; /* Unlock bonus level */
+                    lg->bonus = 1;
+                    nl->is_locked = 0;
                 }
+
                 nl = next_normal_level(nl->number);
-                if(nl == NULL && lg->mode == MODE_CHALLENGE)
+
+                if (nl == NULL && lg->mode == MODE_CHALLENGE)
                 {
                     lg->win = 1;
                 }
index dfb50f0..b28bed1 100644 (file)
@@ -100,7 +100,7 @@ static int goal_enter(void)
 
     int id, jd, kd;
 
-          struct level_game *lg = curr_lg(); /* Note: const removed.  Is this really needed? */
+    struct level_game *lg = curr_lg();
     const struct level *l = lg->level;
 
     int high;
@@ -120,11 +120,9 @@ static int goal_enter(void)
     {
         int gid;
 
-        if(lg->mode == MODE_CHALLENGE && lg->bonus > 0)
+        if (lg->mode == MODE_CHALLENGE && lg->bonus)
         {
-            lg->bonus = 0;
-            lg->bonusid += 1;
-            char *buf = malloc(MAXSTR);
+            char buf[MAXSTR];
 
             const char *roman[] =
             {
@@ -135,7 +133,13 @@ static int goal_enter(void)
                 "XVI", "XVII", "XVIII", "XIX",  "XX",
                 "XXI", "XXII", "XXIII", "XXIV", "XXV"
             };
-            sprintf(buf, "You Have Unlocked Bonus Level %s!", roman[lg->bonusid]);
+
+            lg->bonus = 0;
+            lg->bonusid += 1;
+
+            sprintf(buf, _("You have unlocked bonus level %s!"),
+                    roman[lg->bonusid]);
+
             gid = gui_label(id, s3,  GUI_MED, GUI_ALL, gui_grn, gui_red);
             gid = gui_label(id, buf, GUI_SML, GUI_ALL, gui_blu, gui_grn);
         }
index 0109c72..b49a301 100644 (file)
@@ -54,22 +54,20 @@ static int level_enter(void)
 
                 if ((ld = gui_hstack(kd)))
                 {
-                    if(b == 0)
+                    if (b == 0)
                     {
                         gui_label(ld, ln,          GUI_LRG, GUI_NE,
                                   textcol1, textcol2);
                         gui_label(ld, _("Level "), GUI_LRG, GUI_NW,
                                   textcol1, textcol2);
                     }
-
                     else
                     {
-                        gui_label(ld, ln,          GUI_MED, GUI_NE,
+                        gui_label(ld, ln,                GUI_MED, GUI_NE,
                                   textcol1, textcol2);
                         gui_label(ld, _("Bonus Level "), GUI_MED, GUI_NW,
                                   textcol1, textcol2);
                     }
-
                 }
 
                 gui_label(kd, mode_to_str(lg->mode, 1), GUI_SML, GUI_BOT,