Moved Levelset into it's own class, pass WorldState around instead of PlayerState...
[supertux.git] / src / worldmap / worldmap.cpp
index dfc3bfc..998695f 100644 (file)
@@ -59,6 +59,7 @@
 #include "supertux/tile_manager.hpp"
 #include "supertux/tile_set.hpp"
 #include "supertux/world.hpp"
+#include "supertux/world_state.hpp"
 #include "util/file_system.hpp"
 #include "util/gettext.hpp"
 #include "util/log.hpp"
@@ -77,9 +78,9 @@ namespace worldmap {
 
 WorldMap* WorldMap::current_ = NULL;
 
-WorldMap::WorldMap(const std::string& filename, PlayerStatus* player_status, const std::string& force_spawnpoint) :
-  tux(0),
-  player_status(player_status),
+WorldMap::WorldMap(const std::string& filename, WorldState& world_state, const std::string& force_spawnpoint) :
+  tux(),
+  m_world_state(world_state),
   tileset(NULL),
   free_tileset(false),
   camera_offset(),
@@ -239,7 +240,7 @@ void
 WorldMap::change(const std::string& filename, const std::string& force_spawnpoint)
 {
   g_screen_manager->pop_screen();
-  g_screen_manager->push_screen(std::unique_ptr<Screen>(new WorldMap(filename, player_status, force_spawnpoint)));
+  g_screen_manager->push_screen(std::unique_ptr<Screen>(new WorldMap(filename, m_world_state, force_spawnpoint)));
 }
 
 void
@@ -694,7 +695,7 @@ WorldMap::update(float delta)
           // update state and savegame
           save_state();
 
-          g_screen_manager->push_screen(std::unique_ptr<Screen>(new GameSession(levelfile, player_status, &level->statistics)),
+          g_screen_manager->push_screen(std::unique_ptr<Screen>(new GameSession(levelfile, m_world_state, &level->statistics)),
                                         std::unique_ptr<ScreenFade>(new ShrinkFade(shrinkpos, 1.0f)));
           in_level = true;
         } catch(std::exception& e) {
@@ -829,7 +830,7 @@ WorldMap::draw_status(DrawingContext& context)
   context.push_transform();
   context.set_translation(Vector(0, 0));
 
-  player_status->draw(context);
+  m_world_state.get_player_status()->draw(context);
 
   if (!tux->is_moving()) {
     for(LevelTiles::iterator i = levels.begin(); i != levels.end(); ++i) {
@@ -1031,8 +1032,16 @@ WorldMap::save_state()
 
   sq_settop(vm, oldtop);
 
-  if(World::current() != NULL)
-    World::current()->save_state();
+  if (!World::current())
+  {
+    log_fatal << "no World::current(), so can't savegame" << std::endl;
+  }
+  else
+  {
+#ifdef GRUMBEL
+    m_world_state->save_state();
+#endif
+  }
 }
 
 void