Tools/mmaps_generator: fixed processing liquids broken in e5d23103f3
This commit is contained in:
1 parent
d6281d4fb4
commit
e8586b0bcb
5 files changed
+116
-94
No files matched your search
@@ -416,7 +416,7 @@ void ReadLiquidTypeTable()
|
||||
|
||||
// Map file format data
|
||||
static char const* MAP_MAGIC = "MAPS";
|
||||
static char const* MAP_VERSION_MAGIC = "v1.6";
|
||||
static char const* MAP_VERSION_MAGIC = "v1.7";
|
||||
static char const* MAP_AREA_MAGIC = "AREA";
|
||||
static char const* MAP_HEIGHT_MAGIC = "MHGT";
|
||||
static char const* MAP_LIQUID_MAGIC = "MLIQ";
|
||||
@@ -464,7 +464,6 @@ struct map_heightHeader
|
||||
#define MAP_LIQUID_TYPE_SLIME 0x08
|
||||
|
||||
#define MAP_LIQUID_TYPE_DARK_WATER 0x10
|
||||
#define MAP_LIQUID_TYPE_WMO_WATER 0x20
|
||||
|
||||
|
||||
#define MAP_LIQUID_NO_TYPE 0x0001
|
||||
@@ -473,7 +472,8 @@ struct map_heightHeader
|
||||
struct map_liquidHeader
|
||||
{
|
||||
uint32 fourcc;
|
||||
uint16 flags;
|
||||
uint8 flags;
|
||||
uint8 liquidFlags;
|
||||
uint16 liquidType;
|
||||
uint8 offsetX;
|
||||
uint8 offsetY;
|
||||
@@ -848,8 +848,8 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
|
||||
}
|
||||
}
|
||||
|
||||
liquid_entry[i][j] = h->LiquidType;
|
||||
switch (LiquidTypes.at(h->LiquidType).SoundBank)
|
||||
liquid_entry[i][j] = h2o->GetLiquidType(h);
|
||||
switch (LiquidTypes.at(liquid_entry[i][j]).SoundBank)
|
||||
{
|
||||
case LIQUID_TYPE_WATER: liquid_flags[i][j] |= MAP_LIQUID_TYPE_WATER; break;
|
||||
case LIQUID_TYPE_OCEAN: liquid_flags[i][j] |= MAP_LIQUID_TYPE_OCEAN; if (!ignoreDeepWater && attrs.Deep) liquid_flags[i][j] |= MAP_LIQUID_TYPE_DARK_WATER; break;
|
||||
@@ -883,13 +883,14 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
|
||||
//============================================
|
||||
// Pack liquid data
|
||||
//============================================
|
||||
uint8 type = liquid_flags[0][0];
|
||||
uint16 firstLiquidType = liquid_entry[0][0];
|
||||
uint8 firstLiquidFlag = liquid_flags[0][0];
|
||||
bool fullType = false;
|
||||
for (int y = 0; y < ADT_CELLS_PER_GRID; y++)
|
||||
{
|
||||
for (int x = 0; x < ADT_CELLS_PER_GRID; x++)
|
||||
{
|
||||
if (liquid_flags[y][x] != type)
|
||||
if (liquid_entry[y][x] != firstLiquidType || liquid_flags[y][x] != firstLiquidFlag)
|
||||
{
|
||||
fullType = true;
|
||||
y = ADT_CELLS_PER_GRID;
|
||||
@@ -901,7 +902,7 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
|
||||
map_liquidHeader liquidHeader;
|
||||
|
||||
// no water data (if all grid have 0 liquid type)
|
||||
if (type == 0 && !fullType)
|
||||
if (firstLiquidFlag == 0 && !fullType)
|
||||
{
|
||||
// No liquid data
|
||||
map.liquidMapOffset = 0;
|
||||
@@ -953,7 +954,10 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
|
||||
liquidHeader.flags |= MAP_LIQUID_NO_TYPE;
|
||||
|
||||
if (liquidHeader.flags & MAP_LIQUID_NO_TYPE)
|
||||
liquidHeader.liquidType = type;
|
||||
{
|
||||
liquidHeader.liquidFlags = firstLiquidFlag;
|
||||
liquidHeader.liquidType = firstLiquidType;
|
||||
}
|
||||
else
|
||||
map.liquidMapSize += sizeof(liquid_entry) + sizeof(liquid_flags);
|
||||
|
||||
@@ -964,11 +968,6 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
|
||||
// map hole info
|
||||
uint16 holes[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
|
||||
|
||||
if (map.liquidMapOffset)
|
||||
map.holesOffset = map.liquidMapOffset + map.liquidMapSize;
|
||||
else
|
||||
map.holesOffset = map.heightMapOffset + map.heightMapSize;
|
||||
|
||||
memset(holes, 0, sizeof(holes));
|
||||
bool hasHoles = false;
|
||||
|
||||
@@ -986,9 +985,19 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
|
||||
}
|
||||
|
||||
if (hasHoles)
|
||||
{
|
||||
if (map.liquidMapOffset)
|
||||
map.holesOffset = map.liquidMapOffset + map.liquidMapSize;
|
||||
else
|
||||
map.holesOffset = map.heightMapOffset + map.heightMapSize;
|
||||
|
||||
map.holesSize = sizeof(holes);
|
||||
}
|
||||
else
|
||||
{
|
||||
map.holesOffset = 0;
|
||||
map.holesSize = 0;
|
||||
}
|
||||
|
||||
// Ok all data prepared - store it
|
||||
FILE* output = fopen(filename2, "wb");
|
||||
|
||||
Reference in new issue
Block a user