Skip to content
Snippets Groups Projects
Commit eeea454b authored by kwolekr's avatar kwolekr
Browse files

Fix missing map_meta.txt error when creating new worlds

A missing map_meta.txt should be treated simply as if there were a blank file.
parent ca217d04
No related branches found
No related tags found
No related merge requests found
......@@ -3109,7 +3109,7 @@ void ServerMap::saveMapMeta()
createDirs(m_savedir);
std::string fullpath = m_savedir + DIR_DELIM + "map_meta.txt";
std::string fullpath = m_savedir + DIR_DELIM "map_meta.txt";
std::ostringstream ss(std::ios_base::binary);
Settings params;
......@@ -3133,19 +3133,21 @@ void ServerMap::loadMapMeta()
{
DSTACK(__FUNCTION_NAME);
Settings params;
std::string fullpath = m_savedir + DIR_DELIM "map_meta.txt";
std::ifstream is(fullpath.c_str(), std::ios_base::binary);
if (!is.good()) {
errorstream << "ServerMap::loadMapMeta(): "
<< "could not open" << fullpath << std::endl;
throw FileNotGoodException("Cannot open map metadata");
}
Settings params;
if (fs::PathExists(fullpath)) {
std::ifstream is(fullpath.c_str(), std::ios_base::binary);
if (!is.good()) {
errorstream << "ServerMap::loadMapMeta(): "
"could not open " << fullpath << std::endl;
throw FileNotGoodException("Cannot open map metadata");
}
if (!params.parseConfigLines(is, "[end_of_params]")) {
throw SerializationError("ServerMap::loadMapMeta(): "
if (!params.parseConfigLines(is, "[end_of_params]")) {
throw SerializationError("ServerMap::loadMapMeta(): "
"[end_of_params] not found!");
}
}
m_emerge->loadParamsFromSettings(&params);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment