mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-03-05 16:57:52 +00:00
feat(Core/Vmaps): Changed error message when loading outdated vmaps (#10490)
This commit is contained in:
committed by
GitHub
parent
e8e8c34590
commit
cc5f26db7f
@@ -249,7 +249,7 @@ 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] != '\\')
|
||||
@@ -257,19 +257,21 @@ namespace VMAP
|
||||
basePath.push_back('/');
|
||||
}
|
||||
std::string fullname = basePath + VMapMgr2::getMapFileName(mapID);
|
||||
bool success = true;
|
||||
|
||||
LoadResult result = LoadResult::Success;
|
||||
|
||||
FILE* rf = fopen(fullname.c_str(), "rb");
|
||||
if (!rf)
|
||||
{
|
||||
return false;
|
||||
return LoadResult::FileNotFound;
|
||||
}
|
||||
// TODO: check magic number when implemented...
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -277,19 +279,19 @@ namespace VMAP
|
||||
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;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace VMAP
|
||||
class ModelInstance;
|
||||
class GroupModel;
|
||||
class VMapMgr2;
|
||||
enum class LoadResult : uint8;
|
||||
|
||||
struct LocationInfo
|
||||
{
|
||||
@@ -63,7 +64,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();
|
||||
|
||||
Reference in New Issue
Block a user