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

(cherry picked from commit 42877e75e2)
This commit is contained in:
Giacomo Pozzoni
2021-04-04 21:49:50 +02:00
committed by Shauren
parent 89e183704c
commit 1ba940b17a
5 changed files with 10 additions and 12 deletions

View File

@@ -18,7 +18,7 @@
#include "MapDefines.h"
u_map_magic const MapMagic = { { 'M','A','P','S' } };
u_map_magic const MapVersionMagic = { { 'v','1','.','9' } };
uint32 const MapVersionMagic = 9;
u_map_magic const MapAreaMagic = { { 'A','R','E','A' } };
u_map_magic const MapHeightMagic = { { 'M','H','G','T' } };
u_map_magic const MapLiquidMagic = { { 'M','L','I','Q' } };

View File

@@ -26,7 +26,7 @@
using u_map_magic = std::array<char, 4>;
TC_COMMON_API extern u_map_magic const MapMagic;
TC_COMMON_API extern u_map_magic const MapVersionMagic;
TC_COMMON_API extern uint32 const MapVersionMagic;
TC_COMMON_API extern u_map_magic const MapAreaMagic;
TC_COMMON_API extern u_map_magic const MapHeightMagic;
TC_COMMON_API extern u_map_magic const MapLiquidMagic;
@@ -37,7 +37,7 @@ TC_COMMON_API extern u_map_magic const MapLiquidMagic;
struct map_fileheader
{
u_map_magic mapMagic;
u_map_magic versionMagic;
uint32 versionMagic;
uint32 buildMagic;
uint32 areaMapOffset;
uint32 areaMapSize;

View File

@@ -103,12 +103,12 @@ void Map::DiscoverGridMapFiles()
if (FILE* tileList = fopen(tileListName.c_str(), "rb"))
{
u_map_magic mapMagic = { };
u_map_magic versionMagic = { };
uint32 versionMagic = { };
uint32 build;
char tilesData[MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS] = { };
if (fread(mapMagic.data(), mapMagic.size(), 1, tileList) == 1
&& mapMagic == MapMagic
&& fread(versionMagic.data(), versionMagic.size(), 1, tileList) == 1
&& fread(&versionMagic, sizeof(versionMagic), 1, tileList) == 1
&& versionMagic == MapVersionMagic
&& fread(&build, sizeof(build), 1, tileList) == 1
&& fread(&tilesData[0], MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS, 1, tileList) == 1)
@@ -157,8 +157,8 @@ bool Map::ExistMap(uint32 mapid, int gx, int gy, bool log /*= true*/)
if (header.mapMagic != MapMagic || header.versionMagic != MapVersionMagic)
{
if (log)
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.c_str(), 4, header.mapMagic.data(), 4, header.versionMagic.data(), 4, MapMagic.data(), 4, MapVersionMagic.data());
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.c_str(), 4, header.mapMagic.data(), header.versionMagic, 4, MapMagic.data(), MapVersionMagic);
}
else
ret = true;
@@ -1927,8 +1927,8 @@ GridMap::LoadResult GridMap::loadData(char const* filename)
return LoadResult::Ok;
}
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.data(), 4, header.versionMagic.data(), 4, MapMagic.data(), 4, MapVersionMagic.data());
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.data(), header.versionMagic, 4, MapMagic.data(), MapVersionMagic);
fclose(in);
return LoadResult::InvalidFile;
}

View File

@@ -1098,7 +1098,7 @@ void ExtractMaps(uint32 build)
if (FILE* tileList = fopen(Trinity::StringFormat("%s/maps/%04u.tilelist", output_path.string().c_str(), map_ids[z].Id).c_str(), "wb"))
{
fwrite(MapMagic.data(), 1, MapMagic.size(), tileList);
fwrite(MapVersionMagic.data(), 1, MapVersionMagic.size(), tileList);
fwrite(&MapVersionMagic, 1, sizeof(MapVersionMagic), tileList);
fwrite(&build, sizeof(build), 1, tileList);
fwrite(existingTiles.to_string().c_str(), 1, existingTiles.size(), tileList);
fclose(tileList);

View File

@@ -26,8 +26,6 @@
namespace MMAP
{
char const* MAP_VERSION_MAGIC = "v1.9";
TerrainBuilder::TerrainBuilder(bool skipLiquid) : m_skipLiquid (skipLiquid){ }
TerrainBuilder::~TerrainBuilder() { }