- moved some activate_bad_guy stuff into the world, where it belongs
authorIngo Ruhnke <grumbel@gmx.de>
Sun, 11 Apr 2004 01:36:22 +0000 (01:36 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Sun, 11 Apr 2004 01:36:22 +0000 (01:36 +0000)
SVN-Revision: 466

src/gameloop.cpp
src/gameloop.h
src/leveleditor.cpp
src/world.cpp
src/world.h

index 838ccd7..93c5aef 100644 (file)
@@ -119,7 +119,8 @@ GameSession::GameSession(const std::string& subset, int levelnb, int mode)
 
   world->get_level()->load_gfx();
   loadshared();
-  activate_bad_guys(world->get_level());
+  
+  world->activate_bad_guys();
   world->activate_particle_systems();
   world->get_level()->load_song();
 
@@ -169,16 +170,6 @@ GameSession::start_timers()
   update_time = st_get_ticks();
 }
 
-void activate_bad_guys(Level* plevel)
-{
-  for (std::vector<BadGuyData>::iterator i = plevel->badguy_data.begin();
-       i != plevel->badguy_data.end();
-       ++i)
-    {
-      world.add_bad_guy(i->x, i->y, i->kind);
-    }
-}
-
 void
 GameSession::process_events()
 {
@@ -370,8 +361,9 @@ GameSession::action()
               world->get_level()->free_gfx();
               world->get_level()->cleanup();
               world->get_level()->free_song();
-              unloadshared();
               world->arrays_free();
+
+              unloadshared();
               return(0);
             }
           tux.level_begin();
@@ -392,19 +384,21 @@ GameSession::action()
                   if (score > hs_score)
                     save_hs(score);
                 }
+
               world->get_level()->free_gfx();
               world->get_level()->cleanup();
               world->get_level()->free_song();
-              unloadshared();
               world->arrays_free();
+
+              unloadshared();
               return(0);
             } /* if (lives < 0) */
         }
 
       /* Either way, (re-)load the (next) level... */
-
       tux.level_begin();
       set_defaults();
+      
       world->get_level()->cleanup();
 
       if (st_gl_mode == ST_GL_LOAD_LEVEL_FILE)
@@ -419,7 +413,7 @@ GameSession::action()
         }
 
       world->arrays_free();
-      activate_bad_guys(world->get_level());
+      world->activate_bad_guys();
       world->activate_particle_systems();
 
       world->get_level()->free_gfx();
@@ -844,10 +838,11 @@ GameSession::loadgame(int slot)
 
       set_defaults();
       world->get_level()->cleanup();
+      world->arrays_free();
+
       if(world->get_level()->load(level_subset,level) != 0)
         exit(1);
-      world->arrays_free();
-      activate_bad_guys(world->get_level());
+      world->activate_bad_guys();
       world->activate_particle_systems();
       
       world->get_level()->free_gfx();
index df0868d..ee7cf35 100644 (file)
@@ -63,8 +63,6 @@ class GameSession
   void start_timers();
 };
 
-void  activate_bad_guys(Level* plevel);
-
 std::string slotinfo(int slot);
 
 bool  rectcollision(base_type* one, base_type* two);
index a4c40fa..6d16632 100644 (file)
@@ -252,7 +252,7 @@ int leveleditor(int levelnb)
                         }
                       le_set_defaults();
                       le_current_level->load_gfx();
-                     activate_bad_guys(le_current_level);
+                     world.activate_bad_guys();
                       show_menu = true;
                     }
                   break;
@@ -283,7 +283,7 @@ int leveleditor(int levelnb)
                         }
                       le_set_defaults();
                       le_current_level->load_gfx();
-                     activate_bad_guys(le_current_level);
+                     world.activate_bad_guys();
                       menu_item_change_input(&subset_new_menu->item[2],"");
                       show_menu = true;
                       break;
@@ -559,7 +559,7 @@ void le_goto_level(int levelnb)
   le_current_level->free_gfx();
   le_current_level->load_gfx();
 
-  activate_bad_guys(le_current_level);
+  world.activate_bad_guys();
 }
 
 void le_quit(void)
@@ -595,8 +595,8 @@ void le_quit(void)
     {
       le_current_level->free_gfx();
       le_current_level->cleanup();
-      unloadshared();
       world.arrays_free();
+      unloadshared();
     }
 }
 
@@ -1196,7 +1196,7 @@ void le_testlevel()
   world.arrays_free();
   le_current_level->load_gfx();
   loadshared();
-  activate_bad_guys(le_current_level);
+  world.activate_bad_guys();
 }
 
 void le_showhelp()
index b4eca07..b129cd5 100644 (file)
@@ -64,6 +64,16 @@ World::arrays_free(void)
   particle_systems.clear();
 }
 
+void
+World::activate_bad_guys()
+{
+  for (std::vector<BadGuyData>::iterator i = level->badguy_data.begin();
+       i != level->badguy_data.end();
+       ++i)
+    {
+      add_bad_guy(i->x, i->y, i->kind);
+    }
+}
 
 void
 World::activate_particle_systems()
index 3398b2d..99ca51b 100644 (file)
@@ -124,6 +124,7 @@ class World
   int  load(const std::string& filename);
 
   void activate_particle_systems();
+  void activate_bad_guys();
 
   void add_score(float x, float y, int s);
   void add_bouncy_distro(float x, float y);