From: Ingo Ruhnke Date: Sun, 11 Apr 2004 01:36:22 +0000 (+0000) Subject: - moved some activate_bad_guy stuff into the world, where it belongs X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=f2ef2cce111f31796ddea0a36f0d52d10ab71d0f;p=supertux.git - moved some activate_bad_guy stuff into the world, where it belongs SVN-Revision: 466 --- diff --git a/src/gameloop.cpp b/src/gameloop.cpp index 838ccd7d2..93c5aef96 100644 --- a/src/gameloop.cpp +++ b/src/gameloop.cpp @@ -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::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(); diff --git a/src/gameloop.h b/src/gameloop.h index df0868d66..ee7cf35e3 100644 --- a/src/gameloop.h +++ b/src/gameloop.h @@ -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); diff --git a/src/leveleditor.cpp b/src/leveleditor.cpp index a4c40fa9c..6d1663261 100644 --- a/src/leveleditor.cpp +++ b/src/leveleditor.cpp @@ -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() diff --git a/src/world.cpp b/src/world.cpp index b4eca079e..b129cd5f4 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -64,6 +64,16 @@ World::arrays_free(void) particle_systems.clear(); } +void +World::activate_bad_guys() +{ + for (std::vector::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() diff --git a/src/world.h b/src/world.h index 3398b2db6..99ca51b3f 100644 --- a/src/world.h +++ b/src/world.h @@ -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);