summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-04-11 00:19:40 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-04-11 00:19:40 +0300
commit32360321018b83cb7b2c2018f6f477c70b9f633b (patch)
treeccbf1e74bde5cf92dd27632f8524f64fc6d80d49 /src
parentdc6966cb9d5f6b31ad7fb45d33aaa21192c3b89c (diff)
downloadminetest-32360321018b83cb7b2c2018f6f477c70b9f633b.tar.gz
minetest-32360321018b83cb7b2c2018f6f477c70b9f633b.tar.bz2
minetest-32360321018b83cb7b2c2018f6f477c70b9f633b.zip
improved old map support
Diffstat (limited to 'src')
-rw-r--r--src/map.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/map.cpp b/src/map.cpp
index 5ab7e5b02..ff823af94 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -5121,14 +5121,31 @@ MapSector* ServerMap::loadSectorMeta(std::string dirname)
// Get destination
v2s16 p2d = getSectorPos(dirname);
std::string dir = m_savedir + "/sectors/" + dirname;
+
+ ServerMapSector *sector = NULL;
std::string fullpath = dir + "/meta";
std::ifstream is(fullpath.c_str(), std::ios_base::binary);
if(is.good() == false)
- throw FileNotGoodException("Cannot open sector metafile");
-
- ServerMapSector *sector = ServerMapSector::deSerialize
- (is, this, p2d, m_sectors);
+ {
+ // If the directory exists anyway, it probably is in some old
+ // format. Just go ahead and create the sector.
+ if(fs::PathExists(dir))
+ {
+ dstream<<"ServerMap::loadSectorMeta(): Sector metafile "
+ <<fullpath<<" doesn't exist but directory does."
+ <<" Continuing with a sector with no metadata."
+ <<std::endl;
+ sector = createSector(p2d);
+ }
+ else
+ throw FileNotGoodException("Cannot open sector metafile");
+ }
+ else
+ {
+ sector = ServerMapSector::deSerialize
+ (is, this, p2d, m_sectors);
+ }
sector->differs_from_disk = false;