mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-09 08:17:56 +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
@@ -37,6 +37,13 @@ namespace VMAP
|
|||||||
VMAP_LOAD_RESULT_IGNORED
|
VMAP_LOAD_RESULT_IGNORED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class LoadResult : uint8
|
||||||
|
{
|
||||||
|
Success,
|
||||||
|
FileNotFound,
|
||||||
|
VersionMismatch
|
||||||
|
};
|
||||||
|
|
||||||
#define VMAP_INVALID_HEIGHT -100000.0f // for check
|
#define VMAP_INVALID_HEIGHT -100000.0f // for check
|
||||||
#define VMAP_INVALID_HEIGHT_VALUE -200000.0f // real assigned value in unknown height case
|
#define VMAP_INVALID_HEIGHT_VALUE -200000.0f // real assigned value in unknown height case
|
||||||
|
|
||||||
@@ -79,7 +86,7 @@ namespace VMAP
|
|||||||
|
|
||||||
virtual int loadMap(const char* pBasePath, unsigned int pMapId, int x, int y) = 0;
|
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, int x, int y) = 0;
|
||||||
virtual void unloadMap(unsigned int pMapId) = 0;
|
virtual void unloadMap(unsigned int pMapId) = 0;
|
||||||
|
|||||||
@@ -379,7 +379,7 @@ namespace VMAP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VMapMgr2::existsMap(const char* basePath, unsigned int mapId, int x, int y)
|
LoadResult VMapMgr2::existsMap(const char* basePath, unsigned int mapId, int x, int y)
|
||||||
{
|
{
|
||||||
return StaticMapTree::CanLoadMap(std::string(basePath), mapId, x, y);
|
return StaticMapTree::CanLoadMap(std::string(basePath), mapId, x, y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ namespace VMAP
|
|||||||
{
|
{
|
||||||
return getMapFileName(mapId);
|
return getMapFileName(mapId);
|
||||||
}
|
}
|
||||||
bool existsMap(const char* basePath, unsigned int mapId, int x, int y) override;
|
LoadResult existsMap(const char* basePath, unsigned int mapId, int x, int y) override;
|
||||||
void GetInstanceMapTree(InstanceTreeMap& instanceMapTree);
|
void GetInstanceMapTree(InstanceTreeMap& instanceMapTree);
|
||||||
|
|
||||||
typedef uint32(*GetLiquidFlagsFn)(uint32 liquidType);
|
typedef uint32(*GetLiquidFlagsFn)(uint32 liquidType);
|
||||||
|
|||||||
@@ -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;
|
std::string basePath = vmapPath;
|
||||||
if (basePath.length() > 0 && basePath[basePath.length() - 1] != '/' && basePath[basePath.length() - 1] != '\\')
|
if (basePath.length() > 0 && basePath[basePath.length() - 1] != '/' && basePath[basePath.length() - 1] != '\\')
|
||||||
@@ -257,19 +257,21 @@ namespace VMAP
|
|||||||
basePath.push_back('/');
|
basePath.push_back('/');
|
||||||
}
|
}
|
||||||
std::string fullname = basePath + VMapMgr2::getMapFileName(mapID);
|
std::string fullname = basePath + VMapMgr2::getMapFileName(mapID);
|
||||||
bool success = true;
|
|
||||||
|
LoadResult result = LoadResult::Success;
|
||||||
|
|
||||||
FILE* rf = fopen(fullname.c_str(), "rb");
|
FILE* rf = fopen(fullname.c_str(), "rb");
|
||||||
if (!rf)
|
if (!rf)
|
||||||
{
|
{
|
||||||
return false;
|
return LoadResult::FileNotFound;
|
||||||
}
|
}
|
||||||
// TODO: check magic number when implemented...
|
|
||||||
char tiled;
|
char tiled;
|
||||||
char chunk[8];
|
char chunk[8];
|
||||||
if (!readChunk(rf, chunk, VMAP_MAGIC, 8) || fread(&tiled, sizeof(char), 1, rf) != 1)
|
if (!readChunk(rf, chunk, VMAP_MAGIC, 8) || fread(&tiled, sizeof(char), 1, rf) != 1)
|
||||||
{
|
{
|
||||||
fclose(rf);
|
fclose(rf);
|
||||||
return false;
|
return LoadResult::VersionMismatch;
|
||||||
}
|
}
|
||||||
if (tiled)
|
if (tiled)
|
||||||
{
|
{
|
||||||
@@ -277,19 +279,19 @@ namespace VMAP
|
|||||||
FILE* tf = fopen(tilefile.c_str(), "rb");
|
FILE* tf = fopen(tilefile.c_str(), "rb");
|
||||||
if (!tf)
|
if (!tf)
|
||||||
{
|
{
|
||||||
success = false;
|
result = LoadResult::FileNotFound;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!readChunk(tf, chunk, VMAP_MAGIC, 8))
|
if (!readChunk(tf, chunk, VMAP_MAGIC, 8))
|
||||||
{
|
{
|
||||||
success = false;
|
result = LoadResult::VersionMismatch;
|
||||||
}
|
}
|
||||||
fclose(tf);
|
fclose(tf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(rf);
|
fclose(rf);
|
||||||
return success;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=========================================================
|
//=========================================================
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ namespace VMAP
|
|||||||
class ModelInstance;
|
class ModelInstance;
|
||||||
class GroupModel;
|
class GroupModel;
|
||||||
class VMapMgr2;
|
class VMapMgr2;
|
||||||
|
enum class LoadResult : uint8;
|
||||||
|
|
||||||
struct LocationInfo
|
struct LocationInfo
|
||||||
{
|
{
|
||||||
@@ -63,7 +64,7 @@ namespace VMAP
|
|||||||
static std::string getTileFileName(uint32 mapID, uint32 tileX, uint32 tileY);
|
static std::string getTileFileName(uint32 mapID, uint32 tileX, uint32 tileY);
|
||||||
static uint32 packTileID(uint32 tileX, uint32 tileY) { return tileX << 16 | 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 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(uint32 mapID, const std::string& basePath);
|
||||||
~StaticMapTree();
|
~StaticMapTree();
|
||||||
|
|||||||
@@ -121,12 +121,20 @@ bool Map::ExistVMap(uint32 mapid, int gx, int gy)
|
|||||||
{
|
{
|
||||||
if (vmgr->isMapLoadingEnabled())
|
if (vmgr->isMapLoadingEnabled())
|
||||||
{
|
{
|
||||||
bool exists = vmgr->existsMap((sWorld->GetDataPath() + "vmaps").c_str(), mapid, gx, gy);
|
VMAP::LoadResult result = vmgr->existsMap((sWorld->GetDataPath() + "vmaps").c_str(), mapid, gx, gy);
|
||||||
if (!exists)
|
std::string name = vmgr->getDirFileName(mapid, gx, gy);
|
||||||
|
switch (result)
|
||||||
{
|
{
|
||||||
std::string name = vmgr->getDirFileName(mapid, gx, gy);
|
case VMAP::LoadResult::Success:
|
||||||
LOG_ERROR("maps", "VMap file '{}' is missing or points to wrong version of vmap file. Redo vmaps with latest version of vmap_assembler.exe.", (sWorld->GetDataPath() + "vmaps/" + name));
|
break;
|
||||||
return false;
|
case VMAP::LoadResult::FileNotFound:
|
||||||
|
LOG_ERROR("maps", "VMap file '{}' does not exist", (sWorld->GetDataPath() + "vmaps/" + name));
|
||||||
|
LOG_ERROR("maps", "Please place VMAP files (*.vmtree and *.vmtile) in the vmap directory ({}), or correct the DataDir setting in your worldserver.conf file.", (sWorld->GetDataPath() + "vmaps/"));
|
||||||
|
return false;
|
||||||
|
case VMAP::LoadResult::VersionMismatch:
|
||||||
|
LOG_ERROR("maps", "VMap file '{}' couldn't be loaded", (sWorld->GetDataPath() + "vmaps/" + name));
|
||||||
|
LOG_ERROR("maps", "This is because the version of the VMap file and the version of this module are different, please re-extract the maps with the tools compiled with this module.");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user