[11904] Fix Liquid Extraction and better hole support

This commit is contained in:
faramir118 2012-01-29 22:08:43 +01:00 committed by Schmoozerd
parent deb97590a1
commit 73b3ae889d
4 changed files with 38 additions and 4 deletions

View file

@ -60,6 +60,7 @@ enum Extract
// Select data for extract // Select data for extract
int CONF_extract = EXTRACT_MAP | EXTRACT_DBC; int CONF_extract = EXTRACT_MAP | EXTRACT_DBC;
// This option allow limit minimum height to some value (Allow save some memory) // This option allow limit minimum height to some value (Allow save some memory)
// see contrib/mmap/src/Tilebuilder.h, INVALID_MAP_LIQ_HEIGHT
bool CONF_allow_height_limit = true; bool CONF_allow_height_limit = true;
float CONF_use_minHeight = -500.0f; float CONF_use_minHeight = -500.0f;
@ -292,6 +293,8 @@ struct map_fileheader
uint32 heightMapSize; uint32 heightMapSize;
uint32 liquidMapOffset; uint32 liquidMapOffset;
uint32 liquidMapSize; uint32 liquidMapSize;
uint32 holesOffset;
uint32 holesSize;
}; };
#define MAP_AREA_NO_AREA 0x0001 #define MAP_AREA_NO_AREA 0x0001
@ -795,8 +798,8 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32
liquidHeader.liquidType = 0; liquidHeader.liquidType = 0;
liquidHeader.offsetX = minX; liquidHeader.offsetX = minX;
liquidHeader.offsetY = minY; liquidHeader.offsetY = minY;
liquidHeader.width = maxX - minX + 1; liquidHeader.width = maxX - minX + 1 + 1;
liquidHeader.height = maxY - minY + 1; liquidHeader.height = maxY - minY + 1 + 1;
liquidHeader.liquidLevel = minHeight; liquidHeader.liquidLevel = minHeight;
if (maxHeight == minHeight) if (maxHeight == minHeight)
@ -818,6 +821,28 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32
map.liquidMapSize += sizeof(float)*liquidHeader.width*liquidHeader.height; map.liquidMapSize += sizeof(float)*liquidHeader.width*liquidHeader.height;
} }
// 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;
map.holesSize = sizeof(holes);
memset(holes, 0, map.holesSize);
for(int i = 0; i < ADT_CELLS_PER_GRID; ++i)
{
for(int j = 0; j < ADT_CELLS_PER_GRID; ++j)
{
adt_MCNK * cell = cells->getMCNK(i,j);
if(!cell)
continue;
holes[i][j] = cell->holes;
}
}
// Ok all data prepared - store it // Ok all data prepared - store it
FILE *output=fopen(filename2, "wb"); FILE *output=fopen(filename2, "wb");
if(!output) if(!output)
@ -864,6 +889,10 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32
fwrite(&liquid_height[y+liquidHeader.offsetY][liquidHeader.offsetX], sizeof(float), liquidHeader.width, output); fwrite(&liquid_height[y+liquidHeader.offsetY][liquidHeader.offsetX], sizeof(float), liquidHeader.width, output);
} }
} }
// store hole data
fwrite(holes, map.holesSize, 1, output);
fclose(output); fclose(output);
return true; return true;

View file

@ -93,7 +93,8 @@ public:
uint32 sizeMCSH; uint32 sizeMCSH;
uint32 areaid; uint32 areaid;
uint32 nMapObjRefs; uint32 nMapObjRefs;
uint32 holes; uint16 holes; // locations where models pierce the heightmap
uint16 pad;
uint16 s[2]; uint16 s[2];
uint32 data1; uint32 data1;
uint32 data2; uint32 data2;
@ -286,4 +287,6 @@ public:
adt_MHDR *a_grid; adt_MHDR *a_grid;
}; };
bool isHole(int holes, int i, int j);
#endif #endif

View file

@ -48,6 +48,8 @@ struct GridMapFileHeader
uint32 heightMapSize; uint32 heightMapSize;
uint32 liquidMapOffset; uint32 liquidMapOffset;
uint32 liquidMapSize; uint32 liquidMapSize;
uint32 holesOffset;
uint32 holesSize;
}; };
#define MAP_AREA_NO_AREA 0x0001 #define MAP_AREA_NO_AREA 0x0001

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "11903" #define REVISION_NR "11904"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__