]> git.itanic.dy.fi Git - sdl-planets/blobdiff - main.c
main.c: Skip simulation when time step is zero
[sdl-planets] / main.c
diff --git a/main.c b/main.c
index f2a012cf50d24036580df98f060e70e9c8e776aa..eb1b127c14058c2c3a5cce379d51c17134826d06 100644 (file)
--- a/main.c
+++ b/main.c
@@ -221,23 +221,25 @@ static void loop(SDL_Surface *screen, int num_of_planets, double total_mass,
        while (1) {
                planets = 0;
 
-               list_for_each_entry(pl1, &planet->list, list) {
-                       pl2 = list_to_planet(pl1->list.next);
-                       list_for_each_entry_from(pl2, &planet->list, list) {
-                               struct planet *ptmp;
-                               if (!gravitize_planets(pl1, pl2,
-                                                      step_time))
-                                       continue;
-
-                               ptmp = list_to_planet(pl2->list.prev);
-                               merge_planets(pl1, pl2);
-                               pl2 = ptmp;
+               if (status.time_scale > 0) {
+                       list_for_each_entry(pl1, &planet->list, list) {
+                               pl2 = list_to_planet(pl1->list.next);
+                               list_for_each_entry_from(pl2, &planet->list,
+                                                        list) {
+                                       struct planet *ptmp;
+                                       if (!gravitize_planets(pl1, pl2,
+                                                              step_time))
+                                               continue;
+
+                                       ptmp = list_to_planet(pl2->list.prev);
+                                       merge_planets(pl1, pl2);
+                                       pl2 = ptmp;
+                               }
+
+                               planet_root = move_planet(pl1, step_time);
+                               planets++;
                        }
-
-                       planet_root = move_planet(pl1, step_time);
-                       planets++;
                }
-
                move_camera(&camera, true_time);
 
                if (poll_events(&status, true_time))