]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Graphic/Models.cpp
Added braces to all statements with clang-tidy and ran clang-format again
[lugaru.git] / Source / Graphic / Models.cpp
index 09036ae9d5009e9d85e4e442a4d0c755c288f2d6..eedaea0753cf5040ad19e21803b30fa27875b997 100644 (file)
@@ -30,7 +30,7 @@ extern float fadestart;
 extern float texdetail;
 extern bool decalstoggle;
 
-int Model::LineCheck(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate)
+int Model::LineCheck(XYZ* p1, XYZ* p2, XYZ* p, XYZ* move, float* rotate)
 {
     static float distance;
     static float olddistance;
@@ -40,12 +40,15 @@ int Model::LineCheck(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate)
 
     *p1 = *p1 - *move;
     *p2 = *p2 - *move;
-    if (*rotate)
+    if (*rotate) {
         *p1 = DoRotation(*p1, 0, -*rotate, 0);
-    if (*rotate)
+    }
+    if (*rotate) {
         *p2 = DoRotation(*p2, 0, -*rotate, 0);
-    if (!sphere_line_intersection(p1, p2, &boundingspherecenter, &boundingsphereradius))
+    }
+    if (!sphere_line_intersection(p1, p2, &boundingspherecenter, &boundingsphereradius)) {
         return -1;
+    }
     firstintersecting = -1;
 
     for (unsigned int j = 0; j < Triangles.size(); j++) {
@@ -58,13 +61,14 @@ int Model::LineCheck(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate)
         }
     }
 
-    if (*rotate)
+    if (*rotate) {
         *p = DoRotation(*p, 0, *rotate, 0);
+    }
     *p = *p + *move;
     return firstintersecting;
 }
 
-int Model::LineCheckPossible(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate)
+int Model::LineCheckPossible(XYZ* p1, XYZ* p2, XYZ* p, XYZ* move, float* rotate)
 {
     static float distance;
     static float olddistance;
@@ -74,13 +78,16 @@ int Model::LineCheckPossible(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate)
 
     *p1 = *p1 - *move;
     *p2 = *p2 - *move;
-    if (!sphere_line_intersection(p1, p2, &boundingspherecenter, &boundingsphereradius))
+    if (!sphere_line_intersection(p1, p2, &boundingspherecenter, &boundingsphereradius)) {
         return -1;
+    }
     firstintersecting = -1;
-    if (*rotate)
+    if (*rotate) {
         *p1 = DoRotation(*p1, 0, -*rotate, 0);
-    if (*rotate)
+    }
+    if (*rotate) {
         *p2 = DoRotation(*p2, 0, -*rotate, 0);
+    }
 
     for (unsigned int j = 0; j < possible.size(); j++) {
         if (possible[j] < Triangles.size()) {
@@ -94,13 +101,14 @@ int Model::LineCheckPossible(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate)
         }
     }
 
-    if (*rotate)
+    if (*rotate) {
         *p = DoRotation(*p, 0, *rotate, 0);
+    }
     *p = *p + *move;
     return firstintersecting;
 }
 
-int Model::LineCheckSlidePossible(XYZ *p1, XYZ *p2, XYZ *move, float *rotate)
+int Model::LineCheckSlidePossible(XYZ* p1, XYZ* p2, XYZ* move, float* rotate)
 {
     static float distance;
     static float olddistance;
@@ -110,13 +118,16 @@ int Model::LineCheckSlidePossible(XYZ *p1, XYZ *p2, XYZ *move, float *rotate)
 
     *p1 = *p1 - *move;
     *p2 = *p2 - *move;
-    if (!sphere_line_intersection(p1, p2, &boundingspherecenter, &boundingsphereradius))
+    if (!sphere_line_intersection(p1, p2, &boundingspherecenter, &boundingsphereradius)) {
         return -1;
+    }
     firstintersecting = -1;
-    if (*rotate)
+    if (*rotate) {
         *p1 = DoRotation(*p1, 0, -*rotate, 0);
-    if (*rotate)
+    }
+    if (*rotate) {
         *p2 = DoRotation(*p2, 0, -*rotate, 0);
+    }
 
     for (unsigned int j = 0; j < possible.size(); j++) {
         if (possible[j] < Triangles.size()) {
@@ -134,13 +145,14 @@ int Model::LineCheckSlidePossible(XYZ *p1, XYZ *p2, XYZ *move, float *rotate)
         *p2 -= Triangles[firstintersecting].facenormal * distance;
     }
 
-    if (*rotate)
+    if (*rotate) {
         *p2 = DoRotation(*p2, 0, *rotate, 0);
+    }
     *p2 = *p2 + *move;
     return firstintersecting;
 }
 
-int Model::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate)
+int Model::SphereCheck(XYZ* p1, float radius, XYZ* p, XYZ* move, float* rotate)
 {
     static int i;
     static float distance;
@@ -154,10 +166,12 @@ int Model::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate)
 
     oldp1 = *p1;
     *p1 = *p1 - *move;
-    if (*rotate)
+    if (*rotate) {
         *p1 = DoRotation(*p1, 0, -*rotate, 0);
-    if (distsq(p1, &boundingspherecenter) > radius * radius + boundingsphereradius * boundingsphereradius)
+    }
+    if (distsq(p1, &boundingspherecenter) > radius * radius + boundingsphereradius * boundingsphereradius) {
         return -1;
+    }
 
     for (i = 0; i < 4; i++) {
         for (unsigned int j = 0; j < Triangles.size(); j++) {
@@ -165,14 +179,18 @@ int Model::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate)
             distance = abs((Triangles[j].facenormal.x * p1->x) + (Triangles[j].facenormal.y * p1->y) + (Triangles[j].facenormal.z * p1->z) - ((Triangles[j].facenormal.x * vertex[Triangles[j].vertex[0]].x) + (Triangles[j].facenormal.y * vertex[Triangles[j].vertex[0]].y) + (Triangles[j].facenormal.z * vertex[Triangles[j].vertex[0]].z)));
             if (distance < radius) {
                 point = *p1 - Triangles[j].facenormal * distance;
-                if (PointInTriangle( &point, Triangles[j].facenormal, &vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]]))
+                if (PointInTriangle(&point, Triangles[j].facenormal, &vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]])) {
                     intersecting = 1;
-                if (!intersecting)
+                }
+                if (!intersecting) {
                     intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], p1, &radius);
-                if (!intersecting)
+                }
+                if (!intersecting) {
                     intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]], p1, &radius);
-                if (!intersecting)
+                }
+                if (!intersecting) {
                     intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[2]], p1, &radius);
+                }
                 if (intersecting) {
                     *p1 += Triangles[j].facenormal * (distance - radius);
                 }
@@ -184,16 +202,18 @@ int Model::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate)
             }
         }
     }
-    if (*rotate)
+    if (*rotate) {
         *p = DoRotation(*p, 0, *rotate, 0);
+    }
     *p = *p + *move;
-    if (*rotate)
+    if (*rotate) {
         *p1 = DoRotation(*p1, 0, *rotate, 0);
+    }
     *p1 += *move;
     return firstintersecting;
 }
 
-int Model::SphereCheckPossible(XYZ *p1, float radius, XYZ *move, float *rotate)
+int Model::SphereCheckPossible(XYZ* p1, float radius, XYZ* move, float* rotate)
 {
     static float distance;
     static float olddistance;
@@ -209,8 +229,9 @@ int Model::SphereCheckPossible(XYZ *p1, float radius, XYZ *move, float *rotate)
 
     possible.clear();
 
-    if (*rotate)
+    if (*rotate) {
         *p1 = DoRotation(*p1, 0, -*rotate, 0);
+    }
     if (distsq(p1, &boundingspherecenter) > radius * radius + boundingsphereradius * boundingsphereradius) {
         *p1 = oldp1;
         return -1;
@@ -221,14 +242,18 @@ int Model::SphereCheckPossible(XYZ *p1, float radius, XYZ *move, float *rotate)
         distance = abs((Triangles[j].facenormal.x * p1->x) + (Triangles[j].facenormal.y * p1->y) + (Triangles[j].facenormal.z * p1->z) - ((Triangles[j].facenormal.x * vertex[Triangles[j].vertex[0]].x) + (Triangles[j].facenormal.y * vertex[Triangles[j].vertex[0]].y) + (Triangles[j].facenormal.z * vertex[Triangles[j].vertex[0]].z)));
         if (distance < radius) {
             point = *p1 - Triangles[j].facenormal * distance;
-            if (PointInTriangle( &point, Triangles[j].facenormal, &vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]]))
+            if (PointInTriangle(&point, Triangles[j].facenormal, &vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]])) {
                 intersecting = 1;
-            if (!intersecting)
+            }
+            if (!intersecting) {
                 intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], p1, &radius);
-            if (!intersecting)
+            }
+            if (!intersecting) {
                 intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]], p1, &radius);
-            if (!intersecting)
+            }
+            if (!intersecting) {
                 intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[2]], p1, &radius);
+            }
             if (intersecting) {
                 possible.push_back(j);
             }
@@ -238,18 +263,19 @@ int Model::SphereCheckPossible(XYZ *p1, float radius, XYZ *move, float *rotate)
             firstintersecting = j;
         }
     }
-    if (*rotate)
+    if (*rotate) {
         *p1 = DoRotation(*p1, 0, *rotate, 0);
+    }
     *p1 += *move;
 
     return firstintersecting;
 }
 
-
 void Model::UpdateVertexArray()
 {
-    if (type != normaltype && type != decalstype)
+    if (type != normaltype && type != decalstype) {
         return;
+    }
 
     if (flat) {
         for (unsigned int i = 0; i < Triangles.size(); i++) {
@@ -316,8 +342,9 @@ void Model::UpdateVertexArray()
 
 void Model::UpdateVertexArrayNoTex()
 {
-    if (type != normaltype && type != decalstype)
+    if (type != normaltype && type != decalstype) {
         return;
+    }
 
     if (flat) {
         for (unsigned int i = 0; i < Triangles.size(); i++) {
@@ -372,8 +399,9 @@ void Model::UpdateVertexArrayNoTex()
 
 void Model::UpdateVertexArrayNoTexNoNorm()
 {
-    if (type != normaltype && type != decalstype)
+    if (type != normaltype && type != decalstype) {
         return;
+    }
 
     for (unsigned int i = 0; i < Triangles.size(); i++) {
         unsigned int j = i * 24;
@@ -393,14 +421,14 @@ void Model::UpdateVertexArrayNoTexNoNorm()
 
 bool Model::loadnotex(const std::string& filename)
 {
-    FILE *tfile;
+    FILEtfile;
     long i;
     short triangleNum;
 
     type = notextype;
     color = 0;
 
-    tfile = Folders::openMandatoryFile( Folders::getResourcePath(filename), "rb" );
+    tfile = Folders::openMandatoryFile(Folders::getResourcePath(filename), "rb");
 
     // read model settings
 
@@ -453,10 +481,9 @@ bool Model::loadnotex(const std::string& filename)
     return true;
 }
 
-
 bool Model::load(const std::string& filename)
 {
-    FILE *tfile;
+    FILEtfile;
     long i;
     short triangleNum;
 
@@ -469,7 +496,7 @@ bool Model::load(const std::string& filename)
     type = normaltype;
     color = 0;
 
-    tfile = Folders::openMandatoryFile( Folders::getResourcePath(filename), "rb" );
+    tfile = Folders::openMandatoryFile(Folders::getResourcePath(filename), "rb");
 
     // read model settings
 
@@ -528,7 +555,7 @@ bool Model::load(const std::string& filename)
 
 bool Model::loaddecal(const std::string& filename)
 {
-    FILE *tfile;
+    FILEtfile;
     long i, j;
     short triangleNum;
 
@@ -539,7 +566,7 @@ bool Model::loaddecal(const std::string& filename)
     type = decalstype;
     color = 0;
 
-    tfile = Folders::openMandatoryFile( Folders::getResourcePath(filename), "rb" );
+    tfile = Folders::openMandatoryFile(Folders::getResourcePath(filename), "rb");
 
     // read model settings
 
@@ -572,7 +599,6 @@ bool Model::loaddecal(const std::string& filename)
         funpackf(tfile, "Bf Bf Bf", &Triangles[i].gy[0], &Triangles[i].gy[1], &Triangles[i].gy[2]);
     }
 
-
     modelTexture.xsz = 0;
 
     fclose(tfile);
@@ -599,7 +625,7 @@ bool Model::loaddecal(const std::string& filename)
 
 bool Model::loadraw(const std::string& filename)
 {
-    FILE *tfile;
+    FILEtfile;
     long i;
     short triangleNum;
 
@@ -610,7 +636,7 @@ bool Model::loadraw(const std::string& filename)
     type = rawtype;
     color = 0;
 
-    tfile = Folders::openMandatoryFile( Folders::getResourcePath(filename), "rb" );
+    tfile = Folders::openMandatoryFile(Folders::getResourcePath(filename), "rb");
 
     // read model settings
 
@@ -627,7 +653,6 @@ bool Model::loadraw(const std::string& filename)
     Triangles.resize(triangleNum);
     vArray = (GLfloat*)malloc(sizeof(GLfloat) * triangleNum * 24);
 
-
     for (i = 0; i < vertexNum; i++) {
         funpackf(tfile, "Bf Bf Bf", &vertex[i].x, &vertex[i].y, &vertex[i].z);
     }
@@ -642,7 +667,6 @@ bool Model::loadraw(const std::string& filename)
         funpackf(tfile, "Bf Bf Bf", &Triangles[i].gy[0], &Triangles[i].gy[1], &Triangles[i].gy[2]);
     }
 
-
     fclose(tfile);
 
     for (i = 0; i < vertexNum; i++) {
@@ -652,7 +676,6 @@ bool Model::loadraw(const std::string& filename)
     return true;
 }
 
-
 void Model::UniformTexCoords()
 {
     for (unsigned int i = 0; i < Triangles.size(); i++) {
@@ -666,7 +689,6 @@ void Model::UniformTexCoords()
     UpdateVertexArray();
 }
 
-
 void Model::FlipTexCoords()
 {
     for (unsigned int i = 0; i < Triangles.size(); i++) {
@@ -716,8 +738,9 @@ void Model::Scale(float xscale, float yscale, float zscale)
 
 void Model::ScaleNormals(float xscale, float yscale, float zscale)
 {
-    if (type != normaltype && type != decalstype)
+    if (type != normaltype && type != decalstype) {
         return;
+    }
 
     for (int i = 0; i < vertexNum; i++) {
         normals[i].x *= xscale;
@@ -776,13 +799,13 @@ void Model::Rotate(float xang, float yang, float zang)
     boundingsphereradius = fast_sqrt(boundingsphereradius);
 }
 
-
 void Model::CalculateNormals(bool facenormalise)
 {
     Game::LoadingScreen();
 
-    if (type != normaltype && type != decalstype)
+    if (type != normaltype && type != decalstype) {
         return;
+    }
 
     for (int i = 0; i < vertexNum; i++) {
         normals[i].x = 0;
@@ -804,8 +827,9 @@ void Model::CalculateNormals(bool facenormalise)
         normals[Triangles[i].vertex[2]].x += Triangles[i].facenormal.x;
         normals[Triangles[i].vertex[2]].y += Triangles[i].facenormal.y;
         normals[Triangles[i].vertex[2]].z += Triangles[i].facenormal.z;
-        if (facenormalise)
+        if (facenormalise) {
             Normalise(&Triangles[i].facenormal);
+        }
     }
     for (int i = 0; i < vertexNum; i++) {
         Normalise(&normals[i]);
@@ -854,17 +878,18 @@ void Model::drawimmediate()
 
 void Model::draw()
 {
-    if (type != normaltype && type != decalstype)
+    if (type != normaltype && type != decalstype) {
         return;
+    }
 
     glEnableClientState(GL_NORMAL_ARRAY);
     glEnableClientState(GL_VERTEX_ARRAY);
     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 
     if (color) {
-        glInterleavedArrays( GL_T2F_C3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
+        glInterleavedArrays(GL_T2F_C3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
     } else {
-        glInterleavedArrays( GL_T2F_N3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
+        glInterleavedArrays(GL_T2F_N3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
     }
     textureptr.bind();
 
@@ -885,14 +910,14 @@ void Model::drawdifftex(Texture texture)
     glEnableClientState(GL_VERTEX_ARRAY);
     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
     if (color) {
-        glInterleavedArrays( GL_T2F_C3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
+        glInterleavedArrays(GL_T2F_C3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
     } else {
-        glInterleavedArrays( GL_T2F_N3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
+        glInterleavedArrays(GL_T2F_N3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
     }
 
     texture.bind();
-    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
-    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
+    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
 
     glDrawArrays(GL_TRIANGLES, 0, Triangles.size() * 3);
 
@@ -921,8 +946,9 @@ void Model::drawdecals(Texture shadowtexture, Texture bloodtexture, Texture bloo
         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
         glDepthMask(0);
         for (unsigned int i = 0; i < decals.size(); i++) {
-            if (decals[i].type == blooddecalfast && decals[i].alivetime < 2)
+            if (decals[i].type == blooddecalfast && decals[i].alivetime < 2) {
                 decals[i].alivetime = 2;
+            }
 
             if (decals[i].type != lasttype) {
                 if (decals[i].type == shadowdecal) {
@@ -963,15 +989,18 @@ void Model::drawdecals(Texture shadowtexture, Texture bloodtexture, Texture bloo
             }
             if (decals[i].type == breakdecal) {
                 glColor4f(1, 1, 1, decals[i].opacity);
-                if (decals[i].alivetime > 58)
+                if (decals[i].alivetime > 58) {
                     glColor4f(1, 1, 1, decals[i].opacity * (60 - decals[i].alivetime) / 2);
+                }
             }
             if ((decals[i].type == blooddecal || decals[i].type == blooddecalfast || decals[i].type == blooddecalslow)) {
                 glColor4f(1, 1, 1, decals[i].opacity);
-                if (decals[i].alivetime < 4)
-                    glColor4f(1, 1, 1, decals[i].opacity*decals[i].alivetime*.25);
-                if (decals[i].alivetime > 58)
+                if (decals[i].alivetime < 4) {
+                    glColor4f(1, 1, 1, decals[i].opacity * decals[i].alivetime * .25);
+                }
+                if (decals[i].alivetime > 58) {
                     glColor4f(1, 1, 1, decals[i].opacity * (60 - decals[i].alivetime) / 2);
+                }
             }
             lasttype = decals[i].type;
             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
@@ -989,14 +1018,18 @@ void Model::drawdecals(Texture shadowtexture, Texture bloodtexture, Texture bloo
         }
         for (int i = decals.size() - 1; i >= 0; i--) {
             decals[i].alivetime += multiplier;
-            if (decals[i].type == blooddecalslow)
+            if (decals[i].type == blooddecalslow) {
                 decals[i].alivetime -= multiplier * 2 / 3;
-            if (decals[i].type == blooddecalfast)
+            }
+            if (decals[i].type == blooddecalfast) {
                 decals[i].alivetime += multiplier * 4;
-            if (decals[i].type == shadowdecal)
+            }
+            if (decals[i].type == shadowdecal) {
                 DeleteDecal(i);
-            if ((decals[i].type == blooddecal || decals[i].type == blooddecalfast || decals[i].type == blooddecalslow) && decals[i].alivetime >= 60)
+            }
+            if ((decals[i].type == blooddecal || decals[i].type == blooddecalfast || decals[i].type == blooddecalslow) && decals[i].alivetime >= 60) {
                 DeleteDecal(i);
+            }
         }
         glAlphaFunc(GL_GREATER, 0.0001);
         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -1006,23 +1039,25 @@ void Model::drawdecals(Texture shadowtexture, Texture bloodtexture, Texture bloo
 void Model::DeleteDecal(int which)
 {
     if (decalstoggle) {
-        if (type != decalstype)
+        if (type != decalstype) {
             return;
+        }
         decals.erase(decals.begin() + which);
     }
 }
 
-void Model::MakeDecal(decal_type atype, XYZ *where, float *size, float *opacity, float *rotation)
+void Model::MakeDecal(decal_type atype, XYZ* where, float* size, float* opacity, float* rotation)
 {
     if (decalstoggle) {
-        if (type != decalstype)
+        if (type != decalstype) {
             return;
+        }
 
         static XYZ rot;
         static float distance;
 
-        if (*opacity > 0)
-            if (distsq(where, &boundingspherecenter) < (boundingsphereradius + *size) * (boundingsphereradius + *size))
+        if (*opacity > 0) {
+            if (distsq(where, &boundingspherecenter) < (boundingsphereradius + *size) * (boundingsphereradius + *size)) {
                 for (unsigned int i = 0; i < Triangles.size(); i++) {
                     if (Triangles[i].facenormal.y < -.1 && (vertex[Triangles[i].vertex[0]].y < where->y || vertex[Triangles[i].vertex[1]].y < where->y || vertex[Triangles[i].vertex[2]].y < where->y)) {
                         distance = abs(((Triangles[i].facenormal.x * where->x) + (Triangles[i].facenormal.y * where->y) + (Triangles[i].facenormal.z * where->z) - ((Triangles[i].facenormal.x * vertex[Triangles[i].vertex[0]].x) + (Triangles[i].facenormal.y * vertex[Triangles[i].vertex[0]].y) + (Triangles[i].facenormal.z * vertex[Triangles[i].vertex[0]].z))) / Triangles[i].facenormal.y);
@@ -1030,9 +1065,9 @@ void Model::MakeDecal(decal_type atype, XYZ *where, float *size, float *opacity,
                         if ((*opacity - distance / 10) > 0) {
                             Decal decal(*where, atype, *opacity - distance / 10, *rotation, *size, *this, i, 0);
 
-                            if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0))
-                                if (!(decal.texcoords[0][1] < 0 && decal.texcoords[1][1] < 0 && decal.texcoords[2][1] < 0))
-                                    if (!(decal.texcoords[0][0] > 1 && decal.texcoords[1][0] > 1 && decal.texcoords[2][0] > 1))
+                            if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0)) {
+                                if (!(decal.texcoords[0][1] < 0 && decal.texcoords[1][1] < 0 && decal.texcoords[2][1] < 0)) {
+                                    if (!(decal.texcoords[0][0] > 1 && decal.texcoords[1][0] > 1 && decal.texcoords[2][0] > 1)) {
                                         if (!(decal.texcoords[0][1] > 1 && decal.texcoords[1][1] > 1 && decal.texcoords[2][1] > 1)) {
                                             if (decal.rotation) {
                                                 for (int j = 0; j < 3; j++) {
@@ -1048,32 +1083,38 @@ void Model::MakeDecal(decal_type atype, XYZ *where, float *size, float *opacity,
                                                 decals.push_back(decal);
                                             }
                                         }
+                                    }
+                                }
+                            }
                         }
                     }
                 }
+            }
+        }
     }
 }
 
 void Model::MakeDecal(decal_type atype, XYZ where, float size, float opacity, float rotation)
 {
     if (decalstoggle) {
-        if (type != decalstype)
+        if (type != decalstype) {
             return;
+        }
 
         static XYZ rot;
         static float distance;
 
-        if (opacity > 0)
-            if (distsq(&where, &boundingspherecenter) < (boundingsphereradius + size) * (boundingsphereradius + size))
+        if (opacity > 0) {
+            if (distsq(&where, &boundingspherecenter) < (boundingsphereradius + size) * (boundingsphereradius + size)) {
                 for (unsigned int i = 0; i < Triangles.size(); i++) {
                     distance = abs(((Triangles[i].facenormal.x * where.x) + (Triangles[i].facenormal.y * where.y) + (Triangles[i].facenormal.z * where.z) - ((Triangles[i].facenormal.x * vertex[Triangles[i].vertex[0]].x) + (Triangles[i].facenormal.y * vertex[Triangles[i].vertex[0]].y) + (Triangles[i].facenormal.z * vertex[Triangles[i].vertex[0]].z))));
                     if (distance < .02 && abs(Triangles[i].facenormal.y) > abs(Triangles[i].facenormal.x) && abs(Triangles[i].facenormal.y) > abs(Triangles[i].facenormal.z)) {
                         if ((opacity - distance / 10) > 0) {
                             Decal decal(where, atype, opacity - distance / 10, rotation, size, *this, i, 0);
 
-                            if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0))
-                                if (!(decal.texcoords[0][1] < 0 && decal.texcoords[1][1] < 0 && decal.texcoords[2][1] < 0))
-                                    if (!(decal.texcoords[0][0] > 1 && decal.texcoords[1][0] > 1 && decal.texcoords[2][0] > 1))
+                            if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0)) {
+                                if (!(decal.texcoords[0][1] < 0 && decal.texcoords[1][1] < 0 && decal.texcoords[2][1] < 0)) {
+                                    if (!(decal.texcoords[0][0] > 1 && decal.texcoords[1][0] > 1 && decal.texcoords[2][0] > 1)) {
                                         if (!(decal.texcoords[0][1] > 1 && decal.texcoords[1][1] > 1 && decal.texcoords[2][1] > 1)) {
                                             if (decal.rotation) {
                                                 for (int j = 0; j < 3; j++) {
@@ -1089,14 +1130,17 @@ void Model::MakeDecal(decal_type atype, XYZ where, float size, float opacity, fl
                                                 decals.push_back(decal);
                                             }
                                         }
+                                    }
+                                }
+                            }
                         }
                     } else if (distance < .02 && abs(Triangles[i].facenormal.x) > abs(Triangles[i].facenormal.y) && abs(Triangles[i].facenormal.x) > abs(Triangles[i].facenormal.z)) {
                         if ((opacity - distance / 10) > 0) {
                             Decal decal(where, atype, opacity - distance / 10, rotation, size, *this, i, 1);
 
-                            if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0))
-                                if (!(decal.texcoords[0][1] < 0 && decal.texcoords[1][1] < 0 && decal.texcoords[2][1] < 0))
-                                    if (!(decal.texcoords[0][0] > 1 && decal.texcoords[1][0] > 1 && decal.texcoords[2][0] > 1))
+                            if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0)) {
+                                if (!(decal.texcoords[0][1] < 0 && decal.texcoords[1][1] < 0 && decal.texcoords[2][1] < 0)) {
+                                    if (!(decal.texcoords[0][0] > 1 && decal.texcoords[1][0] > 1 && decal.texcoords[2][0] > 1)) {
                                         if (!(decal.texcoords[0][1] > 1 && decal.texcoords[1][1] > 1 && decal.texcoords[2][1] > 1)) {
                                             if (decal.rotation) {
                                                 for (int j = 0; j < 3; j++) {
@@ -1112,14 +1156,17 @@ void Model::MakeDecal(decal_type atype, XYZ where, float size, float opacity, fl
                                                 decals.push_back(decal);
                                             }
                                         }
+                                    }
+                                }
+                            }
                         }
                     } else if (distance < .02 && abs(Triangles[i].facenormal.z) > abs(Triangles[i].facenormal.y) && abs(Triangles[i].facenormal.z) > abs(Triangles[i].facenormal.x)) {
                         if ((opacity - distance / 10) > 0) {
                             Decal decal(where, atype, opacity - distance / 10, rotation, size, *this, i, 2);
 
-                            if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0))
-                                if (!(decal.texcoords[0][1] < 0 && decal.texcoords[1][1] < 0 && decal.texcoords[2][1] < 0))
-                                    if (!(decal.texcoords[0][0] > 1 && decal.texcoords[1][0] > 1 && decal.texcoords[2][0] > 1))
+                            if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0)) {
+                                if (!(decal.texcoords[0][1] < 0 && decal.texcoords[1][1] < 0 && decal.texcoords[2][1] < 0)) {
+                                    if (!(decal.texcoords[0][0] > 1 && decal.texcoords[1][0] > 1 && decal.texcoords[2][0] > 1)) {
                                         if (!(decal.texcoords[0][1] > 1 && decal.texcoords[1][1] > 1 && decal.texcoords[2][1] > 1)) {
                                             if (decal.rotation) {
                                                 for (int j = 0; j < 3; j++) {
@@ -1135,9 +1182,14 @@ void Model::MakeDecal(decal_type atype, XYZ where, float size, float opacity, fl
                                                 decals.push_back(decal);
                                             }
                                         }
+                                    }
+                                }
+                            }
                         }
                     }
                 }
+            }
+        }
     }
 }
 
@@ -1162,36 +1214,40 @@ Model::~Model()
 
 void Model::deallocate()
 {
-    if (owner)
+    if (owner) {
         free(owner);
+    }
     owner = 0;
 
-    if (vertex)
+    if (vertex) {
         free(vertex);
+    }
     vertex = 0;
 
-    if (normals)
+    if (normals) {
         free(normals);
+    }
     normals = 0;
 
-    if (vArray)
+    if (vArray) {
         free(vArray);
+    }
     vArray = 0;
 
     decals.clear();
 }
 
 Model::Model()
-  : vertexNum(0),
-    type(nothing),
-    owner(0),
-    vertex(0),
-    normals(0),
-    vArray(0),
-    color(0),
-    boundingspherecenter(),
-    boundingsphereradius(0),
-    flat(false)
+    : vertexNum(0)
+    , type(nothing)
+    , owner(0)
+    , vertex(0)
+    , normals(0)
+    , vArray(0)
+    , color(0)
+    , boundingspherecenter()
+    , boundingsphereradius(0)
+    flat(false)
 {
     memset(&modelTexture, 0, sizeof(modelTexture));
 }