diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index f407ff36a5..0df15ade6a 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -56,7 +56,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'} }; @@ -108,13 +108,13 @@ 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.asUInt, sizeof(u_map_magic), 1, tileList) == 1 && mapMagic.asUInt == MapMagic.asUInt - && fread(&versionMagic.asUInt, sizeof(u_map_magic), 1, tileList) == 1 - && versionMagic.asUInt == MapVersionMagic.asUInt + && 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) { @@ -159,11 +159,11 @@ bool Map::ExistMap(uint32 mapid, int gx, int gy, bool log /*= true*/) map_fileheader header; if (fread(&header, sizeof(header), 1, file) == 1) { - if (header.mapMagic.asUInt != MapMagic.asUInt || header.versionMagic.asUInt != MapVersionMagic.asUInt) + if (header.mapMagic.asUInt != MapMagic.asUInt || 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.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.c_str(), 4, header.mapMagic.asChar, header.versionMagic, 4, MapMagic.asChar, MapVersionMagic); } else ret = true; @@ -1804,7 +1804,7 @@ GridMap::LoadResult GridMap::loadData(const char* filename) return LoadResult::InvalidFile; } - 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)) @@ -1838,8 +1838,8 @@ GridMap::LoadResult GridMap::loadData(const char* 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.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 LoadResult::InvalidFile; } diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 70ad8e8dec..5aea49f942 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -88,7 +88,7 @@ union u_map_magic struct map_fileheader { u_map_magic mapMagic; - u_map_magic versionMagic; + uint32 versionMagic; uint32 buildMagic; uint32 areaMapOffset; uint32 areaMapSize; diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp index 710b08b8f2..f52244dcfb 100644 --- a/src/tools/map_extractor/System.cpp +++ b/src/tools/map_extractor/System.cpp @@ -451,7 +451,7 @@ void ReadLiquidTypeTable() // 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"; @@ -575,7 +575,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int // Prepare map header map_fileheader map; map.mapMagic = *reinterpret_cast(MAP_MAGIC); - map.versionMagic = *reinterpret_cast(MAP_VERSION_MAGIC); + map.versionMagic = MAP_VERSION_MAGIC; map.buildMagic = build; // Get area flags data @@ -1181,7 +1181,7 @@ void ExtractMapsFromMpq(uint32 build) if (FILE* tileList = fopen(Trinity::StringFormat("%s/maps/%03u.tilelist", output_path, map_ids[z].id).c_str(), "wb")) { fwrite(MAP_MAGIC, 1, strlen(MAP_MAGIC), tileList); - fwrite(MAP_VERSION_MAGIC, 1, strlen(MAP_VERSION_MAGIC), tileList); + fwrite(&MAP_VERSION_MAGIC, sizeof(MAP_VERSION_MAGIC), 1, tileList); fwrite(&build, sizeof(build), 1, tileList); fwrite(existingTiles.to_string().c_str(), 1, existingTiles.size(), tileList); fclose(tileList); diff --git a/src/tools/mmaps_generator/TerrainBuilder.cpp b/src/tools/mmaps_generator/TerrainBuilder.cpp index c21bd44819..118b83f1c8 100644 --- a/src/tools/mmaps_generator/TerrainBuilder.cpp +++ b/src/tools/mmaps_generator/TerrainBuilder.cpp @@ -79,7 +79,7 @@ struct map_liquidHeader namespace MMAP { - char const* MAP_VERSION_MAGIC = "v1.9"; + uint32 const MAP_VERSION_MAGIC = 9; TerrainBuilder::TerrainBuilder(bool skipLiquid) : m_skipLiquid (skipLiquid){ } TerrainBuilder::~TerrainBuilder() { } @@ -151,7 +151,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);