Added uniform sync option.
authorrlk <rlk@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Sat, 26 Jan 2008 22:26:42 +0000 (22:26 +0000)
committerrlk <rlk@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Sat, 26 Jan 2008 22:26:42 +0000 (22:26 +0000)
git-svn-id: https://s.snth.net/svn/neverball/trunk@1608 78b8d119-cf0a-0410-b17c-f493084dd1d7

ball/main.c
data/ball/atom/atom-inner.autosave.map [deleted file]
share/config.c
share/config.h

index 99c98f7..9ef2ac3 100644 (file)
@@ -342,7 +342,7 @@ int main(int argc, char *argv[])
     SDL_Surface *icon;
 #endif
 
-    int t1, t0;
+    int t1, t0, uniform;
 
     lang_init("neverball", CONFIG_LOCALE);
 
@@ -446,18 +446,31 @@ int main(int argc, char *argv[])
 
     /* Run the main game loop. */
 
+    uniform = config_get_d(CONFIG_UNIFORM);
     t0 = SDL_GetTicks();
 
     while (loop())
     {
         t1 = SDL_GetTicks();
 
-        /* Step the game state at least up to the current time. */
+        if (uniform)
+        {
+            /* Step the game uniformly, as configured. */
+
+            int u;
 
-        while (t1 > t0)
+            for (u = 0; u < abs(uniform); ++u)
+                st_timer(DT);
+        }
+        else
         {
-            st_timer(DT);
-            t0 += (int) (DT * 1000);
+            /* Step the game state at least up to the current time. */
+
+            while (t1 > t0)
+            {
+                st_timer(DT);
+                t0 += (int) (DT * 1000);
+            }
         }
 
         /* Render. */
@@ -465,6 +478,9 @@ int main(int argc, char *argv[])
         st_paint();
         config_swap();
 
+        if (uniform < 0)
+            shot();
+
         if (config_get_d(CONFIG_NICE))
             SDL_Delay(1);
     }
diff --git a/data/ball/atom/atom-inner.autosave.map b/data/ball/atom/atom-inner.autosave.map
deleted file mode 100644 (file)
index a2eb986..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-
-// entity 0
-{
-"classname" "worldspawn"
-"depthmask" "1"
-"alphatest" "0.5"
-"pendulum" "1"
-}
-// entity 1
-{
-"classname" "info_null"
-"origin" "24 0 0"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/proton"
-}
-// entity 2
-{
-"classname" "info_null"
-"origin" "-20 -20 0"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/proton"
-}
-// entity 3
-{
-"classname" "info_null"
-"origin" "-20 20 0"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/neutron"
-}
-// entity 4
-{
-"classname" "info_null"
-"origin" "8 16 -16"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/neutron"
-}
-// entity 5
-{
-"classname" "info_null"
-"origin" "0 0 -24"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/proton"
-}
-// entity 6
-{
-"classname" "info_null"
-"origin" "20 -20 0"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/neutron"
-}
-// entity 7
-{
-"classname" "info_null"
-"origin" "-8 -16 -16"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/neutron"
-}
-// entity 8
-{
-"classname" "info_null"
-"origin" "0 -24 0"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/neutron"
-}
-// entity 9
-{
-"classname" "info_null"
-"origin" "-24 0 0"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/neutron"
-}
-// entity 10
-{
-"classname" "info_null"
-"origin" "16 -8 -16"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/proton"
-}
-// entity 11
-{
-"classname" "info_null"
-"origin" "20 20 0"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/proton"
-}
-// entity 12
-{
-"classname" "info_null"
-"origin" "0 24 0"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/neutron"
-}
-// entity 13
-{
-"classname" "info_null"
-"origin" "0 0 24"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/neutron"
-}
-// entity 14
-{
-"classname" "info_null"
-"origin" "-16 8 -16"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/proton"
-}
-// entity 15
-{
-"classname" "info_null"
-"origin" "-8 16 0"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/neutron"
-}
-// entity 16
-{
-"classname" "info_null"
-"origin" "8 -16 0"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/neutron"
-}
-// entity 17
-{
-"classname" "info_null"
-"origin" "16 8 0"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/proton"
-}
-// entity 18
-{
-"classname" "info_null"
-"origin" "-16 -8 0"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/proton"
-}
-// entity 19
-{
-"classname" "info_null"
-"origin" "8 16 16"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/neutron"
-}
-// entity 20
-{
-"classname" "info_null"
-"origin" "-8 -16 16"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/neutron"
-}
-// entity 21
-{
-"classname" "info_null"
-"origin" "-16 8 16"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/proton"
-}
-// entity 22
-{
-"classname" "info_null"
-"origin" "16 -8 16"
-"height" "0.4 0.0 0.0"
-"width" "0.4 0.0 0.0"
-"image" "ball/atom/proton"
-}
index ed855a2..c495f2a 100644 (file)
@@ -117,6 +117,7 @@ void config_init(void)
     config_set_s(CONFIG_WIIMOTE_ADDR,         DEFAULT_WIIMOTE_ADDR);
     config_set_d(CONFIG_CHEAT,                DEFAULT_CHEAT);
     config_set_d(CONFIG_STATS,                DEFAULT_STATS);
+    config_set_d(CONFIG_UNIFORM,              DEFAULT_UNIFORM);
     config_set_d(CONFIG_KEY_FORWARD,          DEFAULT_KEY_FORWARD);
     config_set_d(CONFIG_KEY_BACKWARD,         DEFAULT_KEY_BACKWARD);
     config_set_d(CONFIG_KEY_LEFT,             DEFAULT_KEY_LEFT);
@@ -250,10 +251,12 @@ void config_load(void)
                 else if (strcmp(key, "wiimote_addr") == 0)
                     config_set_s(CONFIG_WIIMOTE_ADDR, val);
 
-                else if (strcmp(key, "cheat") == 0)
+                else if (strcmp(key, "cheat")   == 0)
                     config_set_d(CONFIG_CHEAT, atoi(val));
-                else if (strcmp(key, "stats") == 0)
+                else if (strcmp(key, "stats")   == 0)
                     config_set_d(CONFIG_STATS, atoi(val));
+                else if (strcmp(key, "uniform") == 0)
+                    config_set_d(CONFIG_UNIFORM, atoi(val));
 
                 else if (strcmp(key, "contrib") == 0)
                     config_set_d(CONFIG_SHOW_CONTRIBUTIONS, atoi(val));
@@ -384,6 +387,8 @@ void config_save(void)
 
         fprintf(fp, "stats                %d\n",
                 option_d[CONFIG_STATS]);
+        fprintf(fp, "uniform              %d\n",
+                option_d[CONFIG_UNIFORM]);
         if (config_cheat())
             fprintf(fp, "cheat                %d\n", option_d[CONFIG_CHEAT]);
 
index 1fe892d..b89c599 100644 (file)
@@ -87,6 +87,7 @@ enum {
     CONFIG_KEY_RESTART,
     CONFIG_CHEAT,
     CONFIG_STATS,
+    CONFIG_UNIFORM,
     CONFIG_SHOW_CONTRIBUTIONS,
 
     CONFIG_OPTION_D_COUNT
@@ -161,6 +162,7 @@ enum {
 #define DEFAULT_KEY_PAUSE            SDLK_SPACE
 #define DEFAULT_KEY_RESTART          SDLK_r
 #define DEFAULT_STATS                0
+#define DEFAULT_UNIFORM              0
 #define DEFAULT_SHOW_CONTRIBUTIONS   0
 
 /*---------------------------------------------------------------------------*/