Core/Maps: Change .map file version from FourCC to uint32 (#26326)

This commit is contained in:
Giacomo Pozzoni
2021-04-04 21:49:50 +02:00
committed by GitHub
parent 39bd263c72
commit 42877e75e2
4 changed files with 12 additions and 12 deletions

View File

@@ -55,7 +55,7 @@
BOOST_1_74_FIBONACCI_HEAP_MSVC_COMPILE_FIX(RespawnListContainer::value_type)
u_map_magic MapMagic = { {'M','A','P','S'} };
u_map_magic MapVersionMagic = { {'v','1','.','9'} };
uint32 MapVersionMagic = 9;
u_map_magic MapAreaMagic = { {'A','R','E','A'} };
u_map_magic MapHeightMagic = { {'M','H','G','T'} };
u_map_magic MapLiquidMagic = { {'M','L','I','Q'} };
@@ -116,9 +116,9 @@ bool Map::ExistMap(uint32 mapid, int gx, int gy)
map_fileheader header;
if (fread(&header, sizeof(header), 1, pf) == 1)
{
if (header.mapMagic.asUInt != MapMagic.asUInt || header.versionMagic.asUInt != MapVersionMagic.asUInt)
TC_LOG_ERROR("maps", "Map file '%s' is from an incompatible map version (%.*s %.*s), %.*s %.*s is expected. Please pull your source, recompile tools and recreate maps using the updated mapextractor, then replace your old map files with new files. If you still have problems search on forum for error TCE00018.",
fileName, 4, header.mapMagic.asChar, 4, header.versionMagic.asChar, 4, MapMagic.asChar, 4, MapVersionMagic.asChar);
if (header.mapMagic.asUInt != MapMagic.asUInt || header.versionMagic != MapVersionMagic)
TC_LOG_ERROR("maps", "Map file '%s' is from an incompatible map version (%.*s 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. If you still have problems search on forum for error TCE00018.",
fileName, 4, header.mapMagic.asChar, header.versionMagic, 4, MapMagic.asChar, MapVersionMagic);
else
ret = true;
}
@@ -1827,7 +1827,7 @@ bool GridMap::loadData(char const* filename)
return false;
}
if (header.mapMagic.asUInt == MapMagic.asUInt && header.versionMagic.asUInt == MapVersionMagic.asUInt)
if (header.mapMagic.asUInt == MapMagic.asUInt && header.versionMagic == MapVersionMagic)
{
// load up area data
if (header.areaMapOffset && !loadAreaData(in, header.areaMapOffset, header.areaMapSize))
@@ -1861,8 +1861,8 @@ bool GridMap::loadData(char const* filename)
return true;
}
TC_LOG_ERROR("maps", "Map file '%s' is from an incompatible map version (%.*s %.*s), %.*s %.*s is expected. Please pull your source, recompile tools and recreate maps using the updated mapextractor, then replace your old map files with new files. If you still have problems search on forum for error TCE00018.",
filename, 4, header.mapMagic.asChar, 4, header.versionMagic.asChar, 4, MapMagic.asChar, 4, MapVersionMagic.asChar);
TC_LOG_ERROR("maps", "Map file '%s' is from an incompatible map version (%.*s 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. If you still have problems search on forum for error TCE00018.",
filename, 4, header.mapMagic.asChar, header.versionMagic, 4, MapMagic.asChar, MapVersionMagic);
fclose(in);
return false;
}

View File

@@ -89,7 +89,7 @@ union u_map_magic
struct map_fileheader
{
u_map_magic mapMagic;
u_map_magic versionMagic;
uint32 versionMagic;
u_map_magic buildMagic;
uint32 areaMapOffset;
uint32 areaMapSize;

View File

@@ -262,7 +262,7 @@ void ReadLiquidTypeTableDBC()
// Map file format data
static char const* MAP_MAGIC = "MAPS";
static char const* MAP_VERSION_MAGIC = "v1.9";
static uint32 const MAP_VERSION_MAGIC = 9;
static char const* MAP_AREA_MAGIC = "AREA";
static char const* MAP_HEIGHT_MAGIC = "MHGT";
static char const* MAP_LIQUID_MAGIC = "MLIQ";
@@ -379,7 +379,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

@@ -82,7 +82,7 @@ uint32 GetLiquidFlags(uint32 liquidId);
namespace MMAP
{
char const* MAP_VERSION_MAGIC = "v1.9";
uint32 const MAP_VERSION_MAGIC = 9;
TerrainBuilder::TerrainBuilder(bool skipLiquid) : m_skipLiquid (skipLiquid){ }
TerrainBuilder::~TerrainBuilder() { }
@@ -144,7 +144,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);