From: Ingo Ruhnke Date: Sun, 11 Apr 2004 13:05:35 +0000 (+0000) Subject: - renamed 'world' to 'global_world' to emphasis that it is mainly a temporary hack X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=1cb0101ce7c9983bfd83c3d6bcd1b6c2747adaf8;p=supertux.git - renamed 'world' to 'global_world' to emphasis that it is mainly a temporary hack - moved some 'world' to 'World::current()' SVN-Revision: 472 --- diff --git a/src/gameloop.cpp b/src/gameloop.cpp index 62dfa2582..133a2ae6e 100644 --- a/src/gameloop.cpp +++ b/src/gameloop.cpp @@ -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); diff --git a/src/gameloop.h b/src/gameloop.h index ee7cf35e3..dedcfac70 100644 --- a/src/gameloop.h +++ b/src/gameloop.h @@ -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*/ diff --git a/src/gameobjs.cpp b/src/gameobjs.cpp index f1c7a810e..5bd9dd71e 100644 --- a/src/gameobjs.cpp +++ b/src/gameobjs.cpp @@ -38,7 +38,7 @@ BouncyDistro::action() base.ym += 0.1 * frame_ratio; if (base.ym >= 0) - world.bouncy_distros.erase(static_cast::iterator>(this)); + World::current()->bouncy_distros.erase(static_cast::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::iterator>(this)); + World::current()->broken_bricks.erase(static_cast::iterator>(this)); } void @@ -115,7 +115,7 @@ BouncyBrick::action() /* Stop bouncing? */ if (offset >= 0) - world.bouncy_bricks.erase(static_cast::iterator>(this)); + World::current()->bouncy_bricks.erase(static_cast::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::iterator>(this)); + World::current()->floating_scores.erase(static_cast::iterator>(this)); } void diff --git a/src/leveleditor.cpp b/src/leveleditor.cpp index 2a4d648fa..51d7194c4 100644 --- a/src/leveleditor.cpp +++ b/src/leveleditor.cpp @@ -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::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::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::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::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() diff --git a/src/special.cpp b/src/special.cpp index 9070f8e5b..094df3bc3 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -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::iterator>(pbullet)); + World::current()->bullets.erase(static_cast::iterator>(pbullet)); } } @@ -92,9 +92,9 @@ void bullet_collision(bullet_type* pbullet, int c_object) if(c_object == CO_BADGUY) { std::vector::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::iterator>(pupgrade)); + World::current()->upgrades.erase(static_cast::iterator>(pupgrade)); if (pupgrade->base.y > screen->h) - world.upgrades.erase(static_cast::iterator>(pupgrade)); + World::current()->upgrades.erase(static_cast::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::iterator>(pupgrade)); + World::current()->upgrades.erase(static_cast::iterator>(pupgrade)); /* Affect the player: */ diff --git a/src/world.cpp b/src/world.cpp index 1cfac5ed9..234b062c7 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -32,7 +32,7 @@ texture_type img_distro[4]; World* World::current_ = 0; -World world; +World global_world; World::World() { diff --git a/src/world.h b/src/world.h index 5c53c36f9..e655e4620 100644 --- a/src/world.h +++ b/src/world.h @@ -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*/