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

This commit is contained in:
Kargatum
2020-10-06 16:31:28 +07:00
committed by GitHub
parent be09e03756
commit b00a86f6ab
51 changed files with 1004 additions and 936 deletions
+14 -5
View File
@@ -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",
@@ -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;
+22 -11
View File
@@ -33,7 +33,8 @@ enum LiquidType
//
class adt_MCVT
{
union{
union
{
uint32 fcc;
char fcc_txt[4];
};
@@ -49,7 +50,8 @@ public:
//
class adt_MCLQ
{
union{
union
{
uint32 fcc;
char fcc_txt[4];
};
@@ -57,7 +59,8 @@ 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];
@@ -78,7 +81,8 @@ public:
//
class adt_MCNK
{
union{
union
{
uint32 fcc;
char fcc_txt[4];
};
@@ -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;
@@ -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;
@@ -274,7 +283,8 @@ public:
//
class adt_MHDR
{
union{
union
{
uint32 fcc;
char fcc_txt[4];
};
@@ -317,7 +327,8 @@ public:
}
};
class ADT_file : public FileLoader{
class ADT_file : public FileLoader
{
public:
bool prepareLoadedData();
ADT_file();
+4 -2
View File
@@ -79,13 +79,15 @@ public:
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 {
const Record* operator->() const
{
return &record;
}
/// Comparison
+4 -2
View File
@@ -48,7 +48,8 @@ union u_map_fcc
//
struct file_MVER
{
union{
union
{
uint32 fcc;
char fcc_txt[4];
};
@@ -56,7 +57,8 @@ struct file_MVER
uint32 ver;
};
class FileLoader{
class FileLoader
{
uint8* data;
uint32 data_size;
public:
+8 -4
View File
@@ -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;
@@ -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("warning: file %s has size %d; cannot read.\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;
}
+4 -2
View File
@@ -27,7 +27,8 @@ public:
~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;
@@ -43,7 +44,8 @@ public:
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;
+16 -8
View File
@@ -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();
+4 -2
View File
@@ -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;
}
+2 -1
View File
@@ -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",
+1 -2
View File
@@ -881,8 +881,7 @@ 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)
{
+1 -2
View File
@@ -93,8 +93,7 @@ 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);
+33 -16
View File
@@ -559,23 +559,41 @@ namespace MMAP
indices[1] = square + V9_SIZE + 1 + rowOffset;
indices[2] = square + V9_SIZE + rowOffset;
break;
default: 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
*/
}
@@ -773,8 +791,7 @@ namespace MMAP
}
}
}
}
while (false);
} while (false);
vmapManager->unloadMap(mapID, tileX, tileY);
delete vmapManager;
+4 -2
View File
@@ -98,13 +98,15 @@ public:
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 {
const Record* operator->() const
{
return &record;
}
/// Comparison
+4 -2
View File
@@ -42,7 +42,8 @@ typedef uint8_t uint8;
//
struct file_MVER
{
union{
union
{
uint32 fcc;
char fcc_txt[4];
};
@@ -50,7 +51,8 @@ struct file_MVER
uint32 ver;
};
class FileLoader{
class FileLoader
{
uint8* data;
uint32 data_size;
public:
+8 -4
View File
@@ -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;
@@ -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;
}
+4 -2
View File
@@ -26,7 +26,8 @@ public:
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;
@@ -42,7 +43,8 @@ public:
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;
+4 -2
View File
@@ -19,7 +19,8 @@ public:
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;
@@ -135,7 +136,8 @@ public:
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;