aboutsummaryrefslogtreecommitdiff
path: root/src/common/Collision/Maps/MapTree.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2017-01-22 12:06:02 +0100
committerShauren <shauren.trinity@gmail.com>2018-12-09 14:18:42 +0100
commit217a9bb34ddfde128df1567877cbef7df8729c28 (patch)
tree1b58a647d7b2f76bdbc4777b19121559ec977619 /src/common/Collision/Maps/MapTree.cpp
parent63fa69d39fea93b96337f0aff441ea1867436c1c (diff)
Core/Vmaps: Changed error message when loading outdated vmaps
Closes #18431 Closes #18857 (cherry-picked from c90882ed6e2aba3b2d421abdc17cb57bea61d04b)
Diffstat (limited to 'src/common/Collision/Maps/MapTree.cpp')
-rw-r--r--src/common/Collision/Maps/MapTree.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/common/Collision/Maps/MapTree.cpp b/src/common/Collision/Maps/MapTree.cpp
index ab48c4ebe0c..9b735061c29 100644
--- a/src/common/Collision/Maps/MapTree.cpp
+++ b/src/common/Collision/Maps/MapTree.cpp
@@ -255,35 +255,43 @@ namespace VMAP
}
//=========================================================
-
- bool StaticMapTree::CanLoadMap(const std::string &vmapPath, uint32 mapID, uint32 tileX, uint32 tileY, VMapManager2* vm)
+ LoadResult StaticMapTree::CanLoadMap(const std::string &vmapPath, uint32 mapID, uint32 tileX, uint32 tileY, VMapManager2* vm)
{
std::string basePath = vmapPath;
if (basePath.length() > 0 && basePath[basePath.length()-1] != '/' && basePath[basePath.length()-1] != '\\')
basePath.push_back('/');
std::string fullname = basePath + VMapManager2::getMapFileName(mapID);
- bool success = true;
+
+ LoadResult result = LoadResult::Success;
+
FILE* rf = fopen(fullname.c_str(), "rb");
if (!rf)
- return false;
+ return LoadResult::FileNotFound;
char chunk[8];
if (!readChunk(rf, chunk, VMAP_MAGIC, 8))
{
fclose(rf);
- return false;
+ return LoadResult::VersionMismatch;
}
FILE* tf = OpenMapTileFile(basePath, mapID, tileX, tileY, vm).File;
if (!tf)
- success = false;
+ return LoadResult::FileNotFound;
else
{
- if (!readChunk(tf, chunk, VMAP_MAGIC, 8))
- success = false;
- fclose(tf);
+ std::string tilefile = basePath + getTileFileName(mapID, tileX, tileY);
+ FILE* tf = fopen(tilefile.c_str(), "rb");
+ if (!tf)
+ result = LoadResult::FileNotFound;
+ else
+ {
+ if (!readChunk(tf, chunk, VMAP_MAGIC, 8))
+ result = LoadResult::VersionMismatch;
+ fclose(tf);
+ }
}
fclose(rf);
- return success;
+ return result;
}
//=========================================================