mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-14 01:29:07 +00:00
refactor(Tools): restyle tools with astyle (#3465)
This commit is contained in:
@@ -29,19 +29,19 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
#if defined( __GNUC__ )
|
||||
#define _open open
|
||||
#define _close close
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
#define _open open
|
||||
#define _close close
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
#else
|
||||
#include <io.h>
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#ifdef O_LARGEFILE
|
||||
#define OPEN_FLAGS (O_RDONLY | O_BINARY | O_LARGEFILE)
|
||||
#define OPEN_FLAGS (O_RDONLY | O_BINARY | O_LARGEFILE)
|
||||
#else
|
||||
#define OPEN_FLAGS (O_RDONLY | O_BINARY)
|
||||
#define OPEN_FLAGS (O_RDONLY | O_BINARY)
|
||||
#endif
|
||||
extern ArchiveSet gOpenArchives;
|
||||
|
||||
@@ -51,8 +51,8 @@ typedef struct
|
||||
uint32 id;
|
||||
} map_id;
|
||||
|
||||
map_id *map_ids;
|
||||
uint16 *LiqType;
|
||||
map_id* map_ids;
|
||||
uint16* LiqType;
|
||||
#define MAX_PATH_LENGTH 128
|
||||
char output_path[MAX_PATH_LENGTH] = ".";
|
||||
char input_path[MAX_PATH_LENGTH] = ".";
|
||||
@@ -80,7 +80,8 @@ float CONF_flat_height_delta_limit = 0.005f; // If max - min less this value - s
|
||||
float CONF_flat_liquid_delta_limit = 0.001f; // If max - min less this value - liquid surface is flat
|
||||
|
||||
// List MPQ for extract from
|
||||
const char *CONF_mpq_list[]={
|
||||
const char* CONF_mpq_list[] =
|
||||
{
|
||||
"common.MPQ",
|
||||
"common-2.MPQ",
|
||||
"lichking.MPQ",
|
||||
@@ -108,11 +109,11 @@ void CreateDir( const std::string& Path )
|
||||
}
|
||||
|
||||
int ret;
|
||||
#ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
ret = _mkdir( Path.c_str());
|
||||
#else
|
||||
#else
|
||||
ret = mkdir( Path.c_str(), 0777 );
|
||||
#endif
|
||||
#endif
|
||||
if (ret != 0)
|
||||
{
|
||||
printf("Fatal Error: Could not create directory %s check your permissions", Path.c_str());
|
||||
@@ -145,7 +146,7 @@ void Usage(char* prg)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void HandleArgs(int argc, char * arg[])
|
||||
void HandleArgs(int argc, char* arg[])
|
||||
{
|
||||
for(int c = 1; c < argc; ++c)
|
||||
{
|
||||
@@ -173,14 +174,14 @@ void HandleArgs(int argc, char * arg[])
|
||||
break;
|
||||
case 'f':
|
||||
if(c + 1 < argc) // all ok
|
||||
CONF_allow_float_to_int=atoi(arg[(c++) + 1])!=0;
|
||||
CONF_allow_float_to_int = atoi(arg[(c++) + 1]) != 0;
|
||||
else
|
||||
Usage(arg[0]);
|
||||
break;
|
||||
case 'e':
|
||||
if(c + 1 < argc) // all ok
|
||||
{
|
||||
CONF_extract=atoi(arg[(c++) + 1]);
|
||||
CONF_extract = atoi(arg[(c++) + 1]);
|
||||
if(!(CONF_extract > 0 && CONF_extract < 4))
|
||||
Usage(arg[0]);
|
||||
}
|
||||
@@ -194,7 +195,7 @@ void HandleArgs(int argc, char * arg[])
|
||||
uint32 ReadBuild(int locale)
|
||||
{
|
||||
// include build info file also
|
||||
std::string filename = std::string("component.wow-")+langs[locale]+".txt";
|
||||
std::string filename = std::string("component.wow-") + langs[locale] + ".txt";
|
||||
//printf("Read %s file... ", filename.c_str());
|
||||
|
||||
MPQFile m(filename.c_str());
|
||||
@@ -209,14 +210,14 @@ uint32 ReadBuild(int locale)
|
||||
|
||||
size_t pos = text.find("version=\"");
|
||||
size_t pos1 = pos + strlen("version=\"");
|
||||
size_t pos2 = text.find("\"",pos1);
|
||||
size_t pos2 = text.find("\"", pos1);
|
||||
if (pos == text.npos || pos2 == text.npos || pos1 >= pos2)
|
||||
{
|
||||
printf("Fatal error: Invalid %s file format!\n", filename.c_str());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
std::string build_str = text.substr(pos1,pos2-pos1);
|
||||
std::string build_str = text.substr(pos1, pos2 - pos1);
|
||||
|
||||
int build = atoi(build_str.c_str());
|
||||
if (build <= 0)
|
||||
@@ -357,16 +358,16 @@ float selectUInt16StepStore(float maxDiff)
|
||||
uint16 area_ids[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
|
||||
|
||||
float V8[ADT_GRID_SIZE][ADT_GRID_SIZE];
|
||||
float V9[ADT_GRID_SIZE+1][ADT_GRID_SIZE+1];
|
||||
float V9[ADT_GRID_SIZE + 1][ADT_GRID_SIZE + 1];
|
||||
uint16 uint16_V8[ADT_GRID_SIZE][ADT_GRID_SIZE];
|
||||
uint16 uint16_V9[ADT_GRID_SIZE+1][ADT_GRID_SIZE+1];
|
||||
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 uint8_V9[ADT_GRID_SIZE + 1][ADT_GRID_SIZE + 1];
|
||||
|
||||
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];
|
||||
float liquid_height[ADT_GRID_SIZE + 1][ADT_GRID_SIZE + 1];
|
||||
|
||||
int16 flight_box_max[3][3];
|
||||
int16 flight_box_min[3][3];
|
||||
@@ -378,7 +379,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
if (!adt.loadFile(inputPath))
|
||||
return false;
|
||||
|
||||
adt_MCIN *cells = adt.a_grid->getMCIN();
|
||||
adt_MCIN* cells = adt.a_grid->getMCIN();
|
||||
if (!cells)
|
||||
{
|
||||
printf("Can't find cells in '%s'\n", inputPath.c_str());
|
||||
@@ -437,11 +438,11 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
//
|
||||
// Get Height map from grid
|
||||
//
|
||||
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_MCNK * cell = cells->getMCNK(i, j);
|
||||
adt_MCNK* cell = cells->getMCNK(i, j);
|
||||
if (!cell)
|
||||
continue;
|
||||
// Height values for triangles stored in order:
|
||||
@@ -463,44 +464,44 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
// Set map height as grid height
|
||||
for (int y = 0; y <= ADT_CELL_SIZE; y++)
|
||||
{
|
||||
int cy = i*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;
|
||||
int cx = j * ADT_CELL_SIZE + x;
|
||||
V9[cy][cx] = cell->ypos;
|
||||
}
|
||||
}
|
||||
for (int y = 0; y < ADT_CELL_SIZE; y++)
|
||||
{
|
||||
int cy = i*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;
|
||||
int cx = j * ADT_CELL_SIZE + x;
|
||||
V8[cy][cx] = cell->ypos;
|
||||
}
|
||||
}
|
||||
// Get custom height
|
||||
adt_MCVT *v = cell->getMCVT();
|
||||
adt_MCVT* v = cell->getMCVT();
|
||||
if (!v)
|
||||
continue;
|
||||
// get V9 height map
|
||||
for (int y = 0; y <= ADT_CELL_SIZE; y++)
|
||||
{
|
||||
int cy = i*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;
|
||||
V9[cy][cx] += v->height_map[y*(ADT_CELL_SIZE * 2 + 1) + x];
|
||||
int cx = j * ADT_CELL_SIZE + x;
|
||||
V9[cy][cx] += v->height_map[y * (ADT_CELL_SIZE * 2 + 1) + x];
|
||||
}
|
||||
}
|
||||
// get V8 height map
|
||||
for (int y = 0; y < ADT_CELL_SIZE; y++)
|
||||
{
|
||||
int cy = i*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;
|
||||
V8[cy][cx] += v->height_map[y*(ADT_CELL_SIZE * 2 + 1) + ADT_CELL_SIZE + 1 + x];
|
||||
int cx = j * ADT_CELL_SIZE + x;
|
||||
V8[cy][cx] += v->height_map[y * (ADT_CELL_SIZE * 2 + 1) + ADT_CELL_SIZE + 1 + x];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -510,9 +511,9 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
//============================================
|
||||
float maxHeight = -20000;
|
||||
float minHeight = 20000;
|
||||
for (int y = 0; y<ADT_GRID_SIZE; y++)
|
||||
for (int y = 0; y < ADT_GRID_SIZE; y++)
|
||||
{
|
||||
for (int x = 0; x<ADT_GRID_SIZE; x++)
|
||||
for (int x = 0; x < ADT_GRID_SIZE; x++)
|
||||
{
|
||||
float h = V8[y][x];
|
||||
if (maxHeight < h) maxHeight = h;
|
||||
@@ -521,7 +522,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
}
|
||||
for (int y = 0; y <= ADT_GRID_SIZE; y++)
|
||||
{
|
||||
for(int x = 0; x<= ADT_GRID_SIZE; x++)
|
||||
for(int x = 0; x <= ADT_GRID_SIZE; x++)
|
||||
{
|
||||
float h = V9[y][x];
|
||||
if (maxHeight < h) maxHeight = h;
|
||||
@@ -532,8 +533,8 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
// Check for allow limit minimum height (not store height in deep ochean - allow save some memory)
|
||||
if (CONF_allow_height_limit && minHeight < CONF_use_minHeight)
|
||||
{
|
||||
for (int y = 0; y<ADT_GRID_SIZE; y++)
|
||||
for (int x = 0; x<ADT_GRID_SIZE; x++)
|
||||
for (int y = 0; y < ADT_GRID_SIZE; y++)
|
||||
for (int x = 0; x < ADT_GRID_SIZE; x++)
|
||||
if (V8[y][x] < CONF_use_minHeight)
|
||||
V8[y][x] = CONF_use_minHeight;
|
||||
for (int y = 0; y <= ADT_GRID_SIZE; y++)
|
||||
@@ -569,7 +570,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
// Not need store if flat surface
|
||||
if (CONF_allow_float_to_int && (maxHeight - minHeight) < CONF_flat_height_delta_limit)
|
||||
heightHeader.flags |= MAP_HEIGHT_NO_HEIGHT;
|
||||
|
||||
|
||||
if (hasFlightBox)
|
||||
{
|
||||
heightHeader.flags |= MAP_HEIGHT_HAS_FLIGHT_BOUNDS;
|
||||
@@ -589,7 +590,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
heightHeader.flags |= MAP_HEIGHT_AS_INT8;
|
||||
step = selectUInt8StepStore(diff);
|
||||
}
|
||||
else if (diff<CONF_float_to_int16_limit) // As uint16 (max accuracy = CONF_float_to_int16_limit/65536)
|
||||
else if (diff < CONF_float_to_int16_limit) // As uint16 (max accuracy = CONF_float_to_int16_limit/65536)
|
||||
{
|
||||
heightHeader.flags |= MAP_HEIGHT_AS_INT16;
|
||||
step = selectUInt16StepStore(diff);
|
||||
@@ -597,20 +598,20 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
}
|
||||
|
||||
// Pack it to int values if need
|
||||
if (heightHeader.flags&MAP_HEIGHT_AS_INT8)
|
||||
if (heightHeader.flags & MAP_HEIGHT_AS_INT8)
|
||||
{
|
||||
for (int y = 0; y<ADT_GRID_SIZE; y++)
|
||||
for (int x = 0; x<ADT_GRID_SIZE; x++)
|
||||
for (int y = 0; y < ADT_GRID_SIZE; y++)
|
||||
for (int x = 0; x < ADT_GRID_SIZE; x++)
|
||||
uint8_V8[y][x] = uint8((V8[y][x] - minHeight) * step + 0.5f);
|
||||
for (int y = 0; y <= ADT_GRID_SIZE; y++)
|
||||
for (int x = 0; x <= ADT_GRID_SIZE; x++)
|
||||
uint8_V9[y][x] = uint8((V9[y][x] - minHeight) * step + 0.5f);
|
||||
map.heightMapSize += sizeof(uint8_V9) + sizeof(uint8_V8);
|
||||
}
|
||||
else if (heightHeader.flags&MAP_HEIGHT_AS_INT16)
|
||||
else if (heightHeader.flags & MAP_HEIGHT_AS_INT16)
|
||||
{
|
||||
for (int y = 0; y<ADT_GRID_SIZE; y++)
|
||||
for (int x = 0; x<ADT_GRID_SIZE; x++)
|
||||
for (int y = 0; y < ADT_GRID_SIZE; y++)
|
||||
for (int x = 0; x < ADT_GRID_SIZE; x++)
|
||||
uint16_V8[y][x] = uint16((V8[y][x] - minHeight) * step + 0.5f);
|
||||
for (int y = 0; y <= ADT_GRID_SIZE; y++)
|
||||
for (int x = 0; x <= ADT_GRID_SIZE; x++)
|
||||
@@ -626,11 +627,11 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
{
|
||||
for (int j = 0; j < ADT_CELLS_PER_GRID; j++)
|
||||
{
|
||||
adt_MCNK *cell = cells->getMCNK(i, j);
|
||||
adt_MCNK* cell = cells->getMCNK(i, j);
|
||||
if (!cell)
|
||||
continue;
|
||||
|
||||
adt_MCLQ *liquid = cell->getMCLQ();
|
||||
adt_MCLQ* liquid = cell->getMCLQ();
|
||||
int count = 0;
|
||||
if (!liquid || cell->sizeMCLQ <= 8)
|
||||
continue;
|
||||
@@ -684,14 +685,14 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
}
|
||||
|
||||
// Get liquid map for grid (in WOTLK used MH2O chunk)
|
||||
adt_MH2O * h2o = adt.a_grid->getMH2O();
|
||||
adt_MH2O* h2o = adt.a_grid->getMH2O();
|
||||
if (h2o)
|
||||
{
|
||||
for (int i = 0; i < ADT_CELLS_PER_GRID; i++)
|
||||
{
|
||||
for(int j = 0; j < ADT_CELLS_PER_GRID; j++)
|
||||
{
|
||||
adt_liquid_header *h = h2o->getLiquidData(i,j);
|
||||
adt_liquid_header* h = h2o->getLiquidData(i, j);
|
||||
if (!h)
|
||||
continue;
|
||||
|
||||
@@ -715,10 +716,18 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
liquid_entry[i][j] = h->liquidType;
|
||||
switch (LiqType[h->liquidType])
|
||||
{
|
||||
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;
|
||||
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, inputPath.c_str(), i, j);
|
||||
break;
|
||||
@@ -726,7 +735,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
// Dark water detect
|
||||
if (LiqType[h->liquidType] == LIQUID_TYPE_OCEAN)
|
||||
{
|
||||
uint8 *lm = h2o->getLiquidLightMap(h);
|
||||
uint8* lm = h2o->getLiquidLightMap(h);
|
||||
if (!lm)
|
||||
liquid_flags[i][j] |= MAP_LIQUID_TYPE_DARK_WATER;
|
||||
}
|
||||
@@ -734,14 +743,14 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
if (!count && liquid_flags[i][j])
|
||||
printf("Wrong liquid detect in MH2O chunk");
|
||||
|
||||
float *height = h2o->getLiquidHeightMap(h);
|
||||
float* height = h2o->getLiquidHeightMap(h);
|
||||
int pos = 0;
|
||||
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 (height)
|
||||
liquid_height[cy][cx] = height[pos];
|
||||
else
|
||||
@@ -757,11 +766,11 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
//============================================
|
||||
uint8 type = liquid_flags[0][0];
|
||||
bool fullType = false;
|
||||
for (int y=0;y<ADT_CELLS_PER_GRID;y++)
|
||||
for (int y = 0; y < ADT_CELLS_PER_GRID; y++)
|
||||
{
|
||||
for(int x=0;x<ADT_CELLS_PER_GRID;x++)
|
||||
for(int x = 0; x < ADT_CELLS_PER_GRID; x++)
|
||||
{
|
||||
if (liquid_flags[y][x]!=type)
|
||||
if (liquid_flags[y][x] != type)
|
||||
{
|
||||
fullType = true;
|
||||
y = ADT_CELLS_PER_GRID;
|
||||
@@ -785,9 +794,9 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
int maxX = 0, maxY = 0;
|
||||
maxHeight = -20000;
|
||||
minHeight = 20000;
|
||||
for (int y=0; y<ADT_GRID_SIZE; y++)
|
||||
for (int y = 0; y < ADT_GRID_SIZE; y++)
|
||||
{
|
||||
for(int x=0; x<ADT_GRID_SIZE; x++)
|
||||
for(int x = 0; x < ADT_GRID_SIZE; x++)
|
||||
{
|
||||
if (liquid_show[y][x])
|
||||
{
|
||||
@@ -830,7 +839,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
map.liquidMapSize += sizeof(liquid_entry) + sizeof(liquid_flags);
|
||||
|
||||
if (!(liquidHeader.flags & MAP_LIQUID_NO_HEIGHT))
|
||||
map.liquidMapSize += sizeof(float)*liquidHeader.width*liquidHeader.height;
|
||||
map.liquidMapSize += sizeof(float) * liquidHeader.width * liquidHeader.height;
|
||||
}
|
||||
|
||||
// map hole info
|
||||
@@ -848,7 +857,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
{
|
||||
for (int j = 0; j < ADT_CELLS_PER_GRID; ++j)
|
||||
{
|
||||
adt_MCNK * cell = cells->getMCNK(i,j);
|
||||
adt_MCNK* cell = cells->getMCNK(i, j);
|
||||
if (!cell)
|
||||
continue;
|
||||
holes[i][j] = cell->holes;
|
||||
@@ -872,7 +881,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
fwrite(&map, sizeof(map), 1, output);
|
||||
// Store area data
|
||||
fwrite(&areaHeader, sizeof(areaHeader), 1, output);
|
||||
if (!(areaHeader.flags&MAP_AREA_NO_AREA))
|
||||
if (!(areaHeader.flags & MAP_AREA_NO_AREA))
|
||||
fwrite(area_ids, sizeof(area_ids), 1, output);
|
||||
|
||||
// Store height data
|
||||
@@ -906,15 +915,15 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
if (map.liquidMapOffset)
|
||||
{
|
||||
fwrite(&liquidHeader, sizeof(liquidHeader), 1, output);
|
||||
if (!(liquidHeader.flags&MAP_LIQUID_NO_TYPE))
|
||||
if (!(liquidHeader.flags & MAP_LIQUID_NO_TYPE))
|
||||
{
|
||||
fwrite(liquid_entry, sizeof(liquid_entry), 1, output);
|
||||
fwrite(liquid_flags, sizeof(liquid_flags), 1, output);
|
||||
}
|
||||
if (!(liquidHeader.flags&MAP_LIQUID_NO_HEIGHT))
|
||||
if (!(liquidHeader.flags & MAP_LIQUID_NO_HEIGHT))
|
||||
{
|
||||
for (int y=0; y<liquidHeader.height;y++)
|
||||
fwrite(&liquid_height[y+liquidHeader.offsetY][liquidHeader.offsetX], sizeof(float), liquidHeader.width, output);
|
||||
for (int y = 0; y < liquidHeader.height; y++)
|
||||
fwrite(&liquid_height[y + liquidHeader.offsetY][liquidHeader.offsetX], sizeof(float), liquidHeader.width, output);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -946,13 +955,13 @@ void ExtractMapsFromMpq(uint32 build)
|
||||
printf("Convert map files\n");
|
||||
for(uint32 z = 0; z < map_count; ++z)
|
||||
{
|
||||
printf("Extract %s (%d/%u) \n", map_ids[z].name, z+1, map_count);
|
||||
printf("Extract %s (%d/%u) \n", map_ids[z].name, z + 1, map_count);
|
||||
// Loadup map grid data
|
||||
mpqMapName = acore::StringFormat("World\\Maps\\%s\\%s.wdt", map_ids[z].name, map_ids[z].name);
|
||||
WDT_file wdt;
|
||||
if (!wdt.loadFile(mpqMapName, false))
|
||||
{
|
||||
// printf("Error loading %s map wdt data\n", map_ids[z].name);
|
||||
// printf("Error loading %s map wdt data\n", map_ids[z].name);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -967,7 +976,7 @@ void ExtractMapsFromMpq(uint32 build)
|
||||
ConvertADT(mpqFileName, outputFileName, y, x, build);
|
||||
}
|
||||
// draw progress bar
|
||||
printf("Processing........................%d%%\r", (100 * (y+1)) / WDT_MAP_SIZE);
|
||||
printf("Processing........................%d%%\r", (100 * (y + 1)) / WDT_MAP_SIZE);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
@@ -976,7 +985,7 @@ void ExtractMapsFromMpq(uint32 build)
|
||||
|
||||
bool ExtractFile( char const* mpq_name, std::string const& filename )
|
||||
{
|
||||
FILE *output = fopen(filename.c_str(), "wb");
|
||||
FILE* output = fopen(filename.c_str(), "wb");
|
||||
if(!output)
|
||||
{
|
||||
printf("Can't create the output file '%s'\n", filename.c_str());
|
||||
@@ -997,13 +1006,13 @@ void ExtractDBCFiles(int locale, bool basicLocale)
|
||||
std::set<std::string> dbcfiles;
|
||||
|
||||
// get DBC file list
|
||||
for(ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end();++i)
|
||||
for(ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end(); ++i)
|
||||
{
|
||||
vector<string> files;
|
||||
(*i)->GetFileListTo(files);
|
||||
for (vector<string>::iterator iter = files.begin(); iter != files.end(); ++iter)
|
||||
if (iter->rfind(".dbc") == iter->length() - strlen(".dbc"))
|
||||
dbcfiles.insert(*iter);
|
||||
dbcfiles.insert(*iter);
|
||||
}
|
||||
|
||||
std::string path = output_path;
|
||||
@@ -1030,7 +1039,7 @@ void ExtractDBCFiles(int locale, bool basicLocale)
|
||||
{
|
||||
string filename = path;
|
||||
filename += (iter->c_str() + strlen("DBFilesClient\\"));
|
||||
|
||||
|
||||
if(FileExists(filename.c_str()))
|
||||
continue;
|
||||
|
||||
@@ -1044,7 +1053,7 @@ void LoadLocaleMPQFiles(int const locale)
|
||||
{
|
||||
char filename[512];
|
||||
|
||||
sprintf(filename,"%s/Data/%s/locale-%s.MPQ", input_path, langs[locale], langs[locale]);
|
||||
sprintf(filename, "%s/Data/%s/locale-%s.MPQ", input_path, langs[locale], langs[locale]);
|
||||
new MPQArchive(filename);
|
||||
|
||||
for(int i = 1; i < 5; ++i)
|
||||
@@ -1053,7 +1062,7 @@ void LoadLocaleMPQFiles(int const locale)
|
||||
if(i > 1)
|
||||
sprintf(ext, "-%i", i);
|
||||
|
||||
sprintf(filename,"%s/Data/%s/patch-%s%s.MPQ", input_path, langs[locale], langs[locale], ext);
|
||||
sprintf(filename, "%s/Data/%s/patch-%s%s.MPQ", input_path, langs[locale], langs[locale], ext);
|
||||
if(FileExists(filename))
|
||||
new MPQArchive(filename);
|
||||
}
|
||||
@@ -1062,7 +1071,7 @@ void LoadLocaleMPQFiles(int const locale)
|
||||
void LoadCommonMPQFiles()
|
||||
{
|
||||
char filename[512];
|
||||
int count = sizeof(CONF_mpq_list)/sizeof(char*);
|
||||
int count = sizeof(CONF_mpq_list) / sizeof(char*);
|
||||
for(int i = 0; i < count; ++i)
|
||||
{
|
||||
sprintf(filename, "%s/Data/%s", input_path, CONF_mpq_list[i]);
|
||||
@@ -1073,11 +1082,11 @@ void LoadCommonMPQFiles()
|
||||
|
||||
inline void CloseMPQFiles()
|
||||
{
|
||||
for(ArchiveSet::iterator j = gOpenArchives.begin(); j != gOpenArchives.end();++j) (*j)->close();
|
||||
gOpenArchives.clear();
|
||||
for(ArchiveSet::iterator j = gOpenArchives.begin(); j != gOpenArchives.end(); ++j) (*j)->close();
|
||||
gOpenArchives.clear();
|
||||
}
|
||||
|
||||
int main(int argc, char * arg[])
|
||||
int main(int argc, char* arg[])
|
||||
{
|
||||
printf("Map & DBC Extractor\n");
|
||||
printf("===================\n\n");
|
||||
|
||||
Reference in New Issue
Block a user