leaks fix (valgrind full leak check)
This commit is contained in:
@@ -2,18 +2,13 @@
|
||||
#include "../voxels/WorldGenerator.h"
|
||||
#include "../voxels/FlatWorldGenerator.h"
|
||||
#include "../content/Content.h"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
std::vector<std::string> WorldGenerators::getGeneratorsIDs() {
|
||||
std::vector<std::string> ids;
|
||||
|
||||
for(std::map<std::string, gen_constructor>::iterator it = generators.begin(); it != generators.end(); ++it) {
|
||||
ids.push_back(it->first);
|
||||
for (auto& entry : generators) {
|
||||
ids.push_back(entry.first);
|
||||
}
|
||||
|
||||
return ids;
|
||||
}
|
||||
|
||||
@@ -21,13 +16,10 @@ std::string WorldGenerators::getDefaultGeneratorID() {
|
||||
return "core:default";
|
||||
}
|
||||
|
||||
WorldGenerator* WorldGenerators::createGenerator(std::string id, const Content* content) {
|
||||
for(std::map<std::string, gen_constructor>::iterator it = generators.begin(); it != generators.end(); ++it) {
|
||||
if(id == it->first) {
|
||||
return (WorldGenerator*) it->second(content);
|
||||
}
|
||||
std::unique_ptr<WorldGenerator> WorldGenerators::createGenerator(std::string id, const Content* content) {
|
||||
auto found = generators.find(id);
|
||||
if (found == generators.end()) {
|
||||
throw std::runtime_error("unknown generator id: "+id);
|
||||
}
|
||||
|
||||
std::cerr << "unknown generator id: " << id << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
return std::unique_ptr<WorldGenerator>(found->second(content));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user