aboutsummaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-01-27 02:07:41 -0500
committerkwolekr <kwolekr@minetest.net>2015-01-27 02:10:04 -0500
commiteeea454bff0cfcda495c20029a0246f63f14393e (patch)
tree699a9c5eed431d52cfc36f010269e49f67bf5e34 /src/map.cpp
parentca217d041639883ffcc1c7f7856502efca1b90a4 (diff)
downloadminetest-eeea454bff0cfcda495c20029a0246f63f14393e.tar.gz
minetest-eeea454bff0cfcda495c20029a0246f63f14393e.tar.bz2
minetest-eeea454bff0cfcda495c20029a0246f63f14393e.zip
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.
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/map.cpp b/src/map.cpp
index bd3636c7b..d8f018742 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -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);