diff options
| author | Shauren <shauren.trinity@gmail.com> | 2020-09-04 13:38:24 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2020-09-04 13:38:24 +0200 |
| commit | b23190393248455f04d3a06def030a1ec7efad1e (patch) | |
| tree | 1ce3772314492dcdb985641269a3114813d4b4dc /src/tools/vmap4_extractor | |
| parent | b20acfe701e6f5f995f2776f076d3c494c02e1aa (diff) | |
Core/Misc: Port all the refactors sneaked in master to 3.3.5 include cleanup port
Diffstat (limited to 'src/tools/vmap4_extractor')
| -rw-r--r-- | src/tools/vmap4_extractor/model.cpp | 14 | ||||
| -rw-r--r-- | src/tools/vmap4_extractor/vec3d.h | 92 | ||||
| -rw-r--r-- | src/tools/vmap4_extractor/vmapexport.cpp | 8 | ||||
| -rw-r--r-- | src/tools/vmap4_extractor/wmo.cpp | 2 | ||||
| -rw-r--r-- | src/tools/vmap4_extractor/wmo.h | 2 |
5 files changed, 59 insertions, 59 deletions
diff --git a/src/tools/vmap4_extractor/model.cpp b/src/tools/vmap4_extractor/model.cpp index fb46d7691a3..690571703b5 100644 --- a/src/tools/vmap4_extractor/model.cpp +++ b/src/tools/vmap4_extractor/model.cpp @@ -84,11 +84,11 @@ bool Model::open() 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] = { }; + 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(VMAP::RAW_VMAP_MAGIC, 8, 1, output); @@ -107,7 +107,7 @@ bool Model::ConvertToVMAPModel(const char * outfilename) fwrite(&branches, sizeof(branches), 1, output); uint32 nIndexes = header.nBoundingTriangles; fwrite(&nIndexes, sizeof(uint32), 1, output); - fwrite("INDX",4, 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); @@ -129,7 +129,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) { @@ -138,7 +138,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); @@ -162,7 +162,7 @@ void Doodad::Extract(ADT::MDDF const& doodadDef, char const* ModelInstName, uint fseek(input, 8, SEEK_SET); // get the correct no of vertices int nVertices; - int count = fread(&nVertices, sizeof (int), 1, input); + int count = fread(&nVertices, sizeof(int), 1, input); fclose(input); if (count != 1 || nVertices == 0) diff --git a/src/tools/vmap4_extractor/vec3d.h b/src/tools/vmap4_extractor/vec3d.h index 8bb822d9d4c..9f80c2e6acf 100644 --- a/src/tools/vmap4_extractor/vec3d.h +++ b/src/tools/vmap4_extractor/vec3d.h @@ -24,49 +24,49 @@ 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(float x0 = 0.0f, float y0 = 0.0f, float z0 = 0.0f) : x(x0), y(y0), z(z0) { } - Vec3D(const Vec3D& v) = default; + Vec3D(Vec3D const& v) = default; - Vec3D& operator= (const Vec3D &v) = default; + Vec3D& operator=(Vec3D const& v) = default; - Vec3D operator+ (const Vec3D &v) const + Vec3D operator+(Vec3D const& 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-(Vec3D const& 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*(Vec3D const& 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 operator*(float d) const { - Vec3D r(x*d,y*d,z*d); + Vec3D r(x * d, y * d, z * d); return r; } - friend Vec3D operator* (float d, const Vec3D& v) + friend Vec3D operator*(float d, Vec3D const& v) { return v * d; } - Vec3D operator% (const Vec3D &v) const + Vec3D operator%(Vec3D const& 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+=(Vec3D const& v) { x += v.x; y += v.y; @@ -74,7 +74,7 @@ public: return *this; } - Vec3D& operator-= (const Vec3D &v) + Vec3D& operator-=(Vec3D const& v) { x -= v.x; y -= v.y; @@ -82,7 +82,7 @@ public: return *this; } - Vec3D& operator*= (float d) + Vec3D& operator*=(float d) { x *= d; y *= d; @@ -92,21 +92,21 @@ public: float lengthSquared() const { - return x*x+y*y+z*z; + return x * x + y * y + z * z; } float length() const { - return std::sqrt(x*x+y*y+z*z); + return std::sqrt(lengthSquared()); } Vec3D& normalize() { - this->operator*= (1.0f/length()); + *this *= (1.0f / length()); return *this; } - Vec3D operator~ () const + Vec3D operator~() const { Vec3D r(*this); r.normalize(); @@ -119,7 +119,7 @@ public: return in; } - friend std::ostream& operator<<(std::ostream& out, const Vec3D& v) + friend std::ostream& operator<<(std::ostream& out, Vec3D const& v) { out << v.x << " " << v.y << " " << v.z; return out; @@ -148,57 +148,57 @@ public: class Vec2D { public: - float x,y; + float x, y; - Vec2D(float x0 = 0.0f, float y0 = 0.0f) : x(x0), y(y0) {} + Vec2D(float x0 = 0.0f, float y0 = 0.0f) : x(x0), y(y0) { } - Vec2D(const Vec2D& v) = default; + Vec2D(Vec2D const& v) = default; - Vec2D& operator= (const Vec2D &v) = default; + Vec2D& operator=(Vec2D const& v) = default; - Vec2D operator+ (const Vec2D &v) const + Vec2D operator+(Vec2D const& 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-(Vec2D const& 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*(Vec2D const& v) const { - return x*v.x + y*v.y; + return x * v.x + y * v.y; } - Vec2D operator* (float d) const + Vec2D operator*(float d) const { - Vec2D r(x*d,y*d); + Vec2D r(x * d, y * d); return r; } - friend Vec2D operator* (float d, const Vec2D& v) + friend Vec2D operator*(float d, Vec2D const& v) { return v * d; } - Vec2D& operator+= (const Vec2D &v) + Vec2D& operator+=(Vec2D const& v) { x += v.x; y += v.y; return *this; } - Vec2D& operator-= (const Vec2D &v) + Vec2D& operator-=(Vec2D const& v) { x -= v.x; y -= v.y; return *this; } - Vec2D& operator*= (float d) + Vec2D& operator*=(float d) { x *= d; y *= d; @@ -207,28 +207,27 @@ public: float lengthSquared() const { - return x*x+y*y; + return x * x + y * y; } float length() const { - return std::sqrt(x*x+y*y); + return std::sqrt(lengthSquared()); } Vec2D& normalize() { - this->operator*= (1.0f/length()); + *this *= (1.0f / length()); return *this; } - Vec2D operator~ () const + Vec2D operator~() const { Vec2D r(*this); r.normalize(); return r; } - friend std::istream& operator>>(std::istream& in, Vec2D& v) { in >> v.x >> v.y; @@ -241,9 +240,10 @@ public: } }; -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; + float xa = *x - x0; + float ya = *y - y0; *x = xa*cosf(angle) - ya*sinf(angle) + x0; *y = xa*sinf(angle) + ya*cosf(angle) + y0; } diff --git a/src/tools/vmap4_extractor/vmapexport.cpp b/src/tools/vmap4_extractor/vmapexport.cpp index 6ad05e45f82..f633347f387 100644 --- a/src/tools/vmap4_extractor/vmapexport.cpp +++ b/src/tools/vmap4_extractor/vmapexport.cpp @@ -65,7 +65,7 @@ std::unordered_map<std::string, WMODoodadData> WmoDoodads; // Constants -const char* szWorkDirWmo = "./Buildings"; +char const* szWorkDirWmo = "./Buildings"; #define CASC_LOCALES_COUNT 17 char const* CascLocaleNames[CASC_LOCALES_COUNT] = @@ -111,7 +111,7 @@ bool OpenCascStorage(int locale) return true; } - catch (boost::filesystem::filesystem_error& error) + catch (boost::filesystem::filesystem_error const& error) { printf("error opening casc storage : %s\n", error.what()); return false; @@ -145,7 +145,7 @@ uint32 GenerateUniqueObjectId(uint32 clientId, uint16 clientDoodadId) } // Local testing functions -bool FileExists(const char* file) +bool FileExists(char const* file) { if (FILE* n = fopen(file, "rb")) { @@ -426,7 +426,7 @@ int main(int argc, char ** argv) } } - printf("Extract %s. Beginning work ....\n\n", versionString); + printf("Extract %s. Beginning work ....\n", versionString); //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // Create the working directory if (mkdir(szWorkDirWmo diff --git a/src/tools/vmap4_extractor/wmo.cpp b/src/tools/vmap4_extractor/wmo.cpp index 5c060c9dafd..3cffab838d7 100644 --- a/src/tools/vmap4_extractor/wmo.cpp +++ b/src/tools/vmap4_extractor/wmo.cpp @@ -584,7 +584,7 @@ void MapObject::Extract(ADT::MODF const& mapObjDef, char const* WmoInstName, boo fseek(input, 8, SEEK_SET); // get the correct no of vertices int nVertices; - int count = fread(&nVertices, sizeof (int), 1, input); + int count = fread(&nVertices, sizeof(int), 1, input); fclose(input); if (count != 1 || nVertices == 0) diff --git a/src/tools/vmap4_extractor/wmo.h b/src/tools/vmap4_extractor/wmo.h index 9751b1fa2cb..a2dc39a2e81 100644 --- a/src/tools/vmap4_extractor/wmo.h +++ b/src/tools/vmap4_extractor/wmo.h @@ -64,7 +64,7 @@ namespace WMO } /* 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(Vec3D const& v){ return Vec3D(v.z, v.x, v.y); } struct WMODoodadData { |
