Skip to content

Commit

Permalink
Cleaned up the file handling in World, Worlds are now loaded by direc…
Browse files Browse the repository at this point in the history
…tory name instead of ".../info" filename
  • Loading branch information
Grumbel committed Aug 11, 2014
1 parent 4d8c468 commit 1a9e5d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/supertux/world.cpp
Expand Up @@ -37,7 +37,7 @@ World::load(const std::string& directory)
{
std::unique_ptr<World> world(new World);

world->load_(directory + "/info");
world->load_(directory);

{ // generate savegame filename
std::string worlddirname = FileSystem::basename(directory);
Expand All @@ -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(),
Expand All @@ -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)
Expand Down Expand Up @@ -156,7 +156,7 @@ World::run()
{
// fallback: try to load worldmap worldmap.stwm
g_screen_manager->push_screen(std::unique_ptr<Screen>(
new worldmap::WorldMap(m_basedir + "worldmap.stwm",
new worldmap::WorldMap(m_worldmap_filename,
get_player_status())));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/supertux/world.hpp
Expand Up @@ -31,7 +31,7 @@ class World : public Currenton<World>
private:
World();

void load_(const std::string& filename);
void load_(const std::string& directory);

public:
/**
Expand Down Expand Up @@ -62,7 +62,6 @@ class World : public Currenton<World>
bool is_levelset() const { return m_is_levelset; }

private:
std::string m_worldmap_filename;
struct Level
{
Level() : fullpath(), name() {}
Expand All @@ -72,6 +71,7 @@ class World : public Currenton<World>

std::vector<Level> m_levels;
std::string m_basedir;
std::string m_worldmap_filename;
std::string m_savegame_filename;
HSQOBJECT m_world_thread;
std::string m_title;
Expand Down

0 comments on commit 1a9e5d9

Please sign in to comment.