diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 9a3971fe09b..c41b5cd4983 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -50,7 +50,7 @@ #include u_map_magic MapMagic = { {'M','A','P','S'} }; -u_map_magic MapVersionMagic = { {'v','1','.','8'} }; +u_map_magic MapVersionMagic = { {'v','1','.','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'} }; @@ -1841,7 +1841,6 @@ bool GridMap::loadData(char const* filename) return true; _fileExists = true; - if (fread(&header, sizeof(header), 1, in) != 1) { fclose(in); @@ -1922,7 +1921,7 @@ bool GridMap::loadAreaData(FILE* in, uint32 offset, uint32 /*size*/) if (!(header.flags & MAP_AREA_NO_AREA)) { _areaMap = new uint16[16 * 16]; - if (fread(_areaMap, sizeof(uint16), 16*16, in) != 16*16) + if (fread(_areaMap, sizeof(uint16), 16 * 16, in) != 16 * 16) return false; } return true; @@ -2086,15 +2085,15 @@ float GridMap::getHeightFromFloat(float x, float y) const if (!m_V8 || !m_V9) return _gridHeight; - x = MAP_RESOLUTION * (CENTER_GRID_ID - x/SIZE_OF_GRIDS); - y = MAP_RESOLUTION * (CENTER_GRID_ID - y/SIZE_OF_GRIDS); + x = MAP_RESOLUTION * (CENTER_GRID_ID - x / SIZE_OF_GRIDS); + y = MAP_RESOLUTION * (CENTER_GRID_ID - y / SIZE_OF_GRIDS); int x_int = (int)x; int y_int = (int)y; x -= x_int; y -= y_int; - x_int&=(MAP_RESOLUTION - 1); - y_int&=(MAP_RESOLUTION - 1); + x_int &= (MAP_RESOLUTION - 1); + y_int &= (MAP_RESOLUTION - 1); if (isHole(x_int, y_int)) return INVALID_HEIGHT; @@ -2116,24 +2115,24 @@ float GridMap::getHeightFromFloat(float x, float y) const float a, b, c; // Select triangle: - if (x+y < 1) + if (x + y < 1) { if (x > y) { // 1 triangle (h1, h2, h5 points) - float h1 = m_V9[(x_int)*129 + y_int]; - float h2 = m_V9[(x_int+1)*129 + y_int]; - float h5 = 2 * m_V8[x_int*128 + y_int]; - a = h2-h1; - b = h5-h1-h2; + float h1 = m_V9[(x_int) * 129 + y_int]; + float h2 = m_V9[(x_int + 1) * 129 + y_int]; + float h5 = 2 * m_V8[x_int * 128 + y_int]; + a = h2 - h1; + b = h5 - h1 - h2; c = h1; } else { // 2 triangle (h1, h3, h5 points) - float h1 = m_V9[x_int*129 + y_int ]; - float h3 = m_V9[x_int*129 + y_int+1]; - float h5 = 2 * m_V8[x_int*128 + y_int]; + float h1 = m_V9[x_int * 129 + y_int]; + float h3 = m_V9[x_int * 129 + y_int + 1]; + float h5 = 2 * m_V8[x_int * 128 + y_int]; a = h5 - h1 - h3; b = h3 - h1; c = h1; @@ -2144,9 +2143,9 @@ float GridMap::getHeightFromFloat(float x, float y) const if (x > y) { // 3 triangle (h2, h4, h5 points) - float h2 = m_V9[(x_int+1)*129 + y_int ]; - float h4 = m_V9[(x_int+1)*129 + y_int+1]; - float h5 = 2 * m_V8[x_int*128 + y_int]; + float h2 = m_V9[(x_int + 1) * 129 + y_int]; + float h4 = m_V9[(x_int + 1) * 129 + y_int + 1]; + float h5 = 2 * m_V8[x_int * 128 + y_int]; a = h2 + h4 - h5; b = h4 - h2; c = h5 - h4; @@ -2154,9 +2153,9 @@ float GridMap::getHeightFromFloat(float x, float y) const else { // 4 triangle (h3, h4, h5 points) - float h3 = m_V9[(x_int)*129 + y_int+1]; - float h4 = m_V9[(x_int+1)*129 + y_int+1]; - float h5 = 2 * m_V8[x_int*128 + y_int]; + float h3 = m_V9[(x_int) * 129 + y_int + 1]; + float h4 = m_V9[(x_int + 1) * 129 + y_int + 1]; + float h5 = 2 * m_V8[x_int * 128 + y_int]; a = h4 - h3; b = h3 + h4 - h5; c = h5 - h4; @@ -2166,6 +2165,7 @@ float GridMap::getHeightFromFloat(float x, float y) const return a * x + b * y + c; } + float GridMap::getHeightFromUint8(float x, float y) const { if (!m_uint8_V8 || !m_uint8_V9) diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp index 24d81f50d14..810bc5abae3 100644 --- a/src/tools/map_extractor/System.cpp +++ b/src/tools/map_extractor/System.cpp @@ -418,7 +418,7 @@ void ReadLiquidTypeTable() // Map file format data static char const* MAP_MAGIC = "MAPS"; -static char const* MAP_VERSION_MAGIC = "v1.8"; +static char const* MAP_VERSION_MAGIC = "v1.9"; static char const* MAP_AREA_MAGIC = "AREA"; static char const* MAP_HEIGHT_MAGIC = "MHGT"; static char const* MAP_LIQUID_MAGIC = "MLIQ"; @@ -508,7 +508,8 @@ uint16 liquid_entry[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID]; uint8 liquid_flags[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID]; bool liquid_show[ADT_GRID_SIZE][ADT_GRID_SIZE]; float liquid_height[ADT_GRID_SIZE+1][ADT_GRID_SIZE+1]; -uint8 holes[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID][8]; +uint16 holes[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID]; + int16 flight_box_max[3][3]; int16 flight_box_min[3][3]; @@ -531,21 +532,6 @@ LiquidVertexFormatType adt_MH2O::GetLiquidVertexFormat(adt_liquid_instance const return static_cast(-1); } -bool TransformToHighRes(uint16 lowResHoles, uint8 hiResHoles[8]) -{ - for (uint8 i = 0; i < 8; i++) - { - for (uint8 j = 0; j < 8; j++) - { - int32 holeIdxL = (i / 2) * 4 + (j / 2); - if (((lowResHoles >> holeIdxL) & 1) == 1) - hiResHoles[i] |= (1 << j); - } - } - - return *((uint64*)hiResHoles) != 0; -} - bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int /*cell_y*/, int /*cell_x*/, uint32 build, bool ignoreDeepWater) { ChunkedFile adt; @@ -580,7 +566,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int // Area data area_ids[mcnk->iy][mcnk->ix] = mcnk->areaid; - // Height + // Height // Height values for triangles stored in order: // 1 2 3 4 5 6 7 8 9 // 10 11 12 13 14 15 16 17 @@ -629,7 +615,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int for (int x = 0; x <= ADT_CELL_SIZE; x++) { int cx = mcnk->ix * ADT_CELL_SIZE + x; - V9[cy][cx] += mcvt->height_map[y*(ADT_CELL_SIZE * 2 + 1) + x]; + V9[cy][cx] += mcvt->height_map[y * (ADT_CELL_SIZE * 2 + 1) + x]; } } // get V8 height map @@ -639,12 +625,12 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int for (int x = 0; x < ADT_CELL_SIZE; x++) { int cx = mcnk->ix * ADT_CELL_SIZE + x; - V8[cy][cx] += mcvt->height_map[y*(ADT_CELL_SIZE * 2 + 1) + ADT_CELL_SIZE + 1 + x]; + V8[cy][cx] += mcvt->height_map[y * (ADT_CELL_SIZE * 2 + 1) + ADT_CELL_SIZE + 1 + x]; } } } - // Liquid data + // Liquid data if (mcnk->sizeMCLQ > 8) { if (FileChunk* chunk = itr->second->GetSubChunk("MCLQ")) @@ -700,18 +686,9 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int } // Hole data - if (!(mcnk->flags & 0x10000)) - { - if (uint16 hole = mcnk->holes) - if (TransformToHighRes(hole, holes[mcnk->iy][mcnk->ix])) - hasHoles = true; - } - else - { - memcpy(holes[mcnk->iy][mcnk->ix], mcnk->union_5_3_0.HighResHoles, sizeof(uint64)); - if (*((uint64*)holes[mcnk->iy][mcnk->ix]) != 0) - hasHoles = true; - } + holes[mcnk->iy][mcnk->ix] = mcnk->holes; + if (!hasHoles && mcnk->holes != 0) + hasHoles = true; } // Get liquid map for grid (in WOTLK used MH2O chunk) @@ -926,7 +903,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int map.heightMapSize+= sizeof(V9) + sizeof(V8); } - //============================================ + //============================================ // Pack liquid data //============================================ uint16 firstLiquidType = liquid_entry[0][0]; diff --git a/src/tools/map_extractor/adt.h b/src/tools/map_extractor/adt.h index 92cbb75d12e..289b72e7e44 100644 --- a/src/tools/map_extractor/adt.h +++ b/src/tools/map_extractor/adt.h @@ -96,15 +96,8 @@ struct adt_MCNK uint32 iy; uint32 nLayers; uint32 nDoodadRefs; - union - { - struct - { - uint32 offsMCVT; // height map - uint32 offsMCNR; // Normal vectors for each vertex - } offsets; - uint8 HighResHoles[8]; - } union_5_3_0; + uint32 offsMCVT; // height map + uint32 offsMCNR; // Normal vectors for each vertex uint32 offsMCLY; // Texture layer definitions uint32 offsMCRF; // A list of indices into the parent file's MDDF chunk uint32 offsMCAL; // Alpha maps for additional texture layers diff --git a/src/tools/mmaps_generator/TerrainBuilder.cpp b/src/tools/mmaps_generator/TerrainBuilder.cpp index 0bed266ab62..23b0a19c63e 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.8"; + char const* MAP_VERSION_MAGIC = "v1.9"; TerrainBuilder::TerrainBuilder(bool skipLiquid) : m_skipLiquid (skipLiquid){ } TerrainBuilder::~TerrainBuilder() { }