Restore the cheat setting in neverballrc.
authorlorant <lorant@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Wed, 18 Jul 2007 16:50:37 +0000 (16:50 +0000)
committerlorant <lorant@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Wed, 18 Jul 2007 16:50:37 +0000 (16:50 +0000)
git-svn-id: https://s.snth.net/svn/neverball/trunk@1071 78b8d119-cf0a-0410-b17c-f493084dd1d7

ball/main.c
ball/st_play.c
ball/st_start.c
ball/st_title.c
share/config.c
share/config.h

index 398c2aa..1995ad2 100644 (file)
@@ -148,7 +148,7 @@ static int loop(void)
             case SDLK_F8:    config_tgl_d(CONFIG_NICE); break;
 
             case SDLK_F7:
-                if (config_get_cheat())
+                if (config_get_d(CONFIG_CHEAT))
                     toggle_wire();
                 break;
 
index f7d1c0e..81a6050 100644 (file)
@@ -301,14 +301,14 @@ static int play_loop_keybd(int c, int d)
             view_rotate = 0;
     }
 
-    if (d && c == SDLK_F12 && config_get_cheat())
+    if (d && c == SDLK_F12 && config_get_d(CONFIG_CHEAT))
         return goto_state(&st_look);
 
     if (d && c == SDLK_F6)
         nohud = !nohud;
 
     /* Cheat */
-    if (d && c == SDLK_c && config_get_cheat())
+    if (d && c == SDLK_c && config_get_d(CONFIG_CHEAT))
     {
         level_stop(GAME_GOAL, 0, curr_clock(), curr_coins());
         return goto_state(&st_play_end);
index 8357633..fc8e5c5 100644 (file)
@@ -90,7 +90,7 @@ static void gui_level(int id, int i)
 static void start_over_level(i)
 {
     const struct level *l = get_level(i);
-    if (!l->is_locked || config_get_cheat())
+    if (!l->is_locked || config_get_d(CONFIG_CHEAT))
     {
         gui_set_image(shot_id, l->shot);
 
@@ -115,7 +115,7 @@ static void start_over_level(i)
             else
                 gui_set_label(status_id, _("Play this level in normal mode"));
         }
-        if (config_get_cheat())
+        if (config_get_d(CONFIG_CHEAT))
         {
             gui_set_label(status_id, l->file);
         }
@@ -185,7 +185,7 @@ static int start_action(int i)
     if (i == START_CHALLENGE)
     {
         /* On cheat, start challenge mode where you want */
-        if (config_get_cheat())
+        if (config_get_d(CONFIG_CHEAT))
         {
             config_set_d(CONFIG_MODE, MODE_CHALLENGE);
             return goto_state(&st_start);
@@ -198,7 +198,7 @@ static int start_action(int i)
     {
         const struct level *l = get_level(i);
 
-        if (!l->is_locked || config_get_cheat())
+        if (!l->is_locked || config_get_d(CONFIG_CHEAT))
         {
             level_play(l, mode);
             return goto_state(&st_level);
@@ -217,7 +217,7 @@ static int start_enter(void)
     int id, jd, kd, ld;
 
     /* Deactivate cheat */
-    if (m == MODE_CHALLENGE && !config_get_cheat())
+    if (m == MODE_CHALLENGE && !config_get_d(CONFIG_CHEAT))
     {
         m = MODE_NORMAL;
         config_set_d(CONFIG_MODE, m);
@@ -295,7 +295,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_cheat())
+    if (d && c == SDLK_c && config_get_d(CONFIG_CHEAT))
     {
         set_cheat();
         return goto_state(&st_start);
index 9b0ab94..1627766 100644 (file)
@@ -187,8 +187,8 @@ static void title_timer(int id, float dt)
 
 static int title_keybd(int c, int d)
 {
-    if (d && c == SDLK_c)
-        config_tgl_cheat();
+    if (d && c == SDLK_c && ALLOW_CHEAT)
+        config_tgl_d(CONFIG_CHEAT);
     return 1;
 }
 
index c214c30..cbfaf82 100644 (file)
@@ -107,6 +107,7 @@ void config_init(void)
     config_set_d(CONFIG_ROTATE_FAST,          DEFAULT_ROTATE_FAST);
     config_set_d(CONFIG_ROTATE_SLOW,          DEFAULT_ROTATE_SLOW);
     config_set_d(CONFIG_MODE,                 DEFAULT_MODE);
+    config_set_d(CONFIG_CHEAT,                DEFAULT_CHEAT);
     config_set_s(CONFIG_PLAYER,               DEFAULT_PLAYER);
     config_set_s(CONFIG_BALL,                 DEFAULT_BALL);
     config_set_s(CONFIG_BALL_BONUS,           DEFAULT_BALL_BONUS);
@@ -208,6 +209,8 @@ void config_load(void)
                     config_set_d(CONFIG_ROTATE_SLOW,          atoi(val));
                 else if (strcmp(key, "mode")                  == 0)
                     config_set_d(CONFIG_MODE,                 atoi(val));
+                else if (strcmp(key, "cheat") == 0 && ALLOW_CHEAT)
+                    config_set_d(CONFIG_CHEAT,                atoi(val));
 
                 else if (strcmp(key, "key_forward")  == 0)
                     config_key(val, CONFIG_KEY_FORWARD, DEFAULT_KEY_FORWARD);
@@ -342,6 +345,11 @@ void config_save(void)
         fprintf(fp, "key_right            %s\n",
                 SDL_GetKeyName(option_d[CONFIG_KEY_RIGHT]));
 
+        if (option_d[CONFIG_CHEAT])
+            fprintf(fp,
+                    "cheat                %d\n",
+                    option_d[CONFIG_CHEAT]);
+
         fprintf(fp, "key_camera_1         %s\n",
                 SDL_GetKeyName(option_d[CONFIG_KEY_CAMERA_1]));
         fprintf(fp, "key_camera_2         %s\n",
@@ -612,20 +620,3 @@ void config_clear(void)
 }
 
 /*---------------------------------------------------------------------------*/
-
-static int cheat = 0;
-
-int config_get_cheat(void)
-{
-    return cheat;
-}
-
-void config_tgl_cheat()
-{
-    if (ALLOW_CHEAT && !cheat)
-        cheat = 1;
-    else
-        cheat = 0;
-}
-
-/*---------------------------------------------------------------------------*/
index 2a52901..1a3356a 100644 (file)
@@ -72,6 +72,7 @@ enum {
     CONFIG_ROTATE_FAST,
     CONFIG_ROTATE_SLOW,
     CONFIG_MODE,
+    CONFIG_CHEAT,
     CONFIG_KEY_FORWARD,
     CONFIG_KEY_BACKWARD,
     CONFIG_KEY_LEFT,
@@ -136,6 +137,7 @@ enum {
 #define DEFAULT_ROTATE_SLOW          100
 #define DEFAULT_ROTATE_FAST          200
 #define DEFAULT_MODE                 1
+#define DEFAULT_CHEAT                0
 #define DEFAULT_PLAYER               ""
 #define DEFAULT_BALL                 "png/ball.png"
 #define DEFAULT_BALL_BONUS           "png/ball-bonus.png"
@@ -181,9 +183,4 @@ void config_clear(void);
 
 /*---------------------------------------------------------------------------*/
 
-int config_get_cheat(void);
-void config_tgl_cheat();
-
-/*---------------------------------------------------------------------------*/
-
 #endif