- renamed 'world' to 'global_world' to emphasis that it is mainly a temporary hack
authorIngo Ruhnke <grumbel@gmx.de>
Sun, 11 Apr 2004 13:05:35 +0000 (13:05 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Sun, 11 Apr 2004 13:05:35 +0000 (13:05 +0000)
- moved some 'world' to 'World::current()'

SVN-Revision: 472

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

index 62dfa25..133a2ae 100644 (file)
@@ -78,7 +78,7 @@ GameSession::GameSession(const std::string& filename)
 {
   current_ = this;
 
-  world = &::world;
+  world = &::global_world;
 
   timer_init(&fps_timer, true);
   timer_init(&frame_timer, true);
@@ -90,7 +90,7 @@ GameSession::GameSession(const std::string& subset, int levelnb, int mode)
 {
   current_ = this;
 
-  world = &::world;
+  world = &::global_world;
 
   timer_init(&fps_timer, true);
   timer_init(&frame_timer, true);
@@ -648,7 +648,7 @@ GameSession::run()
 /* Bounce a brick: */
 void bumpbrick(float x, float y)
 {
-  world.add_bouncy_brick(((int)(x + 1) / 32) * 32,
+  World::current()->add_bouncy_brick(((int)(x + 1) / 32) * 32,
                          (int)(y / 32) * 32);
 
   play_sound(sounds[SND_BRICK], SOUND_CENTER_SPEAKER);
index ee7cf35..dedcfac 100644 (file)
@@ -65,8 +65,7 @@ class GameSession
 
 std::string slotinfo(int slot);
 
-bool  rectcollision(base_type* one, base_type* two);
-void  drawshape(float x, float y, unsigned int c, Uint8 alpha = 255);
+bool rectcollision(base_type* one, base_type* two);
 void bumpbrick(float x, float y);
 
 #endif /*SUPERTUX_GAMELOOP_H*/
index f1c7a81..5bd9dd7 100644 (file)
@@ -38,7 +38,7 @@ BouncyDistro::action()
   base.ym += 0.1 * frame_ratio;
 
   if (base.ym >= 0)
-    world.bouncy_distros.erase(static_cast<std::vector<BouncyDistro>::iterator>(this));
+    World::current()->bouncy_distros.erase(static_cast<std::vector<BouncyDistro>::iterator>(this));
 }
 
 void
@@ -70,7 +70,7 @@ BrokenBrick::action()
   base.y = base.y + base.ym * frame_ratio;
 
   if (!timer_check(&timer))
-    world.broken_bricks.erase(static_cast<std::vector<BrokenBrick>::iterator>(this));
+    World::current()->broken_bricks.erase(static_cast<std::vector<BrokenBrick>::iterator>(this));
 }
 
 void
@@ -115,7 +115,7 @@ BouncyBrick::action()
 
   /* Stop bouncing? */
   if (offset >= 0)
-    world.bouncy_bricks.erase(static_cast<std::vector<BouncyBrick>::iterator>(this));
+    World::current()->bouncy_bricks.erase(static_cast<std::vector<BouncyBrick>::iterator>(this));
 }
 
 void
@@ -171,7 +171,7 @@ FloatingScore::action()
   base.y = base.y - 2 * frame_ratio;
 
   if(!timer_check(&timer))
-    world.floating_scores.erase(static_cast<std::vector<FloatingScore>::iterator>(this));
+    World::current()->floating_scores.erase(static_cast<std::vector<FloatingScore>::iterator>(this));
 }
 
 void
index 2a4d648..51d7194 100644 (file)
@@ -244,7 +244,7 @@ int leveleditor(int levelnb)
                       le_level_subset.load(level_subsets.item[i-2]);
                       leveleditor_menu->item[3].kind = MN_GOTO;
                       le_level = 1;
-                      world.arrays_free();
+                      global_world.arrays_free();
                       loadshared();
                       le_current_level = new Level;
                       if(le_current_level->load(le_level_subset.name.c_str(), le_level) != 0)
@@ -254,7 +254,7 @@ int leveleditor(int levelnb)
                         }
                       le_set_defaults();
                       le_current_level->load_gfx();
-                     world.activate_bad_guys();
+                     global_world.activate_bad_guys();
                       show_menu = true;
                     }
                   break;
@@ -275,7 +275,7 @@ int leveleditor(int levelnb)
                       le_level_subset.load(subset_new_menu->item[2].input);
                       leveleditor_menu->item[3].kind = MN_GOTO;
                       le_level = 1;
-                      world.arrays_free();
+                      global_world.arrays_free();
                       loadshared();
                       le_current_level = new Level;
                       if(le_current_level->load(le_level_subset.name.c_str(), le_level) != 0)
@@ -285,7 +285,7 @@ int leveleditor(int levelnb)
                         }
                       le_set_defaults();
                       le_current_level->load_gfx();
-                     world.activate_bad_guys();
+                     global_world.activate_bad_guys();
                       menu_item_change_input(&subset_new_menu->item[2],"");
                       show_menu = true;
                       break;
@@ -544,7 +544,7 @@ void save_subset_settings_menu()
 
 void le_goto_level(int levelnb)
 {
-  world.arrays_free();
+  global_world.arrays_free();
 
   le_current_level->cleanup();
   if(le_current_level->load(le_level_subset.name.c_str(), levelnb) != 0)
@@ -561,7 +561,7 @@ void le_goto_level(int levelnb)
   le_current_level->free_gfx();
   le_current_level->load_gfx();
 
-  world.activate_bad_guys();
+  global_world.activate_bad_guys();
 }
 
 void le_quit(void)
@@ -597,7 +597,7 @@ void le_quit(void)
     {
       le_current_level->free_gfx();
       le_current_level->cleanup();
-      world.arrays_free();
+      global_world.arrays_free();
       unloadshared();
     }
 }
@@ -729,12 +729,12 @@ void le_drawlevel()
       }
 
   /* Draw the Bad guys: */
-  for (i = 0; i < world.bad_guys.size(); ++i)
+  for (i = 0; i < global_world.bad_guys.size(); ++i)
     {
       /* to support frames: img_bsod_left[(frame / 5) % 4] */
       
       scroll_x = pos_x;
-      world.bad_guys[i].draw();
+      global_world.bad_guys[i].draw();
     }
 
 
@@ -1123,16 +1123,16 @@ void le_change(float x, float y, int tm, unsigned int c)
           xx = ((int)x / 32);
 
           /* if there is a bad guy over there, remove it */
-          for(i = 0; i < world.bad_guys.size(); ++i)
-            if(xx == world.bad_guys[i].base.x/32 && yy == world.bad_guys[i].base.y/32)
-              world.bad_guys.erase(static_cast<std::vector<BadGuy>::iterator>(&world.bad_guys[i]));
+          for(i = 0; i < global_world.bad_guys.size(); ++i)
+            if(xx == global_world.bad_guys[i].base.x/32 && yy == global_world.bad_guys[i].base.y/32)
+              global_world.bad_guys.erase(static_cast<std::vector<BadGuy>::iterator>(&global_world.bad_guys[i]));
 
           if(c == '0')  /* if it's a bad guy */
-            world.add_bad_guy(xx*32, yy*32, BAD_BSOD);
+            global_world.add_bad_guy(xx*32, yy*32, BAD_BSOD);
           else if(c == '1')
-            world.add_bad_guy(xx*32, yy*32, BAD_LAPTOP);
+            global_world.add_bad_guy(xx*32, yy*32, BAD_LAPTOP);
           else if(c == '2')
-            world.add_bad_guy(xx*32, yy*32, BAD_MONEY);
+            global_world.add_bad_guy(xx*32, yy*32, BAD_MONEY);
 
           break;
         case SQUARE:
@@ -1163,10 +1163,10 @@ void le_change(float x, float y, int tm, unsigned int c)
           y2 /= 32;
 
           /* if there is a bad guy over there, remove it */
-          for(i = 0; i < world.bad_guys.size(); ++i)
-            if(world.bad_guys[i].base.x/32 >= x1 && world.bad_guys[i].base.x/32 <= x2
-               && world.bad_guys[i].base.y/32 >= y1 && world.bad_guys[i].base.y/32 <= y2)
-              world.bad_guys.erase(static_cast<std::vector<BadGuy>::iterator>(&world.bad_guys[i]));
+          for(i = 0; i < global_world.bad_guys.size(); ++i)
+            if(global_world.bad_guys[i].base.x/32 >= x1 && global_world.bad_guys[i].base.x/32 <= x2
+               && global_world.bad_guys[i].base.y/32 >= y1 && global_world.bad_guys[i].base.y/32 <= y2)
+              global_world.bad_guys.erase(static_cast<std::vector<BadGuy>::iterator>(&global_world.bad_guys[i]));
 
           for(xx = x1; xx <= x2; xx++)
             for(yy = y1; yy <= y2; yy++)
@@ -1174,11 +1174,11 @@ void le_change(float x, float y, int tm, unsigned int c)
                 le_current_level->change(xx*32, yy*32, tm, c);
 
                 if(c == '0')  // if it's a bad guy
-                  world.add_bad_guy(xx*32, yy*32, BAD_BSOD);
+                  global_world.add_bad_guy(xx*32, yy*32, BAD_BSOD);
                 else if(c == '1')
-                  world.add_bad_guy(xx*32, yy*32, BAD_LAPTOP);
+                  global_world.add_bad_guy(xx*32, yy*32, BAD_LAPTOP);
                 else if(c == '2')
-                  world.add_bad_guy(xx*32, yy*32, BAD_MONEY);
+                  global_world.add_bad_guy(xx*32, yy*32, BAD_MONEY);
               }
           break;
         default:
@@ -1195,10 +1195,10 @@ void le_testlevel()
   session.run();
 
   Menu::set_current(leveleditor_menu);
-  world.arrays_free();
+  global_world.arrays_free();
   le_current_level->load_gfx();
   loadshared();
-  world.activate_bad_guys();
+  global_world.activate_bad_guys();
 }
 
 void le_showhelp()
index 9070f8e..094df3b 100644 (file)
@@ -72,7 +72,7 @@ void bullet_action(bullet_type* pbullet)
       issolid(pbullet->base.x + 4, pbullet->base.y + 2) ||
       issolid(pbullet->base.x, pbullet->base.y + 2))
     {
-      world.bullets.erase(static_cast<std::vector<bullet_type>::iterator>(pbullet));
+      World::current()->bullets.erase(static_cast<std::vector<bullet_type>::iterator>(pbullet));
     }
 
 }
@@ -92,9 +92,9 @@ void bullet_collision(bullet_type* pbullet, int c_object)
   if(c_object == CO_BADGUY) {
     std::vector<bullet_type>::iterator i;
     
-    for(i = world.bullets.begin(); i != world.bullets.end(); ++i) {
+    for(i = World::current()->bullets.begin(); i != World::current()->bullets.end(); ++i) {
       if(& (*i) == pbullet) {
-        world.bullets.erase(i);
+        World::current()->bullets.erase(i);
         return;
       }
     }
@@ -144,9 +144,9 @@ void upgrade_action(upgrade_type *pupgrade)
           /* Off the screen?  Kill it! */
 
           if (pupgrade->base.x < scroll_x - pupgrade->base.width)
-            world.upgrades.erase(static_cast<std::vector<upgrade_type>::iterator>(pupgrade));
+            World::current()->upgrades.erase(static_cast<std::vector<upgrade_type>::iterator>(pupgrade));
           if (pupgrade->base.y > screen->h)
-            world.upgrades.erase(static_cast<std::vector<upgrade_type>::iterator>(pupgrade));
+            World::current()->upgrades.erase(static_cast<std::vector<upgrade_type>::iterator>(pupgrade));
 
           if (issolid(pupgrade->base.x + 1, pupgrade->base.y + 32.) ||
               issolid(pupgrade->base.x + 31., pupgrade->base.y + 32.))
@@ -234,7 +234,7 @@ void upgrade_collision(upgrade_type* pupgrade, void* p_c_object, int c_object)
       /* p_c_object is CO_PLAYER, so assign it to pplayer */
       pplayer = (Player*) p_c_object;
 
-      world.upgrades.erase(static_cast<std::vector<upgrade_type>::iterator>(pupgrade));
+      World::current()->upgrades.erase(static_cast<std::vector<upgrade_type>::iterator>(pupgrade));
 
       /* Affect the player: */
 
index 1cfac5e..234b062 100644 (file)
@@ -32,7 +32,7 @@ texture_type img_distro[4];
 
 World* World::current_ = 0;
 
-World world;
+World global_world;
 
 World::World()
 {
index 5c53c36..e655e46 100644 (file)
@@ -100,7 +100,8 @@ class World
   void trybumpbadguy(float x, float y);
 };
 
-extern World world;
+/** FIMXE: Workaround for the leveleditor mainly */
+extern World global_world;
 
 #endif /*SUPERTUX_WORLD_H*/