refactor(Core/Maps): Change map file version from FourCC to uint32 (#7866)

Co-Authored-By: Giacomo Pozzoni <giacomopoz@gmail.com>
This commit is contained in:
Kitzunu
2021-09-20 00:45:42 +02:00
committed by GitHub
parent b70083599b
commit 6df7303b24
3 changed files with 12 additions and 8 deletions

View File

@@ -38,7 +38,7 @@ union u_map_magic
};
u_map_magic MapMagic = { {'M', 'A', 'P', 'S'} };
u_map_magic MapVersionMagic = { {'v', '1', '.', '8'} };
uint32 MapVersionMagic = 8;
u_map_magic MapAreaMagic = { {'A', 'R', 'E', 'A'} };
u_map_magic MapHeightMagic = { {'M', 'H', 'G', 'T'} };
u_map_magic MapLiquidMagic = { {'M', 'L', 'I', 'Q'} };
@@ -85,8 +85,12 @@ bool Map::ExistMap(uint32 mapid, int gx, int gy)
map_fileheader header;
if (fread(&header, sizeof(header), 1, pf) == 1)
{
if (header.mapMagic != MapMagic.asUInt || header.versionMagic != MapVersionMagic.asUInt)
LOG_ERROR("maps", "Map file '%s' is from an incompatible clientversion. Please recreate using the mapextractor.", tmp);
if (header.mapMagic != MapMagic.asUInt || header.versionMagic != MapVersionMagic)
{
LOG_ERROR("maps", "Map file '%s' is from an incompatible map version (%.*u v%u), %.*s v%u is expected. Please pull your source, recompile tools and recreate maps using the updated mapextractor, then replace your old map files with new files.",
tmp, 4, header.mapMagic, header.versionMagic, 4, MapMagic.asChar, MapVersionMagic);
}
else
ret = true;
}
@@ -1335,7 +1339,7 @@ bool GridMap::loadData(char* filename)
return false;
}
if (header.mapMagic == MapMagic.asUInt && header.versionMagic == MapVersionMagic.asUInt)
if (header.mapMagic == MapMagic.asUInt && header.versionMagic == MapVersionMagic)
{
// loadup area data
if (header.areaMapOffset && !loadAreaData(in, header.areaMapOffset, header.areaMapSize))

View File

@@ -298,7 +298,7 @@ void ReadLiquidTypeTableDBC()
// Map file format data
static char const* MAP_MAGIC = "MAPS";
static char const* MAP_VERSION_MAGIC = "v1.8";
static uint32 const MAP_VERSION_MAGIC = 8;
static char const* MAP_AREA_MAGIC = "AREA";
static char const* MAP_HEIGHT_MAGIC = "MHGT";
static char const* MAP_LIQUID_MAGIC = "MLIQ";
@@ -415,7 +415,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
// Prepare map header
map_fileheader map;
map.mapMagic = *reinterpret_cast<uint32 const*>(MAP_MAGIC);
map.versionMagic = *reinterpret_cast<uint32 const*>(MAP_VERSION_MAGIC);
map.versionMagic = MAP_VERSION_MAGIC;
map.buildMagic = build;
// Get area flags data

View File

@@ -69,7 +69,7 @@ struct map_liquidHeader
namespace MMAP
{
char const* MAP_VERSION_MAGIC = "v1.8";
uint32 const MAP_VERSION_MAGIC = 8;
TerrainBuilder::TerrainBuilder(bool skipLiquid) : m_skipLiquid (skipLiquid) { }
TerrainBuilder::~TerrainBuilder() = default;
@@ -131,7 +131,7 @@ namespace MMAP
map_fileheader fheader;
if (fread(&fheader, sizeof(map_fileheader), 1, mapFile) != 1 ||
fheader.versionMagic != *((uint32 const*)(MAP_VERSION_MAGIC)))
fheader.versionMagic != MAP_VERSION_MAGIC)
{
fclose(mapFile);
printf("%s is the wrong version, please extract new .map files\n", mapFileName);