From: Ingo Ruhnke Date: Sun, 10 Aug 2014 21:43:52 +0000 (+0200) Subject: Cleaned up the file handling in World, Worlds are now loaded by directory name instea... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=1a9e5d95df809bbc0612357ed965fa3f11d31f64;p=supertux.git Cleaned up the file handling in World, Worlds are now loaded by directory name instead of ".../info" filename --- diff --git a/src/supertux/world.cpp b/src/supertux/world.cpp index b87aab55f..60ce1cf1c 100644 --- a/src/supertux/world.cpp +++ b/src/supertux/world.cpp @@ -37,7 +37,7 @@ World::load(const std::string& directory) { std::unique_ptr world(new World); - world->load_(directory + "/info"); + world->load_(directory); { // generate savegame filename std::string worlddirname = FileSystem::basename(directory); @@ -51,9 +51,9 @@ World::load(const std::string& directory) } World::World() : - m_worldmap_filename(), m_levels(), m_basedir(), + m_worldmap_filename(), m_savegame_filename(), m_world_thread(), m_title(), @@ -71,13 +71,13 @@ World::~World() } void -World::load_(const std::string& filename) +World::load_(const std::string& directory) { - m_basedir = FileSystem::dirname(filename); - m_worldmap_filename = m_basedir + "worldmap.stwm"; + m_basedir = directory; + m_worldmap_filename = m_basedir + "/worldmap.stwm"; lisp::Parser parser; - const lisp::Lisp* root = parser.parse(filename); + const lisp::Lisp* root = parser.parse(m_basedir + "/info"); const lisp::Lisp* info = root->get_lisp("supertux-world"); if(info == NULL) @@ -156,7 +156,7 @@ World::run() { // fallback: try to load worldmap worldmap.stwm g_screen_manager->push_screen(std::unique_ptr( - new worldmap::WorldMap(m_basedir + "worldmap.stwm", + new worldmap::WorldMap(m_worldmap_filename, get_player_status()))); } } diff --git a/src/supertux/world.hpp b/src/supertux/world.hpp index fd2171bfc..f61ea7e63 100644 --- a/src/supertux/world.hpp +++ b/src/supertux/world.hpp @@ -31,7 +31,7 @@ class World : public Currenton private: World(); - void load_(const std::string& filename); + void load_(const std::string& directory); public: /** @@ -62,7 +62,6 @@ public: bool is_levelset() const { return m_is_levelset; } private: - std::string m_worldmap_filename; struct Level { Level() : fullpath(), name() {} @@ -72,6 +71,7 @@ private: std::vector m_levels; std::string m_basedir; + std::string m_worldmap_filename; std::string m_savegame_filename; HSQOBJECT m_world_thread; std::string m_title;