Fixed the problem that in a rare case, a set is downloaded and the neverballrc is...
[neverball] / ball / st_start.c
index eb9ce38..ec5b582 100644 (file)
 
 /*---------------------------------------------------------------------------*/
 
-int goto_end_level(void)
-{
-    switch (curr_lg()->mode)
-    {
-    case MODE_CHALLENGE:
-        return goto_state(&st_over);
-    default:
-        return goto_state(&st_start);
-    }
-}
-
-
-/*---------------------------------------------------------------------------*/
-
 #define START_BACK      -1
 #define START_PRACTICE  -2
 #define START_NORMAL    -3
@@ -58,13 +44,11 @@ static int status_id;
 static void gui_level(int id, int i)
 {
     const GLfloat *fore, *back;
-
-    const struct set *s = curr_set();
     const struct level *l;
 
     int jd;
 
-    if (!set_level_exists(s, i))
+    if (!set_level_exists(curr_set(), i))
     {
         gui_space(id);
         return;
@@ -88,7 +72,7 @@ static void gui_level(int id, int i)
 static void start_over_level(int i)
 {
     const struct level *l = get_level(i);
-    if (!l->is_locked || config_get_d(CONFIG_CHEAT))
+    if (!l->is_locked || config_cheat())
     {
         gui_set_image(shot_id, l->shot);
 
@@ -113,7 +97,7 @@ static void start_over_level(int i)
             else
                 gui_set_label(status_id, _("Play this level in normal mode"));
         }
-        if (config_get_d(CONFIG_CHEAT))
+        if (config_cheat())
         {
             gui_set_label(status_id, l->file);
         }
@@ -141,9 +125,9 @@ static void start_over(int id)
     switch (i)
     {
     case START_CHALLENGE:
-        gui_set_image(shot_id, curr_set()->shot);
-        set_most_coins(&curr_set()->coin_score, -1);
-        set_best_times(&curr_set()->time_score, -1, 0);
+        gui_set_image(shot_id, set_shot(curr_set()));
+        set_most_coins(set_coin_score(curr_set()), -1);
+        set_best_times(set_time_score(curr_set()), -1, 0);
         gui_set_label(status_id, _("Challenge all levels from the first one"));
         break;
 
@@ -183,7 +167,7 @@ static int start_action(int i)
     if (i == START_CHALLENGE)
     {
         /* On cheat, start challenge mode where you want */
-        if (config_get_d(CONFIG_CHEAT))
+        if (config_cheat())
         {
             mode_set(MODE_CHALLENGE);
             return goto_state(&st_start);
@@ -196,10 +180,17 @@ static int start_action(int i)
     {
         const struct level *l = get_level(i);
 
-        if (!l->is_locked || config_get_d(CONFIG_CHEAT))
+        if (!l->is_locked || config_cheat())
         {
-            level_play(l, mode);
-            return goto_state(&st_level);
+            if (level_play(l, mode))
+            {
+                return goto_state(&st_level);
+            }
+            else
+            {
+                level_stop();
+                return 1;
+            }
         }
     }
     return 1;
@@ -216,7 +207,7 @@ static int start_enter(void)
 
     /* Deactivate cheat */
 
-    if (m == MODE_CHALLENGE && !config_get_d(CONFIG_CHEAT))
+    if (m == MODE_CHALLENGE && !config_cheat())
     {
         mode_set(MODE_NORMAL);
         m = MODE_NORMAL;
@@ -227,7 +218,7 @@ static int start_enter(void)
         if ((jd = gui_hstack(id)))
         {
 
-            gui_label(jd, _(curr_set()->name), GUI_SML, GUI_ALL,
+            gui_label(jd, set_name(curr_set()), GUI_SML, GUI_ALL,
                       gui_yel, gui_red);
             gui_filler(jd);
             gui_start(jd, _("Back"),  GUI_SML, START_BACK, 0);
@@ -236,7 +227,7 @@ static int start_enter(void)
 
         if ((jd = gui_harray(id)))
         {
-            shot_id = gui_image(jd, curr_set()->shot, 7 * w / 16, 7 * h / 16);
+            shot_id = gui_image(jd, set_shot(curr_set()), 7 * w / 16, 7 * h / 16);
 
             if ((kd = gui_varray(jd)))
             {
@@ -294,7 +285,7 @@ static void start_stick(int id, int a, int v)
 
 static int start_keybd(int c, int d)
 {
-    if (d && c == SDLK_c && config_get_d(CONFIG_CHEAT))
+    if (d && c == SDLK_c && config_cheat())
     {
         set_cheat();
         return goto_state(&st_start);
@@ -335,6 +326,7 @@ struct state st_start = {
     shared_timer,
     start_point,
     start_stick,
+    shared_angle,
     shared_click,
     start_keybd,
     start_buttn,