aboutsummaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2012-03-07 13:09:35 +0100
committerShauren <shauren.trinity@gmail.com>2012-03-07 13:09:35 +0100
commite5d23103f37c40d2e946fa0e2db66d2f527ad9af (patch)
tree4970c3f8fcb3e39bd433084113e7653739e3f5b9 /src/tools
parent9f93681625f16b4a118df755eccb8ac80f713c16 (diff)
Core/Maps
* Corrected liquid type extraction in maps - MCLQ chunk must be parsed together with MH2O (they stack) * Fixed liquid detection in WMO objects * Implemented LiquidType.dbc use, players will now get proper auras in special liquids * Turned off slime damage by default (Naxxramas uses periodic damage aura for this purpose) * Implemented liquid type overrides basing on area/zone * Renamed final temp_gameobject_models to GameObjectModels.dtree (the temporary one produced by vmap extractor remains unaffected) Note: Map and Vmap re-extraction is required
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/map_extractor/System.cpp173
-rw-r--r--src/tools/vmap4_extractor/vmapexport.cpp2
-rw-r--r--src/tools/vmap4_extractor/wmo.cpp48
3 files changed, 138 insertions, 85 deletions
diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp
index 335fd924be8..bbde9f4675e 100644
--- a/src/tools/map_extractor/System.cpp
+++ b/src/tools/map_extractor/System.cpp
@@ -276,7 +276,7 @@ void ReadLiquidTypeTableDBC()
// Map file format data
static char const* MAP_MAGIC = "MAPS";
-static char const* MAP_VERSION_MAGIC = "v1.1";
+static char const* MAP_VERSION_MAGIC = "v1.2";
static char const* MAP_AREA_MAGIC = "AREA";
static char const* MAP_HEIGHT_MAGIC = "MHGT";
static char const* MAP_LIQUID_MAGIC = "MLIQ";
@@ -359,7 +359,8 @@ uint16 uint16_V9[ADT_GRID_SIZE+1][ADT_GRID_SIZE+1];
uint8 uint8_V8[ADT_GRID_SIZE][ADT_GRID_SIZE];
uint8 uint8_V9[ADT_GRID_SIZE+1][ADT_GRID_SIZE+1];
-uint8 liquid_type[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
+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];
@@ -378,7 +379,8 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32
}
memset(liquid_show, 0, sizeof(liquid_show));
- memset(liquid_type, 0, sizeof(liquid_type));
+ memset(liquid_flags, 0, sizeof(liquid_flags));
+ memset(liquid_entry, 0, sizeof(liquid_entry));
// Prepare map header
map_fileheader map;
@@ -612,13 +614,75 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32
map.heightMapSize+= sizeof(V9) + sizeof(V8);
}
+ // Get from MCLQ chunk (old)
+ 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;
+
+ adt_MCLQ *liquid = cell->getMCLQ();
+ int count = 0;
+ if (!liquid || cell->sizeMCLQ <= 8)
+ continue;
+
+ for (int y = 0; y < ADT_CELL_SIZE; y++)
+ {
+ int cy = i * ADT_CELL_SIZE + y;
+ for (int x = 0; x < ADT_CELL_SIZE; x++)
+ {
+ int cx = j * ADT_CELL_SIZE + x;
+ if (liquid->flags[y][x] != 0x0F)
+ {
+ liquid_show[cy][cx] = true;
+ if (liquid->flags[y][x] & (1<<7))
+ liquid_flags[i][j] |= MAP_LIQUID_TYPE_DARK_WATER;
+ ++count;
+ }
+ }
+ }
+
+ uint32 c_flag = cell->flags;
+ if (c_flag & (1<<2))
+ {
+ liquid_entry[i][j] = 1;
+ liquid_flags[i][j] |= MAP_LIQUID_TYPE_WATER; // water
+ }
+ if (c_flag & (1<<3))
+ {
+ liquid_entry[i][j] = 2;
+ liquid_flags[i][j] |= MAP_LIQUID_TYPE_OCEAN; // ocean
+ }
+ if (c_flag & (1<<4))
+ {
+ liquid_entry[i][j] = 3;
+ liquid_flags[i][j] |= MAP_LIQUID_TYPE_MAGMA; // magma/slime
+ }
+
+ if (!count && liquid_flags[i][j])
+ fprintf(stderr, "Wrong liquid detect in MCLQ chunk");
+
+ for (int y = 0; y <= ADT_CELL_SIZE; y++)
+ {
+ int cy = i * ADT_CELL_SIZE + y;
+ for (int x = 0; x <= ADT_CELL_SIZE; x++)
+ {
+ int cx = j * ADT_CELL_SIZE + x;
+ liquid_height[cy][cx] = liquid->liquid[y][x].height;
+ }
+ }
+ }
+ }
+
// Get liquid map for grid (in WOTLK used MH2O chunk)
adt_MH2O * h2o = adt.a_grid->getMH2O();
if (h2o)
{
- for (int i=0;i<ADT_CELLS_PER_GRID;i++)
+ for (int i = 0; i < ADT_CELLS_PER_GRID; i++)
{
- for(int j=0;j<ADT_CELLS_PER_GRID;j++)
+ for(int j = 0; j < ADT_CELLS_PER_GRID; j++)
{
adt_liquid_header *h = h2o->getLiquidData(i,j);
if (!h)
@@ -626,41 +690,41 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32
int count = 0;
uint64 show = h2o->getLiquidShowMap(h);
- for (int y=0; y < h->height;y++)
+ for (int y = 0; y < h->height; y++)
{
- int cy = i*ADT_CELL_SIZE + y + h->yOffset;
- for (int x=0; x < h->width; x++)
+ int cy = i * ADT_CELL_SIZE + y + h->yOffset;
+ for (int x = 0; x < h->width; x++)
{
- int cx = j*ADT_CELL_SIZE + x + h->xOffset;
+ int cx = j * ADT_CELL_SIZE + x + h->xOffset;
if (show & 1)
{
liquid_show[cy][cx] = true;
++count;
}
- show>>=1;
+ show >>= 1;
}
}
- uint32 type = LiqType[h->liquidType];
- switch (type)
+ liquid_entry[i][j] = h->liquidType;
+ switch (LiqType[h->liquidType])
{
- case LIQUID_TYPE_WATER: liquid_type[i][j] |= MAP_LIQUID_TYPE_WATER; break;
- case LIQUID_TYPE_OCEAN: liquid_type[i][j] |= MAP_LIQUID_TYPE_OCEAN; break;
- case LIQUID_TYPE_MAGMA: liquid_type[i][j] |= MAP_LIQUID_TYPE_MAGMA; break;
- case LIQUID_TYPE_SLIME: liquid_type[i][j] |= MAP_LIQUID_TYPE_SLIME; break;
+ 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; break;
+ case LIQUID_TYPE_MAGMA: liquid_flags[i][j] |= MAP_LIQUID_TYPE_MAGMA; break;
+ case LIQUID_TYPE_SLIME: liquid_flags[i][j] |= MAP_LIQUID_TYPE_SLIME; break;
default:
printf("\nCan't find Liquid type %u for map %s\nchunk %d,%d\n", h->liquidType, filename, i, j);
break;
}
// Dark water detect
- if (type == LIQUID_TYPE_OCEAN)
+ if (LiqType[h->liquidType] == LIQUID_TYPE_OCEAN)
{
uint8 *lm = h2o->getLiquidLightMap(h);
if (!lm)
- liquid_type[i][j]|=MAP_LIQUID_TYPE_DARK_WATER;
+ liquid_flags[i][j] |= MAP_LIQUID_TYPE_DARK_WATER;
}
- if (!count && liquid_type[i][j])
+ if (!count && liquid_flags[i][j])
printf("Wrong liquid detect in MH2O chunk");
float *height = h2o->getLiquidHeightMap(h);
@@ -681,72 +745,16 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32
}
}
}
- else
- {
- // Get from MCLQ chunk (old)
- 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;
-
- adt_MCLQ *liquid = cell->getMCLQ();
- int count = 0;
- if (!liquid || cell->sizeMCLQ <= 8)
- continue;
-
- for (int y=0; y < ADT_CELL_SIZE; y++)
- {
- int cy = i*ADT_CELL_SIZE + y;
- for (int x=0; x < ADT_CELL_SIZE; x++)
- {
- int cx = j*ADT_CELL_SIZE + x;
- if (liquid->flags[y][x] != 0x0F)
- {
- liquid_show[cy][cx] = true;
- if (liquid->flags[y][x]&(1<<7))
- liquid_type[i][j]|=MAP_LIQUID_TYPE_DARK_WATER;
- ++count;
- }
- }
- }
-
- uint32 c_flag = cell->flags;
- if(c_flag & (1<<2))
- liquid_type[i][j]|=MAP_LIQUID_TYPE_WATER; // water
- if(c_flag & (1<<3))
- liquid_type[i][j]|=MAP_LIQUID_TYPE_OCEAN; // ochean
- if(c_flag & (1<<4))
- liquid_type[i][j]|=MAP_LIQUID_TYPE_MAGMA; // magma/slime
-
- if (!count && liquid_type[i][j])
- printf("Wrong liquid detect in MCLQ chunk");
-
- for (int y=0; y <= ADT_CELL_SIZE; y++)
- {
- int cy = i*ADT_CELL_SIZE + y;
- for (int x=0; x<= ADT_CELL_SIZE; x++)
- {
- int cx = j*ADT_CELL_SIZE + x;
- liquid_height[cy][cx] = liquid->liquid[y][x].height;
- }
- }
- }
- }
- }
-
//============================================
// Pack liquid data
//============================================
- uint8 type = liquid_type[0][0];
+ uint8 type = 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_type[y][x]!=type)
+ if (liquid_flags[y][x]!=type)
{
fullType = true;
y = ADT_CELLS_PER_GRID;
@@ -795,8 +803,8 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32
liquidHeader.liquidType = 0;
liquidHeader.offsetX = minX;
liquidHeader.offsetY = minY;
- liquidHeader.width = maxX - minX + 1;
- liquidHeader.height = maxY - minY + 1;
+ liquidHeader.width = maxX - minX + 1 + 1;
+ liquidHeader.height = maxY - minY + 1 + 1;
liquidHeader.liquidLevel = minHeight;
if (maxHeight == minHeight)
@@ -812,7 +820,7 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32
if (liquidHeader.flags & MAP_LIQUID_NO_TYPE)
liquidHeader.liquidType = type;
else
- map.liquidMapSize+=sizeof(liquid_type);
+ map.liquidMapSize += sizeof(liquid_entry) + sizeof(liquid_flags);
if (!(liquidHeader.flags & MAP_LIQUID_NO_HEIGHT))
map.liquidMapSize += sizeof(float)*liquidHeader.width*liquidHeader.height;
@@ -857,7 +865,10 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32
{
fwrite(&liquidHeader, sizeof(liquidHeader), 1, output);
if (!(liquidHeader.flags&MAP_LIQUID_NO_TYPE))
- fwrite(liquid_type, sizeof(liquid_type), 1, output);
+ {
+ fwrite(liquid_entry, sizeof(liquid_entry), 1, output);
+ fwrite(liquid_flags, sizeof(liquid_flags), 1, output);
+ }
if (!(liquidHeader.flags&MAP_LIQUID_NO_HEIGHT))
{
for (int y=0; y<liquidHeader.height;y++)
diff --git a/src/tools/vmap4_extractor/vmapexport.cpp b/src/tools/vmap4_extractor/vmapexport.cpp
index 599290a9254..68de8d653ba 100644
--- a/src/tools/vmap4_extractor/vmapexport.cpp
+++ b/src/tools/vmap4_extractor/vmapexport.cpp
@@ -76,7 +76,7 @@ bool preciseVectorData = false;
//static const char * szWorkDirMaps = ".\\Maps";
const char* szWorkDirWmo = "./Buildings";
-const char* szRawVMAPMagic = "VMAP004";
+const char* szRawVMAPMagic = "VMAP041";
// Local testing functions
diff --git a/src/tools/vmap4_extractor/wmo.cpp b/src/tools/vmap4_extractor/wmo.cpp
index 58957e007c1..6703872111b 100644
--- a/src/tools/vmap4_extractor/wmo.cpp
+++ b/src/tools/vmap4_extractor/wmo.cpp
@@ -404,11 +404,53 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool pPrecis
if (rootWMO->liquidType & 4)
liquidEntry = liquidType;
else if (liquidType == 15)
- liquidEntry = 1; // first entry, generic "Water"
+ liquidEntry = 0;
else
liquidEntry = liquidType + 1;
- // overwrite material type in header...
- hlq->type = LiqType[liquidEntry];
+
+ if (!liquidEntry)
+ {
+ int v1; // edx@1
+ int v2; // eax@1
+
+ v1 = hlq->xtiles * hlq->ytiles;
+ v2 = 0;
+ if (v1 > 0)
+ {
+ while ((LiquBytes[v2] & 0xF) == 15)
+ {
+ ++v2;
+ if (v2 >= v1)
+ break;
+ }
+
+ if (v2 < v1 && (LiquBytes[v2] & 0xF) != 15)
+ liquidEntry = (LiquBytes[v2] & 0xF) + 1;
+ }
+ }
+
+ if (liquidEntry && liquidEntry < 21)
+ {
+ switch (((uint8)liquidEntry - 1) & 3)
+ {
+ case 0:
+ liquidEntry = ((mogpFlags & 0x80000) != 0) + 13;
+ break;
+ case 1:
+ liquidEntry = 14;
+ break;
+ case 2:
+ liquidEntry = 19;
+ break;
+ case 3:
+ liquidEntry = 20;
+ break;
+ default:
+ break;
+ }
+ }
+
+ hlq->type = liquidEntry;
/* std::ofstream llog("Buildings/liquid.log", ios_base::out | ios_base::app);
llog << filename;