{
try
{
- std::unique_ptr<World> world (new World);
-
- world->load(*it + "/info");
+ std::unique_ptr<World> world = World::load(*it + "/info");
if (!world->hide_from_contribs())
{
{
case MNID_STARTGAME:
{
- std::unique_ptr<World> world(new World);
- world->load("levels/world1/info");
+ std::unique_ptr<World> world = World::load("levels/world1/info");
GameManager::current()->start_game(std::move(world));
}
break;
#include "util/string_util.hpp"
#include "worldmap/worldmap.hpp"
+std::unique_ptr<World>
+World::load(const std::string& filename)
+{
+ std::unique_ptr<World> world(new World);
+ world->load_(filename);
+ return std::move(world);
+}
+
World::World() :
m_worldmap_filename(),
m_levels(),
}
void
-World::load(const std::string& filename)
+World::load_(const std::string& filename)
{
m_basedir = FileSystem::dirname(filename);
m_worldmap_filename = m_basedir + "worldmap.stwm";
#ifndef HEADER_SUPERTUX_SUPERTUX_WORLD_HPP
#define HEADER_SUPERTUX_SUPERTUX_WORLD_HPP
+#include <memory>
#include <squirrel.h>
#include <string>
#include <vector>
class World : public Currenton<World>
{
-public:
+private:
World();
+
+ void load_(const std::string& filename);
+
+public:
+ static std::unique_ptr<World> load(const std::string& filename);
+
+public:
~World();
void set_savegame_filename(const std::string& filename);
- void load(const std::string& filename);
void save_state();
void load_state();