mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 17:19: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");
|
||||
|
||||
@@ -12,13 +12,13 @@
|
||||
int holetab_h[4] = { 0x1111, 0x2222, 0x4444, 0x8888 };
|
||||
int holetab_v[4] = { 0x000F, 0x00F0, 0x0F00, 0xF000 };
|
||||
|
||||
u_map_fcc MHDRMagic = { { 'R','D','H','M' } };
|
||||
u_map_fcc MCINMagic = { { 'N','I','C','M' } };
|
||||
u_map_fcc MH2OMagic = { { 'O','2','H','M' } };
|
||||
u_map_fcc MCNKMagic = { { 'K','N','C','M' } };
|
||||
u_map_fcc MCVTMagic = { { 'T','V','C','M' } };
|
||||
u_map_fcc MCLQMagic = { { 'Q','L','C','M' } };
|
||||
u_map_fcc MFBOMagic = { { 'O','B','F','M' } };
|
||||
u_map_fcc MHDRMagic = { { 'R', 'D', 'H', 'M' } };
|
||||
u_map_fcc MCINMagic = { { 'N', 'I', 'C', 'M' } };
|
||||
u_map_fcc MH2OMagic = { { 'O', '2', 'H', 'M' } };
|
||||
u_map_fcc MCNKMagic = { { 'K', 'N', 'C', 'M' } };
|
||||
u_map_fcc MCVTMagic = { { 'T', 'V', 'C', 'M' } };
|
||||
u_map_fcc MCLQMagic = { { 'Q', 'L', 'C', 'M' } };
|
||||
u_map_fcc MFBOMagic = { { 'O', 'B', 'F', 'M' } };
|
||||
|
||||
bool isHole(int holes, int i, int j)
|
||||
{
|
||||
@@ -58,7 +58,7 @@ bool ADT_file::prepareLoadedData()
|
||||
return false;
|
||||
|
||||
// Check and prepare MHDR
|
||||
a_grid = (adt_MHDR *)(GetData()+8+version->size);
|
||||
a_grid = (adt_MHDR*)(GetData() + 8 + version->size);
|
||||
if (!a_grid->prepareLoadedData())
|
||||
return false;
|
||||
|
||||
@@ -93,9 +93,9 @@ bool adt_MCIN::prepareLoadedData()
|
||||
return false;
|
||||
|
||||
// Check cells data
|
||||
for (int i=0; i<ADT_CELLS_PER_GRID;i++)
|
||||
for (int j=0; j<ADT_CELLS_PER_GRID;j++)
|
||||
if (cells[i][j].offsMCNK && !getMCNK(i,j)->prepareLoadedData())
|
||||
for (int i = 0; i < ADT_CELLS_PER_GRID; i++)
|
||||
for (int j = 0; j < ADT_CELLS_PER_GRID; j++)
|
||||
if (cells[i][j].offsMCNK && !getMCNK(i, j)->prepareLoadedData())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -107,8 +107,8 @@ bool adt_MH2O::prepareLoadedData()
|
||||
return false;
|
||||
|
||||
// Check liquid data
|
||||
// for (int i=0; i<ADT_CELLS_PER_GRID;i++)
|
||||
// for (int j=0; j<ADT_CELLS_PER_GRID;j++)
|
||||
// for (int i=0; i<ADT_CELLS_PER_GRID;i++)
|
||||
// for (int j=0; j<ADT_CELLS_PER_GRID;j++)
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ bool adt_MCVT::prepareLoadedData()
|
||||
if (fcc != MCVTMagic.fcc)
|
||||
return false;
|
||||
|
||||
if (size != sizeof(adt_MCVT)-8)
|
||||
if (size != sizeof(adt_MCVT) - 8)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -33,13 +33,14 @@ enum LiquidType
|
||||
//
|
||||
class adt_MCVT
|
||||
{
|
||||
union{
|
||||
union
|
||||
{
|
||||
uint32 fcc;
|
||||
char fcc_txt[4];
|
||||
};
|
||||
uint32 size;
|
||||
public:
|
||||
float height_map[(ADT_CELL_SIZE+1)*(ADT_CELL_SIZE+1)+ADT_CELL_SIZE*ADT_CELL_SIZE];
|
||||
float height_map[(ADT_CELL_SIZE + 1) * (ADT_CELL_SIZE + 1) + ADT_CELL_SIZE * ADT_CELL_SIZE];
|
||||
|
||||
bool prepareLoadedData();
|
||||
};
|
||||
@@ -49,7 +50,8 @@ public:
|
||||
//
|
||||
class adt_MCLQ
|
||||
{
|
||||
union{
|
||||
union
|
||||
{
|
||||
uint32 fcc;
|
||||
char fcc_txt[4];
|
||||
};
|
||||
@@ -57,10 +59,11 @@ public:
|
||||
uint32 size;
|
||||
float height1;
|
||||
float height2;
|
||||
struct liquid_data{
|
||||
struct liquid_data
|
||||
{
|
||||
uint32 light;
|
||||
float height;
|
||||
} liquid[ADT_CELL_SIZE+1][ADT_CELL_SIZE+1];
|
||||
} liquid[ADT_CELL_SIZE + 1][ADT_CELL_SIZE + 1];
|
||||
|
||||
// 1<<0 - ochen
|
||||
// 1<<1 - lava/slime
|
||||
@@ -78,7 +81,8 @@ public:
|
||||
//
|
||||
class adt_MCNK
|
||||
{
|
||||
union{
|
||||
union
|
||||
{
|
||||
uint32 fcc;
|
||||
char fcc_txt[4];
|
||||
};
|
||||
@@ -118,16 +122,16 @@ public:
|
||||
uint32 effectId;
|
||||
|
||||
bool prepareLoadedData();
|
||||
adt_MCVT *getMCVT()
|
||||
adt_MCVT* getMCVT()
|
||||
{
|
||||
if (offsMCVT)
|
||||
return (adt_MCVT *)((uint8 *)this + offsMCVT);
|
||||
return (adt_MCVT*)((uint8*)this + offsMCVT);
|
||||
return 0;
|
||||
}
|
||||
adt_MCLQ *getMCLQ()
|
||||
adt_MCLQ* getMCLQ()
|
||||
{
|
||||
if (offsMCLQ)
|
||||
return (adt_MCLQ *)((uint8 *)this + offsMCLQ);
|
||||
return (adt_MCLQ*)((uint8*)this + offsMCLQ);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
@@ -137,13 +141,15 @@ public:
|
||||
//
|
||||
class adt_MCIN
|
||||
{
|
||||
union{
|
||||
union
|
||||
{
|
||||
uint32 fcc;
|
||||
char fcc_txt[4];
|
||||
};
|
||||
public:
|
||||
uint32 size;
|
||||
struct adt_CELLS{
|
||||
struct adt_CELLS
|
||||
{
|
||||
uint32 offsMCNK;
|
||||
uint32 size;
|
||||
uint32 flags;
|
||||
@@ -152,10 +158,10 @@ public:
|
||||
|
||||
bool prepareLoadedData();
|
||||
// offset from begin file (used this-84)
|
||||
adt_MCNK *getMCNK(int x, int y)
|
||||
adt_MCNK* getMCNK(int x, int y)
|
||||
{
|
||||
if (cells[x][y].offsMCNK)
|
||||
return (adt_MCNK *)((uint8 *)this + cells[x][y].offsMCNK - 84);
|
||||
return (adt_MCNK*)((uint8*)this + cells[x][y].offsMCNK - 84);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
@@ -163,7 +169,8 @@ public:
|
||||
#define ADT_LIQUID_HEADER_FULL_LIGHT 0x01
|
||||
#define ADT_LIQUID_HEADER_NO_HIGHT 0x02
|
||||
|
||||
struct adt_liquid_header{
|
||||
struct adt_liquid_header
|
||||
{
|
||||
uint16 liquidType; // Index from LiquidType.dbc
|
||||
uint16 formatFlags;
|
||||
float heightLevel1;
|
||||
@@ -182,13 +189,15 @@ struct adt_liquid_header{
|
||||
class adt_MH2O
|
||||
{
|
||||
public:
|
||||
union{
|
||||
union
|
||||
{
|
||||
uint32 fcc;
|
||||
char fcc_txt[4];
|
||||
};
|
||||
uint32 size;
|
||||
|
||||
struct adt_LIQUID{
|
||||
struct adt_LIQUID
|
||||
{
|
||||
uint32 offsData1;
|
||||
uint32 used;
|
||||
uint32 offsData2;
|
||||
@@ -196,52 +205,52 @@ public:
|
||||
|
||||
bool prepareLoadedData();
|
||||
|
||||
adt_liquid_header *getLiquidData(int x, int y)
|
||||
adt_liquid_header* getLiquidData(int x, int y)
|
||||
{
|
||||
if (liquid[x][y].used && liquid[x][y].offsData1)
|
||||
return (adt_liquid_header *)((uint8*)this + 8 + liquid[x][y].offsData1);
|
||||
return (adt_liquid_header*)((uint8*)this + 8 + liquid[x][y].offsData1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
float *getLiquidHeightMap(adt_liquid_header *h)
|
||||
float* getLiquidHeightMap(adt_liquid_header* h)
|
||||
{
|
||||
if (h->formatFlags & ADT_LIQUID_HEADER_NO_HIGHT)
|
||||
return 0;
|
||||
if (h->offsData2b)
|
||||
return (float *)((uint8*)this + 8 + h->offsData2b);
|
||||
return (float*)((uint8*)this + 8 + h->offsData2b);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8 *getLiquidLightMap(adt_liquid_header *h)
|
||||
uint8* getLiquidLightMap(adt_liquid_header* h)
|
||||
{
|
||||
if (h->formatFlags&ADT_LIQUID_HEADER_FULL_LIGHT)
|
||||
if (h->formatFlags & ADT_LIQUID_HEADER_FULL_LIGHT)
|
||||
return 0;
|
||||
if (h->offsData2b)
|
||||
{
|
||||
if (h->formatFlags & ADT_LIQUID_HEADER_NO_HIGHT)
|
||||
return (uint8 *)((uint8*)this + 8 + h->offsData2b);
|
||||
return (uint8 *)((uint8*)this + 8 + h->offsData2b + (h->width+1)*(h->height+1)*4);
|
||||
return (uint8*)((uint8*)this + 8 + h->offsData2b);
|
||||
return (uint8*)((uint8*)this + 8 + h->offsData2b + (h->width + 1) * (h->height + 1) * 4);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 *getLiquidFullLightMap(adt_liquid_header *h)
|
||||
uint32* getLiquidFullLightMap(adt_liquid_header* h)
|
||||
{
|
||||
if (!(h->formatFlags&ADT_LIQUID_HEADER_FULL_LIGHT))
|
||||
if (!(h->formatFlags & ADT_LIQUID_HEADER_FULL_LIGHT))
|
||||
return 0;
|
||||
if (h->offsData2b)
|
||||
{
|
||||
if (h->formatFlags & ADT_LIQUID_HEADER_NO_HIGHT)
|
||||
return (uint32 *)((uint8*)this + 8 + h->offsData2b);
|
||||
return (uint32 *)((uint8*)this + 8 + h->offsData2b + (h->width+1)*(h->height+1)*4);
|
||||
return (uint32*)((uint8*)this + 8 + h->offsData2b);
|
||||
return (uint32*)((uint8*)this + 8 + h->offsData2b + (h->width + 1) * (h->height + 1) * 4);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64 getLiquidShowMap(adt_liquid_header *h)
|
||||
uint64 getLiquidShowMap(adt_liquid_header* h)
|
||||
{
|
||||
if (h->offsData2a)
|
||||
return *((uint64 *)((uint8*)this + 8 + h->offsData2a));
|
||||
return *((uint64*)((uint8*)this + 8 + h->offsData2a));
|
||||
else
|
||||
return 0xFFFFFFFFFFFFFFFFuLL;
|
||||
}
|
||||
@@ -274,7 +283,8 @@ public:
|
||||
//
|
||||
class adt_MHDR
|
||||
{
|
||||
union{
|
||||
union
|
||||
{
|
||||
uint32 fcc;
|
||||
char fcc_txt[4];
|
||||
};
|
||||
@@ -317,14 +327,15 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class ADT_file : public FileLoader{
|
||||
class ADT_file : public FileLoader
|
||||
{
|
||||
public:
|
||||
bool prepareLoadedData();
|
||||
ADT_file();
|
||||
~ADT_file();
|
||||
void free();
|
||||
|
||||
adt_MHDR *a_grid;
|
||||
adt_MHDR* a_grid;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,35 +19,35 @@ bool DBCFile::open()
|
||||
{
|
||||
MPQFile f(filename.c_str());
|
||||
char header[4];
|
||||
unsigned int na,nb,es,ss;
|
||||
unsigned int na, nb, es, ss;
|
||||
|
||||
if(f.read(header,4)!=4) // Number of records
|
||||
if(f.read(header, 4) != 4) // Number of records
|
||||
return false;
|
||||
|
||||
if(header[0]!='W' || header[1]!='D' || header[2]!='B' || header[3]!='C')
|
||||
if(header[0] != 'W' || header[1] != 'D' || header[2] != 'B' || header[3] != 'C')
|
||||
return false;
|
||||
|
||||
if(f.read(&na,4)!=4) // Number of records
|
||||
if(f.read(&na, 4) != 4) // Number of records
|
||||
return false;
|
||||
if(f.read(&nb,4)!=4) // Number of fields
|
||||
if(f.read(&nb, 4) != 4) // Number of fields
|
||||
return false;
|
||||
if(f.read(&es,4)!=4) // Size of a record
|
||||
if(f.read(&es, 4) != 4) // Size of a record
|
||||
return false;
|
||||
if(f.read(&ss,4)!=4) // String size
|
||||
if(f.read(&ss, 4) != 4) // String size
|
||||
return false;
|
||||
|
||||
recordSize = es;
|
||||
recordCount = na;
|
||||
fieldCount = nb;
|
||||
stringSize = ss;
|
||||
if(fieldCount*4 != recordSize)
|
||||
if(fieldCount * 4 != recordSize)
|
||||
return false;
|
||||
|
||||
data = new unsigned char[recordSize*recordCount+stringSize];
|
||||
stringTable = data + recordSize*recordCount;
|
||||
data = new unsigned char[recordSize * recordCount + stringSize];
|
||||
stringTable = data + recordSize * recordCount;
|
||||
|
||||
size_t data_size = recordSize*recordCount+stringSize;
|
||||
if(f.read(data,data_size)!=data_size)
|
||||
size_t data_size = recordSize * recordCount + stringSize;
|
||||
if(f.read(data, data_size) != data_size)
|
||||
return false;
|
||||
f.close();
|
||||
return true;
|
||||
@@ -60,7 +60,7 @@ DBCFile::~DBCFile()
|
||||
DBCFile::Record DBCFile::getRecord(size_t id)
|
||||
{
|
||||
assert(data);
|
||||
return Record(*this, data + id*recordSize);
|
||||
return Record(*this, data + id * recordSize);
|
||||
}
|
||||
|
||||
size_t DBCFile::getMaxId()
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
class DBCFile
|
||||
{
|
||||
public:
|
||||
DBCFile(const std::string &filename);
|
||||
DBCFile(const std::string& filename);
|
||||
~DBCFile();
|
||||
|
||||
// Open database. It must be openened before it can be used.
|
||||
@@ -22,11 +22,11 @@ public:
|
||||
class Exception
|
||||
{
|
||||
public:
|
||||
Exception(const std::string &message): message(message)
|
||||
Exception(const std::string& message): message(message)
|
||||
{ }
|
||||
virtual ~Exception()
|
||||
{ }
|
||||
const std::string &getMessage() {return message;}
|
||||
const std::string& getMessage() {return message;}
|
||||
private:
|
||||
std::string message;
|
||||
};
|
||||
@@ -44,19 +44,19 @@ public:
|
||||
float getFloat(size_t field) const
|
||||
{
|
||||
assert(field < file.fieldCount);
|
||||
return *reinterpret_cast<float*>(offset+field*4);
|
||||
return *reinterpret_cast<float*>(offset + field * 4);
|
||||
}
|
||||
unsigned int getUInt(size_t field) const
|
||||
{
|
||||
assert(field < file.fieldCount);
|
||||
return *reinterpret_cast<unsigned int*>(offset+field*4);
|
||||
return *reinterpret_cast<unsigned int*>(offset + field * 4);
|
||||
}
|
||||
int getInt(size_t field) const
|
||||
{
|
||||
assert(field < file.fieldCount);
|
||||
return *reinterpret_cast<int*>(offset+field*4);
|
||||
return *reinterpret_cast<int*>(offset + field * 4);
|
||||
}
|
||||
const char *getString(size_t field) const
|
||||
const char* getString(size_t field) const
|
||||
{
|
||||
assert(field < file.fieldCount);
|
||||
size_t stringOffset = getUInt(field);
|
||||
@@ -64,9 +64,9 @@ public:
|
||||
return reinterpret_cast<char*>(file.stringTable + stringOffset);
|
||||
}
|
||||
private:
|
||||
Record(DBCFile &file, unsigned char *offset): file(file), offset(offset) {}
|
||||
DBCFile &file;
|
||||
unsigned char *offset;
|
||||
Record(DBCFile& file, unsigned char* offset): file(file), offset(offset) {}
|
||||
DBCFile& file;
|
||||
unsigned char* offset;
|
||||
|
||||
friend class DBCFile;
|
||||
friend class DBCFile::Iterator;
|
||||
@@ -76,24 +76,26 @@ public:
|
||||
class Iterator
|
||||
{
|
||||
public:
|
||||
Iterator(DBCFile &file, unsigned char *offset):
|
||||
Iterator(DBCFile& file, unsigned char* offset):
|
||||
record(file, offset) {}
|
||||
/// Advance (prefix only)
|
||||
Iterator & operator++() {
|
||||
Iterator& operator++()
|
||||
{
|
||||
record.offset += record.file.recordSize;
|
||||
return *this;
|
||||
}
|
||||
/// Return address of current instance
|
||||
Record const & operator*() const { return record; }
|
||||
const Record* operator->() const {
|
||||
Record const& operator*() const { return record; }
|
||||
const Record* operator->() const
|
||||
{
|
||||
return &record;
|
||||
}
|
||||
/// Comparison
|
||||
bool operator==(const Iterator &b) const
|
||||
bool operator==(const Iterator& b) const
|
||||
{
|
||||
return record.offset == b.record.offset;
|
||||
}
|
||||
bool operator!=(const Iterator &b) const
|
||||
bool operator!=(const Iterator& b) const
|
||||
{
|
||||
return record.offset != b.record.offset;
|
||||
}
|
||||
@@ -117,8 +119,8 @@ private:
|
||||
size_t recordCount;
|
||||
size_t fieldCount;
|
||||
size_t stringSize;
|
||||
unsigned char *data;
|
||||
unsigned char *stringTable;
|
||||
unsigned char* data;
|
||||
unsigned char* stringTable;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
class MPQFile;
|
||||
|
||||
u_map_fcc MverMagic = { {'R','E','V','M'} };
|
||||
u_map_fcc MverMagic = { {'R', 'E', 'V', 'M'} };
|
||||
|
||||
FileLoader::FileLoader()
|
||||
{
|
||||
@@ -54,7 +54,7 @@ bool FileLoader::loadFile(std::string const& fileName, bool log)
|
||||
bool FileLoader::prepareLoadedData()
|
||||
{
|
||||
// Check version
|
||||
version = (file_MVER *) data;
|
||||
version = (file_MVER*) data;
|
||||
if (version->fcc != MverMagic.fcc)
|
||||
return false;
|
||||
if (version->ver != FILE_FORMAT_VERSION)
|
||||
|
||||
@@ -48,7 +48,8 @@ union u_map_fcc
|
||||
//
|
||||
struct file_MVER
|
||||
{
|
||||
union{
|
||||
union
|
||||
{
|
||||
uint32 fcc;
|
||||
char fcc_txt[4];
|
||||
};
|
||||
@@ -56,15 +57,16 @@ struct file_MVER
|
||||
uint32 ver;
|
||||
};
|
||||
|
||||
class FileLoader{
|
||||
uint8 *data;
|
||||
class FileLoader
|
||||
{
|
||||
uint8* data;
|
||||
uint32 data_size;
|
||||
public:
|
||||
virtual bool prepareLoadedData();
|
||||
uint8 *GetData() {return data;}
|
||||
uint8* GetData() {return data;}
|
||||
uint32 GetDataSize() {return data_size;}
|
||||
|
||||
file_MVER *version;
|
||||
file_MVER* version;
|
||||
FileLoader();
|
||||
~FileLoader();
|
||||
bool loadFile(std::string const& filename, bool log = true);
|
||||
|
||||
@@ -14,8 +14,10 @@ MPQArchive::MPQArchive(const char* filename)
|
||||
{
|
||||
int result = libmpq__archive_open(&mpq_a, filename, -1);
|
||||
printf("Opening %s\n", filename);
|
||||
if(result) {
|
||||
switch(result) {
|
||||
if(result)
|
||||
{
|
||||
switch(result)
|
||||
{
|
||||
case LIBMPQ_ERROR_OPEN :
|
||||
printf("Error opening archive '%s': Does file really exist?\n", filename);
|
||||
break;
|
||||
@@ -52,9 +54,9 @@ MPQFile::MPQFile(const char* filename):
|
||||
pointer(0),
|
||||
size(0)
|
||||
{
|
||||
for(ArchiveSet::iterator i=gOpenArchives.begin(); i!=gOpenArchives.end();++i)
|
||||
for(ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end(); ++i)
|
||||
{
|
||||
mpq_archive *mpq_a = (*i)->mpq_a;
|
||||
mpq_archive* mpq_a = (*i)->mpq_a;
|
||||
|
||||
uint32_t filenum;
|
||||
if(libmpq__file_number(mpq_a, filename, &filenum)) continue;
|
||||
@@ -62,8 +64,9 @@ MPQFile::MPQFile(const char* filename):
|
||||
libmpq__file_unpacked_size(mpq_a, filenum, &size);
|
||||
|
||||
// HACK: in patch.mpq some files don't want to open and give 1 for filesize
|
||||
if (size<=1) {
|
||||
// printf("warning: file %s has size %d; cannot read.\n", filename, size);
|
||||
if (size <= 1)
|
||||
{
|
||||
// printf("warning: file %s has size %d; cannot read.\n", filename, size);
|
||||
eof = true;
|
||||
buffer = 0;
|
||||
return;
|
||||
@@ -85,7 +88,8 @@ size_t MPQFile::read(void* dest, size_t bytes)
|
||||
if (eof) return 0;
|
||||
|
||||
size_t rpos = pointer + bytes;
|
||||
if (rpos > size_t(size)) {
|
||||
if (rpos > size_t(size))
|
||||
{
|
||||
bytes = size - pointer;
|
||||
eof = true;
|
||||
}
|
||||
|
||||
@@ -21,29 +21,31 @@ class MPQArchive
|
||||
{
|
||||
|
||||
public:
|
||||
mpq_archive_s *mpq_a;
|
||||
mpq_archive_s* mpq_a;
|
||||
|
||||
MPQArchive(const char* filename);
|
||||
~MPQArchive() { close(); }
|
||||
void close();
|
||||
|
||||
void GetFileListTo(vector<string>& filelist) {
|
||||
void GetFileListTo(vector<string>& filelist)
|
||||
{
|
||||
uint32_t filenum;
|
||||
if(libmpq__file_number(mpq_a, "(listfile)", &filenum)) return;
|
||||
libmpq__off_t size, transferred;
|
||||
libmpq__file_unpacked_size(mpq_a, filenum, &size);
|
||||
|
||||
char *buffer = new char[size+1];
|
||||
char* buffer = new char[size + 1];
|
||||
buffer[size] = '\0';
|
||||
|
||||
libmpq__file_read(mpq_a, filenum, (unsigned char*)buffer, size, &transferred);
|
||||
|
||||
char seps[] = "\n";
|
||||
char *token;
|
||||
char* token;
|
||||
|
||||
token = strtok( buffer, seps );
|
||||
uint32 counter = 0;
|
||||
while ((token != nullptr) && (counter < size)) {
|
||||
while ((token != nullptr) && (counter < size))
|
||||
{
|
||||
//cout << token << endl;
|
||||
token[strlen(token) - 1] = 0;
|
||||
string s = token;
|
||||
@@ -61,8 +63,8 @@ class MPQFile
|
||||
{
|
||||
//MPQHANDLE handle;
|
||||
bool eof;
|
||||
char *buffer;
|
||||
libmpq__off_t pointer,size;
|
||||
char* buffer;
|
||||
libmpq__off_t pointer, size;
|
||||
|
||||
// disable copying
|
||||
MPQFile(const MPQFile& /*f*/) {}
|
||||
@@ -82,15 +84,15 @@ public:
|
||||
void close();
|
||||
};
|
||||
|
||||
inline void flipcc(char *fcc)
|
||||
inline void flipcc(char* fcc)
|
||||
{
|
||||
char t;
|
||||
t=fcc[0];
|
||||
fcc[0]=fcc[3];
|
||||
fcc[3]=t;
|
||||
t=fcc[1];
|
||||
fcc[1]=fcc[2];
|
||||
fcc[2]=t;
|
||||
t = fcc[0];
|
||||
fcc[0] = fcc[3];
|
||||
fcc[3] = t;
|
||||
t = fcc[1];
|
||||
fcc[1] = fcc[2];
|
||||
fcc[2] = t;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -59,13 +59,13 @@ bool WDT_file::prepareLoadedData()
|
||||
if (!FileLoader::prepareLoadedData())
|
||||
return false;
|
||||
|
||||
mphd = (wdt_MPHD *)((uint8*)version+version->size+8);
|
||||
mphd = (wdt_MPHD*)((uint8*)version + version->size + 8);
|
||||
if (!mphd->prepareLoadedData())
|
||||
return false;
|
||||
main = (wdt_MAIN *)((uint8*)mphd + mphd->size+8);
|
||||
main = (wdt_MAIN*)((uint8*)mphd + mphd->size + 8);
|
||||
if (!main->prepareLoadedData())
|
||||
return false;
|
||||
wmo = (wdt_MWMO *)((uint8*)main+ main->size+8);
|
||||
wmo = (wdt_MWMO*)((uint8*)main + main->size + 8);
|
||||
if (!wmo->prepareLoadedData())
|
||||
return false;
|
||||
return true;
|
||||
|
||||
@@ -13,8 +13,10 @@
|
||||
//**************************************************************************************
|
||||
#define WDT_MAP_SIZE 64
|
||||
|
||||
class wdt_MWMO{
|
||||
union{
|
||||
class wdt_MWMO
|
||||
{
|
||||
union
|
||||
{
|
||||
uint32 fcc;
|
||||
char fcc_txt[4];
|
||||
};
|
||||
@@ -23,8 +25,10 @@ public:
|
||||
bool prepareLoadedData();
|
||||
};
|
||||
|
||||
class wdt_MPHD{
|
||||
union{
|
||||
class wdt_MPHD
|
||||
{
|
||||
union
|
||||
{
|
||||
uint32 fcc;
|
||||
char fcc_txt[4];
|
||||
};
|
||||
@@ -42,15 +46,18 @@ public:
|
||||
bool prepareLoadedData();
|
||||
};
|
||||
|
||||
class wdt_MAIN{
|
||||
union{
|
||||
class wdt_MAIN
|
||||
{
|
||||
union
|
||||
{
|
||||
uint32 fcc;
|
||||
char fcc_txt[4];
|
||||
};
|
||||
public:
|
||||
uint32 size;
|
||||
|
||||
struct adtData{
|
||||
struct adtData
|
||||
{
|
||||
uint32 exist;
|
||||
uint32 data1;
|
||||
} adt_list[64][64];
|
||||
@@ -58,7 +65,8 @@ public:
|
||||
bool prepareLoadedData();
|
||||
};
|
||||
|
||||
class WDT_file : public FileLoader{
|
||||
class WDT_file : public FileLoader
|
||||
{
|
||||
public:
|
||||
bool prepareLoadedData();
|
||||
|
||||
@@ -66,9 +74,9 @@ public:
|
||||
~WDT_file();
|
||||
void free();
|
||||
|
||||
wdt_MPHD *mphd;
|
||||
wdt_MAIN *main;
|
||||
wdt_MWMO *wmo;
|
||||
wdt_MPHD* mphd;
|
||||
wdt_MAIN* main;
|
||||
wdt_MWMO* wmo;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <string>
|
||||
|
||||
ChunkedData::ChunkedData( FILE* stream, uint32 maxLength, uint32 chunksHint /*= 300*/ ) :
|
||||
Stream(stream)
|
||||
Stream(stream)
|
||||
{
|
||||
if (!Stream)
|
||||
return;
|
||||
|
||||
@@ -14,7 +14,7 @@ class ChunkedData
|
||||
{
|
||||
public:
|
||||
ChunkedData(FILE* stream, uint32 maxLength, uint32 chunksHint = 300);
|
||||
ChunkedData(const std::string &file, uint32 chunksHint = 300);
|
||||
ChunkedData(const std::string& file, uint32 chunksHint = 300);
|
||||
~ChunkedData();
|
||||
|
||||
int GetFirstIndex(const std::string& name);
|
||||
|
||||
@@ -23,13 +23,13 @@ private:
|
||||
ContinentBuilder* cBuilder;
|
||||
public:
|
||||
BuilderThread(ContinentBuilder* _cBuilder, dtNavMeshParams& params) : Params(params), cBuilder(_cBuilder), Free(true) {}
|
||||
|
||||
void SetData(int x, int y, int map, const std::string& cont)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
MapId = map;
|
||||
Continent = cont;
|
||||
|
||||
void SetData(int x, int y, int map, const std::string& cont)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
MapId = map;
|
||||
Continent = cont;
|
||||
}
|
||||
|
||||
int svc()
|
||||
@@ -116,13 +116,13 @@ void ContinentBuilder::Build()
|
||||
CalculateTileBounds();
|
||||
|
||||
dtNavMeshParams params;
|
||||
|
||||
|
||||
std::vector<BuilderThread*> Threads;
|
||||
|
||||
if (TileMap->IsGlobalModel)
|
||||
{
|
||||
printf("Map %s ( %u ) is a WMO. Building with 1 thread.\n", Continent.c_str(), MapId);
|
||||
|
||||
|
||||
TileBuilder* builder = new TileBuilder(this, Continent, 0, 0, MapId);
|
||||
builder->AddGeometry(TileMap->Model, TileMap->ModelDefinition);
|
||||
uint8* nav = builder->BuildInstance(params);
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
ContinentBuilder(std::string continent, uint32 mapId, WDT* wdt, uint32 tn) :
|
||||
Continent(continent), TileMap(wdt), MapId(mapId),
|
||||
NumberOfThreads(tn), tileXMin(64), tileYMin(64), tileXMax(0), tileYMax(0)
|
||||
{}
|
||||
{}
|
||||
|
||||
void Build();
|
||||
void getTileBounds(uint32 tileX, uint32 tileY, float* verts, int vertCount, float* bmin, float* bmax);
|
||||
|
||||
@@ -58,7 +58,7 @@ std::string DBC::GetStringByOffset( int offset )
|
||||
break;
|
||||
}
|
||||
}
|
||||
char* d = new char[len+1];
|
||||
char* d = new char[len + 1];
|
||||
strcpy(d, (const char*)(StringBlock + offset));
|
||||
d[len] = '\0';
|
||||
std::string val = std::string(d);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "Model.h"
|
||||
#include "G3D/Matrix4.h"
|
||||
|
||||
DoodadHandler::DoodadHandler( ADT* adt ) :
|
||||
DoodadHandler::DoodadHandler( ADT* adt ) :
|
||||
ObjectDataHandler(adt), _definitions(nullptr), _paths(nullptr)
|
||||
{
|
||||
Chunk* mddf = adt->ObjectData->GetChunkByName("MDDF");
|
||||
@@ -27,7 +27,7 @@ void DoodadHandler::ProcessInternal( MapChunk* mcnk )
|
||||
{
|
||||
if (!IsSane())
|
||||
return;
|
||||
|
||||
|
||||
uint32 refCount = mcnk->Header.DoodadRefs;
|
||||
FILE* stream = mcnk->Source->GetStream();
|
||||
fseek(stream, mcnk->Source->Offset + mcnk->Header.OffsetMCRF, SEEK_SET);
|
||||
@@ -100,7 +100,7 @@ void DoodadHandler::ReadDoodadPaths( Chunk* id, Chunk* data )
|
||||
void DoodadHandler::InsertModelGeometry(const DoodadDefinition& def, Model* model)
|
||||
{
|
||||
uint32 vertOffset = Vertices.size();
|
||||
|
||||
|
||||
for (std::vector<Vector3>::iterator itr = model->Vertices.begin(); itr != model->Vertices.end(); ++itr)
|
||||
Vertices.push_back(Utils::TransformDoodadVertex(def, *itr)); // Vertices have to be converted based on the information from the DoodadDefinition struct
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ void LiquidHandler::HandleNewLiquid()
|
||||
Vertices.push_back(Vector3(location.x, location.y - Constants::UnitSize, location.z));
|
||||
Vertices.push_back(Vector3(location.x - Constants::UnitSize, location.y - Constants::UnitSize, location.z));
|
||||
|
||||
Triangles.push_back(Triangle<uint32>(Constants::TRIANGLE_TYPE_WATER, vertOffset, vertOffset+2, vertOffset + 1));
|
||||
Triangles.push_back(Triangle<uint32>(Constants::TRIANGLE_TYPE_WATER, vertOffset, vertOffset + 2, vertOffset + 1));
|
||||
Triangles.push_back(Triangle<uint32>(Constants::TRIANGLE_TYPE_WATER, vertOffset + 2, vertOffset + 3, vertOffset + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,9 +46,9 @@ void MPQArchive::close()
|
||||
}
|
||||
|
||||
MPQFile::MPQFile(const char* filename):
|
||||
eof(false), buffer(0), pointer(0), size(0)
|
||||
eof(false), buffer(0), pointer(0), size(0)
|
||||
{
|
||||
for (std::deque<MPQArchive*>::iterator i = MPQHandler->Archives.begin(); i != MPQHandler->Archives.end();++i)
|
||||
for (std::deque<MPQArchive*>::iterator i = MPQHandler->Archives.begin(); i != MPQHandler->Archives.end(); ++i)
|
||||
{
|
||||
mpq_archive* mpq_a = (*i)->mpq_a;
|
||||
|
||||
@@ -59,7 +59,8 @@ eof(false), buffer(0), pointer(0), size(0)
|
||||
libmpq__file_unpacked_size(mpq_a, filenum, &size);
|
||||
|
||||
// HACK: in patch.mpq some files don't want to open and give 1 for filesize
|
||||
if (size<=1) {
|
||||
if (size <= 1)
|
||||
{
|
||||
// printf("warning: file %s has size %d; cannot Read.\n", filename, size);
|
||||
eof = true;
|
||||
buffer = 0;
|
||||
@@ -83,7 +84,8 @@ size_t MPQFile::Read(void* dest, size_t bytes)
|
||||
return 0;
|
||||
|
||||
size_t rpos = pointer + bytes;
|
||||
if (rpos > size_t(size)) {
|
||||
if (rpos > size_t(size))
|
||||
{
|
||||
bytes = size - pointer;
|
||||
eof = true;
|
||||
}
|
||||
|
||||
@@ -18,52 +18,52 @@
|
||||
|
||||
class MPQArchive
|
||||
{
|
||||
|
||||
public:
|
||||
mpq_archive_s *mpq_a;
|
||||
|
||||
std::vector<std::string> Files;
|
||||
|
||||
MPQArchive(const char* filename);
|
||||
void close();
|
||||
|
||||
void GetFileListTo(std::vector<std::string>& filelist)
|
||||
|
||||
public:
|
||||
mpq_archive_s* mpq_a;
|
||||
|
||||
std::vector<std::string> Files;
|
||||
|
||||
MPQArchive(const char* filename);
|
||||
void close();
|
||||
|
||||
void GetFileListTo(std::vector<std::string>& filelist)
|
||||
{
|
||||
uint32_t filenum;
|
||||
if(libmpq__file_number(mpq_a, "(listfile)", &filenum)) return;
|
||||
libmpq__off_t size, transferred;
|
||||
libmpq__file_unpacked_size(mpq_a, filenum, &size);
|
||||
|
||||
char* buffer = new char[size + 1];
|
||||
buffer[size] = '\0';
|
||||
|
||||
libmpq__file_read(mpq_a, filenum, (unsigned char*)buffer, size, &transferred);
|
||||
|
||||
char seps[] = "\n";
|
||||
char* token;
|
||||
|
||||
token = strtok( buffer, seps );
|
||||
uint32 counter = 0;
|
||||
while ((token != nullptr) && (counter < size))
|
||||
{
|
||||
uint32_t filenum;
|
||||
if(libmpq__file_number(mpq_a, "(listfile)", &filenum)) return;
|
||||
libmpq__off_t size, transferred;
|
||||
libmpq__file_unpacked_size(mpq_a, filenum, &size);
|
||||
|
||||
char* buffer = new char[size + 1];
|
||||
buffer[size] = '\0';
|
||||
|
||||
libmpq__file_read(mpq_a, filenum, (unsigned char*)buffer, size, &transferred);
|
||||
|
||||
char seps[] = "\n";
|
||||
char* token;
|
||||
|
||||
token = strtok( buffer, seps );
|
||||
uint32 counter = 0;
|
||||
while ((token != nullptr) && (counter < size))
|
||||
{
|
||||
//cout << token << endl;
|
||||
token[strlen(token) - 1] = 0;
|
||||
std::string s = token;
|
||||
filelist.push_back(s);
|
||||
counter += strlen(token) + 2;
|
||||
token = strtok(nullptr, seps);
|
||||
}
|
||||
|
||||
delete[] buffer;
|
||||
//cout << token << endl;
|
||||
token[strlen(token) - 1] = 0;
|
||||
std::string s = token;
|
||||
filelist.push_back(s);
|
||||
counter += strlen(token) + 2;
|
||||
token = strtok(nullptr, seps);
|
||||
}
|
||||
|
||||
delete[] buffer;
|
||||
}
|
||||
};
|
||||
|
||||
class MPQFile
|
||||
{
|
||||
//MPQHANDLE handle;
|
||||
bool eof;
|
||||
char *buffer;
|
||||
libmpq__off_t pointer,size;
|
||||
char* buffer;
|
||||
libmpq__off_t pointer, size;
|
||||
|
||||
// disable copying
|
||||
MPQFile(const MPQFile& /*f*/) {}
|
||||
@@ -84,15 +84,15 @@ public:
|
||||
void close();
|
||||
};
|
||||
|
||||
inline void flipcc(char *fcc)
|
||||
inline void flipcc(char* fcc)
|
||||
{
|
||||
char t;
|
||||
t=fcc[0];
|
||||
fcc[0]=fcc[3];
|
||||
fcc[3]=t;
|
||||
t=fcc[1];
|
||||
fcc[1]=fcc[2];
|
||||
fcc[2]=t;
|
||||
t = fcc[0];
|
||||
fcc[0] = fcc[3];
|
||||
fcc[3] = t;
|
||||
t = fcc[1];
|
||||
fcc[1] = fcc[2];
|
||||
fcc[2] = t;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
#include "DBC.h"
|
||||
#include "Utils.h"
|
||||
|
||||
char const* MPQManager::Files[] = {
|
||||
char const* MPQManager::Files[] =
|
||||
{
|
||||
"common.MPQ",
|
||||
"common-2.MPQ",
|
||||
"expansion.MPQ",
|
||||
|
||||
@@ -38,9 +38,9 @@ void MapChunk::GenerateTriangles()
|
||||
{
|
||||
MCNKLiquidData& data = Adt->_LiquidHandler->MCNKData[Index];
|
||||
float maxHeight = std::max(
|
||||
std::max(
|
||||
std::max(std::max(Vertices[topLeft].z, Vertices[topRight].z), Vertices[bottomLeft].z),
|
||||
Vertices[bottomRight].z), Vertices[center].z);
|
||||
std::max(
|
||||
std::max(std::max(Vertices[topLeft].z, Vertices[topRight].z), Vertices[bottomLeft].z),
|
||||
Vertices[bottomRight].z), Vertices[center].z);
|
||||
if (data.IsWater(x, y, maxHeight))
|
||||
triangleType = Constants::TRIANGLE_TYPE_WATER;
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ void ExtractGameobjectModels()
|
||||
fwrite(&numVerts, sizeof(uint32), 1, output);
|
||||
uint32 numGroups = 1;
|
||||
fwrite(&numGroups, sizeof(uint32), 1, output);
|
||||
fwrite(Nop, 4 * 3 , 1, output); // rootwmoid, flags, groupid
|
||||
fwrite(Nop, 4 * 3, 1, output); // rootwmoid, flags, groupid
|
||||
fwrite(Nop, sizeof(float), 3 * 2, output);//bbox, only needed for WMO currently
|
||||
fwrite(Nop, 4, 1, output);// liquidflags
|
||||
fwrite("GRP ", 4, 1, output);
|
||||
@@ -171,7 +171,7 @@ void ExtractGameobjectModels()
|
||||
wsize = sizeof(int) + sizeof(float) * 3 * numVerts;
|
||||
fwrite(&wsize, sizeof(int), 1, output);
|
||||
fwrite(&numVerts, sizeof(int), 1, output);
|
||||
float* vertices = new float[numVerts*3];
|
||||
float* vertices = new float[numVerts * 3];
|
||||
|
||||
if (numVerts > 0)
|
||||
{
|
||||
@@ -213,7 +213,7 @@ void ExtractGameobjectModels()
|
||||
fwrite(&model.Header.CountGroups, sizeof(uint32), 1, output);
|
||||
fwrite(&model.Header.WmoId, sizeof(uint32), 1, output);
|
||||
|
||||
const char grp[] = { 'G' , 'R' , 'P', ' ' };
|
||||
const char grp[] = { 'G', 'R', 'P', ' ' };
|
||||
for (std::vector<WorldModelGroup>::iterator itr2 = model.Groups.begin(); itr2 != model.Groups.end(); ++itr2)
|
||||
{
|
||||
const WMOGroupHeader& header = itr2->Header;
|
||||
@@ -227,7 +227,7 @@ void ExtractGameobjectModels()
|
||||
fwrite(grp, sizeof(char), sizeof(grp), output);
|
||||
uint32 k = 0;
|
||||
uint32 mobaBatch = itr2->MOBALength / 12;
|
||||
uint32* MobaEx = new uint32[mobaBatch*4];
|
||||
uint32* MobaEx = new uint32[mobaBatch * 4];
|
||||
|
||||
for(uint32 i = 8; i < itr2->MOBALength; i += 12)
|
||||
MobaEx[k++] = itr2->MOBA[i];
|
||||
@@ -279,7 +279,7 @@ bool HandleArgs(int argc, char** argv, uint32& threads, std::set<uint32>& mapLis
|
||||
mapList.insert(atoi(token));
|
||||
token = strtok(nullptr, ",");
|
||||
}
|
||||
|
||||
|
||||
free(copy);
|
||||
|
||||
printf("Extracting only provided list of maps (%u).\n", uint32(mapList.size()));
|
||||
@@ -437,7 +437,7 @@ int main(int argc, char* argv[])
|
||||
LoadTile(navMesh, buff);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
navMeshQuery->init(navMesh, 2048);
|
||||
|
||||
float nearestPt[3];
|
||||
@@ -454,9 +454,9 @@ int main(int argc, char* argv[])
|
||||
int hops;
|
||||
dtPolyRef* hopBuffer = new dtPolyRef[8192];
|
||||
dtStatus status = navMeshQuery->findPath(m_startRef, m_endRef, m_spos, m_epos, &m_filter, hopBuffer, &hops, 8192);
|
||||
|
||||
|
||||
int resultHopCount;
|
||||
float* straightPath = new float[2048*3];
|
||||
float* straightPath = new float[2048 * 3];
|
||||
unsigned char* pathFlags = new unsigned char[2048];
|
||||
dtPolyRef* pathRefs = new dtPolyRef[2048];
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ Model::Model( std::string path ) : IsCollidable(false), IsBad(false)
|
||||
}
|
||||
Header.Read(Stream);
|
||||
if (Header.OffsetBoundingNormals > 0 && Header.OffsetBoundingVertices > 0 &&
|
||||
Header.OffsetBoundingTriangles > 0 && Header.BoundingRadius > 0.0f)
|
||||
Header.OffsetBoundingTriangles > 0 && Header.BoundingRadius > 0.0f)
|
||||
{
|
||||
IsCollidable = true;
|
||||
ReadVertices();
|
||||
|
||||
@@ -244,7 +244,7 @@ uint8* TileBuilder::BuildTiled(dtNavMeshParams& navMeshParams)
|
||||
}
|
||||
|
||||
OutputDebugVertices();
|
||||
|
||||
|
||||
uint32 numVerts = _Geometry->Vertices.size();
|
||||
uint32 numTris = _Geometry->Triangles.size();
|
||||
float* vertices;
|
||||
|
||||
@@ -12,13 +12,13 @@
|
||||
#include "G3D/Quat.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "direct.h"
|
||||
#include "direct.h"
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
const float Constants::TileSize = 533.0f + (1/3.0f);
|
||||
const float Constants::TileSize = 533.0f + (1 / 3.0f);
|
||||
const float Constants::MaxXY = 32.0f * Constants::TileSize;
|
||||
const float Constants::ChunkSize = Constants::TileSize / 16.0f;
|
||||
const float Constants::UnitSize = Constants::ChunkSize / 8.0f;
|
||||
@@ -45,11 +45,11 @@ void Utils::CreateDir( const std::string& Path )
|
||||
void Utils::Reverse(char word[])
|
||||
{
|
||||
int len = strlen(word);
|
||||
for (int i = 0;i < len / 2; i++)
|
||||
for (int i = 0; i < len / 2; i++)
|
||||
{
|
||||
word[i] ^= word[len-i-1];
|
||||
word[len-i-1] ^= word[i];
|
||||
word[i] ^= word[len-i-1];
|
||||
word[i] ^= word[len - i - 1];
|
||||
word[len - i - 1] ^= word[i];
|
||||
word[i] ^= word[len - i - 1];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ Vector3 Utils::GetLiquidVert(const IDefinition& def, Vector3 basePosition, float
|
||||
|
||||
float Utils::Distance( float x, float y )
|
||||
{
|
||||
return sqrt(x*x + y*y);
|
||||
return sqrt(x * x + y * y);
|
||||
}
|
||||
|
||||
std::string Utils::Replace( std::string str, const std::string& oldStr, const std::string& newStr )
|
||||
@@ -194,7 +194,7 @@ void Utils::SaveToDisk( FILE* stream, const std::string& path )
|
||||
fclose(stream);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// And write it in the file
|
||||
size_t wrote = fwrite(data, size, 1, disk);
|
||||
if (wrote != 1)
|
||||
@@ -224,7 +224,7 @@ std::string Utils::GetExtension( std::string path )
|
||||
std::string extension = "";
|
||||
|
||||
if(idx != std::string::npos)
|
||||
extension = path.substr(idx+1);
|
||||
extension = path.substr(idx + 1);
|
||||
return extension;
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ void MapChunkHeader::Read(FILE* stream)
|
||||
count += fread(&OffsetMCCV, sizeof(uint32), 1, stream);
|
||||
|
||||
if (count != 27)
|
||||
printf("MapChunkHeader::Read: Failed to read some data expected 27, read %d\n", count);
|
||||
printf("MapChunkHeader::Read: Failed to read some data expected 27, read %d\n", count);
|
||||
}
|
||||
|
||||
void MHDR::Read(FILE* stream)
|
||||
@@ -281,7 +281,7 @@ void MHDR::Read(FILE* stream)
|
||||
count += fread(&OffsetMTFX, sizeof(uint32), 1, stream);
|
||||
|
||||
if (count != 12)
|
||||
printf("MHDR::Read: Failed to read some data expected 12, read %d\n", count);
|
||||
printf("MHDR::Read: Failed to read some data expected 12, read %d\n", count);
|
||||
}
|
||||
|
||||
void ModelHeader::Read(FILE* stream)
|
||||
@@ -343,7 +343,7 @@ void ModelHeader::Read(FILE* stream)
|
||||
count += fread(&OffsetBoundingNormals, sizeof(uint32), 1, stream);
|
||||
|
||||
if (count != 51)
|
||||
printf("ModelHeader::Read: Failed to read some data expected 51, read %d\n", count);
|
||||
printf("ModelHeader::Read: Failed to read some data expected 51, read %d\n", count);
|
||||
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ WorldModelHeader WorldModelHeader::Read(FILE* stream)
|
||||
count += fread(&ret.LiquidTypeRelated, sizeof(uint32), 1, stream);
|
||||
|
||||
if (count != 10)
|
||||
printf("WorldModelHeader::Read: Failed to read some data expected 10, read %d\n", count);
|
||||
printf("WorldModelHeader::Read: Failed to read some data expected 10, read %d\n", count);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -386,7 +386,7 @@ DoodadInstance DoodadInstance::Read(FILE* stream)
|
||||
count += fread(&ret.LightColor, sizeof(uint32), 1, stream);
|
||||
|
||||
if (count != 7)
|
||||
printf("DoodadInstance::Read: Failed to read some data expected 7, read %d\n", count);
|
||||
printf("DoodadInstance::Read: Failed to read some data expected 7, read %d\n", count);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -405,7 +405,7 @@ DoodadSet DoodadSet::Read(FILE* stream)
|
||||
count += fread(&ret.UnknownZero, sizeof(uint32), 1, stream);
|
||||
|
||||
if (count != 23)
|
||||
printf("DoodadSet::Read: Failed to read some data expected 23, read %d\n", count);
|
||||
printf("DoodadSet::Read: Failed to read some data expected 23, read %d\n", count);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -422,7 +422,7 @@ LiquidHeader LiquidHeader::Read(FILE* stream)
|
||||
count += fread(&ret.MaterialId, sizeof(uint16), 1, stream);
|
||||
|
||||
if (count != 5)
|
||||
printf("LiquidHeader::Read: Failed to read some data expected 5, read %d\n", count);
|
||||
printf("LiquidHeader::Read: Failed to read some data expected 5, read %d\n", count);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -445,7 +445,7 @@ LiquidData LiquidData::Read(FILE* stream, LiquidHeader& header)
|
||||
uint32 discard;
|
||||
float tmp;
|
||||
if (fread(&discard, sizeof(uint32), 1, stream) == 1 &&
|
||||
fread(&tmp, sizeof(float), 1, stream) == 1)
|
||||
fread(&tmp, sizeof(float), 1, stream) == 1)
|
||||
{
|
||||
ret.HeightMap[x][y] = tmp;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ WorldModelDefinition WorldModelDefinition::Read( FILE* file )
|
||||
count += fread(&discard, sizeof(uint32), 1, file);
|
||||
|
||||
if (count != 5)
|
||||
printf("WorldModelDefinition::Read: Error reading data, expected 5, read %d\n", count);
|
||||
printf("WorldModelDefinition::Read: Error reading data, expected 5, read %d\n", count);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ void WorldModelHandler::ProcessInternal( MapChunk* mcnk )
|
||||
{
|
||||
if (!IsSane())
|
||||
return;
|
||||
|
||||
|
||||
uint32 refCount = mcnk->Header.MapObjectRefs;
|
||||
FILE* stream = mcnk->Source->GetStream();
|
||||
fseek(stream, mcnk->Source->Offset + mcnk->Header.OffsetMCRF, SEEK_SET);
|
||||
@@ -159,13 +159,13 @@ void WorldModelHandler::InsertModelGeometry( std::vector<Vector3>& verts, std::v
|
||||
uint32 vertOffset = verts.size();
|
||||
|
||||
Vector3 v1 = Utils::GetLiquidVert(def, liquidHeader.BaseLocation,
|
||||
liquidDataGeometry.HeightMap[x][y], x, y, translate);
|
||||
liquidDataGeometry.HeightMap[x][y], x, y, translate);
|
||||
Vector3 v2 = Utils::GetLiquidVert(def, liquidHeader.BaseLocation,
|
||||
liquidDataGeometry.HeightMap[x + 1][y], x + 1, y, translate);
|
||||
liquidDataGeometry.HeightMap[x + 1][y], x + 1, y, translate);
|
||||
Vector3 v3 = Utils::GetLiquidVert(def, liquidHeader.BaseLocation,
|
||||
liquidDataGeometry.HeightMap[x][y + 1], x, y + 1, translate);
|
||||
liquidDataGeometry.HeightMap[x][y + 1], x, y + 1, translate);
|
||||
Vector3 v4 = Utils::GetLiquidVert(def, liquidHeader.BaseLocation,
|
||||
liquidDataGeometry.HeightMap[x + 1][y + 1], x + 1, y + 1, translate);
|
||||
liquidDataGeometry.HeightMap[x + 1][y + 1], x + 1, y + 1, translate);
|
||||
|
||||
verts.push_back(translate ? v1 : Utils::ToRecast(v1));
|
||||
verts.push_back(translate ? v2 : Utils::ToRecast(v2));
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace MMAP
|
||||
for (int y = 0; y < mesh->height; ++y)
|
||||
for (int x = 0; x < mesh->width; ++x)
|
||||
{
|
||||
rcSpan* span = mesh->spans[x+y*mesh->width];
|
||||
rcSpan* span = mesh->spans[x + y * mesh->width];
|
||||
|
||||
// first, count the number of spans
|
||||
int spanCount = 0;
|
||||
@@ -86,7 +86,7 @@ namespace MMAP
|
||||
fwrite(&spanCount, sizeof(int), 1, file);
|
||||
|
||||
// write the spans
|
||||
span = mesh->spans[x+y*mesh->width];
|
||||
span = mesh->spans[x + y * mesh->width];
|
||||
while (span)
|
||||
{
|
||||
fwrite(span, sizeof(rcSpan), 1, file);
|
||||
@@ -125,7 +125,7 @@ namespace MMAP
|
||||
fwrite(&tmp, sizeof(tmp), 1, file);
|
||||
|
||||
if (chf->cells)
|
||||
fwrite(chf->cells, sizeof(rcCompactCell), chf->width*chf->height, file);
|
||||
fwrite(chf->cells, sizeof(rcCompactCell), chf->width * chf->height, file);
|
||||
if (chf->spans)
|
||||
fwrite(chf->spans, sizeof(rcCompactSpan), chf->spanCount, file);
|
||||
if (chf->dist)
|
||||
@@ -149,9 +149,9 @@ namespace MMAP
|
||||
fwrite(&cs->conts[i].area, sizeof(unsigned char), 1, file);
|
||||
fwrite(&cs->conts[i].reg, sizeof(unsigned short), 1, file);
|
||||
fwrite(&cs->conts[i].nverts, sizeof(int), 1, file);
|
||||
fwrite(cs->conts[i].verts, sizeof(int), cs->conts[i].nverts*4, file);
|
||||
fwrite(cs->conts[i].verts, sizeof(int), cs->conts[i].nverts * 4, file);
|
||||
fwrite(&cs->conts[i].nrverts, sizeof(int), 1, file);
|
||||
fwrite(cs->conts[i].rverts, sizeof(int), cs->conts[i].nrverts*4, file);
|
||||
fwrite(cs->conts[i].rverts, sizeof(int), cs->conts[i].nrverts * 4, file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,9 +166,9 @@ namespace MMAP
|
||||
fwrite(mesh->bmin, sizeof(float), 3, file);
|
||||
fwrite(mesh->bmax, sizeof(float), 3, file);
|
||||
fwrite(&(mesh->nverts), sizeof(int), 1, file);
|
||||
fwrite(mesh->verts, sizeof(unsigned short), mesh->nverts*3, file);
|
||||
fwrite(mesh->verts, sizeof(unsigned short), mesh->nverts * 3, file);
|
||||
fwrite(&(mesh->npolys), sizeof(int), 1, file);
|
||||
fwrite(mesh->polys, sizeof(unsigned short), mesh->npolys*mesh->nvp*2, file);
|
||||
fwrite(mesh->polys, sizeof(unsigned short), mesh->npolys * mesh->nvp * 2, file);
|
||||
fwrite(mesh->flags, sizeof(unsigned short), mesh->npolys, file);
|
||||
fwrite(mesh->areas, sizeof(unsigned char), mesh->npolys, file);
|
||||
fwrite(mesh->regs, sizeof(unsigned short), mesh->npolys, file);
|
||||
@@ -180,14 +180,14 @@ namespace MMAP
|
||||
return;
|
||||
|
||||
fwrite(&(mesh->nverts), sizeof(int), 1, file);
|
||||
fwrite(mesh->verts, sizeof(float), mesh->nverts*3, file);
|
||||
fwrite(mesh->verts, sizeof(float), mesh->nverts * 3, file);
|
||||
fwrite(&(mesh->ntris), sizeof(int), 1, file);
|
||||
fwrite(mesh->tris, sizeof(char), mesh->ntris*4, file);
|
||||
fwrite(mesh->tris, sizeof(char), mesh->ntris * 4, file);
|
||||
fwrite(&(mesh->nmeshes), sizeof(int), 1, file);
|
||||
fwrite(mesh->meshes, sizeof(int), mesh->nmeshes*4, file);
|
||||
fwrite(mesh->meshes, sizeof(int), mesh->nmeshes * 4, file);
|
||||
}
|
||||
|
||||
void IntermediateValues::generateObjFile(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData)
|
||||
void IntermediateValues::generateObjFile(uint32 mapID, uint32 tileX, uint32 tileY, MeshData& meshData)
|
||||
{
|
||||
char objFileName[255];
|
||||
sprintf(objFileName, "meshes/map%03u%02u%02u.obj", mapID, tileY, tileX);
|
||||
@@ -215,10 +215,10 @@ namespace MMAP
|
||||
int triCount = allTris.size() / 3;
|
||||
|
||||
for (int i = 0; i < allVerts.size() / 3; i++)
|
||||
fprintf(objFile, "v %f %f %f\n", verts[i*3], verts[i*3 + 1], verts[i*3 + 2]);
|
||||
fprintf(objFile, "v %f %f %f\n", verts[i * 3], verts[i * 3 + 1], verts[i * 3 + 2]);
|
||||
|
||||
for (int i = 0; i < allTris.size() / 3; i++)
|
||||
fprintf(objFile, "f %i %i %i\n", tris[i*3] + 1, tris[i*3 + 1] + 1, tris[i*3 + 2] + 1);
|
||||
fprintf(objFile, "f %i %i %i\n", tris[i * 3] + 1, tris[i * 3 + 1] + 1, tris[i * 3 + 2] + 1);
|
||||
|
||||
fclose(objFile);
|
||||
|
||||
@@ -253,11 +253,11 @@ namespace MMAP
|
||||
}
|
||||
|
||||
fwrite(&vertCount, sizeof(int), 1, objFile);
|
||||
fwrite(verts, sizeof(float), vertCount*3, objFile);
|
||||
fwrite(verts, sizeof(float), vertCount * 3, objFile);
|
||||
fflush(objFile);
|
||||
|
||||
fwrite(&triCount, sizeof(int), 1, objFile);
|
||||
fwrite(tris, sizeof(int), triCount*3, objFile);
|
||||
fwrite(tris, sizeof(int), triCount * 3, objFile);
|
||||
fflush(objFile);
|
||||
|
||||
fclose(objFile);
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace MMAP
|
||||
rcPolyMeshDetail* polyMeshDetail;
|
||||
|
||||
IntermediateValues() : heightfield(nullptr), compactHeightfield(nullptr),
|
||||
contours(nullptr), polyMesh(nullptr), polyMeshDetail(nullptr) {}
|
||||
contours(nullptr), polyMesh(nullptr), polyMeshDetail(nullptr) {}
|
||||
~IntermediateValues();
|
||||
|
||||
void writeIV(uint32 mapID, uint32 tileX, uint32 tileY);
|
||||
@@ -35,7 +35,7 @@ namespace MMAP
|
||||
void debugWrite(FILE* file, const rcPolyMesh* mesh);
|
||||
void debugWrite(FILE* file, const rcPolyMeshDetail* mesh);
|
||||
|
||||
void generateObjFile(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData);
|
||||
void generateObjFile(uint32 mapID, uint32 tileX, uint32 tileY, MeshData& meshData);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -39,17 +39,17 @@ struct MmapTileHeader
|
||||
// All padding fields must be handled and initialized to ensure mmaps_generator will produce binary-identical *.mmtile files
|
||||
static_assert(sizeof(MmapTileHeader) == 20, "MmapTileHeader size is not correct, adjust the padding field size");
|
||||
static_assert(sizeof(MmapTileHeader) == (sizeof(MmapTileHeader::mmapMagic) +
|
||||
sizeof(MmapTileHeader::dtVersion) +
|
||||
sizeof(MmapTileHeader::mmapVersion) +
|
||||
sizeof(MmapTileHeader::size) +
|
||||
sizeof(MmapTileHeader::usesLiquids) +
|
||||
sizeof(MmapTileHeader::padding)), "MmapTileHeader has uninitialized padding fields");
|
||||
sizeof(MmapTileHeader::dtVersion) +
|
||||
sizeof(MmapTileHeader::mmapVersion) +
|
||||
sizeof(MmapTileHeader::size) +
|
||||
sizeof(MmapTileHeader::usesLiquids) +
|
||||
sizeof(MmapTileHeader::padding)), "MmapTileHeader has uninitialized padding fields");
|
||||
|
||||
namespace MMAP
|
||||
{
|
||||
MapBuilder::MapBuilder(float maxWalkableAngle, bool skipLiquid,
|
||||
bool skipContinents, bool skipJunkMaps, bool skipBattlegrounds,
|
||||
bool debugOutput, bool bigBaseUnit, const char* offMeshFilePath) :
|
||||
bool skipContinents, bool skipJunkMaps, bool skipBattlegrounds,
|
||||
bool debugOutput, bool bigBaseUnit, const char* offMeshFilePath) :
|
||||
m_terrainBuilder (nullptr),
|
||||
m_debugOutput (debugOutput),
|
||||
m_offMeshFilePath (offMeshFilePath),
|
||||
@@ -96,7 +96,7 @@ namespace MMAP
|
||||
getDirContents(files, "maps");
|
||||
for (uint32 i = 0; i < files.size(); ++i)
|
||||
{
|
||||
mapID = uint32(atoi(files[i].substr(0,3).c_str()));
|
||||
mapID = uint32(atoi(files[i].substr(0, 3).c_str()));
|
||||
if (std::find(m_tiles.begin(), m_tiles.end(), mapID) == m_tiles.end())
|
||||
{
|
||||
m_tiles.emplace_back(MapTiles(mapID, new std::set<uint32>));
|
||||
@@ -108,7 +108,7 @@ namespace MMAP
|
||||
getDirContents(files, "vmaps", "*.vmtree");
|
||||
for (uint32 i = 0; i < files.size(); ++i)
|
||||
{
|
||||
mapID = uint32(atoi(files[i].substr(0,3).c_str()));
|
||||
mapID = uint32(atoi(files[i].substr(0, 3).c_str()));
|
||||
if (std::find(m_tiles.begin(), m_tiles.end(), mapID) == m_tiles.end())
|
||||
{
|
||||
m_tiles.emplace_back(MapTiles(mapID, new std::set<uint32>));
|
||||
@@ -129,8 +129,8 @@ namespace MMAP
|
||||
getDirContents(files, "vmaps", filter);
|
||||
for (uint32 i = 0; i < files.size(); ++i)
|
||||
{
|
||||
tileX = uint32(atoi(files[i].substr(7,2).c_str()));
|
||||
tileY = uint32(atoi(files[i].substr(4,2).c_str()));
|
||||
tileX = uint32(atoi(files[i].substr(7, 2).c_str()));
|
||||
tileY = uint32(atoi(files[i].substr(4, 2).c_str()));
|
||||
tileID = StaticMapTree::packTileID(tileY, tileX);
|
||||
|
||||
tiles->insert(tileID);
|
||||
@@ -142,8 +142,8 @@ namespace MMAP
|
||||
getDirContents(files, "maps", filter);
|
||||
for (uint32 i = 0; i < files.size(); ++i)
|
||||
{
|
||||
tileY = uint32(atoi(files[i].substr(3,2).c_str()));
|
||||
tileX = uint32(atoi(files[i].substr(5,2).c_str()));
|
||||
tileY = uint32(atoi(files[i].substr(3, 2).c_str()));
|
||||
tileX = uint32(atoi(files[i].substr(5, 2).c_str()));
|
||||
tileID = StaticMapTree::packTileID(tileX, tileY);
|
||||
|
||||
if (tiles->insert(tileID).second)
|
||||
@@ -229,7 +229,7 @@ namespace MMAP
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void MapBuilder::getGridBounds(uint32 mapID, uint32 &minX, uint32 &minY, uint32 &maxX, uint32 &maxY) const
|
||||
void MapBuilder::getGridBounds(uint32 mapID, uint32& minX, uint32& minY, uint32& maxX, uint32& maxY) const
|
||||
{
|
||||
// min and max are initialized to invalid values so the caller iterating the [min, max] range
|
||||
// will never enter the loop unless valid min/max values are found
|
||||
@@ -481,7 +481,7 @@ namespace MMAP
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void MapBuilder::buildNavMesh(uint32 mapID, dtNavMesh* &navMesh)
|
||||
void MapBuilder::buildNavMesh(uint32 mapID, dtNavMesh*& navMesh)
|
||||
{
|
||||
std::set<uint32>* tiles = getTileList(mapID);
|
||||
|
||||
@@ -557,8 +557,8 @@ namespace MMAP
|
||||
|
||||
/**************************************************************************/
|
||||
void MapBuilder::buildMoveMapTile(uint32 mapID, uint32 tileX, uint32 tileY,
|
||||
MeshData &meshData, float bmin[3], float bmax[3],
|
||||
dtNavMesh* navMesh)
|
||||
MeshData& meshData, float bmin[3], float bmax[3],
|
||||
dtNavMesh* navMesh)
|
||||
{
|
||||
// console output
|
||||
char tileString[20];
|
||||
@@ -584,9 +584,9 @@ namespace MMAP
|
||||
const static float BASE_UNIT_DIM = m_bigBaseUnit ? 0.5333333f : 0.2666666f;
|
||||
|
||||
// All are in UNIT metrics!
|
||||
const static int VERTEX_PER_MAP = int(GRID_SIZE/BASE_UNIT_DIM + 0.5f);
|
||||
const static int VERTEX_PER_MAP = int(GRID_SIZE / BASE_UNIT_DIM + 0.5f);
|
||||
const static int VERTEX_PER_TILE = m_bigBaseUnit ? 40 : 80; // must divide VERTEX_PER_MAP
|
||||
const static int TILES_PER_MAP = VERTEX_PER_MAP/VERTEX_PER_TILE;
|
||||
const static int TILES_PER_MAP = VERTEX_PER_MAP / VERTEX_PER_TILE;
|
||||
|
||||
rcConfig config;
|
||||
memset(&config, 0, sizeof(rcConfig));
|
||||
@@ -620,8 +620,8 @@ namespace MMAP
|
||||
|
||||
// Initialize per tile config.
|
||||
rcConfig tileCfg = config;
|
||||
tileCfg.width = config.tileSize + config.borderSize*2;
|
||||
tileCfg.height = config.tileSize + config.borderSize*2;
|
||||
tileCfg.width = config.tileSize + config.borderSize * 2;
|
||||
tileCfg.height = config.tileSize + config.borderSize * 2;
|
||||
|
||||
// merge per tile poly and detail meshes
|
||||
rcPolyMesh** pmmerge = new rcPolyMesh*[TILES_PER_MAP * TILES_PER_MAP];
|
||||
@@ -635,10 +635,10 @@ namespace MMAP
|
||||
Tile& tile = tiles[x + y * TILES_PER_MAP];
|
||||
|
||||
// Calculate the per tile bounding box.
|
||||
tileCfg.bmin[0] = config.bmin[0] + float(x*config.tileSize - config.borderSize)*config.cs;
|
||||
tileCfg.bmin[2] = config.bmin[2] + float(y*config.tileSize - config.borderSize)*config.cs;
|
||||
tileCfg.bmax[0] = config.bmin[0] + float((x+1)*config.tileSize + config.borderSize)*config.cs;
|
||||
tileCfg.bmax[2] = config.bmin[2] + float((y+1)*config.tileSize + config.borderSize)*config.cs;
|
||||
tileCfg.bmin[0] = config.bmin[0] + float(x * config.tileSize - config.borderSize) * config.cs;
|
||||
tileCfg.bmin[2] = config.bmin[2] + float(y * config.tileSize - config.borderSize) * config.cs;
|
||||
tileCfg.bmax[0] = config.bmin[0] + float((x + 1) * config.tileSize + config.borderSize) * config.cs;
|
||||
tileCfg.bmax[2] = config.bmin[2] + float((y + 1) * config.tileSize + config.borderSize) * config.cs;
|
||||
|
||||
// build heightfield
|
||||
tile.solid = rcAllocHeightfield();
|
||||
@@ -650,7 +650,7 @@ namespace MMAP
|
||||
|
||||
// mark all walkable tiles, both liquids and solids
|
||||
unsigned char* triFlags = new unsigned char[tTriCount];
|
||||
memset(triFlags, NAV_GROUND, tTriCount*sizeof(unsigned char));
|
||||
memset(triFlags, NAV_GROUND, tTriCount * sizeof(unsigned char));
|
||||
rcClearUnwalkableTriangles(m_rcContext, tileCfg.walkableSlopeAngle, tVerts, tVertCount, tTris, tTriCount, triFlags);
|
||||
rcRasterizeTriangles(m_rcContext, tVerts, tVertCount, tTris, triFlags, tTriCount, *tile.solid, config.walkableClimb);
|
||||
delete[] triFlags;
|
||||
@@ -776,15 +776,15 @@ namespace MMAP
|
||||
params.detailTriCount = iv.polyMeshDetail->ntris;
|
||||
|
||||
params.offMeshConVerts = meshData.offMeshConnections.getCArray();
|
||||
params.offMeshConCount = meshData.offMeshConnections.size()/6;
|
||||
params.offMeshConCount = meshData.offMeshConnections.size() / 6;
|
||||
params.offMeshConRad = meshData.offMeshConnectionRads.getCArray();
|
||||
params.offMeshConDir = meshData.offMeshConnectionDirs.getCArray();
|
||||
params.offMeshConAreas = meshData.offMeshConnectionsAreas.getCArray();
|
||||
params.offMeshConFlags = meshData.offMeshConnectionsFlags.getCArray();
|
||||
|
||||
params.walkableHeight = BASE_UNIT_DIM*config.walkableHeight; // agent height
|
||||
params.walkableRadius = BASE_UNIT_DIM*config.walkableRadius; // agent radius
|
||||
params.walkableClimb = BASE_UNIT_DIM*config.walkableClimb; // keep less that walkableHeight (aka agent height)!
|
||||
params.walkableHeight = BASE_UNIT_DIM * config.walkableHeight; // agent height
|
||||
params.walkableRadius = BASE_UNIT_DIM * config.walkableRadius; // agent radius
|
||||
params.walkableClimb = BASE_UNIT_DIM * config.walkableClimb; // keep less that walkableHeight (aka agent height)!
|
||||
params.tileX = (((bmin[0] + bmax[0]) / 2) - navMesh->getParams()->orig[0]) / GRID_SIZE;
|
||||
params.tileY = (((bmin[2] + bmax[2]) / 2) - navMesh->getParams()->orig[2]) / GRID_SIZE;
|
||||
rcVcopy(params.bmin, bmin);
|
||||
@@ -822,7 +822,7 @@ namespace MMAP
|
||||
break;
|
||||
}
|
||||
if (!params.polyCount || !params.polys ||
|
||||
TILES_PER_MAP*TILES_PER_MAP == params.polyCount)
|
||||
TILES_PER_MAP * TILES_PER_MAP == params.polyCount)
|
||||
{
|
||||
// we have flat tiles with no actual geometry - don't build those, its useless
|
||||
// keep in mind that we do output those into debug info
|
||||
@@ -881,15 +881,14 @@ namespace MMAP
|
||||
|
||||
// now that tile is written to disk, we can unload it
|
||||
navMesh->removeTile(tileRef, nullptr, nullptr);
|
||||
}
|
||||
while (0);
|
||||
} while (0);
|
||||
|
||||
if (m_debugOutput)
|
||||
{
|
||||
// restore padding so that the debug visualization is correct
|
||||
for (int i = 0; i < iv.polyMesh->nverts; ++i)
|
||||
{
|
||||
unsigned short* v = &iv.polyMesh->verts[i*3];
|
||||
unsigned short* v = &iv.polyMesh->verts[i * 3];
|
||||
v[0] += (unsigned short)config.borderSize;
|
||||
v[2] += (unsigned short)config.borderSize;
|
||||
}
|
||||
@@ -1034,7 +1033,7 @@ namespace MMAP
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
uint32 MapBuilder::percentageDone(uint32 totalTiles, uint32 totalTilesBuilt)
|
||||
{
|
||||
|
||||
@@ -63,81 +63,81 @@ namespace MMAP
|
||||
|
||||
class MapBuilder
|
||||
{
|
||||
public:
|
||||
MapBuilder(float maxWalkableAngle = 70.f,
|
||||
bool skipLiquid = false,
|
||||
bool skipContinents = false,
|
||||
bool skipJunkMaps = true,
|
||||
bool skipBattlegrounds = false,
|
||||
bool debugOutput = false,
|
||||
bool bigBaseUnit = false,
|
||||
const char* offMeshFilePath = nullptr);
|
||||
public:
|
||||
MapBuilder(float maxWalkableAngle = 70.f,
|
||||
bool skipLiquid = false,
|
||||
bool skipContinents = false,
|
||||
bool skipJunkMaps = true,
|
||||
bool skipBattlegrounds = false,
|
||||
bool debugOutput = false,
|
||||
bool bigBaseUnit = false,
|
||||
const char* offMeshFilePath = nullptr);
|
||||
|
||||
~MapBuilder();
|
||||
~MapBuilder();
|
||||
|
||||
// builds all mmap tiles for the specified map id (ignores skip settings)
|
||||
void buildMap(uint32 mapID);
|
||||
void buildMeshFromFile(char* name);
|
||||
// builds all mmap tiles for the specified map id (ignores skip settings)
|
||||
void buildMap(uint32 mapID);
|
||||
void buildMeshFromFile(char* name);
|
||||
|
||||
// builds an mmap tile for the specified map and its mesh
|
||||
void buildSingleTile(uint32 mapID, uint32 tileX, uint32 tileY);
|
||||
// builds an mmap tile for the specified map and its mesh
|
||||
void buildSingleTile(uint32 mapID, uint32 tileX, uint32 tileY);
|
||||
|
||||
// builds list of maps, then builds all of mmap tiles (based on the skip settings)
|
||||
void buildAllMaps(unsigned int threads);
|
||||
// builds list of maps, then builds all of mmap tiles (based on the skip settings)
|
||||
void buildAllMaps(unsigned int threads);
|
||||
|
||||
void WorkerThread();
|
||||
void WorkerThread();
|
||||
|
||||
private:
|
||||
// detect maps and tiles
|
||||
void discoverTiles();
|
||||
std::set<uint32>* getTileList(uint32 mapID);
|
||||
private:
|
||||
// detect maps and tiles
|
||||
void discoverTiles();
|
||||
std::set<uint32>* getTileList(uint32 mapID);
|
||||
|
||||
void buildNavMesh(uint32 mapID, dtNavMesh* &navMesh);
|
||||
void buildNavMesh(uint32 mapID, dtNavMesh*& navMesh);
|
||||
|
||||
void buildTile(uint32 mapID, uint32 tileX, uint32 tileY, dtNavMesh* navMesh);
|
||||
void buildTile(uint32 mapID, uint32 tileX, uint32 tileY, dtNavMesh* navMesh);
|
||||
|
||||
// move map building
|
||||
void buildMoveMapTile(uint32 mapID,
|
||||
uint32 tileX,
|
||||
uint32 tileY,
|
||||
MeshData &meshData,
|
||||
float bmin[3],
|
||||
float bmax[3],
|
||||
dtNavMesh* navMesh);
|
||||
// move map building
|
||||
void buildMoveMapTile(uint32 mapID,
|
||||
uint32 tileX,
|
||||
uint32 tileY,
|
||||
MeshData& meshData,
|
||||
float bmin[3],
|
||||
float bmax[3],
|
||||
dtNavMesh* navMesh);
|
||||
|
||||
void getTileBounds(uint32 tileX, uint32 tileY,
|
||||
float* verts, int vertCount,
|
||||
float* bmin, float* bmax);
|
||||
void getGridBounds(uint32 mapID, uint32 &minX, uint32 &minY, uint32 &maxX, uint32 &maxY) const;
|
||||
void getTileBounds(uint32 tileX, uint32 tileY,
|
||||
float* verts, int vertCount,
|
||||
float* bmin, float* bmax);
|
||||
void getGridBounds(uint32 mapID, uint32& minX, uint32& minY, uint32& maxX, uint32& maxY) const;
|
||||
|
||||
bool shouldSkipMap(uint32 mapID);
|
||||
bool isTransportMap(uint32 mapID);
|
||||
bool shouldSkipTile(uint32 mapID, uint32 tileX, uint32 tileY);
|
||||
// percentageDone - method to calculate percentage
|
||||
uint32 percentageDone(uint32 totalTiles, uint32 totalTilesDone);
|
||||
bool shouldSkipMap(uint32 mapID);
|
||||
bool isTransportMap(uint32 mapID);
|
||||
bool shouldSkipTile(uint32 mapID, uint32 tileX, uint32 tileY);
|
||||
// percentageDone - method to calculate percentage
|
||||
uint32 percentageDone(uint32 totalTiles, uint32 totalTilesDone);
|
||||
|
||||
TerrainBuilder* m_terrainBuilder;
|
||||
TileList m_tiles;
|
||||
TerrainBuilder* m_terrainBuilder;
|
||||
TileList m_tiles;
|
||||
|
||||
bool m_debugOutput;
|
||||
bool m_debugOutput;
|
||||
|
||||
const char* m_offMeshFilePath;
|
||||
bool m_skipContinents;
|
||||
bool m_skipJunkMaps;
|
||||
bool m_skipBattlegrounds;
|
||||
const char* m_offMeshFilePath;
|
||||
bool m_skipContinents;
|
||||
bool m_skipJunkMaps;
|
||||
bool m_skipBattlegrounds;
|
||||
|
||||
float m_maxWalkableAngle;
|
||||
bool m_bigBaseUnit;
|
||||
// percentageDone - variables to calculate percentage
|
||||
std::atomic<uint32> m_totalTiles;
|
||||
std::atomic<uint32> m_totalTilesBuilt;
|
||||
float m_maxWalkableAngle;
|
||||
bool m_bigBaseUnit;
|
||||
// percentageDone - variables to calculate percentage
|
||||
std::atomic<uint32> m_totalTiles;
|
||||
std::atomic<uint32> m_totalTilesBuilt;
|
||||
|
||||
// build performance - not really used for now
|
||||
rcContext* m_rcContext;
|
||||
// build performance - not really used for now
|
||||
rcContext* m_rcContext;
|
||||
|
||||
std::vector<std::thread> _workerThreads;
|
||||
ProducerConsumerQueue<uint32> _queue;
|
||||
std::atomic<bool> _cancelationToken;
|
||||
std::vector<std::thread> _workerThreads;
|
||||
ProducerConsumerQueue<uint32> _queue;
|
||||
std::atomic<bool> _cancelationToken;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
#include <vector>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <stddef.h>
|
||||
#include <dirent.h>
|
||||
#include <stddef.h>
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#include <errno.h>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#include "Database/DatabaseEnv.h"
|
||||
@@ -33,7 +33,7 @@ enum NavTerrain
|
||||
NAV_UNUSED2 = 0x20,
|
||||
NAV_UNUSED3 = 0x40,
|
||||
NAV_UNUSED4 = 0x80
|
||||
// we only have 8 bits
|
||||
// we only have 8 bits
|
||||
};
|
||||
|
||||
namespace MMAP
|
||||
@@ -76,9 +76,9 @@ namespace MMAP
|
||||
LISTFILE_OK = 1
|
||||
};
|
||||
|
||||
inline ListFilesResult getDirContents(std::vector<std::string> &fileList, std::string dirpath = ".", std::string filter = "*")
|
||||
inline ListFilesResult getDirContents(std::vector<std::string>& fileList, std::string dirpath = ".", std::string filter = "*")
|
||||
{
|
||||
#ifdef WIN32
|
||||
#ifdef WIN32
|
||||
HANDLE hFind;
|
||||
WIN32_FIND_DATA findFileInfo;
|
||||
std::string directory;
|
||||
@@ -93,15 +93,14 @@ namespace MMAP
|
||||
{
|
||||
if ((findFileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
|
||||
fileList.push_back(std::string(findFileInfo.cFileName));
|
||||
}
|
||||
while (FindNextFile(hFind, &findFileInfo));
|
||||
} while (FindNextFile(hFind, &findFileInfo));
|
||||
|
||||
FindClose(hFind);
|
||||
|
||||
#else
|
||||
const char *p = dirpath.c_str();
|
||||
DIR * dirp = opendir(p);
|
||||
struct dirent * dp;
|
||||
#else
|
||||
const char* p = dirpath.c_str();
|
||||
DIR* dirp = opendir(p);
|
||||
struct dirent* dp;
|
||||
|
||||
while (dirp)
|
||||
{
|
||||
@@ -119,7 +118,7 @@ namespace MMAP
|
||||
closedir(dirp);
|
||||
else
|
||||
return LISTFILE_DIRECTORY_NOT_FOUND;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return LISTFILE_OK;
|
||||
}
|
||||
|
||||
@@ -48,20 +48,20 @@ bool checkDirectories(bool debugOutput)
|
||||
}
|
||||
|
||||
bool handleArgs(int argc, char** argv,
|
||||
int &mapnum,
|
||||
int &tileX,
|
||||
int &tileY,
|
||||
float &maxAngle,
|
||||
bool &skipLiquid,
|
||||
bool &skipContinents,
|
||||
bool &skipJunkMaps,
|
||||
bool &skipBattlegrounds,
|
||||
bool &debugOutput,
|
||||
bool &silent,
|
||||
bool &bigBaseUnit,
|
||||
char* &offMeshInputPath,
|
||||
char* &file,
|
||||
unsigned int& threads)
|
||||
int& mapnum,
|
||||
int& tileX,
|
||||
int& tileY,
|
||||
float& maxAngle,
|
||||
bool& skipLiquid,
|
||||
bool& skipContinents,
|
||||
bool& skipJunkMaps,
|
||||
bool& skipBattlegrounds,
|
||||
bool& debugOutput,
|
||||
bool& silent,
|
||||
bool& bigBaseUnit,
|
||||
char*& offMeshInputPath,
|
||||
char*& file,
|
||||
unsigned int& threads)
|
||||
{
|
||||
char* param = nullptr;
|
||||
for (int i = 1; i < argc; ++i)
|
||||
|
||||
@@ -72,11 +72,11 @@ namespace MMAP
|
||||
|
||||
char const* MAP_VERSION_MAGIC = "v1.8";
|
||||
|
||||
TerrainBuilder::TerrainBuilder(bool skipLiquid) : m_skipLiquid (skipLiquid){ }
|
||||
TerrainBuilder::TerrainBuilder(bool skipLiquid) : m_skipLiquid (skipLiquid) { }
|
||||
TerrainBuilder::~TerrainBuilder() { }
|
||||
|
||||
/**************************************************************************/
|
||||
void TerrainBuilder::getLoopVars(Spot portion, int &loopStart, int &loopEnd, int &loopInc)
|
||||
void TerrainBuilder::getLoopVars(Spot portion, int& loopStart, int& loopEnd, int& loopInc)
|
||||
{
|
||||
switch (portion)
|
||||
{
|
||||
@@ -109,19 +109,19 @@ namespace MMAP
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void TerrainBuilder::loadMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData)
|
||||
void TerrainBuilder::loadMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData& meshData)
|
||||
{
|
||||
if (loadMap(mapID, tileX, tileY, meshData, ENTIRE))
|
||||
{
|
||||
loadMap(mapID, tileX+1, tileY, meshData, LEFT);
|
||||
loadMap(mapID, tileX-1, tileY, meshData, RIGHT);
|
||||
loadMap(mapID, tileX, tileY+1, meshData, TOP);
|
||||
loadMap(mapID, tileX, tileY-1, meshData, BOTTOM);
|
||||
loadMap(mapID, tileX + 1, tileY, meshData, LEFT);
|
||||
loadMap(mapID, tileX - 1, tileY, meshData, RIGHT);
|
||||
loadMap(mapID, tileX, tileY + 1, meshData, TOP);
|
||||
loadMap(mapID, tileX, tileY - 1, meshData, BOTTOM);
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
bool TerrainBuilder::loadMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData, Spot portion)
|
||||
bool TerrainBuilder::loadMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData& meshData, Spot portion)
|
||||
{
|
||||
char mapFileName[255];
|
||||
sprintf(mapFileName, "maps/%03u%02u%02u.map", mapID, tileY, tileX);
|
||||
@@ -132,7 +132,7 @@ namespace MMAP
|
||||
|
||||
map_fileheader fheader;
|
||||
if (fread(&fheader, sizeof(map_fileheader), 1, mapFile) != 1 ||
|
||||
fheader.versionMagic != *((uint32 const*)(MAP_VERSION_MAGIC)))
|
||||
fheader.versionMagic != *((uint32 const*)(MAP_VERSION_MAGIC)))
|
||||
{
|
||||
fclose(mapFile);
|
||||
printf("%s is the wrong version, please extract new .map files\n", mapFileName);
|
||||
@@ -185,10 +185,10 @@ namespace MMAP
|
||||
heightMultiplier = (hheader.gridMaxHeight - hheader.gridHeight) / 255;
|
||||
|
||||
for (int i = 0; i < V9_SIZE_SQ; ++i)
|
||||
V9[i] = (float)v9[i]*heightMultiplier + hheader.gridHeight;
|
||||
V9[i] = (float)v9[i] * heightMultiplier + hheader.gridHeight;
|
||||
|
||||
for (int i = 0; i < V8_SIZE_SQ; ++i)
|
||||
V8[i] = (float)v8[i]*heightMultiplier + hheader.gridHeight;
|
||||
V8[i] = (float)v8[i] * heightMultiplier + hheader.gridHeight;
|
||||
}
|
||||
else if (hheader.flags & MAP_HEIGHT_AS_INT16)
|
||||
{
|
||||
@@ -203,10 +203,10 @@ namespace MMAP
|
||||
heightMultiplier = (hheader.gridMaxHeight - hheader.gridHeight) / 65535;
|
||||
|
||||
for (int i = 0; i < V9_SIZE_SQ; ++i)
|
||||
V9[i] = (float)v9[i]*heightMultiplier + hheader.gridHeight;
|
||||
V9[i] = (float)v9[i] * heightMultiplier + hheader.gridHeight;
|
||||
|
||||
for (int i = 0; i < V8_SIZE_SQ; ++i)
|
||||
V8[i] = (float)v8[i]*heightMultiplier + hheader.gridHeight;
|
||||
V8[i] = (float)v8[i] * heightMultiplier + hheader.gridHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -227,8 +227,8 @@ namespace MMAP
|
||||
}
|
||||
|
||||
int count = meshData.solidVerts.size() / 3;
|
||||
float xoffset = (float(tileX)-32)*GRID_SIZE;
|
||||
float yoffset = (float(tileY)-32)*GRID_SIZE;
|
||||
float xoffset = (float(tileX) - 32) * GRID_SIZE;
|
||||
float yoffset = (float(tileY) - 32) * GRID_SIZE;
|
||||
|
||||
float coord[3];
|
||||
|
||||
@@ -251,8 +251,8 @@ namespace MMAP
|
||||
int indices[] = { 0, 0, 0 };
|
||||
int loopStart = 0, loopEnd = 0, loopInc = 0;
|
||||
getLoopVars(portion, loopStart, loopEnd, loopInc);
|
||||
for (int i = loopStart; i < loopEnd; i+=loopInc)
|
||||
for (int j = TOP; j <= BOTTOM; j+=1)
|
||||
for (int i = loopStart; i < loopEnd; i += loopInc)
|
||||
for (int j = TOP; j <= BOTTOM; j += 1)
|
||||
{
|
||||
getHeightTriangle(i, Spot(j), indices);
|
||||
ttriangles.append(indices[2] + count);
|
||||
@@ -287,8 +287,8 @@ namespace MMAP
|
||||
if (liquid_map)
|
||||
{
|
||||
int count = meshData.liquidVerts.size() / 3;
|
||||
float xoffset = (float(tileX)-32)*GRID_SIZE;
|
||||
float yoffset = (float(tileY)-32)*GRID_SIZE;
|
||||
float xoffset = (float(tileX) - 32) * GRID_SIZE;
|
||||
float yoffset = (float(tileY) - 32) * GRID_SIZE;
|
||||
|
||||
float coord[3];
|
||||
int row, col;
|
||||
@@ -303,10 +303,10 @@ namespace MMAP
|
||||
col = i % V9_SIZE;
|
||||
|
||||
if (row < lheader.offsetY || row >= lheader.offsetY + lheader.height ||
|
||||
col < lheader.offsetX || col >= lheader.offsetX + lheader.width)
|
||||
col < lheader.offsetX || col >= lheader.offsetX + lheader.width)
|
||||
{
|
||||
// dummy vert using invalid height
|
||||
meshData.liquidVerts.append((xoffset+col*GRID_PART_SIZE)*-1, INVALID_MAP_LIQ_HEIGHT, (yoffset+row*GRID_PART_SIZE)*-1);
|
||||
meshData.liquidVerts.append((xoffset + col * GRID_PART_SIZE) * -1, INVALID_MAP_LIQ_HEIGHT, (yoffset + row * GRID_PART_SIZE) * -1);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -323,19 +323,19 @@ namespace MMAP
|
||||
{
|
||||
row = i / V9_SIZE;
|
||||
col = i % V9_SIZE;
|
||||
meshData.liquidVerts.append((xoffset+col*GRID_PART_SIZE)*-1, lheader.liquidLevel, (yoffset+row*GRID_PART_SIZE)*-1);
|
||||
meshData.liquidVerts.append((xoffset + col * GRID_PART_SIZE) * -1, lheader.liquidLevel, (yoffset + row * GRID_PART_SIZE) * -1);
|
||||
}
|
||||
}
|
||||
|
||||
delete [] liquid_map;
|
||||
|
||||
int indices[] = { 0, 0, 0 };
|
||||
int loopStart = 0, loopEnd = 0, loopInc = 0, triInc = BOTTOM-TOP;
|
||||
int loopStart = 0, loopEnd = 0, loopInc = 0, triInc = BOTTOM - TOP;
|
||||
getLoopVars(portion, loopStart, loopEnd, loopInc);
|
||||
|
||||
// generate triangles
|
||||
for (int i = loopStart; i < loopEnd; i+=loopInc)
|
||||
for (int j = TOP; j <= BOTTOM; j+= triInc)
|
||||
for (int i = loopStart; i < loopEnd; i += loopInc)
|
||||
for (int j = TOP; j <= BOTTOM; j += triInc)
|
||||
{
|
||||
getHeightTriangle(i, Spot(j), indices, true);
|
||||
ltriangles.append(indices[2] + count);
|
||||
@@ -371,7 +371,7 @@ namespace MMAP
|
||||
}
|
||||
|
||||
getLoopVars(portion, loopStart, loopEnd, loopInc);
|
||||
for (int i = loopStart; i < loopEnd; i+=loopInc)
|
||||
for (int i = loopStart; i < loopEnd; i += loopInc)
|
||||
{
|
||||
for (int j = 0; j < 2; ++j)
|
||||
{
|
||||
@@ -423,7 +423,7 @@ namespace MMAP
|
||||
uint32 validCount = 0;
|
||||
for(uint32 idx = 0; idx < 3; idx++)
|
||||
{
|
||||
float h = lverts_copy[ltris[idx]*3 + 1];
|
||||
float h = lverts_copy[ltris[idx] * 3 + 1];
|
||||
if (h != INVALID_MAP_LIQ_HEIGHT && h < INVALID_MAP_LIQ_HEIGHT_MAX)
|
||||
{
|
||||
quadHeight += h;
|
||||
@@ -437,9 +437,9 @@ namespace MMAP
|
||||
quadHeight /= validCount;
|
||||
for(uint32 idx = 0; idx < 3; idx++)
|
||||
{
|
||||
float h = lverts[ltris[idx]*3 + 1];
|
||||
float h = lverts[ltris[idx] * 3 + 1];
|
||||
if (h == INVALID_MAP_LIQ_HEIGHT || h > INVALID_MAP_LIQ_HEIGHT_MAX)
|
||||
lverts[ltris[idx]*3 + 1] = quadHeight;
|
||||
lverts[ltris[idx] * 3 + 1] = quadHeight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,7 +459,7 @@ namespace MMAP
|
||||
float maxLLevel = INVALID_MAP_LIQ_HEIGHT;
|
||||
for(uint32 x = 0; x < 3; x++)
|
||||
{
|
||||
float h = lverts[ltris[x]*3 + 1];
|
||||
float h = lverts[ltris[x] * 3 + 1];
|
||||
if (minLLevel > h)
|
||||
minLLevel = h;
|
||||
|
||||
@@ -471,7 +471,7 @@ namespace MMAP
|
||||
float minTLevel = INVALID_MAP_LIQ_HEIGHT_MAX;
|
||||
for(uint32 x = 0; x < 6; x++)
|
||||
{
|
||||
float h = tverts[ttris[x]*3 + 1];
|
||||
float h = tverts[ttris[x] * 3 + 1];
|
||||
if (maxTLevel < h)
|
||||
maxTLevel = h;
|
||||
|
||||
@@ -497,12 +497,12 @@ namespace MMAP
|
||||
}
|
||||
|
||||
if (useTerrain)
|
||||
for (int k = 0; k < 3*tTriCount/2; ++k)
|
||||
for (int k = 0; k < 3 * tTriCount / 2; ++k)
|
||||
meshData.solidTris.append(ttris[k]);
|
||||
|
||||
// advance to next set of triangles
|
||||
ltris += 3;
|
||||
ttris += 3*tTriCount/2;
|
||||
ttris += 3 * tTriCount / 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -519,63 +519,81 @@ namespace MMAP
|
||||
// coord is mirroed about the horizontal axes
|
||||
switch (grid)
|
||||
{
|
||||
case GRID_V9:
|
||||
coord[0] = (xOffset + index%(V9_SIZE)*GRID_PART_SIZE) * -1.f;
|
||||
coord[1] = (yOffset + (int)(index/(V9_SIZE))*GRID_PART_SIZE) * -1.f;
|
||||
coord[2] = v[index];
|
||||
break;
|
||||
case GRID_V8:
|
||||
coord[0] = (xOffset + index%(V8_SIZE)*GRID_PART_SIZE + GRID_PART_SIZE/2.f) * -1.f;
|
||||
coord[1] = (yOffset + (int)(index/(V8_SIZE))*GRID_PART_SIZE + GRID_PART_SIZE/2.f) * -1.f;
|
||||
coord[2] = v[index];
|
||||
break;
|
||||
case GRID_V9:
|
||||
coord[0] = (xOffset + index % (V9_SIZE) * GRID_PART_SIZE) * -1.f;
|
||||
coord[1] = (yOffset + (int)(index / (V9_SIZE)) * GRID_PART_SIZE) * -1.f;
|
||||
coord[2] = v[index];
|
||||
break;
|
||||
case GRID_V8:
|
||||
coord[0] = (xOffset + index % (V8_SIZE) * GRID_PART_SIZE + GRID_PART_SIZE / 2.f) * -1.f;
|
||||
coord[1] = (yOffset + (int)(index / (V8_SIZE)) * GRID_PART_SIZE + GRID_PART_SIZE / 2.f) * -1.f;
|
||||
coord[2] = v[index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void TerrainBuilder::getHeightTriangle(int square, Spot triangle, int* indices, bool liquid/* = false*/)
|
||||
{
|
||||
int rowOffset = square/V8_SIZE;
|
||||
int rowOffset = square / V8_SIZE;
|
||||
if (!liquid)
|
||||
switch (triangle)
|
||||
{
|
||||
case TOP:
|
||||
indices[0] = square+rowOffset; // 0-----1 .... 128
|
||||
indices[1] = square+1+rowOffset; // |\ T /|
|
||||
indices[2] = (V9_SIZE_SQ)+square; // | \ / |
|
||||
break; // |L 0 R| .. 127
|
||||
case LEFT: // | / \ |
|
||||
indices[0] = square+rowOffset; // |/ B \|
|
||||
indices[1] = (V9_SIZE_SQ)+square; // 129---130 ... 386
|
||||
indices[2] = square+V9_SIZE+rowOffset; // |\ /|
|
||||
break; // | \ / |
|
||||
case RIGHT: // | 128 | .. 255
|
||||
indices[0] = square+1+rowOffset; // | / \ |
|
||||
indices[1] = square+V9_SIZE+1+rowOffset; // |/ \|
|
||||
indices[2] = (V9_SIZE_SQ)+square; // 258---259 ... 515
|
||||
break;
|
||||
case BOTTOM:
|
||||
indices[0] = (V9_SIZE_SQ)+square;
|
||||
indices[1] = square+V9_SIZE+1+rowOffset;
|
||||
indices[2] = square+V9_SIZE+rowOffset;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
{
|
||||
case TOP:
|
||||
indices[0] = square + rowOffset; // 0-----1 .... 128
|
||||
indices[1] = square + 1 + rowOffset; // |\ T /|
|
||||
indices[2] = (V9_SIZE_SQ) + square; // | \ / |
|
||||
break; // |L 0 R| .. 127
|
||||
case LEFT: // | / \ |
|
||||
indices[0] = square + rowOffset; // |/ B \|
|
||||
indices[1] = (V9_SIZE_SQ) + square; // 129---130 ... 386
|
||||
indices[2] = square + V9_SIZE + rowOffset; // |\ /|
|
||||
break; // | \ / |
|
||||
case RIGHT: // | 128 | .. 255
|
||||
indices[0] = square + 1 + rowOffset; // | / \ |
|
||||
indices[1] = square + V9_SIZE + 1 + rowOffset; // |/ \|
|
||||
indices[2] = (V9_SIZE_SQ) + square; // 258---259 ... 515
|
||||
break;
|
||||
case BOTTOM:
|
||||
indices[0] = (V9_SIZE_SQ) + square;
|
||||
indices[1] = square + V9_SIZE + 1 + rowOffset;
|
||||
indices[2] = square + V9_SIZE + rowOffset;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
else
|
||||
switch (triangle)
|
||||
{ // 0-----1 .... 128
|
||||
case TOP: // |\ |
|
||||
indices[0] = square+rowOffset; // | \ T |
|
||||
indices[1] = square+1+rowOffset; // | \ |
|
||||
indices[2] = square+V9_SIZE+1+rowOffset; // | B \ |
|
||||
break; // | \|
|
||||
case BOTTOM: // 129---130 ... 386
|
||||
indices[0] = square+rowOffset; // |\ |
|
||||
indices[1] = square+V9_SIZE+1+rowOffset; // | \ |
|
||||
indices[2] = square+V9_SIZE+rowOffset; // | \ |
|
||||
break; // | \ |
|
||||
default: break; // | \|
|
||||
} // 258---259 ... 515
|
||||
{
|
||||
case TOP:
|
||||
indices[0] = square + rowOffset;
|
||||
indices[1] = square + 1 + rowOffset;
|
||||
indices[2] = square + V9_SIZE + 1 + rowOffset;
|
||||
break;
|
||||
case BOTTOM:
|
||||
indices[0] = square + rowOffset;
|
||||
indices[1] = square + V9_SIZE + 1 + rowOffset;
|
||||
indices[2] = square + V9_SIZE + rowOffset;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
0-----1 .... 128
|
||||
|\ |
|
||||
| \ T |
|
||||
| \ |
|
||||
| B \ |
|
||||
| \|
|
||||
129---130 ... 386
|
||||
|\ |
|
||||
| \ |
|
||||
| \ |
|
||||
| \ |
|
||||
| \|
|
||||
258---259 ... 515
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@@ -584,8 +602,8 @@ namespace MMAP
|
||||
{
|
||||
// wow coords: x, y, height
|
||||
// coord is mirroed about the horizontal axes
|
||||
coord[0] = (xOffset + index%(V9_SIZE)*GRID_PART_SIZE) * -1.f;
|
||||
coord[1] = (yOffset + (int)(index/(V9_SIZE))*GRID_PART_SIZE) * -1.f;
|
||||
coord[0] = (xOffset + index % (V9_SIZE) * GRID_PART_SIZE) * -1.f;
|
||||
coord[1] = (yOffset + (int)(index / (V9_SIZE)) * GRID_PART_SIZE) * -1.f;
|
||||
coord[2] = v[index2];
|
||||
}
|
||||
|
||||
@@ -619,7 +637,7 @@ namespace MMAP
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
bool TerrainBuilder::loadVMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData)
|
||||
bool TerrainBuilder::loadVMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData& meshData)
|
||||
{
|
||||
IVMapManager* vmapManager = new VMapManager2();
|
||||
int result = vmapManager->loadMap("vmaps", mapID, tileX, tileY);
|
||||
@@ -663,10 +681,10 @@ namespace MMAP
|
||||
|
||||
// transform data
|
||||
float scale = instance.iScale;
|
||||
G3D::Matrix3 rotation = G3D::Matrix3::fromEulerAnglesXYZ(G3D::pi()*instance.iRot.z/-180.f, G3D::pi()*instance.iRot.x/-180.f, G3D::pi()*instance.iRot.y/-180.f);
|
||||
G3D::Matrix3 rotation = G3D::Matrix3::fromEulerAnglesXYZ(G3D::pi() * instance.iRot.z / -180.f, G3D::pi() * instance.iRot.x / -180.f, G3D::pi() * instance.iRot.y / -180.f);
|
||||
G3D::Vector3 position = instance.iPos;
|
||||
position.x -= 32*GRID_SIZE;
|
||||
position.y -= 32*GRID_SIZE;
|
||||
position.x -= 32 * GRID_SIZE;
|
||||
position.y -= 32 * GRID_SIZE;
|
||||
|
||||
for (std::vector<GroupModel>::iterator it = groupModels.begin(); it != groupModels.end(); ++it)
|
||||
{
|
||||
@@ -702,16 +720,16 @@ namespace MMAP
|
||||
// convert liquid type to NavTerrain
|
||||
switch (liquid->GetType() & 3)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
type = NAV_WATER;
|
||||
break;
|
||||
case 2:
|
||||
type = NAV_MAGMA;
|
||||
break;
|
||||
case 3:
|
||||
type = NAV_SLIME;
|
||||
break;
|
||||
case 0:
|
||||
case 1:
|
||||
type = NAV_WATER;
|
||||
break;
|
||||
case 2:
|
||||
type = NAV_MAGMA;
|
||||
break;
|
||||
case 3:
|
||||
type = NAV_SLIME;
|
||||
break;
|
||||
}
|
||||
|
||||
// indexing is weird...
|
||||
@@ -725,7 +743,7 @@ namespace MMAP
|
||||
{
|
||||
for (uint32 y = 0; y < vertsY; ++y)
|
||||
{
|
||||
vert = G3D::Vector3(corner.x + x * GRID_PART_SIZE, corner.y + y * GRID_PART_SIZE, data[y*vertsX + x]);
|
||||
vert = G3D::Vector3(corner.x + x * GRID_PART_SIZE, corner.y + y * GRID_PART_SIZE, data[y * vertsX + x]);
|
||||
vert = vert * rotation * scale + position;
|
||||
vert.x *= -1.f;
|
||||
vert.y *= -1.f;
|
||||
@@ -767,14 +785,13 @@ namespace MMAP
|
||||
|
||||
for (uint32 j = 0; j < liqTris.size() / 3; ++j)
|
||||
{
|
||||
meshData.liquidTris.append(liqTris[j*3+1] + liqOffset, liqTris[j*3+2] + liqOffset, liqTris[j*3] + liqOffset);
|
||||
meshData.liquidTris.append(liqTris[j * 3 + 1] + liqOffset, liqTris[j * 3 + 2] + liqOffset, liqTris[j * 3] + liqOffset);
|
||||
meshData.liquidType.append(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (false);
|
||||
} while (false);
|
||||
|
||||
vmapManager->unloadMap(mapID, tileX, tileY);
|
||||
delete vmapManager;
|
||||
@@ -783,7 +800,7 @@ namespace MMAP
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void TerrainBuilder::transform(std::vector<G3D::Vector3> &source, std::vector<G3D::Vector3> &transformedVertices, float scale, G3D::Matrix3 &rotation, G3D::Vector3 &position)
|
||||
void TerrainBuilder::transform(std::vector<G3D::Vector3>& source, std::vector<G3D::Vector3>& transformedVertices, float scale, G3D::Matrix3& rotation, G3D::Vector3& position)
|
||||
{
|
||||
for (std::vector<G3D::Vector3>::iterator it = source.begin(); it != source.end(); ++it)
|
||||
{
|
||||
@@ -796,7 +813,7 @@ namespace MMAP
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void TerrainBuilder::copyVertices(std::vector<G3D::Vector3> &source, G3D::Array<float> &dest)
|
||||
void TerrainBuilder::copyVertices(std::vector<G3D::Vector3>& source, G3D::Array<float>& dest)
|
||||
{
|
||||
for (std::vector<G3D::Vector3>::iterator it = source.begin(); it != source.end(); ++it)
|
||||
{
|
||||
@@ -807,30 +824,30 @@ namespace MMAP
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void TerrainBuilder::copyIndices(std::vector<MeshTriangle> &source, G3D::Array<int> &dest, int offset, bool flip)
|
||||
void TerrainBuilder::copyIndices(std::vector<MeshTriangle>& source, G3D::Array<int>& dest, int offset, bool flip)
|
||||
{
|
||||
if (flip)
|
||||
{
|
||||
for (std::vector<MeshTriangle>::iterator it = source.begin(); it != source.end(); ++it)
|
||||
{
|
||||
dest.push_back((*it).idx2+offset);
|
||||
dest.push_back((*it).idx1+offset);
|
||||
dest.push_back((*it).idx0+offset);
|
||||
dest.push_back((*it).idx2 + offset);
|
||||
dest.push_back((*it).idx1 + offset);
|
||||
dest.push_back((*it).idx0 + offset);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (std::vector<MeshTriangle>::iterator it = source.begin(); it != source.end(); ++it)
|
||||
{
|
||||
dest.push_back((*it).idx0+offset);
|
||||
dest.push_back((*it).idx1+offset);
|
||||
dest.push_back((*it).idx2+offset);
|
||||
dest.push_back((*it).idx0 + offset);
|
||||
dest.push_back((*it).idx1 + offset);
|
||||
dest.push_back((*it).idx2 + offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void TerrainBuilder::copyIndices(G3D::Array<int> &source, G3D::Array<int> &dest, int offset)
|
||||
void TerrainBuilder::copyIndices(G3D::Array<int>& source, G3D::Array<int>& dest, int offset)
|
||||
{
|
||||
int* src = source.getCArray();
|
||||
for (int32 i = 0; i < source.size(); ++i)
|
||||
@@ -838,7 +855,7 @@ namespace MMAP
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void TerrainBuilder::cleanVertices(G3D::Array<float> &verts, G3D::Array<int> &tris)
|
||||
void TerrainBuilder::cleanVertices(G3D::Array<float>& verts, G3D::Array<int>& tris)
|
||||
{
|
||||
std::map<int, int> vertMap;
|
||||
|
||||
@@ -881,7 +898,7 @@ namespace MMAP
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void TerrainBuilder::loadOffMeshConnections(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData, const char* offMeshFilePath)
|
||||
void TerrainBuilder::loadOffMeshConnections(uint32 mapID, uint32 tileX, uint32 tileY, MeshData& meshData, const char* offMeshFilePath)
|
||||
{
|
||||
// no meshfile input given?
|
||||
if (offMeshFilePath == nullptr)
|
||||
@@ -903,7 +920,7 @@ namespace MMAP
|
||||
uint32 mid, tx, ty;
|
||||
float size;
|
||||
if (sscanf(buf, "%u %u,%u (%f %f %f) (%f %f %f) %f", &mid, &tx, &ty,
|
||||
&p0[0], &p0[1], &p0[2], &p1[0], &p1[1], &p1[2], &size) != 10)
|
||||
&p0[0], &p0[1], &p0[2], &p1[0], &p1[1], &p1[2], &size) != 10)
|
||||
continue;
|
||||
|
||||
if (mapID == mid && tileX == tx && tileY == ty)
|
||||
|
||||
@@ -32,11 +32,11 @@ namespace MMAP
|
||||
};
|
||||
|
||||
static const int V9_SIZE = 129;
|
||||
static const int V9_SIZE_SQ = V9_SIZE*V9_SIZE;
|
||||
static const int V9_SIZE_SQ = V9_SIZE * V9_SIZE;
|
||||
static const int V8_SIZE = 128;
|
||||
static const int V8_SIZE_SQ = V8_SIZE*V8_SIZE;
|
||||
static const int V8_SIZE_SQ = V8_SIZE * V8_SIZE;
|
||||
static const float GRID_SIZE = 533.3333f;
|
||||
static const float GRID_PART_SIZE = GRID_SIZE/V8_SIZE;
|
||||
static const float GRID_PART_SIZE = GRID_SIZE / V8_SIZE;
|
||||
|
||||
// see contrib/extractor/system.cpp, CONF_use_minHeight
|
||||
static const float INVALID_MAP_LIQ_HEIGHT = -500.f;
|
||||
@@ -65,52 +65,52 @@ namespace MMAP
|
||||
|
||||
class TerrainBuilder
|
||||
{
|
||||
public:
|
||||
TerrainBuilder(bool skipLiquid);
|
||||
~TerrainBuilder();
|
||||
public:
|
||||
TerrainBuilder(bool skipLiquid);
|
||||
~TerrainBuilder();
|
||||
|
||||
TerrainBuilder(const TerrainBuilder &tb) = delete;
|
||||
TerrainBuilder(const TerrainBuilder& tb) = delete;
|
||||
|
||||
void loadMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData);
|
||||
bool loadVMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData);
|
||||
void loadOffMeshConnections(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData, const char* offMeshFilePath);
|
||||
void loadMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData& meshData);
|
||||
bool loadVMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData& meshData);
|
||||
void loadOffMeshConnections(uint32 mapID, uint32 tileX, uint32 tileY, MeshData& meshData, const char* offMeshFilePath);
|
||||
|
||||
bool usesLiquids() const { return !m_skipLiquid; }
|
||||
bool usesLiquids() const { return !m_skipLiquid; }
|
||||
|
||||
// vert and triangle methods
|
||||
static void transform(std::vector<G3D::Vector3> &original, std::vector<G3D::Vector3> &transformed,
|
||||
float scale, G3D::Matrix3 &rotation, G3D::Vector3 &position);
|
||||
static void copyVertices(std::vector<G3D::Vector3> &source, G3D::Array<float> &dest);
|
||||
static void copyIndices(std::vector<VMAP::MeshTriangle> &source, G3D::Array<int> &dest, int offest, bool flip);
|
||||
static void copyIndices(G3D::Array<int> &src, G3D::Array<int> &dest, int offset);
|
||||
static void cleanVertices(G3D::Array<float> &verts, G3D::Array<int> &tris);
|
||||
private:
|
||||
/// Loads a portion of a map's terrain
|
||||
bool loadMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData, Spot portion);
|
||||
// vert and triangle methods
|
||||
static void transform(std::vector<G3D::Vector3>& original, std::vector<G3D::Vector3>& transformed,
|
||||
float scale, G3D::Matrix3& rotation, G3D::Vector3& position);
|
||||
static void copyVertices(std::vector<G3D::Vector3>& source, G3D::Array<float>& dest);
|
||||
static void copyIndices(std::vector<VMAP::MeshTriangle>& source, G3D::Array<int>& dest, int offest, bool flip);
|
||||
static void copyIndices(G3D::Array<int>& src, G3D::Array<int>& dest, int offset);
|
||||
static void cleanVertices(G3D::Array<float>& verts, G3D::Array<int>& tris);
|
||||
private:
|
||||
/// Loads a portion of a map's terrain
|
||||
bool loadMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData& meshData, Spot portion);
|
||||
|
||||
/// Sets loop variables for selecting only certain parts of a map's terrain
|
||||
void getLoopVars(Spot portion, int &loopStart, int &loopEnd, int &loopInc);
|
||||
/// Sets loop variables for selecting only certain parts of a map's terrain
|
||||
void getLoopVars(Spot portion, int& loopStart, int& loopEnd, int& loopInc);
|
||||
|
||||
/// Controls whether liquids are loaded
|
||||
bool m_skipLiquid;
|
||||
/// Controls whether liquids are loaded
|
||||
bool m_skipLiquid;
|
||||
|
||||
/// Load the map terrain from file
|
||||
bool loadHeightMap(uint32 mapID, uint32 tileX, uint32 tileY, G3D::Array<float> &vertices, G3D::Array<int> &triangles, Spot portion);
|
||||
/// Load the map terrain from file
|
||||
bool loadHeightMap(uint32 mapID, uint32 tileX, uint32 tileY, G3D::Array<float>& vertices, G3D::Array<int>& triangles, Spot portion);
|
||||
|
||||
/// Get the vector coordinate for a specific position
|
||||
void getHeightCoord(int index, Grid grid, float xOffset, float yOffset, float* coord, float* v);
|
||||
/// Get the vector coordinate for a specific position
|
||||
void getHeightCoord(int index, Grid grid, float xOffset, float yOffset, float* coord, float* v);
|
||||
|
||||
/// Get the triangle's vector indices for a specific position
|
||||
void getHeightTriangle(int square, Spot triangle, int* indices, bool liquid = false);
|
||||
/// Get the triangle's vector indices for a specific position
|
||||
void getHeightTriangle(int square, Spot triangle, int* indices, bool liquid = false);
|
||||
|
||||
/// Determines if the specific position's triangles should be rendered
|
||||
bool isHole(int square, const uint16 holes[16][16]);
|
||||
/// Determines if the specific position's triangles should be rendered
|
||||
bool isHole(int square, const uint16 holes[16][16]);
|
||||
|
||||
/// Get the liquid vector coordinate for a specific position
|
||||
void getLiquidCoord(int index, int index2, float xOffset, float yOffset, float* coord, float* v);
|
||||
/// Get the liquid vector coordinate for a specific position
|
||||
void getLiquidCoord(int index, int index2, float xOffset, float yOffset, float* coord, float* v);
|
||||
|
||||
/// Get the liquid type for a specific position
|
||||
uint8 getLiquidType(int square, const uint8 liquid_type[16][16]);
|
||||
/// Get the liquid type for a specific position
|
||||
uint8 getLiquidType(int square, const uint8 liquid_type[16][16]);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -20,26 +20,26 @@ namespace VMAP
|
||||
// maybe add MapBuilder as friend to all of the below classes would be better?
|
||||
|
||||
// declared in src/common/vmap/MapTree.h
|
||||
void StaticMapTree::getModelInstances(ModelInstance* &models, uint32 &count)
|
||||
void StaticMapTree::getModelInstances(ModelInstance*& models, uint32& count)
|
||||
{
|
||||
models = iTreeValues;
|
||||
count = iNTreeValues;
|
||||
}
|
||||
|
||||
// declared in src/common/vmap/VMapManager2.h
|
||||
void VMapManager2::getInstanceMapTree(InstanceTreeMap &instanceMapTree)
|
||||
void VMapManager2::getInstanceMapTree(InstanceTreeMap& instanceMapTree)
|
||||
{
|
||||
instanceMapTree = iInstanceMapTrees;
|
||||
}
|
||||
|
||||
// declared in src/common/vmap/WorldModel.h
|
||||
void WorldModel::getGroupModels(std::vector<GroupModel> &groupModels)
|
||||
void WorldModel::getGroupModels(std::vector<GroupModel>& groupModels)
|
||||
{
|
||||
groupModels = this->groupModels;
|
||||
}
|
||||
|
||||
// declared in src/common/vmap/WorldModel.h
|
||||
void GroupModel::getMeshData(std::vector<G3D::Vector3> &vertices, std::vector<MeshTriangle> &triangles, WmoLiquid* &liquid)
|
||||
void GroupModel::getMeshData(std::vector<G3D::Vector3>& vertices, std::vector<MeshTriangle>& triangles, WmoLiquid*& liquid)
|
||||
{
|
||||
vertices = this->vertices;
|
||||
triangles = this->triangles;
|
||||
@@ -53,7 +53,7 @@ namespace VMAP
|
||||
}
|
||||
|
||||
// declared in src/common/vmap/WorldModel.h
|
||||
void WmoLiquid::getPosInfo(uint32 &tilesX, uint32 &tilesY, G3D::Vector3 &corner) const
|
||||
void WmoLiquid::getPosInfo(uint32& tilesX, uint32& tilesY, G3D::Vector3& corner) const
|
||||
{
|
||||
tilesX = iTilesX;
|
||||
tilesY = iTilesY;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
char const* GetPlainName(char const* FileName)
|
||||
{
|
||||
const char * szTemp;
|
||||
const char* szTemp;
|
||||
|
||||
if((szTemp = strrchr(FileName, '\\')) != nullptr)
|
||||
FileName = szTemp + 1;
|
||||
@@ -25,7 +25,7 @@ char const* GetPlainName(char const* FileName)
|
||||
|
||||
char* GetPlainName(char* FileName)
|
||||
{
|
||||
char * szTemp;
|
||||
char* szTemp;
|
||||
|
||||
if((szTemp = strrchr(FileName, '\\')) != nullptr)
|
||||
FileName = szTemp + 1;
|
||||
@@ -34,11 +34,11 @@ char* GetPlainName(char* FileName)
|
||||
|
||||
void fixnamen(char* name, size_t len)
|
||||
{
|
||||
for (size_t i = 0; i < len-3; i++)
|
||||
for (size_t i = 0; i < len - 3; i++)
|
||||
{
|
||||
if (i > 0 && name[i] >= 'A' && name[i] <= 'Z' && isalpha(name[i-1]))
|
||||
if (i > 0 && name[i] >= 'A' && name[i] <= 'Z' && isalpha(name[i - 1]))
|
||||
name[i] |= 0x20;
|
||||
else if ((i == 0 || !isalpha(name[i-1])) && name[i]>='a' && name[i]<='z')
|
||||
else if ((i == 0 || !isalpha(name[i - 1])) && name[i] >= 'a' && name[i] <= 'z')
|
||||
name[i] &= ~0x20;
|
||||
}
|
||||
//extension in lowercase
|
||||
@@ -48,10 +48,10 @@ void fixnamen(char* name, size_t len)
|
||||
|
||||
void fixname2(char* name, size_t len)
|
||||
{
|
||||
for (size_t i=0; i<len-3; i++)
|
||||
for (size_t i = 0; i < len - 3; i++)
|
||||
{
|
||||
if(name[i] == ' ')
|
||||
name[i] = '_';
|
||||
name[i] = '_';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,12 +77,12 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
|
||||
string xMap;
|
||||
string yMap;
|
||||
|
||||
Adtfilename.erase(Adtfilename.find(".adt"),4);
|
||||
Adtfilename.erase(Adtfilename.find(".adt"), 4);
|
||||
string TempMapNumber;
|
||||
TempMapNumber = Adtfilename.substr(Adtfilename.length()-6,6);
|
||||
xMap = TempMapNumber.substr(TempMapNumber.find("_")+1,(TempMapNumber.find_last_of("_")-1) - (TempMapNumber.find("_")));
|
||||
yMap = TempMapNumber.substr(TempMapNumber.find_last_of("_")+1,(TempMapNumber.length()) - (TempMapNumber.find_last_of("_")));
|
||||
Adtfilename.erase((Adtfilename.length()-xMap.length()-yMap.length()-2), (xMap.length()+yMap.length()+2));
|
||||
TempMapNumber = Adtfilename.substr(Adtfilename.length() - 6, 6);
|
||||
xMap = TempMapNumber.substr(TempMapNumber.find("_") + 1, (TempMapNumber.find_last_of("_") - 1) - (TempMapNumber.find("_")));
|
||||
yMap = TempMapNumber.substr(TempMapNumber.find_last_of("_") + 1, (TempMapNumber.length()) - (TempMapNumber.find_last_of("_")));
|
||||
Adtfilename.erase((Adtfilename.length() - xMap.length() - yMap.length() - 2), (xMap.length() + yMap.length() + 2));
|
||||
//string AdtMapNumber = xMap + ' ' + yMap + ' ' + GetPlainName((char*)Adtfilename.c_str());
|
||||
//printf("Processing map %s...\n", AdtMapNumber.c_str());
|
||||
//printf("MapNumber = %s\n", TempMapNumber.c_str());
|
||||
@@ -90,7 +90,7 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
|
||||
//printf("yMap = %s\n", yMap.c_str());
|
||||
|
||||
std::string dirname = std::string(szWorkDirWmo) + "/dir_bin";
|
||||
FILE *dirfile;
|
||||
FILE* dirfile;
|
||||
dirfile = fopen(dirname.c_str(), "ab");
|
||||
if(!dirfile)
|
||||
{
|
||||
@@ -101,54 +101,54 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
|
||||
while (!ADT.isEof())
|
||||
{
|
||||
char fourcc[5];
|
||||
ADT.read(&fourcc,4);
|
||||
ADT.read(&fourcc, 4);
|
||||
ADT.read(&size, 4);
|
||||
flipcc(fourcc);
|
||||
fourcc[4] = 0;
|
||||
|
||||
size_t nextpos = ADT.getPos() + size;
|
||||
|
||||
if (!strcmp(fourcc,"MCIN"))
|
||||
if (!strcmp(fourcc, "MCIN"))
|
||||
{
|
||||
}
|
||||
else if (!strcmp(fourcc,"MTEX"))
|
||||
else if (!strcmp(fourcc, "MTEX"))
|
||||
{
|
||||
}
|
||||
else if (!strcmp(fourcc,"MMDX"))
|
||||
else if (!strcmp(fourcc, "MMDX"))
|
||||
{
|
||||
if (size)
|
||||
{
|
||||
char *buf = new char[size];
|
||||
char* buf = new char[size];
|
||||
ADT.read(buf, size);
|
||||
char *p=buf;
|
||||
int t=0;
|
||||
char* p = buf;
|
||||
int t = 0;
|
||||
ModelInstansName = new string[size];
|
||||
while (p<buf+size)
|
||||
while (p < buf + size)
|
||||
{
|
||||
fixnamen(p,strlen(p));
|
||||
fixnamen(p, strlen(p));
|
||||
char* s = GetPlainName(p);
|
||||
fixname2(s,strlen(s));
|
||||
fixname2(s, strlen(s));
|
||||
|
||||
ModelInstansName[t++] = s;
|
||||
|
||||
string path(p);
|
||||
ExtractSingleModel(path);
|
||||
|
||||
p = p+strlen(p)+1;
|
||||
p = p + strlen(p) + 1;
|
||||
}
|
||||
delete[] buf;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(fourcc,"MWMO"))
|
||||
else if (!strcmp(fourcc, "MWMO"))
|
||||
{
|
||||
if (size)
|
||||
{
|
||||
char* buf = new char[size];
|
||||
ADT.read(buf, size);
|
||||
char* p=buf;
|
||||
char* p = buf;
|
||||
int q = 0;
|
||||
WmoInstansName = new string[size];
|
||||
while (p<buf+size)
|
||||
while (p < buf + size)
|
||||
{
|
||||
char* s = GetPlainName(p);
|
||||
fixnamen(s, strlen(s));
|
||||
@@ -160,30 +160,30 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
|
||||
}
|
||||
}
|
||||
//======================
|
||||
else if (!strcmp(fourcc,"MDDF"))
|
||||
else if (!strcmp(fourcc, "MDDF"))
|
||||
{
|
||||
if (size)
|
||||
{
|
||||
nMDX = (int)size / 36;
|
||||
for (int i=0; i<nMDX; ++i)
|
||||
for (int i = 0; i < nMDX; ++i)
|
||||
{
|
||||
uint32 id;
|
||||
ADT.read(&id, 4);
|
||||
ModelInstance inst(ADT,ModelInstansName[id].c_str(), map_num, tileX, tileY, dirfile);
|
||||
ModelInstance inst(ADT, ModelInstansName[id].c_str(), map_num, tileX, tileY, dirfile);
|
||||
}
|
||||
delete[] ModelInstansName;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(fourcc,"MODF"))
|
||||
else if (!strcmp(fourcc, "MODF"))
|
||||
{
|
||||
if (size)
|
||||
{
|
||||
nWMO = (int)size / 64;
|
||||
for (int i=0; i<nWMO; ++i)
|
||||
for (int i = 0; i < nWMO; ++i)
|
||||
{
|
||||
uint32 id;
|
||||
ADT.read(&id, 4);
|
||||
WMOInstance inst(ADT,WmoInstansName[id].c_str(), map_num, tileX, tileY, dirfile);
|
||||
WMOInstance inst(ADT, WmoInstansName[id].c_str(), map_num, tileX, tileY, dirfile);
|
||||
}
|
||||
delete[] WmoInstansName;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ typedef struct
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
}svec;
|
||||
} svec;
|
||||
|
||||
struct vec
|
||||
{
|
||||
@@ -38,9 +38,9 @@ struct triangle
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float v9[16*8+1][16*8+1];
|
||||
float v8[16*8][16*8];
|
||||
}Cell;
|
||||
float v9[16 * 8 + 1][16 * 8 + 1];
|
||||
float v8[16 * 8][16 * 8];
|
||||
} Cell;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -50,12 +50,12 @@ typedef struct
|
||||
//Liquid *lq;
|
||||
float waterlevel[9][9];
|
||||
uint8 flag;
|
||||
}chunk;
|
||||
} chunk;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
chunk ch[16][16];
|
||||
}mcell;
|
||||
} mcell;
|
||||
|
||||
struct MapChunkHeader
|
||||
{
|
||||
@@ -113,19 +113,19 @@ public:
|
||||
//void LoadMapChunks();
|
||||
|
||||
//uint32 wmo_count;
|
||||
/*
|
||||
const mcell& Getmcell() const
|
||||
{
|
||||
return Mcell;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
const mcell& Getmcell() const
|
||||
{
|
||||
return Mcell;
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
const char * GetPlainName(const char * FileName);
|
||||
char * GetPlainName(char * FileName);
|
||||
char * GetExtension(char * FileName);
|
||||
void fixnamen(char *name, size_t len);
|
||||
void fixname2(char *name, size_t len);
|
||||
const char* GetPlainName(const char* FileName);
|
||||
char* GetPlainName(char* FileName);
|
||||
char* GetExtension(char* FileName);
|
||||
void fixnamen(char* name, size_t len);
|
||||
void fixname2(char* name, size_t len);
|
||||
//void fixMapNamen(char *name, size_t len);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -27,11 +27,11 @@ bool DBCFile::open()
|
||||
return false;
|
||||
|
||||
unsigned char header[4];
|
||||
unsigned int na,nb,es,ss;
|
||||
unsigned int na, nb, es, ss;
|
||||
|
||||
f.read(header,4); // File Header
|
||||
f.read(header, 4); // File Header
|
||||
|
||||
if (header[0]!='W' || header[1]!='D' || header[2]!='B' || header[3] != 'C')
|
||||
if (header[0] != 'W' || header[1] != 'D' || header[2] != 'B' || header[3] != 'C')
|
||||
{
|
||||
f.close();
|
||||
data = nullptr;
|
||||
@@ -41,21 +41,21 @@ bool DBCFile::open()
|
||||
|
||||
//assert(header[0]=='W' && header[1]=='D' && header[2]=='B' && header[3] == 'C');
|
||||
|
||||
f.read(&na,4); // Number of records
|
||||
f.read(&nb,4); // Number of fields
|
||||
f.read(&es,4); // Size of a record
|
||||
f.read(&ss,4); // String size
|
||||
f.read(&na, 4); // Number of records
|
||||
f.read(&nb, 4); // Number of fields
|
||||
f.read(&es, 4); // Size of a record
|
||||
f.read(&ss, 4); // String size
|
||||
|
||||
recordSize = es;
|
||||
recordCount = na;
|
||||
fieldCount = nb;
|
||||
stringSize = ss;
|
||||
//assert(fieldCount*4 == recordSize);
|
||||
assert(fieldCount*4 >= recordSize);
|
||||
assert(fieldCount * 4 >= recordSize);
|
||||
|
||||
data = new unsigned char[recordSize*recordCount+stringSize];
|
||||
stringTable = data + recordSize*recordCount;
|
||||
f.read(data,recordSize*recordCount+stringSize);
|
||||
data = new unsigned char[recordSize * recordCount + stringSize];
|
||||
stringTable = data + recordSize * recordCount;
|
||||
f.read(data, recordSize * recordCount + stringSize);
|
||||
f.close();
|
||||
return true;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ DBCFile::~DBCFile()
|
||||
DBCFile::Record DBCFile::getRecord(size_t id)
|
||||
{
|
||||
assert(data);
|
||||
return Record(*this, data + id*recordSize);
|
||||
return Record(*this, data + id * recordSize);
|
||||
}
|
||||
|
||||
DBCFile::Iterator DBCFile::begin()
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
class DBCFile
|
||||
{
|
||||
public:
|
||||
DBCFile(const std::string &filename);
|
||||
DBCFile(const std::string& filename);
|
||||
~DBCFile();
|
||||
|
||||
// Open database. It must be openened before it can be used.
|
||||
@@ -25,11 +25,11 @@ public:
|
||||
class Exception
|
||||
{
|
||||
public:
|
||||
Exception(const std::string &message): message(message)
|
||||
Exception(const std::string& message): message(message)
|
||||
{ }
|
||||
virtual ~Exception()
|
||||
{ }
|
||||
const std::string &getMessage() {return message;}
|
||||
const std::string& getMessage() {return message;}
|
||||
private:
|
||||
std::string message;
|
||||
};
|
||||
@@ -56,24 +56,24 @@ public:
|
||||
float getFloat(size_t field) const
|
||||
{
|
||||
assert(field < file.fieldCount);
|
||||
return *reinterpret_cast<float*>(offset+field*4);
|
||||
return *reinterpret_cast<float*>(offset + field * 4);
|
||||
}
|
||||
unsigned int getUInt(size_t field) const
|
||||
{
|
||||
assert(field < file.fieldCount);
|
||||
return *reinterpret_cast<unsigned int*>(offset+(field*4));
|
||||
return *reinterpret_cast<unsigned int*>(offset + (field * 4));
|
||||
}
|
||||
int getInt(size_t field) const
|
||||
{
|
||||
assert(field < file.fieldCount);
|
||||
return *reinterpret_cast<int*>(offset+field*4);
|
||||
return *reinterpret_cast<int*>(offset + field * 4);
|
||||
}
|
||||
unsigned char getByte(size_t ofs) const
|
||||
{
|
||||
assert(ofs < file.recordSize);
|
||||
return *reinterpret_cast<unsigned char*>(offset+ofs);
|
||||
return *reinterpret_cast<unsigned char*>(offset + ofs);
|
||||
}
|
||||
const char *getString(size_t field) const
|
||||
const char* getString(size_t field) const
|
||||
{
|
||||
assert(field < file.fieldCount);
|
||||
size_t stringOffset = getUInt(field);
|
||||
@@ -83,9 +83,9 @@ public:
|
||||
return reinterpret_cast<char*>(file.stringTable + stringOffset);
|
||||
}
|
||||
private:
|
||||
Record(DBCFile &file, unsigned char *offset): file(file), offset(offset) {}
|
||||
DBCFile &file;
|
||||
unsigned char *offset;
|
||||
Record(DBCFile& file, unsigned char* offset): file(file), offset(offset) {}
|
||||
DBCFile& file;
|
||||
unsigned char* offset;
|
||||
|
||||
friend class DBCFile;
|
||||
friend class Iterator;
|
||||
@@ -95,24 +95,26 @@ public:
|
||||
class Iterator
|
||||
{
|
||||
public:
|
||||
Iterator(DBCFile &file, unsigned char *offset):
|
||||
Iterator(DBCFile& file, unsigned char* offset):
|
||||
record(file, offset) {}
|
||||
/// Advance (prefix only)
|
||||
Iterator & operator++() {
|
||||
Iterator& operator++()
|
||||
{
|
||||
record.offset += record.file.recordSize;
|
||||
return *this;
|
||||
}
|
||||
/// Return address of current instance
|
||||
Record const & operator*() const { return record; }
|
||||
const Record* operator->() const {
|
||||
Record const& operator*() const { return record; }
|
||||
const Record* operator->() const
|
||||
{
|
||||
return &record;
|
||||
}
|
||||
/// Comparison
|
||||
bool operator==(const Iterator &b) const
|
||||
bool operator==(const Iterator& b) const
|
||||
{
|
||||
return record.offset == b.record.offset;
|
||||
}
|
||||
bool operator!=(const Iterator &b) const
|
||||
bool operator!=(const Iterator& b) const
|
||||
{
|
||||
return record.offset != b.record.offset;
|
||||
}
|
||||
@@ -136,8 +138,8 @@ private:
|
||||
size_t recordCount;
|
||||
size_t fieldCount;
|
||||
size_t stringSize;
|
||||
unsigned char *data;
|
||||
unsigned char *stringTable;
|
||||
unsigned char* data;
|
||||
unsigned char* stringTable;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
|
||||
bool ExtractSingleModel(std::string& fname)
|
||||
{
|
||||
char * name = GetPlainName((char*)fname.c_str());
|
||||
char * ext = GetExtension(name);
|
||||
char* name = GetPlainName((char*)fname.c_str());
|
||||
char* ext = GetExtension(name);
|
||||
|
||||
// < 3.1.0 ADT MMDX section store filename.mdx filenames for corresponded .m2 file
|
||||
if (!strcmp(ext, ".mdx"))
|
||||
{
|
||||
// replace .mdx -> .m2
|
||||
fname.erase(fname.length()-2,2);
|
||||
fname.erase(fname.length() - 2, 2);
|
||||
fname.append("2");
|
||||
}
|
||||
// >= 3.1.0 ADT MMDX section store filename.m2 filenames for corresponded .m2 file
|
||||
@@ -71,10 +71,10 @@ void ExtractGameobjectModels()
|
||||
continue;
|
||||
|
||||
fixnamen((char*)path.c_str(), path.size());
|
||||
char * name = GetPlainName((char*)path.c_str());
|
||||
char* name = GetPlainName((char*)path.c_str());
|
||||
fixname2(name, strlen(name));
|
||||
|
||||
char * ch_ext = GetExtension(name);
|
||||
char* ch_ext = GetExtension(name);
|
||||
if (!ch_ext)
|
||||
continue;
|
||||
|
||||
|
||||
@@ -42,7 +42,8 @@ typedef uint8_t uint8;
|
||||
//
|
||||
struct file_MVER
|
||||
{
|
||||
union{
|
||||
union
|
||||
{
|
||||
uint32 fcc;
|
||||
char fcc_txt[4];
|
||||
};
|
||||
@@ -50,15 +51,16 @@ struct file_MVER
|
||||
uint32 ver;
|
||||
};
|
||||
|
||||
class FileLoader{
|
||||
uint8 *data;
|
||||
class FileLoader
|
||||
{
|
||||
uint8* data;
|
||||
uint32 data_size;
|
||||
public:
|
||||
virtual bool prepareLoadedData();
|
||||
uint8 *GetData() {return data;}
|
||||
uint8* GetData() {return data;}
|
||||
uint32 GetDataSize() {return data_size;}
|
||||
|
||||
file_MVER *version;
|
||||
file_MVER* version;
|
||||
FileLoader();
|
||||
~FileLoader();
|
||||
bool loadFile(std::string const& filename, bool log = true);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
|
||||
Model::Model(std::string &filename) : filename(filename), vertices(0), indices(0)
|
||||
Model::Model(std::string& filename) : filename(filename), vertices(0), indices(0)
|
||||
{
|
||||
memset(&header, 0, sizeof(header));
|
||||
}
|
||||
@@ -37,13 +37,13 @@ bool Model::open()
|
||||
f.seek(0);
|
||||
f.seekRelative(header.ofsBoundingVertices);
|
||||
vertices = new Vec3D[header.nBoundingVertices];
|
||||
f.read(vertices,header.nBoundingVertices*12);
|
||||
for (uint32 i=0; i<header.nBoundingVertices; i++)
|
||||
f.read(vertices, header.nBoundingVertices * 12);
|
||||
for (uint32 i = 0; i < header.nBoundingVertices; i++)
|
||||
vertices[i] = fixCoordSystem(vertices[i]);
|
||||
f.seek(0);
|
||||
f.seekRelative(header.ofsBoundingTriangles);
|
||||
indices = new uint16[header.nBoundingTriangles];
|
||||
f.read(indices,header.nBoundingTriangles*2);
|
||||
f.read(indices, header.nBoundingTriangles * 2);
|
||||
f.close();
|
||||
}
|
||||
else
|
||||
@@ -55,32 +55,32 @@ bool Model::open()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Model::ConvertToVMAPModel(const char * outfilename)
|
||||
bool Model::ConvertToVMAPModel(const char* outfilename)
|
||||
{
|
||||
int N[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
FILE* output=fopen(outfilename, "wb");
|
||||
int N[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
FILE* output = fopen(outfilename, "wb");
|
||||
if (!output)
|
||||
{
|
||||
printf("Can't create the output file '%s'\n",outfilename);
|
||||
printf("Can't create the output file '%s'\n", outfilename);
|
||||
return false;
|
||||
}
|
||||
fwrite(szRawVMAPMagic, 8, 1, output);
|
||||
uint32 nVertices = header.nBoundingVertices;
|
||||
fwrite(&nVertices, sizeof(int), 1, output);
|
||||
uint32 nofgroups = 1;
|
||||
fwrite(&nofgroups,sizeof(uint32), 1, output);
|
||||
fwrite(N,4*3,1,output);// rootwmoid, flags, groupid
|
||||
fwrite(N,sizeof(float),3*2,output);//bbox, only needed for WMO currently
|
||||
fwrite(N,4,1,output);// liquidflags
|
||||
fwrite("GRP ",4,1,output);
|
||||
fwrite(&nofgroups, sizeof(uint32), 1, output);
|
||||
fwrite(N, 4 * 3, 1, output); // rootwmoid, flags, groupid
|
||||
fwrite(N, sizeof(float), 3 * 2, output); //bbox, only needed for WMO currently
|
||||
fwrite(N, 4, 1, output); // liquidflags
|
||||
fwrite("GRP ", 4, 1, output);
|
||||
uint32 branches = 1;
|
||||
int wsize;
|
||||
wsize = sizeof(branches) + sizeof(uint32) * branches;
|
||||
fwrite(&wsize, sizeof(int), 1, output);
|
||||
fwrite(&branches,sizeof(branches), 1, output);
|
||||
fwrite(&branches, sizeof(branches), 1, output);
|
||||
uint32 nIndexes = header.nBoundingTriangles;
|
||||
fwrite(&nIndexes,sizeof(uint32), 1, output);
|
||||
fwrite("INDX",4, 1, output);
|
||||
fwrite(&nIndexes, sizeof(uint32), 1, output);
|
||||
fwrite("INDX", 4, 1, output);
|
||||
wsize = sizeof(uint32) + sizeof(unsigned short) * nIndexes;
|
||||
fwrite(&wsize, sizeof(int), 1, output);
|
||||
fwrite(&nIndexes, sizeof(uint32), 1, output);
|
||||
@@ -101,7 +101,7 @@ bool Model::ConvertToVMAPModel(const char * outfilename)
|
||||
wsize = sizeof(int) + sizeof(float) * 3 * nVertices;
|
||||
fwrite(&wsize, sizeof(int), 1, output);
|
||||
fwrite(&nVertices, sizeof(int), 1, output);
|
||||
if (nVertices >0)
|
||||
if (nVertices > 0)
|
||||
{
|
||||
for (uint32 vpos = 0; vpos < nVertices; ++vpos)
|
||||
{
|
||||
@@ -110,7 +110,7 @@ bool Model::ConvertToVMAPModel(const char * outfilename)
|
||||
vertices[vpos].z = tmp;
|
||||
}
|
||||
|
||||
fwrite(vertices, sizeof(float)*3, nVertices, output);
|
||||
fwrite(vertices, sizeof(float) * 3, nVertices, output);
|
||||
}
|
||||
|
||||
fclose(output);
|
||||
@@ -129,7 +129,7 @@ Vec3D fixCoordSystem2(Vec3D v)
|
||||
return Vec3D(v.x, v.z, v.y);
|
||||
}
|
||||
|
||||
ModelInstance::ModelInstance(MPQFile& f, char const* ModelInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile)
|
||||
ModelInstance::ModelInstance(MPQFile& f, char const* ModelInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE* pDirfile)
|
||||
{
|
||||
float ff[3];
|
||||
f.read(&id, 4);
|
||||
@@ -175,7 +175,7 @@ ModelInstance::ModelInstance(MPQFile& f, char const* ModelInstName, uint32 mapID
|
||||
fwrite(&pos, sizeof(float), 3, pDirfile);
|
||||
fwrite(&rot, sizeof(float), 3, pDirfile);
|
||||
fwrite(&sc, sizeof(float), 1, pDirfile);
|
||||
uint32 nlen=strlen(ModelInstName);
|
||||
uint32 nlen = strlen(ModelInstName);
|
||||
fwrite(&nlen, sizeof(uint32), 1, pDirfile);
|
||||
fwrite(ModelInstName, sizeof(char), nlen, pDirfile);
|
||||
|
||||
|
||||
@@ -14,8 +14,10 @@ MPQArchive::MPQArchive(const char* filename)
|
||||
{
|
||||
int result = libmpq__archive_open(&mpq_a, filename, -1);
|
||||
printf("Opening %s\n", filename);
|
||||
if(result) {
|
||||
switch(result) {
|
||||
if(result)
|
||||
{
|
||||
switch(result)
|
||||
{
|
||||
case LIBMPQ_ERROR_OPEN :
|
||||
printf("Error opening archive '%s': Does file really exist?\n", filename);
|
||||
break;
|
||||
@@ -52,9 +54,9 @@ MPQFile::MPQFile(const char* filename):
|
||||
pointer(0),
|
||||
size(0)
|
||||
{
|
||||
for(ArchiveSet::iterator i=gOpenArchives.begin(); i!=gOpenArchives.end();++i)
|
||||
for(ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end(); ++i)
|
||||
{
|
||||
mpq_archive *mpq_a = (*i)->mpq_a;
|
||||
mpq_archive* mpq_a = (*i)->mpq_a;
|
||||
|
||||
uint32 filenum;
|
||||
if(libmpq__file_number(mpq_a, filename, &filenum)) continue;
|
||||
@@ -62,7 +64,8 @@ MPQFile::MPQFile(const char* filename):
|
||||
libmpq__file_unpacked_size(mpq_a, filenum, &size);
|
||||
|
||||
// HACK: in patch.mpq some files don't want to open and give 1 for filesize
|
||||
if (size<=1) {
|
||||
if (size <= 1)
|
||||
{
|
||||
// printf("info: file %s has size %d; considered dummy file.\n", filename, size);
|
||||
eof = true;
|
||||
buffer = 0;
|
||||
@@ -85,7 +88,8 @@ size_t MPQFile::read(void* dest, size_t bytes)
|
||||
if (eof) return 0;
|
||||
|
||||
size_t rpos = pointer + bytes;
|
||||
if (rpos > size_t(size)) {
|
||||
if (rpos > size_t(size))
|
||||
{
|
||||
bytes = size - pointer;
|
||||
eof = true;
|
||||
}
|
||||
|
||||
@@ -21,28 +21,30 @@ class MPQArchive
|
||||
{
|
||||
|
||||
public:
|
||||
mpq_archive_s *mpq_a;
|
||||
mpq_archive_s* mpq_a;
|
||||
|
||||
MPQArchive(const char* filename);
|
||||
void close();
|
||||
|
||||
void GetFileListTo(vector<string>& filelist) {
|
||||
void GetFileListTo(vector<string>& filelist)
|
||||
{
|
||||
uint32_t filenum;
|
||||
if(libmpq__file_number(mpq_a, "(listfile)", &filenum)) return;
|
||||
libmpq__off_t size, transferred;
|
||||
libmpq__file_unpacked_size(mpq_a, filenum, &size);
|
||||
|
||||
char *buffer = new char[size + 1];
|
||||
char* buffer = new char[size + 1];
|
||||
buffer[size] = '\0';
|
||||
|
||||
libmpq__file_read(mpq_a, filenum, (unsigned char*)buffer, size, &transferred);
|
||||
|
||||
char seps[] = "\n";
|
||||
char *token;
|
||||
char* token;
|
||||
|
||||
token = strtok( buffer, seps );
|
||||
uint32 counter = 0;
|
||||
while ((token != nullptr) && (counter < size)) {
|
||||
while ((token != nullptr) && (counter < size))
|
||||
{
|
||||
//cout << token << endl;
|
||||
token[strlen(token) - 1] = 0;
|
||||
string s = token;
|
||||
@@ -60,8 +62,8 @@ class MPQFile
|
||||
{
|
||||
//MPQHANDLE handle;
|
||||
bool eof;
|
||||
char *buffer;
|
||||
libmpq__off_t pointer,size;
|
||||
char* buffer;
|
||||
libmpq__off_t pointer, size;
|
||||
|
||||
// disable copying
|
||||
MPQFile(const MPQFile& /*f*/) {}
|
||||
@@ -81,15 +83,15 @@ public:
|
||||
void close();
|
||||
};
|
||||
|
||||
inline void flipcc(char *fcc)
|
||||
inline void flipcc(char* fcc)
|
||||
{
|
||||
char t;
|
||||
t=fcc[0];
|
||||
fcc[0]=fcc[3];
|
||||
fcc[3]=t;
|
||||
t=fcc[1];
|
||||
fcc[1]=fcc[2];
|
||||
fcc[2]=t;
|
||||
t = fcc[0];
|
||||
fcc[0] = fcc[3];
|
||||
fcc[3] = t;
|
||||
t = fcc[1];
|
||||
fcc[1] = fcc[2];
|
||||
fcc[2] = t;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -13,39 +13,40 @@
|
||||
class Vec3D
|
||||
{
|
||||
public:
|
||||
float x,y,z;
|
||||
float x, y, z;
|
||||
|
||||
Vec3D(float x0 = 0.0f, float y0 = 0.0f, float z0 = 0.0f) : x(x0), y(y0), z(z0) {}
|
||||
|
||||
Vec3D(const Vec3D& v) : x(v.x), y(v.y), z(v.z) {}
|
||||
|
||||
Vec3D& operator= (const Vec3D &v) {
|
||||
Vec3D& operator= (const Vec3D& v)
|
||||
{
|
||||
x = v.x;
|
||||
y = v.y;
|
||||
z = v.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vec3D operator+ (const Vec3D &v) const
|
||||
Vec3D operator+ (const Vec3D& v) const
|
||||
{
|
||||
Vec3D r(x+v.x,y+v.y,z+v.z);
|
||||
Vec3D r(x + v.x, y + v.y, z + v.z);
|
||||
return r;
|
||||
}
|
||||
|
||||
Vec3D operator- (const Vec3D &v) const
|
||||
Vec3D operator- (const Vec3D& v) const
|
||||
{
|
||||
Vec3D r(x-v.x,y-v.y,z-v.z);
|
||||
Vec3D r(x - v.x, y - v.y, z - v.z);
|
||||
return r;
|
||||
}
|
||||
|
||||
float operator* (const Vec3D &v) const
|
||||
float operator* (const Vec3D& v) const
|
||||
{
|
||||
return x*v.x + y*v.y + z*v.z;
|
||||
return x * v.x + y * v.y + z * v.z;
|
||||
}
|
||||
|
||||
Vec3D operator* (float d) const
|
||||
{
|
||||
Vec3D r(x*d,y*d,z*d);
|
||||
Vec3D r(x * d, y * d, z * d);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -54,13 +55,13 @@ public:
|
||||
return v * d;
|
||||
}
|
||||
|
||||
Vec3D operator% (const Vec3D &v) const
|
||||
Vec3D operator% (const Vec3D& v) const
|
||||
{
|
||||
Vec3D r(y*v.z-z*v.y, z*v.x-x*v.z, x*v.y-y*v.x);
|
||||
Vec3D r(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x);
|
||||
return r;
|
||||
}
|
||||
|
||||
Vec3D& operator+= (const Vec3D &v)
|
||||
Vec3D& operator+= (const Vec3D& v)
|
||||
{
|
||||
x += v.x;
|
||||
y += v.y;
|
||||
@@ -68,7 +69,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vec3D& operator-= (const Vec3D &v)
|
||||
Vec3D& operator-= (const Vec3D& v)
|
||||
{
|
||||
x -= v.x;
|
||||
y -= v.y;
|
||||
@@ -86,17 +87,17 @@ public:
|
||||
|
||||
float lengthSquared() const
|
||||
{
|
||||
return x*x+y*y+z*z;
|
||||
return x * x + y * y + z * z;
|
||||
}
|
||||
|
||||
float length() const
|
||||
{
|
||||
return sqrt(x*x+y*y+z*z);
|
||||
return sqrt(x * x + y * y + z * z);
|
||||
}
|
||||
|
||||
Vec3D& normalize()
|
||||
{
|
||||
this->operator*= (1.0f/length());
|
||||
this->operator*= (1.0f / length());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -119,7 +120,7 @@ public:
|
||||
return out;
|
||||
}
|
||||
|
||||
operator float*()
|
||||
operator float* ()
|
||||
{
|
||||
return (float*)this;
|
||||
}
|
||||
@@ -129,38 +130,39 @@ public:
|
||||
class Vec2D
|
||||
{
|
||||
public:
|
||||
float x,y;
|
||||
float x, y;
|
||||
|
||||
Vec2D(float x0 = 0.0f, float y0 = 0.0f) : x(x0), y(y0) {}
|
||||
|
||||
Vec2D(const Vec2D& v) : x(v.x), y(v.y) {}
|
||||
|
||||
Vec2D& operator= (const Vec2D &v) {
|
||||
Vec2D& operator= (const Vec2D& v)
|
||||
{
|
||||
x = v.x;
|
||||
y = v.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vec2D operator+ (const Vec2D &v) const
|
||||
Vec2D operator+ (const Vec2D& v) const
|
||||
{
|
||||
Vec2D r(x+v.x,y+v.y);
|
||||
Vec2D r(x + v.x, y + v.y);
|
||||
return r;
|
||||
}
|
||||
|
||||
Vec2D operator- (const Vec2D &v) const
|
||||
Vec2D operator- (const Vec2D& v) const
|
||||
{
|
||||
Vec2D r(x-v.x,y-v.y);
|
||||
Vec2D r(x - v.x, y - v.y);
|
||||
return r;
|
||||
}
|
||||
|
||||
float operator* (const Vec2D &v) const
|
||||
float operator* (const Vec2D& v) const
|
||||
{
|
||||
return x*v.x + y*v.y;
|
||||
return x * v.x + y * v.y;
|
||||
}
|
||||
|
||||
Vec2D operator* (float d) const
|
||||
{
|
||||
Vec2D r(x*d,y*d);
|
||||
Vec2D r(x * d, y * d);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -169,14 +171,14 @@ public:
|
||||
return v * d;
|
||||
}
|
||||
|
||||
Vec2D& operator+= (const Vec2D &v)
|
||||
Vec2D& operator+= (const Vec2D& v)
|
||||
{
|
||||
x += v.x;
|
||||
y += v.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vec2D& operator-= (const Vec2D &v)
|
||||
Vec2D& operator-= (const Vec2D& v)
|
||||
{
|
||||
x -= v.x;
|
||||
y -= v.y;
|
||||
@@ -192,17 +194,17 @@ public:
|
||||
|
||||
float lengthSquared() const
|
||||
{
|
||||
return x*x+y*y;
|
||||
return x * x + y * y;
|
||||
}
|
||||
|
||||
float length() const
|
||||
{
|
||||
return sqrt(x*x+y*y);
|
||||
return sqrt(x * x + y * y);
|
||||
}
|
||||
|
||||
Vec2D& normalize()
|
||||
{
|
||||
this->operator*= (1.0f/length());
|
||||
this->operator*= (1.0f / length());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -220,17 +222,17 @@ public:
|
||||
return in;
|
||||
}
|
||||
|
||||
operator float*()
|
||||
operator float* ()
|
||||
{
|
||||
return (float*)this;
|
||||
}
|
||||
};
|
||||
|
||||
inline void rotate(float x0, float y0, float *x, float *y, float angle)
|
||||
inline void rotate(float x0, float y0, float* x, float* y, float angle)
|
||||
{
|
||||
float xa = *x - x0, ya = *y - y0;
|
||||
*x = xa*cosf(angle) - ya*sinf(angle) + x0;
|
||||
*y = xa*sinf(angle) + ya*cosf(angle) + y0;
|
||||
*x = xa * cosf(angle) - ya * sinf(angle) + x0;
|
||||
*y = xa * sinf(angle) + ya * cosf(angle) + y0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#include <sys/stat.h>
|
||||
#include <direct.h>
|
||||
#define mkdir _mkdir
|
||||
#include <Windows.h>
|
||||
#include <sys/stat.h>
|
||||
#include <direct.h>
|
||||
#define mkdir _mkdir
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#undef min
|
||||
@@ -50,13 +50,13 @@ typedef struct
|
||||
{
|
||||
char name[64];
|
||||
unsigned int id;
|
||||
}map_id;
|
||||
} map_id;
|
||||
|
||||
map_id * map_ids;
|
||||
uint16 *LiqType = 0;
|
||||
map_id* map_ids;
|
||||
uint16* LiqType = 0;
|
||||
uint32 map_count;
|
||||
char output_path[128]=".";
|
||||
char input_path[1024]=".";
|
||||
char output_path[128] = ".";
|
||||
char input_path[1024] = ".";
|
||||
bool hasInputPathParam = false;
|
||||
bool preciseVectorData = false;
|
||||
|
||||
@@ -82,7 +82,7 @@ void strToLower(char* str)
|
||||
{
|
||||
while(*str)
|
||||
{
|
||||
*str=tolower(*str);
|
||||
*str = tolower(*str);
|
||||
++str;
|
||||
}
|
||||
}
|
||||
@@ -138,9 +138,9 @@ bool ExtractSingleWmo(std::string& fname)
|
||||
// Copy files from archive
|
||||
|
||||
char szLocalFile[1024];
|
||||
const char * plain_name = GetPlainName(fname.c_str());
|
||||
const char* plain_name = GetPlainName(fname.c_str());
|
||||
sprintf(szLocalFile, "%s/%s", szWorkDirWmo, plain_name);
|
||||
fixnamen(szLocalFile,strlen(szLocalFile));
|
||||
fixnamen(szLocalFile, strlen(szLocalFile));
|
||||
|
||||
if (FileExists(szLocalFile))
|
||||
return true;
|
||||
@@ -171,7 +171,7 @@ bool ExtractSingleWmo(std::string& fname)
|
||||
printf("Couldn't open RootWmo!!!\n");
|
||||
return true;
|
||||
}
|
||||
FILE *output = fopen(szLocalFile,"wb");
|
||||
FILE* output = fopen(szLocalFile, "wb");
|
||||
if(!output)
|
||||
{
|
||||
printf("couldn't open %s for writing!\n", szLocalFile);
|
||||
@@ -180,13 +180,13 @@ bool ExtractSingleWmo(std::string& fname)
|
||||
froot.ConvertToVMAPRootWmo(output);
|
||||
int Wmo_nVertices = 0;
|
||||
//printf("root has %d groups\n", froot->nGroups);
|
||||
if (froot.nGroups !=0)
|
||||
if (froot.nGroups != 0)
|
||||
{
|
||||
for (uint32 i = 0; i < froot.nGroups; ++i)
|
||||
{
|
||||
char temp[1024];
|
||||
strncpy(temp, fname.c_str(), 1024);
|
||||
temp[fname.length()-4] = 0;
|
||||
temp[fname.length() - 4] = 0;
|
||||
char groupFileName[1024];
|
||||
int ret = snprintf(groupFileName, 1024, "%s_%03u.wmo", temp, i);
|
||||
if (ret < 0)
|
||||
@@ -210,7 +210,7 @@ bool ExtractSingleWmo(std::string& fname)
|
||||
}
|
||||
|
||||
fseek(output, 8, SEEK_SET); // store the correct no of vertices
|
||||
fwrite(&Wmo_nVertices,sizeof(int),1,output);
|
||||
fwrite(&Wmo_nVertices, sizeof(int), 1, output);
|
||||
fclose(output);
|
||||
|
||||
// Delete the extracted file in the case of an error
|
||||
@@ -224,19 +224,19 @@ void ParsMapFiles()
|
||||
char fn[512];
|
||||
//char id_filename[64];
|
||||
char id[10];
|
||||
for (unsigned int i=0; i<map_count; ++i)
|
||||
for (unsigned int i = 0; i < map_count; ++i)
|
||||
{
|
||||
sprintf(id,"%03u",map_ids[i].id);
|
||||
sprintf(fn,"World\\Maps\\%s\\%s.wdt", map_ids[i].name, map_ids[i].name);
|
||||
WDTFile WDT(fn,map_ids[i].name);
|
||||
sprintf(id, "%03u", map_ids[i].id);
|
||||
sprintf(fn, "World\\Maps\\%s\\%s.wdt", map_ids[i].name, map_ids[i].name);
|
||||
WDTFile WDT(fn, map_ids[i].name);
|
||||
if(WDT.init(id, map_ids[i].id))
|
||||
{
|
||||
printf("Processing Map %u\n[", map_ids[i].id);
|
||||
for (int x=0; x<64; ++x)
|
||||
for (int x = 0; x < 64; ++x)
|
||||
{
|
||||
for (int y=0; y<64; ++y)
|
||||
for (int y = 0; y < 64; ++y)
|
||||
{
|
||||
if (ADTFile *ADT = WDT.GetMap(x,y))
|
||||
if (ADTFile* ADT = WDT.GetMap(x, y))
|
||||
{
|
||||
//sprintf(id_filename,"%02u %02u %03u",x,y,map_ids[i].id);//!!!!!!!!!
|
||||
ADT->init(map_ids[i].id, x, y);
|
||||
@@ -254,9 +254,9 @@ void ParsMapFiles()
|
||||
void getGamePath()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
strcpy(input_path,"Data\\");
|
||||
strcpy(input_path, "Data\\");
|
||||
#else
|
||||
strcpy(input_path,"Data/");
|
||||
strcpy(input_path, "Data/");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool processArgv(int argc, char ** argv, const char *versionString)
|
||||
bool processArgv(int argc, char** argv, const char* versionString)
|
||||
{
|
||||
bool result = true;
|
||||
hasInputPathParam = false;
|
||||
@@ -389,16 +389,16 @@ bool processArgv(int argc, char ** argv, const char *versionString)
|
||||
|
||||
for(int i = 1; i < argc; ++i)
|
||||
{
|
||||
if(strcmp("-s",argv[i]) == 0)
|
||||
if(strcmp("-s", argv[i]) == 0)
|
||||
{
|
||||
preciseVectorData = false;
|
||||
}
|
||||
else if(strcmp("-d",argv[i]) == 0)
|
||||
else if(strcmp("-d", argv[i]) == 0)
|
||||
{
|
||||
if((i+1)<argc)
|
||||
if((i + 1) < argc)
|
||||
{
|
||||
hasInputPathParam = true;
|
||||
strcpy(input_path, argv[i+1]);
|
||||
strcpy(input_path, argv[i + 1]);
|
||||
if (input_path[strlen(input_path) - 1] != '\\' && input_path[strlen(input_path) - 1] != '/')
|
||||
strcat(input_path, "/");
|
||||
++i;
|
||||
@@ -408,11 +408,11 @@ bool processArgv(int argc, char ** argv, const char *versionString)
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
else if(strcmp("-?",argv[1]) == 0)
|
||||
else if(strcmp("-?", argv[1]) == 0)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
else if(strcmp("-l",argv[i]) == 0)
|
||||
else if(strcmp("-l", argv[i]) == 0)
|
||||
{
|
||||
preciseVectorData = true;
|
||||
}
|
||||
@@ -424,7 +424,7 @@ bool processArgv(int argc, char ** argv, const char *versionString)
|
||||
}
|
||||
if(!result)
|
||||
{
|
||||
printf("Extract %s.\n",versionString);
|
||||
printf("Extract %s.\n", versionString);
|
||||
printf("%s [-?][-s][-l][-d <path>]\n", argv[0]);
|
||||
printf(" -s : (default) small size (data size optimization), ~500MB less vmap data.\n");
|
||||
printf(" -l : large size, ~500MB more vmap data. (might contain more details)\n");
|
||||
@@ -444,10 +444,10 @@ bool processArgv(int argc, char ** argv, const char *versionString)
|
||||
// Arg2 - Listfile name
|
||||
//
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
bool success=true;
|
||||
const char *versionString = "V4.00 2012_02";
|
||||
bool success = true;
|
||||
const char* versionString = "V4.00 2012_02";
|
||||
|
||||
// Use command line arguments, when some
|
||||
if (!processArgv(argc, argv, versionString))
|
||||
@@ -468,29 +468,29 @@ int main(int argc, char ** argv)
|
||||
}
|
||||
}
|
||||
|
||||
printf("Extract %s. Beginning work ....\n",versionString);
|
||||
printf("Extract %s. Beginning work ....\n", versionString);
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
// Create the working directory
|
||||
if (mkdir(szWorkDirWmo
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
, 0711
|
||||
, 0711
|
||||
#endif
|
||||
))
|
||||
success = (errno == EEXIST);
|
||||
))
|
||||
success = (errno == EEXIST);
|
||||
|
||||
// prepare archive name list
|
||||
std::vector<std::string> archiveNames;
|
||||
fillArchiveNameVector(archiveNames);
|
||||
for (size_t i=0; i < archiveNames.size(); ++i)
|
||||
for (size_t i = 0; i < archiveNames.size(); ++i)
|
||||
{
|
||||
MPQArchive *archive = new MPQArchive(archiveNames[i].c_str());
|
||||
MPQArchive* archive = new MPQArchive(archiveNames[i].c_str());
|
||||
if (gOpenArchives.empty() || gOpenArchives.front() != archive)
|
||||
delete archive;
|
||||
}
|
||||
|
||||
if (gOpenArchives.empty())
|
||||
{
|
||||
printf("FATAL ERROR: None MPQ archive found by path '%s'. Use -d option with proper path.\n",input_path);
|
||||
printf("FATAL ERROR: None MPQ archive found by path '%s'. Use -d option with proper path.\n", input_path);
|
||||
return 1;
|
||||
}
|
||||
ReadLiquidTypeTableDBC();
|
||||
@@ -503,20 +503,20 @@ int main(int argc, char ** argv)
|
||||
//map.dbc
|
||||
if (success)
|
||||
{
|
||||
DBCFile * dbc = new DBCFile("DBFilesClient\\Map.dbc");
|
||||
DBCFile* dbc = new DBCFile("DBFilesClient\\Map.dbc");
|
||||
if (!dbc->open())
|
||||
{
|
||||
delete dbc;
|
||||
printf("FATAL ERROR: Map.dbc not found in data file.\n");
|
||||
return 1;
|
||||
}
|
||||
map_count=dbc->getRecordCount ();
|
||||
map_ids=new map_id[map_count];
|
||||
for (unsigned int x=0;x<map_count;++x)
|
||||
map_count = dbc->getRecordCount ();
|
||||
map_ids = new map_id[map_count];
|
||||
for (unsigned int x = 0; x < map_count; ++x)
|
||||
{
|
||||
map_ids[x].id=dbc->getRecord (x).getUInt(0);
|
||||
strcpy(map_ids[x].name,dbc->getRecord(x).getString(1));
|
||||
printf("Map - %s\n",map_ids[x].name);
|
||||
map_ids[x].id = dbc->getRecord (x).getUInt(0);
|
||||
strcpy(map_ids[x].name, dbc->getRecord(x).getString(1));
|
||||
printf("Map - %s\n", map_ids[x].name);
|
||||
}
|
||||
|
||||
|
||||
@@ -531,11 +531,11 @@ int main(int argc, char ** argv)
|
||||
printf("\n");
|
||||
if (!success)
|
||||
{
|
||||
printf("ERROR: Extract %s. Work NOT complete.\n Precise vector data=%d.\nPress any key.\n",versionString, preciseVectorData);
|
||||
printf("ERROR: Extract %s. Work NOT complete.\n Precise vector data=%d.\nPress any key.\n", versionString, preciseVectorData);
|
||||
getchar();
|
||||
}
|
||||
|
||||
printf("Extract %s. Work complete. No errors.\n",versionString);
|
||||
printf("Extract %s. Work complete. No errors.\n", versionString);
|
||||
delete [] LiqType;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
enum ModelFlags
|
||||
{
|
||||
MOD_M2 = 1,
|
||||
MOD_WORLDSPAWN = 1<<1,
|
||||
MOD_HAS_BOUND = 1<<2
|
||||
MOD_WORLDSPAWN = 1 << 1,
|
||||
MOD_HAS_BOUND = 1 << 2
|
||||
};
|
||||
|
||||
extern const char * szWorkDirWmo;
|
||||
extern const char * szRawVMAPMagic; // vmap magic string for extracted raw vmap data
|
||||
extern const char* szWorkDirWmo;
|
||||
extern const char* szRawVMAPMagic; // vmap magic string for extracted raw vmap data
|
||||
|
||||
bool FileExists(const char * file);
|
||||
bool FileExists(const char* file);
|
||||
void strToLower(char* str);
|
||||
|
||||
bool ExtractSingleWmo(std::string& fname);
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include "adtfile.h"
|
||||
#include <cstdio>
|
||||
|
||||
char * wdtGetPlainName(char * FileName)
|
||||
char* wdtGetPlainName(char* FileName)
|
||||
{
|
||||
char * szTemp;
|
||||
char* szTemp;
|
||||
|
||||
if((szTemp = strrchr(FileName, '\\')) != nullptr)
|
||||
FileName = szTemp + 1;
|
||||
@@ -20,7 +20,7 @@ char * wdtGetPlainName(char * FileName)
|
||||
|
||||
WDTFile::WDTFile(char* file_name, char* file_name1) : WDT(file_name), gWmoInstansName(nullptr), gnWMO(0)
|
||||
{
|
||||
filename.append(file_name1,strlen(file_name1));
|
||||
filename.append(file_name1, strlen(file_name1));
|
||||
}
|
||||
|
||||
bool WDTFile::init(char* /*map_id*/, unsigned int mapID)
|
||||
@@ -35,7 +35,7 @@ bool WDTFile::init(char* /*map_id*/, unsigned int mapID)
|
||||
uint32 size;
|
||||
|
||||
std::string dirname = std::string(szWorkDirWmo) + "/dir_bin";
|
||||
FILE *dirfile;
|
||||
FILE* dirfile;
|
||||
dirfile = fopen(dirname.c_str(), "ab");
|
||||
if(!dirfile)
|
||||
{
|
||||
@@ -45,7 +45,7 @@ bool WDTFile::init(char* /*map_id*/, unsigned int mapID)
|
||||
|
||||
while (!WDT.isEof())
|
||||
{
|
||||
WDT.read(fourcc,4);
|
||||
WDT.read(fourcc, 4);
|
||||
WDT.read(&size, 4);
|
||||
|
||||
flipcc(fourcc);
|
||||
@@ -53,24 +53,24 @@ bool WDTFile::init(char* /*map_id*/, unsigned int mapID)
|
||||
|
||||
size_t nextpos = WDT.getPos() + size;
|
||||
|
||||
if (!strcmp(fourcc,"MAIN"))
|
||||
if (!strcmp(fourcc, "MAIN"))
|
||||
{
|
||||
}
|
||||
if (!strcmp(fourcc,"MWMO"))
|
||||
if (!strcmp(fourcc, "MWMO"))
|
||||
{
|
||||
// global map objects
|
||||
if (size)
|
||||
{
|
||||
char *buf = new char[size];
|
||||
char* buf = new char[size];
|
||||
WDT.read(buf, size);
|
||||
char *p=buf;
|
||||
char* p = buf;
|
||||
int q = 0;
|
||||
gWmoInstansName = new string[size];
|
||||
while (p < buf + size)
|
||||
{
|
||||
char* s=wdtGetPlainName(p);
|
||||
fixnamen(s,strlen(s));
|
||||
p=p+strlen(p)+1;
|
||||
char* s = wdtGetPlainName(p);
|
||||
fixnamen(s, strlen(s));
|
||||
p = p + strlen(p) + 1;
|
||||
gWmoInstansName[q++] = s;
|
||||
}
|
||||
delete[] buf;
|
||||
@@ -87,7 +87,7 @@ bool WDTFile::init(char* /*map_id*/, unsigned int mapID)
|
||||
{
|
||||
int id;
|
||||
WDT.read(&id, 4);
|
||||
WMOInstance inst(WDT,gWmoInstansName[id].c_str(), mapID, 65, 65, dirfile);
|
||||
WMOInstance inst(WDT, gWmoInstansName[id].c_str(), mapID, 65, 65, dirfile);
|
||||
}
|
||||
|
||||
delete[] gWmoInstansName;
|
||||
@@ -108,11 +108,11 @@ WDTFile::~WDTFile(void)
|
||||
|
||||
ADTFile* WDTFile::GetMap(int x, int z)
|
||||
{
|
||||
if(!(x>=0 && z >= 0 && x<64 && z<64))
|
||||
if(!(x >= 0 && z >= 0 && x < 64 && z < 64))
|
||||
return nullptr;
|
||||
|
||||
char name[512];
|
||||
|
||||
sprintf(name,"World\\Maps\\%s\\%s_%d_%d.adt", filename.c_str(), filename.c_str(), x, z);
|
||||
sprintf(name, "World\\Maps\\%s\\%s_%d_%d.adt", filename.c_str(), filename.c_str(), x, z);
|
||||
return new ADTFile(name);
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
#include "mpq_libmpq04.h"
|
||||
|
||||
using namespace std;
|
||||
extern uint16 *LiqType;
|
||||
extern uint16* LiqType;
|
||||
|
||||
WMORoot::WMORoot(std::string &filename)
|
||||
WMORoot::WMORoot(std::string& filename)
|
||||
: filename(filename), col(0), nTextures(0), nGroups(0), nP(0), nLights(0),
|
||||
nModels(0), nDoodads(0), nDoodadSets(0), RootWMOID(0), liquidType(0)
|
||||
nModels(0), nDoodads(0), nDoodadSets(0), RootWMOID(0), liquidType(0)
|
||||
{
|
||||
memset(bbcorn1, 0, sizeof(bbcorn1));
|
||||
memset(bbcorn2, 0, sizeof(bbcorn2));
|
||||
@@ -41,7 +41,7 @@ bool WMORoot::open()
|
||||
|
||||
while (!f.isEof())
|
||||
{
|
||||
f.read(fourcc,4);
|
||||
f.read(fourcc, 4);
|
||||
f.read(&size, 4);
|
||||
|
||||
flipcc(fourcc);
|
||||
@@ -49,7 +49,7 @@ bool WMORoot::open()
|
||||
|
||||
size_t nextpos = f.getPos() + size;
|
||||
|
||||
if (!strcmp(fourcc,"MOHD")) // header
|
||||
if (!strcmp(fourcc, "MOHD")) // header
|
||||
{
|
||||
f.read(&nTextures, 4);
|
||||
f.read(&nGroups, 4);
|
||||
@@ -118,13 +118,13 @@ bool WMORoot::ConvertToVMAPRootWmo(FILE* pOutfile)
|
||||
|
||||
fwrite(szRawVMAPMagic, 1, 8, pOutfile);
|
||||
unsigned int nVectors = 0;
|
||||
fwrite(&nVectors,sizeof(nVectors), 1, pOutfile); // will be filled later
|
||||
fwrite(&nVectors, sizeof(nVectors), 1, pOutfile); // will be filled later
|
||||
fwrite(&nGroups, 4, 1, pOutfile);
|
||||
fwrite(&RootWMOID, 4, 1, pOutfile);
|
||||
return true;
|
||||
}
|
||||
|
||||
WMOGroup::WMOGroup(const std::string &filename) :
|
||||
WMOGroup::WMOGroup(const std::string& filename) :
|
||||
filename(filename), MOPY(0), MOVI(0), MoviEx(0), MOVT(0), MOBA(0), MobaEx(0),
|
||||
hlq(0), LiquEx(0), LiquBytes(0), groupName(0), descGroupName(0), mogpFlags(0),
|
||||
moprIdx(0), moprNItems(0), nBatchA(0), nBatchB(0), nBatchC(0), fogIdx(0),
|
||||
@@ -147,10 +147,10 @@ bool WMOGroup::open()
|
||||
char fourcc[5];
|
||||
while (!f.isEof())
|
||||
{
|
||||
f.read(fourcc,4);
|
||||
f.read(fourcc, 4);
|
||||
f.read(&size, 4);
|
||||
flipcc(fourcc);
|
||||
if (!strcmp(fourcc,"MOGP"))//Fix sizeoff = Data size.
|
||||
if (!strcmp(fourcc, "MOGP")) //Fix sizeoff = Data size.
|
||||
{
|
||||
size = 68;
|
||||
}
|
||||
@@ -159,7 +159,7 @@ bool WMOGroup::open()
|
||||
LiquEx_size = 0;
|
||||
liquflags = 0;
|
||||
|
||||
if (!strcmp(fourcc,"MOGP"))//header
|
||||
if (!strcmp(fourcc, "MOGP")) //header
|
||||
{
|
||||
f.read(&groupName, 4);
|
||||
f.read(&descGroupName, 4);
|
||||
@@ -173,40 +173,40 @@ bool WMOGroup::open()
|
||||
f.read(&nBatchC, 4);
|
||||
f.read(&fogIdx, 4);
|
||||
f.read(&liquidType, 4);
|
||||
f.read(&groupWMOID,4);
|
||||
f.read(&groupWMOID, 4);
|
||||
|
||||
}
|
||||
else if (!strcmp(fourcc,"MOPY"))
|
||||
else if (!strcmp(fourcc, "MOPY"))
|
||||
{
|
||||
MOPY = new char[size];
|
||||
mopy_size = size;
|
||||
nTriangles = (int)size / 2;
|
||||
f.read(MOPY, size);
|
||||
}
|
||||
else if (!strcmp(fourcc,"MOVI"))
|
||||
else if (!strcmp(fourcc, "MOVI"))
|
||||
{
|
||||
MOVI = new uint16[size/2];
|
||||
MOVI = new uint16[size / 2];
|
||||
f.read(MOVI, size);
|
||||
}
|
||||
else if (!strcmp(fourcc,"MOVT"))
|
||||
else if (!strcmp(fourcc, "MOVT"))
|
||||
{
|
||||
MOVT = new float[size/4];
|
||||
MOVT = new float[size / 4];
|
||||
f.read(MOVT, size);
|
||||
nVertices = (int)size / 12;
|
||||
}
|
||||
else if (!strcmp(fourcc,"MONR"))
|
||||
else if (!strcmp(fourcc, "MONR"))
|
||||
{
|
||||
}
|
||||
else if (!strcmp(fourcc,"MOTV"))
|
||||
else if (!strcmp(fourcc, "MOTV"))
|
||||
{
|
||||
}
|
||||
else if (!strcmp(fourcc,"MOBA"))
|
||||
else if (!strcmp(fourcc, "MOBA"))
|
||||
{
|
||||
MOBA = new uint16[size/2];
|
||||
moba_size = size/2;
|
||||
MOBA = new uint16[size / 2];
|
||||
moba_size = size / 2;
|
||||
f.read(MOBA, size);
|
||||
}
|
||||
else if (!strcmp(fourcc,"MLIQ"))
|
||||
else if (!strcmp(fourcc, "MLIQ"))
|
||||
{
|
||||
liquflags |= 1;
|
||||
hlq = new WMOLiquidHeader();
|
||||
@@ -231,36 +231,36 @@ bool WMOGroup::open()
|
||||
return true;
|
||||
}
|
||||
|
||||
int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool preciseVectorData)
|
||||
int WMOGroup::ConvertToVMAPGroupWmo(FILE* output, WMORoot* rootWMO, bool preciseVectorData)
|
||||
{
|
||||
fwrite(&mogpFlags,sizeof(uint32),1,output);
|
||||
fwrite(&groupWMOID,sizeof(uint32),1,output);
|
||||
fwrite(&mogpFlags, sizeof(uint32), 1, output);
|
||||
fwrite(&groupWMOID, sizeof(uint32), 1, output);
|
||||
// group bound
|
||||
fwrite(bbcorn1, sizeof(float), 3, output);
|
||||
fwrite(bbcorn2, sizeof(float), 3, output);
|
||||
fwrite(&liquflags,sizeof(uint32),1,output);
|
||||
fwrite(&liquflags, sizeof(uint32), 1, output);
|
||||
int nColTriangles = 0;
|
||||
if (preciseVectorData)
|
||||
{
|
||||
char GRP[] = "GRP ";
|
||||
fwrite(GRP,1,4,output);
|
||||
fwrite(GRP, 1, 4, output);
|
||||
|
||||
int k = 0;
|
||||
int moba_batch = moba_size/12;
|
||||
MobaEx = new int[moba_batch*4];
|
||||
for(int i=8; i<moba_size; i+=12)
|
||||
int moba_batch = moba_size / 12;
|
||||
MobaEx = new int[moba_batch * 4];
|
||||
for(int i = 8; i < moba_size; i += 12)
|
||||
{
|
||||
MobaEx[k++] = MOBA[i];
|
||||
}
|
||||
int moba_size_grp = moba_batch*4+4;
|
||||
fwrite(&moba_size_grp,4,1,output);
|
||||
fwrite(&moba_batch,4,1,output);
|
||||
fwrite(MobaEx,4,k,output);
|
||||
int moba_size_grp = moba_batch * 4 + 4;
|
||||
fwrite(&moba_size_grp, 4, 1, output);
|
||||
fwrite(&moba_batch, 4, 1, output);
|
||||
fwrite(MobaEx, 4, k, output);
|
||||
delete [] MobaEx;
|
||||
|
||||
uint32 nIdexes = nTriangles * 3;
|
||||
|
||||
if(fwrite("INDX",4, 1, output) != 1)
|
||||
if(fwrite("INDX", 4, 1, output) != 1)
|
||||
{
|
||||
printf("Error while writing file nbraches ID");
|
||||
exit(0);
|
||||
@@ -276,7 +276,7 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool precise
|
||||
printf("Error while writing file nIndexes");
|
||||
exit(0);
|
||||
}
|
||||
if(nIdexes >0)
|
||||
if(nIdexes > 0)
|
||||
{
|
||||
if(fwrite(MOVI, sizeof(unsigned short), nIdexes, output) != nIdexes)
|
||||
{
|
||||
@@ -285,7 +285,7 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool precise
|
||||
}
|
||||
}
|
||||
|
||||
if(fwrite("VERT",4, 1, output) != 1)
|
||||
if(fwrite("VERT", 4, 1, output) != 1)
|
||||
{
|
||||
printf("Error while writing file nbraches ID");
|
||||
exit(0);
|
||||
@@ -301,9 +301,9 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool precise
|
||||
printf("Error while writing file nVertices");
|
||||
exit(0);
|
||||
}
|
||||
if(nVertices >0)
|
||||
if(nVertices > 0)
|
||||
{
|
||||
if(fwrite(MOVT, sizeof(float)*3, nVertices, output) != nVertices)
|
||||
if(fwrite(MOVT, sizeof(float) * 3, nVertices, output) != nVertices)
|
||||
{
|
||||
printf("Error while writing file vectors");
|
||||
exit(0);
|
||||
@@ -315,27 +315,27 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool precise
|
||||
else
|
||||
{
|
||||
char GRP[] = "GRP ";
|
||||
fwrite(GRP,1,4,output);
|
||||
fwrite(GRP, 1, 4, output);
|
||||
int k = 0;
|
||||
int moba_batch = moba_size/12;
|
||||
MobaEx = new int[moba_batch*4];
|
||||
for(int i=8; i<moba_size; i+=12)
|
||||
int moba_batch = moba_size / 12;
|
||||
MobaEx = new int[moba_batch * 4];
|
||||
for(int i = 8; i < moba_size; i += 12)
|
||||
{
|
||||
MobaEx[k++] = MOBA[i];
|
||||
}
|
||||
|
||||
int moba_size_grp = moba_batch*4+4;
|
||||
fwrite(&moba_size_grp,4,1,output);
|
||||
fwrite(&moba_batch,4,1,output);
|
||||
fwrite(MobaEx,4,k,output);
|
||||
int moba_size_grp = moba_batch * 4 + 4;
|
||||
fwrite(&moba_size_grp, 4, 1, output);
|
||||
fwrite(&moba_batch, 4, 1, output);
|
||||
fwrite(MobaEx, 4, k, output);
|
||||
delete [] MobaEx;
|
||||
|
||||
//-------INDX------------------------------------
|
||||
//-------MOPY--------
|
||||
MoviEx = new uint16[nTriangles*3]; // "worst case" size...
|
||||
int *IndexRenum = new int[nVertices];
|
||||
memset(IndexRenum, 0xFF, nVertices*sizeof(int));
|
||||
for (int i=0; i<nTriangles; ++i)
|
||||
MoviEx = new uint16[nTriangles * 3]; // "worst case" size...
|
||||
int* IndexRenum = new int[nVertices];
|
||||
memset(IndexRenum, 0xFF, nVertices * sizeof(int));
|
||||
for (int i = 0; i < nTriangles; ++i)
|
||||
{
|
||||
// Skip no collision triangles
|
||||
bool isRenderFace = (MOPY[2 * i] & WMO_MATERIAL_RENDER) && !(MOPY[2 * i] & WMO_MATERIAL_DETAIL);
|
||||
@@ -343,17 +343,17 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool precise
|
||||
if (!isCollision)
|
||||
continue;
|
||||
// Use this triangle
|
||||
for (int j=0; j<3; ++j)
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
IndexRenum[MOVI[3*i + j]] = 1;
|
||||
MoviEx[3*nColTriangles + j] = MOVI[3*i + j];
|
||||
IndexRenum[MOVI[3 * i + j]] = 1;
|
||||
MoviEx[3 * nColTriangles + j] = MOVI[3 * i + j];
|
||||
}
|
||||
++nColTriangles;
|
||||
}
|
||||
|
||||
// assign new vertex index numbers
|
||||
int nColVertices = 0;
|
||||
for (uint32 i=0; i<nVertices; ++i)
|
||||
for (uint32 i = 0; i < nVertices; ++i)
|
||||
{
|
||||
if (IndexRenum[i] == 1)
|
||||
{
|
||||
@@ -363,26 +363,26 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool precise
|
||||
}
|
||||
|
||||
// translate triangle indices to new numbers
|
||||
for (int i=0; i<3*nColTriangles; ++i)
|
||||
for (int i = 0; i < 3 * nColTriangles; ++i)
|
||||
{
|
||||
assert(MoviEx[i] < nVertices);
|
||||
MoviEx[i] = IndexRenum[MoviEx[i]];
|
||||
}
|
||||
|
||||
// write triangle indices
|
||||
int INDX[] = {0x58444E49, nColTriangles*6+4, nColTriangles*3};
|
||||
fwrite(INDX,4,3,output);
|
||||
fwrite(MoviEx,2,nColTriangles*3,output);
|
||||
int INDX[] = {0x58444E49, nColTriangles * 6 + 4, nColTriangles * 3};
|
||||
fwrite(INDX, 4, 3, output);
|
||||
fwrite(MoviEx, 2, nColTriangles * 3, output);
|
||||
|
||||
// write vertices
|
||||
int VERT[] = {0x54524556, nColVertices*3*static_cast<int>(sizeof(float))+4, nColVertices};// "VERT"
|
||||
int check = 3*nColVertices;
|
||||
fwrite(VERT,4,3,output);
|
||||
for (uint32 i=0; i<nVertices; ++i)
|
||||
int VERT[] = {0x54524556, nColVertices * 3 * static_cast<int>(sizeof(float)) + 4, nColVertices}; // "VERT"
|
||||
int check = 3 * nColVertices;
|
||||
fwrite(VERT, 4, 3, output);
|
||||
for (uint32 i = 0; i < nVertices; ++i)
|
||||
if(IndexRenum[i] >= 0)
|
||||
check -= fwrite(MOVT+3*i, sizeof(float), 3, output);
|
||||
check -= fwrite(MOVT + 3 * i, sizeof(float), 3, output);
|
||||
|
||||
assert(check==0);
|
||||
assert(check == 0);
|
||||
|
||||
delete [] MoviEx;
|
||||
delete [] IndexRenum;
|
||||
@@ -391,7 +391,7 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool precise
|
||||
//------LIQU------------------------
|
||||
if (LiquEx_size != 0)
|
||||
{
|
||||
int LIQU_h[] = {0x5551494C, static_cast<int>(sizeof(WMOLiquidHeader) + LiquEx_size) + hlq->xtiles*hlq->ytiles};// "LIQU"
|
||||
int LIQU_h[] = {0x5551494C, static_cast<int>(sizeof(WMOLiquidHeader) + LiquEx_size) + hlq->xtiles* hlq->ytiles}; // "LIQU"
|
||||
fwrite(LIQU_h, 4, 2, output);
|
||||
|
||||
// according to WoW.Dev Wiki:
|
||||
@@ -452,10 +452,10 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool precise
|
||||
|
||||
fwrite(hlq, sizeof(WMOLiquidHeader), 1, output);
|
||||
// only need height values, the other values are unknown anyway
|
||||
for (uint32 i = 0; i<LiquEx_size/sizeof(WMOLiquidVert); ++i)
|
||||
for (uint32 i = 0; i < LiquEx_size / sizeof(WMOLiquidVert); ++i)
|
||||
fwrite(&LiquEx[i].height, sizeof(float), 1, output);
|
||||
// todo: compress to bit field
|
||||
fwrite(LiquBytes, 1, hlq->xtiles*hlq->ytiles, output);
|
||||
fwrite(LiquBytes, 1, hlq->xtiles * hlq->ytiles, output);
|
||||
}
|
||||
|
||||
return nColTriangles;
|
||||
@@ -477,25 +477,25 @@ WMOInstance::WMOInstance(MPQFile& f, char const* WmoInstName, uint32 mapID, uint
|
||||
{
|
||||
float ff[3];
|
||||
f.read(&id, 4);
|
||||
f.read(ff,12);
|
||||
pos = Vec3D(ff[0],ff[1],ff[2]);
|
||||
f.read(ff,12);
|
||||
rot = Vec3D(ff[0],ff[1],ff[2]);
|
||||
f.read(ff,12);
|
||||
pos2 = Vec3D(ff[0],ff[1],ff[2]);
|
||||
f.read(ff,12);
|
||||
pos3 = Vec3D(ff[0],ff[1],ff[2]);
|
||||
f.read(&d2,4);
|
||||
f.read(ff, 12);
|
||||
pos = Vec3D(ff[0], ff[1], ff[2]);
|
||||
f.read(ff, 12);
|
||||
rot = Vec3D(ff[0], ff[1], ff[2]);
|
||||
f.read(ff, 12);
|
||||
pos2 = Vec3D(ff[0], ff[1], ff[2]);
|
||||
f.read(ff, 12);
|
||||
pos3 = Vec3D(ff[0], ff[1], ff[2]);
|
||||
f.read(&d2, 4);
|
||||
|
||||
uint16 trash,adtId;
|
||||
f.read(&adtId,2);
|
||||
f.read(&trash,2);
|
||||
uint16 trash, adtId;
|
||||
f.read(&adtId, 2);
|
||||
f.read(&trash, 2);
|
||||
|
||||
//-----------add_in _dir_file----------------
|
||||
|
||||
char tempname[512];
|
||||
sprintf(tempname, "%s/%s", szWorkDirWmo, WmoInstName);
|
||||
FILE *input;
|
||||
FILE* input;
|
||||
input = fopen(tempname, "r+b");
|
||||
|
||||
if(!input)
|
||||
@@ -512,13 +512,13 @@ WMOInstance::WMOInstance(MPQFile& f, char const* WmoInstName, uint32 mapID, uint
|
||||
if (count != 1 || nVertices == 0)
|
||||
return;
|
||||
|
||||
float x,z;
|
||||
float x, z;
|
||||
x = pos.x;
|
||||
z = pos.z;
|
||||
if(x==0 && z == 0)
|
||||
if(x == 0 && z == 0)
|
||||
{
|
||||
pos.x = 533.33333f*32;
|
||||
pos.z = 533.33333f*32;
|
||||
pos.x = 533.33333f * 32;
|
||||
pos.z = 533.33333f * 32;
|
||||
}
|
||||
pos = fixCoords(pos);
|
||||
pos2 = fixCoords(pos2);
|
||||
@@ -539,7 +539,7 @@ WMOInstance::WMOInstance(MPQFile& f, char const* WmoInstName, uint32 mapID, uint
|
||||
fwrite(&scale, sizeof(float), 1, pDirfile);
|
||||
fwrite(&pos2, sizeof(float), 3, pDirfile);
|
||||
fwrite(&pos3, sizeof(float), 3, pDirfile);
|
||||
uint32 nlen=strlen(WmoInstName);
|
||||
uint32 nlen = strlen(WmoInstName);
|
||||
fwrite(&nlen, sizeof(uint32), 1, pDirfile);
|
||||
fwrite(WmoInstName, sizeof(char), nlen, pDirfile);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class WMOManager;
|
||||
class MPQFile;
|
||||
|
||||
/* for whatever reason a certain company just can't stick to one coordinate system... */
|
||||
static inline Vec3D fixCoords(const Vec3D &v){ return Vec3D(v.z, v.x, v.y); }
|
||||
static inline Vec3D fixCoords(const Vec3D& v) { return Vec3D(v.z, v.x, v.y); }
|
||||
|
||||
class WMORoot
|
||||
{
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
Vec3D pos2, pos3, rot;
|
||||
uint32 indx, id, d2, d3;
|
||||
|
||||
WMOInstance(MPQFile&f , char const* WmoInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE* pDirfile);
|
||||
WMOInstance(MPQFile& f, char const* WmoInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE* pDirfile);
|
||||
|
||||
static void reset();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user