@@ -8,7 +8,7 @@ class WGDefault: public Swan::WorldGen { | |||
public: | |||
class Factory: public Swan::WorldGen::Factory { | |||
public: | |||
WorldGen *create(Swan::World &world) { return new WGDefault(world); } | |||
WorldGen *create(Swan::World &world) override { return new WGDefault(world); } | |||
}; | |||
WGDefault(Swan::World &world): |
@@ -15,7 +15,7 @@ public: | |||
class Factory { | |||
public: | |||
virtual ~Factory() = default; | |||
virtual WorldGen *create(World &tmap) = 0; | |||
virtual WorldGen *create(World &world) = 0; | |||
std::string name_; | |||
}; | |||
@@ -116,7 +116,7 @@ static char hexchr(uint8_t nibble) { | |||
SRF *SRF::read(std::istream &is) { | |||
Type type = (Type)readByte(is); | |||
SRF *srf; | |||
SRF *srf = nullptr; | |||
switch (type) { | |||
case Type::OBJECT: |
@@ -89,12 +89,13 @@ void World::setCurrentPlane(WorldPlane &plane) { | |||
WorldPlane &World::addPlane(const std::string &gen) { | |||
WorldPlane::ID id = planes_.size(); | |||
auto it = worldgens_.find(gen); | |||
if (it == end(worldgens_)) { | |||
if (it == end(worldgens_)) { | |||
panic << "Tried to add plane with non-existant world gen " << gen << "!"; | |||
abort(); | |||
} | |||
WorldGen *g = it->second->create(*this); | |||
WorldGen::Factory *factory = it->second; | |||
WorldGen *g = factory->create(*this); | |||
planes_.push_back(WorldPlane(id, this, std::shared_ptr<WorldGen>(g))); | |||
return planes_[id]; | |||
} |