Properly init the screen on startup with the stored configuration values
[supertux.git] / src / world.cpp
index 8b68b08..8fd4599 100644 (file)
@@ -72,7 +72,7 @@ World::set_savegame_filename(const std::string& filename)
           throw std::runtime_error(msg.str());
       }
   }
+
   if(!PHYSFS_isDirectory(dirname.c_str())) {
       std::ostringstream msg;
       msg << "Savegame path '" << dirname << "' is not a directory";
@@ -84,9 +84,9 @@ void
 World::load(const std::string& filename)
 {
   basedir = FileSystem::dirname(filename);
-  
+
   lisp::Parser parser;
-  std::auto_ptr<lisp::Lisp> root (parser.parse(filename));
+  const lisp::Lisp* root = parser.parse(filename);
 
   const lisp::Lisp* info = root->get_lisp("supertux-world");
   if(info == NULL)
@@ -105,8 +105,8 @@ World::load(const std::string& filename)
 
   // Level info file doesn't define any levels, so read the
   // directory to see what we can find
-      
-  std::string path = basedir + "/";
+
+  std::string path = basedir;
   char** files = PHYSFS_enumerateFiles(path.c_str());
   if(!files) {
     log_warning << "Couldn't read subset dir '" << path << "'" << std::endl;
@@ -127,7 +127,7 @@ World::run()
   using namespace Scripting;
 
   current_ = this;
-  
+
   // create new squirrel table for persisten game state
   HSQUIRRELVM vm = Scripting::global_vm;
 
@@ -139,7 +139,7 @@ World::run()
   sq_pop(vm, 1);
 
   load_state();
-  
+
   std::string filename = basedir + "/world.nut";
   try {
     IFileStream in(filename);
@@ -147,7 +147,7 @@ World::run()
     sq_release(global_vm, &world_thread);
     world_thread = create_thread(global_vm);
     compile_and_run(object_to_vm(world_thread), in, filename);
-  } catch(std::exception& e) {
+  } catch(std::exception& ) {
     // fallback: try to load worldmap worldmap.stwm
     using namespace WorldMapNS;
     main_loop->push_screen(new WorldMap(basedir + "worldmap.stwm"));
@@ -163,12 +163,12 @@ World::save_state()
 
   writer.start_list("supertux-savegame");
   writer.write_int("version", 1);
-  
+
   using namespace WorldMapNS;
   if(WorldMap::current() != NULL) {
     std::ostringstream title;
     title << WorldMap::current()->get_title();
-    title << " (" << WorldMap::current()->solved_level_count() 
+    title << " (" << WorldMap::current()->solved_level_count()
           << "/" << WorldMap::current()->level_count() << ")";
     writer.write_string("title", title.str());
   }
@@ -178,7 +178,7 @@ World::save_state()
   writer.end_list("tux");
 
   writer.start_list("state");
-  
+
   sq_pushroottable(global_vm);
   sq_pushstring(global_vm, "state", -1);
   if(SQ_SUCCEEDED(sq_get(global_vm, -2))) {
@@ -187,7 +187,7 @@ World::save_state()
   }
   sq_pop(global_vm, 1);
   writer.end_list("state");
-  
+
   writer.end_list("supertux-savegame");
 }
 
@@ -198,7 +198,7 @@ World::load_state()
 
   try {
     lisp::Parser parser;
-    std::auto_ptr<lisp::Lisp> root (parser.parse(savegame_filename));
+    const lisp::Lisp* root = parser.parse(savegame_filename);
 
     const lisp::Lisp* lisp = root->get_lisp("supertux-savegame");
     if(lisp == NULL)
@@ -217,18 +217,18 @@ World::load_state()
     const lisp::Lisp* state = lisp->get_lisp("state");
     if(state == NULL)
       throw std::runtime_error("No state section in savegame");
-    
+
     sq_pushroottable(global_vm);
     sq_pushstring(global_vm, "state", -1);
     if(SQ_FAILED(sq_deleteslot(global_vm, -2, SQFalse)))
       sq_pop(global_vm, 1);
-    
+
     sq_pushstring(global_vm, "state", -1);
     sq_newtable(global_vm);
     load_squirrel_table(global_vm, -1, state);
     if(SQ_FAILED(sq_createslot(global_vm, -3)))
       throw std::runtime_error("Couldn't create state table");
-    sq_pop(global_vm, 1); 
+    sq_pop(global_vm, 1);
   } catch(std::exception& e) {
     log_debug << "Couldn't load savegame: " << e.what() << std::endl;
   }