diff options
author | Shauren <shauren.trinity@gmail.com> | 2017-01-22 12:06:02 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2017-01-22 12:06:02 +0100 |
commit | c90882ed6e2aba3b2d421abdc17cb57bea61d04b (patch) | |
tree | 3daf95f79375d77574bb1c92806263581db90af2 /src/common/Collision/Maps/MapTree.cpp | |
parent | c83092a1276f522cf11f5e3ceded7306e8fdb937 (diff) |
Core/Vmaps: Changed error message when loading outdated vmaps
Closes #18431
Closes #18857
Diffstat (limited to 'src/common/Collision/Maps/MapTree.cpp')
-rw-r--r-- | src/common/Collision/Maps/MapTree.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/common/Collision/Maps/MapTree.cpp b/src/common/Collision/Maps/MapTree.cpp index 6b10c414103..f3fe8c1f56f 100644 --- a/src/common/Collision/Maps/MapTree.cpp +++ b/src/common/Collision/Maps/MapTree.cpp @@ -237,40 +237,41 @@ namespace VMAP } //========================================================= - - bool StaticMapTree::CanLoadMap(const std::string &vmapPath, uint32 mapID, uint32 tileX, uint32 tileY) + LoadResult StaticMapTree::CanLoadMap(const std::string &vmapPath, uint32 mapID, uint32 tileX, uint32 tileY) { 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; - /// @todo check magic number when implemented... + return LoadResult::FileNotFound; + char tiled; char chunk[8]; if (!readChunk(rf, chunk, VMAP_MAGIC, 8) || fread(&tiled, sizeof(char), 1, rf) != 1) { fclose(rf); - return false; + return LoadResult::VersionMismatch; } if (tiled) { std::string tilefile = basePath + getTileFileName(mapID, tileX, tileY); FILE* tf = fopen(tilefile.c_str(), "rb"); if (!tf) - success = false; + result = LoadResult::FileNotFound; else { if (!readChunk(tf, chunk, VMAP_MAGIC, 8)) - success = false; + result = LoadResult::VersionMismatch; fclose(tf); } } fclose(rf); - return success; + return result; } //========================================================= |