New grow and skid sounds from remaxim
[supertux.git] / src / world.cpp
index d8beb4a..a5ec785 100644 (file)
@@ -20,8 +20,7 @@
 #include <config.h>
 
 #include <stddef.h>
-//#include <physfs.h>
-#include <unison/vfs/FileSystem.hpp>
+#include <physfs.h>
 #include <stdexcept>
 
 #include "world.hpp"
@@ -34,6 +33,7 @@
 #include "log.hpp"
 #include "worldmap/worldmap.hpp"
 #include "mainloop.hpp"
+#include "player_status.hpp"
 
 static bool has_suffix(const std::string& data, const std::string& suffix)
 {
@@ -62,21 +62,19 @@ World::~World()
 void
 World::set_savegame_filename(const std::string& filename)
 {
-  Unison::VFS::FileSystem &fs = Unison::VFS::FileSystem::get();
   this->savegame_filename = filename;
   // make sure the savegame directory exists
   std::string dirname = FileSystem::dirname(filename);
-  if(!fs.exists(dirname)) {
-      fs.mkdir(dirname);
-      /*if(PHYSFS_mkdir(dirname.c_str())) {
+  if(!PHYSFS_exists(dirname.c_str())) {
+      if(PHYSFS_mkdir(dirname.c_str())) {
           std::ostringstream msg;
           msg << "Couldn't create directory for savegames '"
               << dirname << "': " <<PHYSFS_getLastError();
           throw std::runtime_error(msg.str());
-      }*/
+      }
   }
 
-  if(!fs.is_dir(dirname)) {
+  if(!PHYSFS_isDirectory(dirname.c_str())) {
       std::ostringstream msg;
       msg << "Savegame path '" << dirname << "' is not a directory";
       throw std::runtime_error(msg.str());
@@ -103,21 +101,14 @@ World::load(const std::string& filename)
   info->get("title", title);
   info->get("description", description);
   info->get("levelset", is_levelset);
-  info->get_vector("levels", levels);
+  info->get("levels", levels);
   info->get("hide-from-contribs", hide_from_contribs);
 
   // Level info file doesn't define any levels, so read the
   // directory to see what we can find
 
   std::string path = basedir;
-  std::vector<std::string> files = Unison::VFS::FileSystem::get().ls(path);
-  for(std::vector<std::string>::iterator iter = files.begin();iter != files.end();++iter)
-  {
-    if(has_suffix(iter->c_str(), ".stl")) {
-      levels.push_back(path + *iter);
-    }
-  }
-  /*char** files = PHYSFS_enumerateFiles(path.c_str());
+  char** files = PHYSFS_enumerateFiles(path.c_str());
   if(!files) {
     log_warning << "Couldn't read subset dir '" << path << "'" << std::endl;
     return;
@@ -128,7 +119,7 @@ World::load(const std::string& filename)
       levels.push_back(path + *filename);
     }
   }
-  PHYSFS_freeList(files);*/
+  PHYSFS_freeList(files);
 }
 
 void
@@ -138,7 +129,7 @@ World::run()
 
   current_ = this;
 
-  // create new squirrel table for persisten game state
+  // create new squirrel table for persistent game state
   HSQUIRRELVM vm = Scripting::global_vm;
 
   sq_pushroottable(vm);
@@ -172,7 +163,7 @@ World::save_state()
   lisp::Writer writer(savegame_filename);
 
   writer.start_list("supertux-savegame");
-  writer.write_int("version", 1);
+  writer.write("version", 1);
 
   using namespace WorldMapNS;
   if(WorldMap::current() != NULL) {
@@ -180,7 +171,7 @@ World::save_state()
     title << WorldMap::current()->get_title();
     title << " (" << WorldMap::current()->solved_level_count()
           << "/" << WorldMap::current()->level_count() << ")";
-    writer.write_string("title", title.str());
+    writer.write("title", title.str());
   }
 
   writer.start_list("tux");