mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-24 22:26:22 +00:00
refactor(Tools): restyle tools with astyle (#3705)
This commit is contained in:
@@ -98,7 +98,7 @@ static const char* const langs[] = {"enGB", "enUS", "deDE", "esES", "frFR", "koK
|
||||
|
||||
void CreateDir( const std::string& Path )
|
||||
{
|
||||
if(chdir(Path.c_str()) == 0)
|
||||
if (chdir(Path.c_str()) == 0)
|
||||
{
|
||||
int ret = chdir("../");
|
||||
if (ret < 0)
|
||||
@@ -124,7 +124,7 @@ void CreateDir( const std::string& Path )
|
||||
bool FileExists( const char* FileName )
|
||||
{
|
||||
int fp = _open(FileName, OPEN_FLAGS);
|
||||
if(fp != -1)
|
||||
if (fp != -1)
|
||||
{
|
||||
_close(fp);
|
||||
return true;
|
||||
@@ -148,41 +148,41 @@ void Usage(char* prg)
|
||||
|
||||
void HandleArgs(int argc, char* arg[])
|
||||
{
|
||||
for(int c = 1; c < argc; ++c)
|
||||
for (int c = 1; c < argc; ++c)
|
||||
{
|
||||
// i - input path
|
||||
// o - output path
|
||||
// e - extract only MAP(1)/DBC(2) - standard both(3)
|
||||
// f - use float to int conversion
|
||||
// h - limit minimum height
|
||||
if(arg[c][0] != '-')
|
||||
if (arg[c][0] != '-')
|
||||
Usage(arg[0]);
|
||||
|
||||
switch(arg[c][1])
|
||||
switch (arg[c][1])
|
||||
{
|
||||
case 'i':
|
||||
if(c + 1 < argc) // all ok
|
||||
if (c + 1 < argc) // all ok
|
||||
strcpy(input_path, arg[(c++) + 1]);
|
||||
else
|
||||
Usage(arg[0]);
|
||||
break;
|
||||
case 'o':
|
||||
if(c + 1 < argc) // all ok
|
||||
if (c + 1 < argc) // all ok
|
||||
strcpy(output_path, arg[(c++) + 1]);
|
||||
else
|
||||
Usage(arg[0]);
|
||||
break;
|
||||
case 'f':
|
||||
if(c + 1 < argc) // all ok
|
||||
if (c + 1 < argc) // all ok
|
||||
CONF_allow_float_to_int = atoi(arg[(c++) + 1]) != 0;
|
||||
else
|
||||
Usage(arg[0]);
|
||||
break;
|
||||
case 'e':
|
||||
if(c + 1 < argc) // all ok
|
||||
if (c + 1 < argc) // all ok
|
||||
{
|
||||
CONF_extract = atoi(arg[(c++) + 1]);
|
||||
if(!(CONF_extract > 0 && CONF_extract < 4))
|
||||
if (!(CONF_extract > 0 && CONF_extract < 4))
|
||||
Usage(arg[0]);
|
||||
}
|
||||
else
|
||||
@@ -199,7 +199,7 @@ uint32 ReadBuild(int locale)
|
||||
//printf("Read %s file... ", filename.c_str());
|
||||
|
||||
MPQFile m(filename.c_str());
|
||||
if(m.isEof())
|
||||
if (m.isEof())
|
||||
{
|
||||
printf("Fatal error: Not found %s file!\n", filename.c_str());
|
||||
exit(1);
|
||||
@@ -234,7 +234,7 @@ uint32 ReadMapDBC()
|
||||
printf("Read Map.dbc file... ");
|
||||
DBCFile dbc("DBFilesClient\\Map.dbc");
|
||||
|
||||
if(!dbc.open())
|
||||
if (!dbc.open())
|
||||
{
|
||||
printf("Fatal error: Invalid Map.dbc file format!\n");
|
||||
exit(1);
|
||||
@@ -242,7 +242,7 @@ uint32 ReadMapDBC()
|
||||
|
||||
size_t map_count = dbc.getRecordCount();
|
||||
map_ids = new map_id[map_count];
|
||||
for(uint32 x = 0; x < map_count; ++x)
|
||||
for (uint32 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));
|
||||
@@ -255,7 +255,7 @@ void ReadLiquidTypeTableDBC()
|
||||
{
|
||||
printf("Read LiquidType.dbc file...");
|
||||
DBCFile dbc("DBFilesClient\\LiquidType.dbc");
|
||||
if(!dbc.open())
|
||||
if (!dbc.open())
|
||||
{
|
||||
printf("Fatal error: Invalid LiquidType.dbc file format!\n");
|
||||
exit(1);
|
||||
@@ -266,7 +266,7 @@ void ReadLiquidTypeTableDBC()
|
||||
LiqType = new uint16[liqTypeMaxId + 1];
|
||||
memset(LiqType, 0xff, (liqTypeMaxId + 1) * sizeof(uint16));
|
||||
|
||||
for(uint32 x = 0; x < liqTypeCount; ++x)
|
||||
for (uint32 x = 0; x < liqTypeCount; ++x)
|
||||
LiqType[dbc.getRecord(x).getUInt(0)] = dbc.getRecord(x).getUInt(3);
|
||||
|
||||
printf("Done! (%u LiqTypes loaded)\n", (uint32)liqTypeCount);
|
||||
@@ -522,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;
|
||||
@@ -690,7 +690,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
{
|
||||
for (int i = 0; i < ADT_CELLS_PER_GRID; i++)
|
||||
{
|
||||
for(int j = 0; j < ADT_CELLS_PER_GRID; j++)
|
||||
for (int j = 0; j < ADT_CELLS_PER_GRID; j++)
|
||||
{
|
||||
adt_liquid_header* h = h2o->getLiquidData(i, j);
|
||||
if (!h)
|
||||
@@ -768,7 +768,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
bool fullType = false;
|
||||
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)
|
||||
{
|
||||
@@ -796,7 +796,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
minHeight = 20000;
|
||||
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])
|
||||
{
|
||||
@@ -953,7 +953,7 @@ void ExtractMapsFromMpq(uint32 build)
|
||||
CreateDir(path);
|
||||
|
||||
printf("Convert map files\n");
|
||||
for(uint32 z = 0; z < map_count; ++z)
|
||||
for (uint32 z = 0; z < map_count; ++z)
|
||||
{
|
||||
printf("Extract %s (%d/%u) \n", map_ids[z].name, z + 1, map_count);
|
||||
// Loadup map grid data
|
||||
@@ -965,9 +965,9 @@ void ExtractMapsFromMpq(uint32 build)
|
||||
continue;
|
||||
}
|
||||
|
||||
for(uint32 y = 0; y < WDT_MAP_SIZE; ++y)
|
||||
for (uint32 y = 0; y < WDT_MAP_SIZE; ++y)
|
||||
{
|
||||
for(uint32 x = 0; x < WDT_MAP_SIZE; ++x)
|
||||
for (uint32 x = 0; x < WDT_MAP_SIZE; ++x)
|
||||
{
|
||||
if (!wdt.main->adt_list[y][x].exist)
|
||||
continue;
|
||||
@@ -986,13 +986,13 @@ void ExtractMapsFromMpq(uint32 build)
|
||||
bool ExtractFile( char const* mpq_name, std::string const& filename )
|
||||
{
|
||||
FILE* output = fopen(filename.c_str(), "wb");
|
||||
if(!output)
|
||||
if (!output)
|
||||
{
|
||||
printf("Can't create the output file '%s'\n", filename.c_str());
|
||||
return false;
|
||||
}
|
||||
MPQFile m(mpq_name);
|
||||
if(!m.isEof())
|
||||
if (!m.isEof())
|
||||
fwrite(m.getPointer(), 1, m.getSize(), output);
|
||||
|
||||
fclose(output);
|
||||
@@ -1006,7 +1006,7 @@ 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);
|
||||
@@ -1018,7 +1018,7 @@ void ExtractDBCFiles(int locale, bool basicLocale)
|
||||
std::string path = output_path;
|
||||
path += "/dbc/";
|
||||
CreateDir(path);
|
||||
if(!basicLocale)
|
||||
if (!basicLocale)
|
||||
{
|
||||
path += langs[locale];
|
||||
path += "/";
|
||||
@@ -1040,7 +1040,7 @@ void ExtractDBCFiles(int locale, bool basicLocale)
|
||||
string filename = path;
|
||||
filename += (iter->c_str() + strlen("DBFilesClient\\"));
|
||||
|
||||
if(FileExists(filename.c_str()))
|
||||
if (FileExists(filename.c_str()))
|
||||
continue;
|
||||
|
||||
if (ExtractFile(iter->c_str(), filename))
|
||||
@@ -1056,14 +1056,14 @@ void LoadLocaleMPQFiles(int const 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)
|
||||
for (int i = 1; i < 5; ++i)
|
||||
{
|
||||
char ext[3] = "";
|
||||
if(i > 1)
|
||||
if (i > 1)
|
||||
sprintf(ext, "-%i", i);
|
||||
|
||||
sprintf(filename, "%s/Data/%s/patch-%s%s.MPQ", input_path, langs[locale], langs[locale], ext);
|
||||
if(FileExists(filename))
|
||||
if (FileExists(filename))
|
||||
new MPQArchive(filename);
|
||||
}
|
||||
}
|
||||
@@ -1072,17 +1072,17 @@ void LoadCommonMPQFiles()
|
||||
{
|
||||
char filename[512];
|
||||
int count = sizeof(CONF_mpq_list) / sizeof(char*);
|
||||
for(int i = 0; i < count; ++i)
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
sprintf(filename, "%s/Data/%s", input_path, CONF_mpq_list[i]);
|
||||
if(FileExists(filename))
|
||||
if (FileExists(filename))
|
||||
new MPQArchive(filename);
|
||||
}
|
||||
}
|
||||
|
||||
inline void CloseMPQFiles()
|
||||
{
|
||||
for(ArchiveSet::iterator j = gOpenArchives.begin(); j != gOpenArchives.end(); ++j) (*j)->close();
|
||||
for (ArchiveSet::iterator j = gOpenArchives.begin(); j != gOpenArchives.end(); ++j) (*j)->close();
|
||||
gOpenArchives.clear();
|
||||
}
|
||||
|
||||
@@ -1107,7 +1107,7 @@ int main(int argc, char* arg[])
|
||||
//Open MPQs
|
||||
LoadLocaleMPQFiles(i);
|
||||
|
||||
if((CONF_extract & EXTRACT_DBC) == 0)
|
||||
if ((CONF_extract & EXTRACT_DBC) == 0)
|
||||
{
|
||||
FirstLocale = i;
|
||||
build = ReadBuild(FirstLocale);
|
||||
@@ -1116,7 +1116,7 @@ int main(int argc, char* arg[])
|
||||
}
|
||||
|
||||
//Extract DBC files
|
||||
if(FirstLocale < 0)
|
||||
if (FirstLocale < 0)
|
||||
{
|
||||
FirstLocale = i;
|
||||
build = ReadBuild(FirstLocale);
|
||||
@@ -1131,7 +1131,7 @@ int main(int argc, char* arg[])
|
||||
}
|
||||
}
|
||||
|
||||
if(FirstLocale < 0)
|
||||
if (FirstLocale < 0)
|
||||
{
|
||||
printf("No locales detected\n");
|
||||
return 0;
|
||||
|
||||
@@ -24,8 +24,8 @@ bool isHole(int holes, int i, int j)
|
||||
{
|
||||
int testi = i / 2;
|
||||
int testj = j / 4;
|
||||
if(testi > 3) testi = 3;
|
||||
if(testj > 3) testj = 3;
|
||||
if (testi > 3) testi = 3;
|
||||
if (testj > 3) testj = 3;
|
||||
return (holes & holetab_h[testi] & holetab_v[testj]) != 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,33 +21,33 @@ bool DBCFile::open()
|
||||
char header[4];
|
||||
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;
|
||||
|
||||
size_t data_size = recordSize * recordCount + stringSize;
|
||||
if(f.read(data, data_size) != data_size)
|
||||
if (f.read(data, data_size) != data_size)
|
||||
return false;
|
||||
f.close();
|
||||
return true;
|
||||
@@ -68,9 +68,9 @@ size_t DBCFile::getMaxId()
|
||||
assert(data);
|
||||
|
||||
size_t maxId = 0;
|
||||
for(size_t i = 0; i < getRecordCount(); ++i)
|
||||
for (size_t i = 0; i < getRecordCount(); ++i)
|
||||
{
|
||||
if(maxId < getRecord(i).getUInt(0))
|
||||
if (maxId < getRecord(i).getUInt(0))
|
||||
maxId = getRecord(i).getUInt(0);
|
||||
}
|
||||
return maxId;
|
||||
|
||||
@@ -30,7 +30,7 @@ bool FileLoader::loadFile(std::string const& fileName, bool log)
|
||||
{
|
||||
free();
|
||||
MPQFile mf(fileName.c_str());
|
||||
if(mf.isEof())
|
||||
if (mf.isEof())
|
||||
{
|
||||
if (log)
|
||||
printf("No such file %s\n", fileName.c_str());
|
||||
|
||||
@@ -14,9 +14,9 @@ MPQArchive::MPQArchive(const char* filename)
|
||||
{
|
||||
int result = libmpq__archive_open(&mpq_a, filename, -1);
|
||||
printf("Opening %s\n", filename);
|
||||
if(result)
|
||||
if (result)
|
||||
{
|
||||
switch(result)
|
||||
switch (result)
|
||||
{
|
||||
case LIBMPQ_ERROR_OPEN :
|
||||
printf("Error opening archive '%s': Does file really exist?\n", filename);
|
||||
@@ -54,12 +54,12 @@ 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;
|
||||
|
||||
uint32_t filenum;
|
||||
if(libmpq__file_number(mpq_a, filename, &filenum)) continue;
|
||||
if (libmpq__file_number(mpq_a, filename, &filenum)) continue;
|
||||
libmpq__off_t transferred;
|
||||
libmpq__file_unpacked_size(mpq_a, filenum, &size);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
void GetFileListTo(vector<string>& filelist)
|
||||
{
|
||||
uint32_t filenum;
|
||||
if(libmpq__file_number(mpq_a, "(listfile)", &filenum)) return;
|
||||
if (libmpq__file_number(mpq_a, "(listfile)", &filenum)) return;
|
||||
libmpq__off_t size, transferred;
|
||||
libmpq__file_unpacked_size(mpq_a, filenum, &size);
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ void DoodadHandler::InsertModelGeometry(const DoodadDefinition& def, Model* mode
|
||||
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
|
||||
|
||||
for (std::vector<Triangle<uint16> >::iterator itr = model->Triangles.begin(); itr != model->Triangles.end(); ++itr)
|
||||
for (std::vector<Triangle<uint16>>::iterator itr = model->Triangles.begin(); itr != model->Triangles.end(); ++itr)
|
||||
Triangles.push_back(Triangle<uint32>(Constants::TRIANGLE_TYPE_DOODAD, itr->V0 + vertOffset, itr->V1 + vertOffset, itr->V2 + vertOffset));
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
~DoodadHandler();
|
||||
|
||||
std::vector<Vector3> Vertices;
|
||||
std::vector<Triangle<uint32> > Triangles;
|
||||
std::vector<Triangle<uint32>> Triangles;
|
||||
bool IsSane() { return _definitions && _paths; }
|
||||
|
||||
|
||||
|
||||
@@ -70,13 +70,13 @@ void Geometry::CalculateMinMaxHeight( float& min, float& max )
|
||||
}
|
||||
}
|
||||
|
||||
void Geometry::AddData( std::vector<Vector3>& verts, std::vector<Triangle<uint32> >& tris )
|
||||
void Geometry::AddData( std::vector<Vector3>& verts, std::vector<Triangle<uint32>>& tris )
|
||||
{
|
||||
uint32 vertOffset = Vertices.size();
|
||||
for (std::vector<Vector3>::iterator itr = verts.begin(); itr != verts.end(); ++itr)
|
||||
Vertices.push_back(Transform ? Utils::ToRecast(*itr) : *itr);
|
||||
|
||||
for (std::vector<Triangle<uint32> >::iterator itr = tris.begin(); itr != tris.end(); ++itr)
|
||||
for (std::vector<Triangle<uint32>>::iterator itr = tris.begin(); itr != tris.end(); ++itr)
|
||||
Triangles.push_back(Triangle<uint32>(itr->Type, itr->V0 + vertOffset, itr->V1 + vertOffset, itr->V2 + vertOffset));
|
||||
}
|
||||
|
||||
@@ -119,9 +119,9 @@ void Geometry::AddAdt( ADT* adt )
|
||||
{
|
||||
for (std::vector<MapChunk*>::iterator itr = adt->MapChunks.begin(); itr != adt->MapChunks.end(); ++itr)
|
||||
{
|
||||
std::vector<Triangle<uint32> > tmp;
|
||||
std::vector<Triangle<uint32>> tmp;
|
||||
tmp.reserve((*itr)->Triangles.size());
|
||||
for (std::vector<Triangle<uint8> >::iterator itr2 = (*itr)->Triangles.begin(); itr2 != (*itr)->Triangles.end(); ++itr2)
|
||||
for (std::vector<Triangle<uint8>>::iterator itr2 = (*itr)->Triangles.begin(); itr2 != (*itr)->Triangles.end(); ++itr2)
|
||||
tmp.push_back(Triangle<uint32>(itr2->Type, itr2->V0, itr2->V1, itr2->V2));
|
||||
AddData((*itr)->Vertices, tmp);
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ public:
|
||||
|
||||
void CalculateBoundingBox(float*& min, float*& max);
|
||||
void CalculateMinMaxHeight(float& min, float& max);
|
||||
void AddData(std::vector<Vector3>& verts, std::vector<Triangle<uint32> >& tris);
|
||||
void AddData(std::vector<Vector3>& verts, std::vector<Triangle<uint32>>& tris);
|
||||
void AddAdt(ADT* adt);
|
||||
void GetRawData(float*& verts, int*& tris, uint8*& areas);
|
||||
|
||||
std::vector<Vector3> Vertices;
|
||||
std::vector<Triangle<uint32> > Triangles;
|
||||
std::vector<Triangle<uint32>> Triangles;
|
||||
bool Transform;
|
||||
};
|
||||
#endif
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
|
||||
ADT* Source;
|
||||
std::vector<Vector3> Vertices;
|
||||
std::vector<Triangle<uint32> > Triangles;
|
||||
std::vector<Triangle<uint32>> Triangles;
|
||||
std::vector<MCNKLiquidData> MCNKData;
|
||||
private:
|
||||
void HandleNewLiquid();
|
||||
|
||||
@@ -53,7 +53,7 @@ MPQFile::MPQFile(const char* filename):
|
||||
mpq_archive* mpq_a = (*i)->mpq_a;
|
||||
|
||||
uint32_t filenum;
|
||||
if(libmpq__file_number(mpq_a, filename, &filenum))
|
||||
if (libmpq__file_number(mpq_a, filename, &filenum))
|
||||
continue;
|
||||
libmpq__off_t transferred;
|
||||
libmpq__file_unpacked_size(mpq_a, filenum, &size);
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
void GetFileListTo(std::vector<std::string>& filelist)
|
||||
{
|
||||
uint32_t filenum;
|
||||
if(libmpq__file_number(mpq_a, "(listfile)", &filenum)) return;
|
||||
if (libmpq__file_number(mpq_a, "(listfile)", &filenum)) return;
|
||||
libmpq__off_t size, transferred;
|
||||
libmpq__file_unpacked_size(mpq_a, filenum, &size);
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ FILE* MPQManager::GetFileFrom(const std::string& path, MPQArchive* file )
|
||||
mpq_archive* mpq_a = file->mpq_a;
|
||||
|
||||
uint32_t filenum;
|
||||
if(libmpq__file_number(mpq_a, path.c_str(), &filenum))
|
||||
if (libmpq__file_number(mpq_a, path.c_str(), &filenum))
|
||||
return nullptr;
|
||||
|
||||
libmpq__off_t transferred;
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
Chunk* Source;
|
||||
MapChunkHeader Header;
|
||||
std::vector<Vector3> Vertices;
|
||||
std::vector<Triangle<uint8> > Triangles;
|
||||
std::vector<Triangle<uint8>> Triangles;
|
||||
int32 Index;
|
||||
};
|
||||
#endif
|
||||
@@ -157,7 +157,7 @@ void ExtractGameobjectModels()
|
||||
if (numTris > 0)
|
||||
{
|
||||
uint32 i = 0;
|
||||
for (std::vector<Triangle<uint16> >::iterator itr2 = model.Triangles.begin(); itr2 != model.Triangles.end(); ++itr2, ++i)
|
||||
for (std::vector<Triangle<uint16>>::iterator itr2 = model.Triangles.begin(); itr2 != model.Triangles.end(); ++itr2, ++i)
|
||||
{
|
||||
indices[i * 3 + 0] = itr2->V0;
|
||||
indices[i * 3 + 1] = itr2->V1;
|
||||
@@ -229,7 +229,7 @@ void ExtractGameobjectModels()
|
||||
uint32 mobaBatch = itr2->MOBALength / 12;
|
||||
uint32* MobaEx = new uint32[mobaBatch * 4];
|
||||
|
||||
for(uint32 i = 8; i < itr2->MOBALength; i += 12)
|
||||
for (uint32 i = 8; i < itr2->MOBALength; i += 12)
|
||||
MobaEx[k++] = itr2->MOBA[i];
|
||||
|
||||
int mobaSizeGrp = mobaBatch * 4 + 4;
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
ModelHeader Header;
|
||||
std::vector<Vector3> Vertices;
|
||||
std::vector<Vector3> Normals;
|
||||
std::vector<Triangle<uint16> > Triangles;
|
||||
std::vector<Triangle<uint16>> Triangles;
|
||||
bool IsCollidable;
|
||||
FILE* Stream;
|
||||
bool IsBad;
|
||||
|
||||
@@ -165,7 +165,7 @@ float Utils::Distance( float x, float y )
|
||||
std::string Utils::Replace( std::string str, const std::string& oldStr, const std::string& newStr )
|
||||
{
|
||||
size_t pos = 0;
|
||||
while((pos = str.find(oldStr, pos)) != std::string::npos)
|
||||
while ((pos = str.find(oldStr, pos)) != std::string::npos)
|
||||
{
|
||||
str.replace(pos, oldStr.length(), newStr);
|
||||
pos += newStr.length();
|
||||
@@ -223,7 +223,7 @@ std::string Utils::GetExtension( std::string path )
|
||||
std::string::size_type idx = path.rfind('.');
|
||||
std::string extension = "";
|
||||
|
||||
if(idx != std::string::npos)
|
||||
if (idx != std::string::npos)
|
||||
extension = path.substr(idx + 1);
|
||||
return extension;
|
||||
}
|
||||
@@ -525,7 +525,7 @@ char* Utils::GetPlainName(const char* FileName)
|
||||
{
|
||||
char* temp;
|
||||
|
||||
if((temp = (char*)strrchr(FileName, '\\')) != nullptr)
|
||||
if ((temp = (char*)strrchr(FileName, '\\')) != nullptr)
|
||||
FileName = temp + 1;
|
||||
return (char*)FileName;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
std::vector<uint8> TriangleFlags;
|
||||
std::vector<uint8> TriangleMaterials;
|
||||
std::vector<Triangle<uint16> > Triangles;
|
||||
std::vector<Triangle<uint16>> Triangles;
|
||||
std::vector<Vector3> Vertices;
|
||||
std::vector<Vector3> Normals;
|
||||
// @ToDo: Research.
|
||||
|
||||
@@ -85,7 +85,7 @@ void WorldModelHandler::ProcessInternal( MapChunk* mcnk )
|
||||
fseek(stream, mcnk->Source->Offset, SEEK_SET);
|
||||
}
|
||||
|
||||
void WorldModelHandler::InsertModelGeometry( std::vector<Vector3>& verts, std::vector<Triangle<uint32> >& tris, const WorldModelDefinition& def, WorldModelRoot* root, bool translate )
|
||||
void WorldModelHandler::InsertModelGeometry( std::vector<Vector3>& verts, std::vector<Triangle<uint32>>& tris, const WorldModelDefinition& def, WorldModelRoot* root, bool translate )
|
||||
{
|
||||
for (std::vector<WorldModelGroup>::iterator group = root->Groups.begin(); group != root->Groups.end(); ++group)
|
||||
{
|
||||
@@ -136,7 +136,7 @@ void WorldModelHandler::InsertModelGeometry( std::vector<Vector3>& verts, std::v
|
||||
Vector3 v = Utils::TransformDoodadVertex(def, Utils::TransformWmoDoodad(*instance, def, *itr2, false), translate);
|
||||
verts.push_back(translate ? v : Utils::ToRecast(v));
|
||||
}
|
||||
for (std::vector<Triangle<uint16> >::iterator itr2 = model->Triangles.begin(); itr2 != model->Triangles.end(); ++itr2)
|
||||
for (std::vector<Triangle<uint16>>::iterator itr2 = model->Triangles.begin(); itr2 != model->Triangles.end(); ++itr2)
|
||||
tris.push_back(Triangle<uint32>(Constants::TRIANGLE_TYPE_WMO, itr2->V0 + vertOffset, itr2->V1 + vertOffset, itr2->V2 + vertOffset));
|
||||
}
|
||||
|
||||
|
||||
@@ -38,9 +38,9 @@ public:
|
||||
~WorldModelHandler();
|
||||
|
||||
std::vector<Vector3> Vertices;
|
||||
std::vector<Triangle<uint32> > Triangles;
|
||||
std::vector<Triangle<uint32>> Triangles;
|
||||
bool IsSane() { return _definitions && _paths; }
|
||||
static void InsertModelGeometry(std::vector<Vector3>& verts, std::vector<Triangle<uint32> >& tris, const WorldModelDefinition& def, WorldModelRoot* root, bool translate = true);
|
||||
static void InsertModelGeometry(std::vector<Vector3>& verts, std::vector<Triangle<uint32>>& tris, const WorldModelDefinition& def, WorldModelRoot* root, bool translate = true);
|
||||
protected:
|
||||
void ProcessInternal(MapChunk* data);
|
||||
private:
|
||||
|
||||
@@ -421,7 +421,7 @@ namespace MMAP
|
||||
{
|
||||
float quadHeight = 0;
|
||||
uint32 validCount = 0;
|
||||
for(uint32 idx = 0; idx < 3; idx++)
|
||||
for (uint32 idx = 0; idx < 3; idx++)
|
||||
{
|
||||
float h = lverts_copy[ltris[idx] * 3 + 1];
|
||||
if (h != INVALID_MAP_LIQ_HEIGHT && h < INVALID_MAP_LIQ_HEIGHT_MAX)
|
||||
@@ -435,7 +435,7 @@ namespace MMAP
|
||||
if (validCount > 0 && validCount < 3)
|
||||
{
|
||||
quadHeight /= validCount;
|
||||
for(uint32 idx = 0; idx < 3; idx++)
|
||||
for (uint32 idx = 0; idx < 3; idx++)
|
||||
{
|
||||
float h = lverts[ltris[idx] * 3 + 1];
|
||||
if (h == INVALID_MAP_LIQ_HEIGHT || h > INVALID_MAP_LIQ_HEIGHT_MAX)
|
||||
@@ -457,7 +457,7 @@ namespace MMAP
|
||||
{
|
||||
float minLLevel = INVALID_MAP_LIQ_HEIGHT_MAX;
|
||||
float maxLLevel = INVALID_MAP_LIQ_HEIGHT;
|
||||
for(uint32 x = 0; x < 3; x++)
|
||||
for (uint32 x = 0; x < 3; x++)
|
||||
{
|
||||
float h = lverts[ltris[x] * 3 + 1];
|
||||
if (minLLevel > h)
|
||||
@@ -469,7 +469,7 @@ namespace MMAP
|
||||
|
||||
float maxTLevel = INVALID_MAP_LIQ_HEIGHT;
|
||||
float minTLevel = INVALID_MAP_LIQ_HEIGHT_MAX;
|
||||
for(uint32 x = 0; x < 6; x++)
|
||||
for (uint32 x = 0; x < 6; x++)
|
||||
{
|
||||
float h = tverts[ttris[x] * 3 + 1];
|
||||
if (maxTLevel < h)
|
||||
@@ -579,21 +579,21 @@ namespace MMAP
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
0-----1 .... 128
|
||||
|\ |
|
||||
| \ T |
|
||||
| \ |
|
||||
| B \ |
|
||||
| \|
|
||||
129---130 ... 386
|
||||
|\ |
|
||||
| \ |
|
||||
| \ |
|
||||
| \ |
|
||||
| \|
|
||||
258---259 ... 515
|
||||
*/
|
||||
/*
|
||||
0-----1 .... 128
|
||||
|\ |
|
||||
| \ T |
|
||||
| \ |
|
||||
| B \ |
|
||||
| \|
|
||||
129---130 ... 386
|
||||
|\ |
|
||||
| \ |
|
||||
| \ |
|
||||
| \ |
|
||||
| \|
|
||||
258---259 ... 515
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@@ -914,7 +914,7 @@ namespace MMAP
|
||||
// pretty silly thing, as we parse entire file and load only the tile we need
|
||||
// but we don't expect this file to be too large
|
||||
char* buf = new char[512];
|
||||
while(fgets(buf, 512, fp))
|
||||
while (fgets(buf, 512, fp))
|
||||
{
|
||||
float p0[3], p1[3];
|
||||
uint32 mid, tx, ty;
|
||||
|
||||
@@ -18,7 +18,7 @@ char const* GetPlainName(char const* FileName)
|
||||
{
|
||||
const char* szTemp;
|
||||
|
||||
if((szTemp = strrchr(FileName, '\\')) != nullptr)
|
||||
if ((szTemp = strrchr(FileName, '\\')) != nullptr)
|
||||
FileName = szTemp + 1;
|
||||
return FileName;
|
||||
}
|
||||
@@ -27,7 +27,7 @@ char* GetPlainName(char* FileName)
|
||||
{
|
||||
char* szTemp;
|
||||
|
||||
if((szTemp = strrchr(FileName, '\\')) != nullptr)
|
||||
if ((szTemp = strrchr(FileName, '\\')) != nullptr)
|
||||
FileName = szTemp + 1;
|
||||
return FileName;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ void fixname2(char* name, size_t len)
|
||||
{
|
||||
for (size_t i = 0; i < len - 3; i++)
|
||||
{
|
||||
if(name[i] == ' ')
|
||||
if (name[i] == ' ')
|
||||
name[i] = '_';
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ ADTFile::ADTFile(char* filename): ADT(filename), nWMO(0), nMDX(0), WmoInstansNam
|
||||
|
||||
bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
|
||||
{
|
||||
if(ADT.isEof ())
|
||||
if (ADT.isEof ())
|
||||
return false;
|
||||
|
||||
uint32 size;
|
||||
@@ -92,7 +92,7 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
|
||||
std::string dirname = std::string(szWorkDirWmo) + "/dir_bin";
|
||||
FILE* dirfile;
|
||||
dirfile = fopen(dirname.c_str(), "ab");
|
||||
if(!dirfile)
|
||||
if (!dirfile)
|
||||
{
|
||||
printf("Can't open dirfile!'%s'\n", dirname.c_str());
|
||||
return false;
|
||||
|
||||
@@ -45,7 +45,7 @@ void ExtractGameobjectModels()
|
||||
{
|
||||
printf("Extracting GameObject models...");
|
||||
DBCFile dbc("DBFilesClient\\GameObjectDisplayInfo.dbc");
|
||||
if(!dbc.open())
|
||||
if (!dbc.open())
|
||||
{
|
||||
printf("Fatal error: Invalid GameObjectDisplayInfo.dbc file format!\n");
|
||||
exit(1);
|
||||
|
||||
@@ -32,7 +32,7 @@ bool Model::open()
|
||||
_unload();
|
||||
|
||||
memcpy(&header, f.getBuffer(), sizeof(ModelHeader));
|
||||
if(header.nBoundingTriangles > 0)
|
||||
if (header.nBoundingTriangles > 0)
|
||||
{
|
||||
f.seek(0);
|
||||
f.seekRelative(header.ofsBoundingVertices);
|
||||
|
||||
@@ -14,9 +14,9 @@ MPQArchive::MPQArchive(const char* filename)
|
||||
{
|
||||
int result = libmpq__archive_open(&mpq_a, filename, -1);
|
||||
printf("Opening %s\n", filename);
|
||||
if(result)
|
||||
if (result)
|
||||
{
|
||||
switch(result)
|
||||
switch (result)
|
||||
{
|
||||
case LIBMPQ_ERROR_OPEN :
|
||||
printf("Error opening archive '%s': Does file really exist?\n", filename);
|
||||
@@ -54,12 +54,12 @@ 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;
|
||||
|
||||
uint32 filenum;
|
||||
if(libmpq__file_number(mpq_a, filename, &filenum)) continue;
|
||||
if (libmpq__file_number(mpq_a, filename, &filenum)) continue;
|
||||
libmpq__off_t transferred;
|
||||
libmpq__file_unpacked_size(mpq_a, filenum, &size);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
void GetFileListTo(vector<string>& filelist)
|
||||
{
|
||||
uint32_t filenum;
|
||||
if(libmpq__file_number(mpq_a, "(listfile)", &filenum)) return;
|
||||
if (libmpq__file_number(mpq_a, "(listfile)", &filenum)) return;
|
||||
libmpq__off_t size, transferred;
|
||||
libmpq__file_unpacked_size(mpq_a, filenum, &size);
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ bool FileExists(const char* file)
|
||||
|
||||
void strToLower(char* str)
|
||||
{
|
||||
while(*str)
|
||||
while (*str)
|
||||
{
|
||||
*str = tolower(*str);
|
||||
++str;
|
||||
@@ -92,7 +92,7 @@ void ReadLiquidTypeTableDBC()
|
||||
{
|
||||
printf("Read LiquidType.dbc file...");
|
||||
DBCFile dbc("DBFilesClient\\LiquidType.dbc");
|
||||
if(!dbc.open())
|
||||
if (!dbc.open())
|
||||
{
|
||||
printf("Fatal error: Invalid LiquidType.dbc file format!\n");
|
||||
exit(1);
|
||||
@@ -103,7 +103,7 @@ void ReadLiquidTypeTableDBC()
|
||||
LiqType = new uint16[LiqType_maxid + 1];
|
||||
memset(LiqType, 0xff, (LiqType_maxid + 1) * sizeof(uint16));
|
||||
|
||||
for(uint32 x = 0; x < LiqType_count; ++x)
|
||||
for (uint32 x = 0; x < LiqType_count; ++x)
|
||||
LiqType[dbc.getRecord(x).getUInt(0)] = dbc.getRecord(x).getUInt(3);
|
||||
|
||||
printf("Done! (%u LiqTypes loaded)\n", (unsigned int)LiqType_count);
|
||||
@@ -166,13 +166,13 @@ bool ExtractSingleWmo(std::string& fname)
|
||||
bool file_ok = true;
|
||||
std::cout << "Extracting " << fname << std::endl;
|
||||
WMORoot froot(fname);
|
||||
if(!froot.open())
|
||||
if (!froot.open())
|
||||
{
|
||||
printf("Couldn't open RootWmo!!!\n");
|
||||
return true;
|
||||
}
|
||||
FILE* output = fopen(szLocalFile, "wb");
|
||||
if(!output)
|
||||
if (!output)
|
||||
{
|
||||
printf("couldn't open %s for writing!\n", szLocalFile);
|
||||
return false;
|
||||
@@ -198,7 +198,7 @@ bool ExtractSingleWmo(std::string& fname)
|
||||
|
||||
string s = groupFileName;
|
||||
WMOGroup fgroup(s);
|
||||
if(!fgroup.open())
|
||||
if (!fgroup.open())
|
||||
{
|
||||
printf("Could not open all Group file for: %s\n", plain_name);
|
||||
file_ok = false;
|
||||
@@ -229,7 +229,7 @@ void ParsMapFiles()
|
||||
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))
|
||||
if (WDT.init(id, map_ids[i].id))
|
||||
{
|
||||
printf("Processing Map %u\n[", map_ids[i].id);
|
||||
for (int x = 0; x < 64; ++x)
|
||||
@@ -276,9 +276,9 @@ bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames)
|
||||
sprintf(path, "%s.MPQ", scanmatch);
|
||||
}
|
||||
#ifdef __linux__
|
||||
if(FILE* h = fopen64(path, "rb"))
|
||||
if (FILE* h = fopen64(path, "rb"))
|
||||
#else
|
||||
if(FILE* h = fopen(path, "rb"))
|
||||
if (FILE* h = fopen(path, "rb"))
|
||||
#endif
|
||||
{
|
||||
fclose(h);
|
||||
@@ -287,12 +287,12 @@ bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames)
|
||||
}
|
||||
}
|
||||
|
||||
return(true);
|
||||
return (true);
|
||||
}
|
||||
|
||||
bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames)
|
||||
{
|
||||
if(!hasInputPathParam)
|
||||
if (!hasInputPathParam)
|
||||
getGamePath();
|
||||
|
||||
printf("\nGame path: %s\n", input_path);
|
||||
@@ -352,7 +352,7 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames)
|
||||
return false;
|
||||
}
|
||||
if (!scan_patches(path, pArchiveNames))
|
||||
return(false);
|
||||
return (false);
|
||||
|
||||
// now, scan for the patch levels in locale dirs
|
||||
printf("Scanning patch levels from locale directories.\n");
|
||||
@@ -366,13 +366,13 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames)
|
||||
printf("Error when formatting string");
|
||||
return false;
|
||||
}
|
||||
if(scan_patches(path, pArchiveNames))
|
||||
if (scan_patches(path, pArchiveNames))
|
||||
foundOne = true;
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
if(!foundOne)
|
||||
if (!foundOne)
|
||||
{
|
||||
printf("no locale found\n");
|
||||
return false;
|
||||
@@ -387,15 +387,15 @@ bool processArgv(int argc, char** argv, const char* versionString)
|
||||
hasInputPathParam = false;
|
||||
preciseVectorData = false;
|
||||
|
||||
for(int i = 1; i < argc; ++i)
|
||||
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]);
|
||||
@@ -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;
|
||||
}
|
||||
@@ -422,7 +422,7 @@ bool processArgv(int argc, char** argv, const char* versionString)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!result)
|
||||
if (!result)
|
||||
{
|
||||
printf("Extract %s.\n", versionString);
|
||||
printf("%s [-?][-s][-l][-d <path>]\n", argv[0]);
|
||||
|
||||
@@ -13,7 +13,7 @@ char* wdtGetPlainName(char* FileName)
|
||||
{
|
||||
char* szTemp;
|
||||
|
||||
if((szTemp = strrchr(FileName, '\\')) != nullptr)
|
||||
if ((szTemp = strrchr(FileName, '\\')) != nullptr)
|
||||
FileName = szTemp + 1;
|
||||
return FileName;
|
||||
}
|
||||
@@ -37,7 +37,7 @@ bool WDTFile::init(char* /*map_id*/, unsigned int mapID)
|
||||
std::string dirname = std::string(szWorkDirWmo) + "/dir_bin";
|
||||
FILE* dirfile;
|
||||
dirfile = fopen(dirname.c_str(), "ab");
|
||||
if(!dirfile)
|
||||
if (!dirfile)
|
||||
{
|
||||
printf("Can't open dirfile!'%s'\n", dirname.c_str());
|
||||
return false;
|
||||
@@ -108,7 +108,7 @@ 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];
|
||||
|
||||
@@ -30,7 +30,7 @@ WMORoot::WMORoot(std::string& filename)
|
||||
bool WMORoot::open()
|
||||
{
|
||||
MPQFile f(filename.c_str());
|
||||
if(f.isEof ())
|
||||
if (f.isEof ())
|
||||
{
|
||||
printf("No such file.\n");
|
||||
return false;
|
||||
@@ -138,7 +138,7 @@ WMOGroup::WMOGroup(const std::string& filename) :
|
||||
bool WMOGroup::open()
|
||||
{
|
||||
MPQFile f(filename.c_str());
|
||||
if(f.isEof ())
|
||||
if (f.isEof ())
|
||||
{
|
||||
printf("No such file.\n");
|
||||
return false;
|
||||
@@ -248,7 +248,7 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE* output, WMORoot* rootWMO, bool precise
|
||||
int k = 0;
|
||||
int moba_batch = moba_size / 12;
|
||||
MobaEx = new int[moba_batch * 4];
|
||||
for(int i = 8; i < moba_size; i += 12)
|
||||
for (int i = 8; i < moba_size; i += 12)
|
||||
{
|
||||
MobaEx[k++] = MOBA[i];
|
||||
}
|
||||
@@ -260,50 +260,50 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE* output, WMORoot* rootWMO, bool precise
|
||||
|
||||
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);
|
||||
}
|
||||
int wsize = sizeof(uint32) + sizeof(unsigned short) * nIdexes;
|
||||
if(fwrite(&wsize, sizeof(int), 1, output) != 1)
|
||||
if (fwrite(&wsize, sizeof(int), 1, output) != 1)
|
||||
{
|
||||
printf("Error while writing file wsize");
|
||||
// no need to exit?
|
||||
}
|
||||
if(fwrite(&nIdexes, sizeof(uint32), 1, output) != 1)
|
||||
if (fwrite(&nIdexes, sizeof(uint32), 1, output) != 1)
|
||||
{
|
||||
printf("Error while writing file nIndexes");
|
||||
exit(0);
|
||||
}
|
||||
if(nIdexes > 0)
|
||||
if (nIdexes > 0)
|
||||
{
|
||||
if(fwrite(MOVI, sizeof(unsigned short), nIdexes, output) != nIdexes)
|
||||
if (fwrite(MOVI, sizeof(unsigned short), nIdexes, output) != nIdexes)
|
||||
{
|
||||
printf("Error while writing file indexarray");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
if(fwrite("VERT", 4, 1, output) != 1)
|
||||
if (fwrite("VERT", 4, 1, output) != 1)
|
||||
{
|
||||
printf("Error while writing file nbraches ID");
|
||||
exit(0);
|
||||
}
|
||||
wsize = sizeof(int) + sizeof(float) * 3 * nVertices;
|
||||
if(fwrite(&wsize, sizeof(int), 1, output) != 1)
|
||||
if (fwrite(&wsize, sizeof(int), 1, output) != 1)
|
||||
{
|
||||
printf("Error while writing file wsize");
|
||||
// no need to exit?
|
||||
}
|
||||
if(fwrite(&nVertices, sizeof(int), 1, output) != 1)
|
||||
if (fwrite(&nVertices, sizeof(int), 1, output) != 1)
|
||||
{
|
||||
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);
|
||||
@@ -319,7 +319,7 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE* output, WMORoot* rootWMO, bool precise
|
||||
int k = 0;
|
||||
int moba_batch = moba_size / 12;
|
||||
MobaEx = new int[moba_batch * 4];
|
||||
for(int i = 8; i < moba_size; i += 12)
|
||||
for (int i = 8; i < moba_size; i += 12)
|
||||
{
|
||||
MobaEx[k++] = MOBA[i];
|
||||
}
|
||||
@@ -379,7 +379,7 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE* output, WMORoot* rootWMO, bool precise
|
||||
int check = 3 * nColVertices;
|
||||
fwrite(VERT, 4, 3, output);
|
||||
for (uint32 i = 0; i < nVertices; ++i)
|
||||
if(IndexRenum[i] >= 0)
|
||||
if (IndexRenum[i] >= 0)
|
||||
check -= fwrite(MOVT + 3 * i, sizeof(float), 3, output);
|
||||
|
||||
assert(check == 0);
|
||||
@@ -498,7 +498,7 @@ WMOInstance::WMOInstance(MPQFile& f, char const* WmoInstName, uint32 mapID, uint
|
||||
FILE* input;
|
||||
input = fopen(tempname, "r+b");
|
||||
|
||||
if(!input)
|
||||
if (!input)
|
||||
{
|
||||
printf("WMOInstance::WMOInstance: couldn't open %s\n", tempname);
|
||||
return;
|
||||
@@ -515,7 +515,7 @@ WMOInstance::WMOInstance(MPQFile& f, char const* WmoInstName, uint32 mapID, uint
|
||||
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;
|
||||
@@ -526,7 +526,7 @@ WMOInstance::WMOInstance(MPQFile& f, char const* WmoInstName, uint32 mapID, uint
|
||||
|
||||
float scale = 1.0f;
|
||||
uint32 flags = MOD_HAS_BOUND;
|
||||
if(tileX == 65 && tileY == 65) flags |= MOD_WORLDSPAWN;
|
||||
if (tileX == 65 && tileY == 65) flags |= MOD_WORLDSPAWN;
|
||||
//write mapID, tileX, tileY, Flags, ID, Pos, Rot, Scale, Bound_lo, Bound_hi, name
|
||||
fwrite(&mapID, sizeof(uint32), 1, pDirfile);
|
||||
fwrite(&tileX, sizeof(uint32), 1, pDirfile);
|
||||
|
||||
Reference in New Issue
Block a user