diff --git a/TileGenerator.cpp b/TileGenerator.cpp index ca3a290..a8c86f3 100644 --- a/TileGenerator.cpp +++ b/TileGenerator.cpp @@ -20,6 +20,7 @@ #include #include #include "config.h" +#include "Settings.h" #include "PlayerAttributes.h" #include "TileGenerator.h" #include "ZlibDecompressor.h" @@ -714,38 +715,8 @@ void TileGenerator::parseHeightMapNodesLine(const std::string &line, std::string std::string TileGenerator::getWorldDatabaseBackend(const std::string &input) { - string backend; - - std::string worldFile = input + PATH_SEPARATOR + "world.mt"; - ifstream in; - in.open(worldFile.c_str(), ifstream::in); - if (!in.is_open()) - throw std::runtime_error(std::string("Failed to open world.mt file '") + worldFile + "'"); - - std::string line; - int linenr = 0; - for (std::getline(in,line); in.good(); std::getline(in,line)) { - linenr++; - istringstream iline; - iline.str(line); - iline >> std::skipws; - string variable; - string eq; - iline >> variable; - if (variable != "backend") - continue; - iline >> eq; - iline >> backend; - if (in.fail() || eq != "=") { - ostringstream oss; - oss << "Error parsing 'backend' in world.mt file at line " << linenr; - throw std::runtime_error(oss.str()); - } - } - in.close(); - if (backend == "") - backend = "sqlite3"; - return backend; + Settings world_mt(input + PATH_SEPARATOR + "world.mt"); + return world_mt.get("backend", "sqlite3"); } int TileGenerator::getMapChunkSize(const std::string &input)