diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/Collision/Management/IVMapManager.h | 9 | ||||
| -rw-r--r-- | src/common/Collision/Management/VMapManager2.cpp | 2 | ||||
| -rw-r--r-- | src/common/Collision/Management/VMapManager2.h | 2 | ||||
| -rw-r--r-- | src/common/Collision/Maps/MapTree.cpp | 19 | ||||
| -rw-r--r-- | src/common/Collision/Maps/MapTree.h | 3 | 
5 files changed, 22 insertions, 13 deletions
diff --git a/src/common/Collision/Management/IVMapManager.h b/src/common/Collision/Management/IVMapManager.h index a28f45c349f..2188da1cadc 100644 --- a/src/common/Collision/Management/IVMapManager.h +++ b/src/common/Collision/Management/IVMapManager.h @@ -39,6 +39,13 @@ namespace VMAP          VMAP_LOAD_RESULT_IGNORED      }; +    enum class LoadResult : uint8 +    { +        Success, +        FileNotFound, +        VersionMismatch +    }; +      #define VMAP_INVALID_HEIGHT       -100000.0f            // for check      #define VMAP_INVALID_HEIGHT_VALUE -200000.0f            // real assigned value in unknown height case @@ -56,7 +63,7 @@ namespace VMAP              virtual int loadMap(const char* pBasePath, unsigned int pMapId, int x, int y) = 0; -            virtual bool existsMap(const char* pBasePath, unsigned int pMapId, int x, int y) = 0; +            virtual LoadResult existsMap(const char* pBasePath, unsigned int pMapId, int x, int y) = 0;              virtual void unloadMap(unsigned int pMapId, int x, int y) = 0;              virtual void unloadMap(unsigned int pMapId) = 0; diff --git a/src/common/Collision/Management/VMapManager2.cpp b/src/common/Collision/Management/VMapManager2.cpp index 74d6c734053..9981f722456 100644 --- a/src/common/Collision/Management/VMapManager2.cpp +++ b/src/common/Collision/Management/VMapManager2.cpp @@ -324,7 +324,7 @@ namespace VMAP          }      } -    bool VMapManager2::existsMap(const char* basePath, unsigned int mapId, int x, int y) +    LoadResult VMapManager2::existsMap(const char* basePath, unsigned int mapId, int x, int y)      {          return StaticMapTree::CanLoadMap(std::string(basePath), mapId, x, y);      } diff --git a/src/common/Collision/Management/VMapManager2.h b/src/common/Collision/Management/VMapManager2.h index 593f046412e..fd325b16434 100644 --- a/src/common/Collision/Management/VMapManager2.h +++ b/src/common/Collision/Management/VMapManager2.h @@ -127,7 +127,7 @@ namespace VMAP              {                  return getMapFileName(mapId);              } -            virtual bool existsMap(const char* basePath, unsigned int mapId, int x, int y) override; +            virtual LoadResult existsMap(const char* basePath, unsigned int mapId, int x, int y) override;              void getInstanceMapTree(InstanceTreeMap &instanceMapTree); 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;      }      //========================================================= diff --git a/src/common/Collision/Maps/MapTree.h b/src/common/Collision/Maps/MapTree.h index 7f1415ff939..f5c11dd2bce 100644 --- a/src/common/Collision/Maps/MapTree.h +++ b/src/common/Collision/Maps/MapTree.h @@ -29,6 +29,7 @@ namespace VMAP      class ModelInstance;      class GroupModel;      class VMapManager2; +    enum class LoadResult : uint8;      enum class ModelIgnoreFlags : uint32;      struct TC_COMMON_API LocationInfo @@ -65,7 +66,7 @@ namespace VMAP              static std::string getTileFileName(uint32 mapID, uint32 tileX, uint32 tileY);              static uint32 packTileID(uint32 tileX, uint32 tileY) { return tileX<<16 | tileY; }              static void unpackTileID(uint32 ID, uint32 &tileX, uint32 &tileY) { tileX = ID>>16; tileY = ID&0xFF; } -            static bool CanLoadMap(const std::string &basePath, uint32 mapID, uint32 tileX, uint32 tileY); +            static LoadResult CanLoadMap(const std::string &basePath, uint32 mapID, uint32 tileX, uint32 tileY);              StaticMapTree(uint32 mapID, const std::string &basePath);              ~StaticMapTree();  | 
