refactor(Tools): restyle tools with astyle (#3705)

This commit is contained in:
Kargatum
2020-11-18 09:49:56 +07:00
committed by GitHub
parent 4457e85079
commit 85927685f2
30 changed files with 152 additions and 152 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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]);

View File

@@ -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];

View File

@@ -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);