From 217a9bb34ddfde128df1567877cbef7df8729c28 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 22 Jan 2017 12:06:02 +0100 Subject: Core/Vmaps: Changed error message when loading outdated vmaps Closes #18431 Closes #18857 (cherry-picked from c90882ed6e2aba3b2d421abdc17cb57bea61d04b) --- src/common/Collision/Maps/MapTree.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'src/common/Collision/Maps/MapTree.cpp') 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; } //========================================================= -- cgit v1.2.3