]> git.jsancho.org Git - lugaru.git/commitdiff
Fixing some warnings
authorNicola Spanti (RyDroid) <dev@nicola-spanti.info>
Tue, 20 Dec 2016 00:02:04 +0000 (01:02 +0100)
committerRémi Verschelde <rverschelde@gmail.com>
Thu, 22 Dec 2016 13:49:24 +0000 (14:49 +0100)
CMakeLists.txt
Source/GameDraw.cpp
Source/GameTick.cpp
Source/Graphic/Models.cpp
Source/Objects/Object.cpp
Source/Objects/Person.cpp

index ef94e17f7757eea7a9b8fcc3dc807b67a76fca5d..4b6094c8408953d64902a3062a8c0a171e4462e6 100644 (file)
@@ -23,7 +23,7 @@ if(NOT CMAKE_BUILD_TYPE)
 endif(NOT CMAKE_BUILD_TYPE)
 message("CMake build type: ${CMAKE_BUILD_TYPE}")
 
-set(CMAKE_CXX_FLAGS "-Wall -Wno-parentheses -pedantic --std=gnu++11 ${CMAKE_CXX_FLAGS}")
+set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-parentheses -pedantic --std=gnu++11 ${CMAKE_CXX_FLAGS}")
 
 if(APPLE)
     set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for OSX")
index 5b3edfa18ffe6e9e3e00df3f9edd6e2bb125d916..d14a07744e3760f888b11d9e4d3d0a710ccb463d 100644 (file)
@@ -1074,7 +1074,7 @@ int Game::DrawGLScene(StereoSide side)
             glPopMatrix();
             glRotatef(Person::players[0]->lookyaw * -1 + 180, 0, 0, 1);
             glTranslatef(-(center.x / terrain.scale / 256 * -2 + 1), (center.z / terrain.scale / 256 * -2 + 1), 0);
-            for (int i = 0; i < Object::objects.size(); i++) {
+            for (unsigned int i = 0; i < Object::objects.size(); i++) {
                 if (Object::objects[i]->type == treetrunktype) {
                     distcheck = distsq(&Person::players[0]->coords, &Object::objects[i]->position);
                     if (distcheck < mapviewdist) {
index 514ab54a9f094b94f266a90bdb6495af12df7dec..f9a3f88a789bc15a21c74de39aef131b2bcf184a 100644 (file)
@@ -313,11 +313,12 @@ static int findClosestObject()
     int closest = -1;
     float closestdist = std::numeric_limits<float>::max();
 
-    for (int i = 0; i < Object::objects.size(); i++) {
-        float distance = distsq(&Object::objects[i]->position, &Person::players[0]->coords);
+    for (unsigned int i = 0; i < Object::objects.size(); i++) {
+        float distance = distsq(&Object::objects[i]->position,
+                               &Person::players[0]->coords);
         if (distance < closestdist) {
             closestdist = distance;
-            closest = i;
+            closest = (int) i;
         }
     }
     return closest;
@@ -416,8 +417,6 @@ void Setenvironment(int which)
                         "Textures/Skybox(snow)/Down.jpg");
 
 
-
-
         texdetail = temptexdetail;
     } else if (environment == desertenvironment) {
         windvector = 0;
@@ -451,8 +450,6 @@ void Setenvironment(int which)
                         "Textures/Skybox(sand)/Down.jpg");
 
 
-
-
         texdetail = temptexdetail;
     } else if (environment == grassyenvironment) {
         windvector = 0;
@@ -485,7 +482,6 @@ void Setenvironment(int which)
                         "Textures/Skybox(grass)/Down.jpg");
 
 
-
         texdetail = temptexdetail;
     }
     temptexdetail = texdetail;
@@ -579,7 +575,7 @@ void Game::Loadlevel(const std::string& name, bool tutorial)
     freeze = 0;
     winfreeze = 0;
 
-    for (int i = 0; i < 100; i++)
+    for (unsigned char i = 0; i < 100; i++)
         bonusnum[i] = 0;
 
     numfalls = 0;
@@ -981,9 +977,9 @@ void doDevKeys()
 
         /* Grow tree leaves?? */
         if (Input::isKeyPressed(SDL_SCANCODE_Y)) {
-            for (int i = 0; i < Object::objects.size(); i++) {
-                if (Object::objects[i]->type == treeleavestype) {
-                    Object::objects[i]->scale *= .9;
+           for (auto& an_object : Object::objects) {
+                if (an_object->type == treeleavestype) {
+                    an_object->scale *= .9;
                 }
             }
         }
@@ -2469,7 +2465,7 @@ void doAttacks()
                                                             terrain.decalalivetime[j] < 2)
                                                         terrain.DeleteDecal(j);
                                                 }
-                                                for (int l = 0; l < Object::objects.size(); l++) {
+                                                for (unsigned int l = 0; l < Object::objects.size(); l++) {
                                                     if (Object::objects[l]->model.type == decalstype)
                                                         for (int j = 0; j < Object::objects[l]->model.numdecals; j++) {
                                                             if ((Object::objects[l]->model.decaltype[j] == blooddecal ||
@@ -2495,7 +2491,7 @@ void doAttacks()
                                                             terrain.DeleteDecal(j);
                                                         }
                                                     }
-                                                    for (int l = 0; l < Object::objects.size(); l++) {
+                                                    for (unsigned int l = 0; l < Object::objects.size(); l++) {
                                                         if (Object::objects[l]->model.type == decalstype)
                                                             for (int j = 0; j < Object::objects[l]->model.numdecals; j++) {
                                                                 if ((Object::objects[l]->model.decaltype[j] == blooddecal ||
@@ -3411,7 +3407,7 @@ void Game::Tick()
                     Person::players[i]->avoidsomething = 0;
 
                     //avoid flaming things
-                    for (int j = 0; j < Object::objects.size(); j++)
+                    for (unsigned int j = 0; j < Object::objects.size(); j++)
                         if (Object::objects[j]->onfire)
                             if (distsq(&Person::players[i]->coords, &Object::objects[j]->position) < sq(Object::objects[j]->scale) * 200)
                                 if (     distsq(&Person::players[i]->coords, &Object::objects[j]->position) <
index 4120864b74146e015f0b4830462cfc40e908a759..f58962c2f4ab5e3c5f57aea22b7f49f1f19abe26 100644 (file)
@@ -399,7 +399,7 @@ void Model::UpdateVertexArrayNoTexNoNorm()
     }
 }
 
-bool Model::loadnotex(const std::string& filename )
+bool Model::loadnotex(const std::string& filename)
 {
     FILE *tfile;
     long i;
@@ -463,7 +463,7 @@ bool Model::loadnotex(const std::string& filename )
 }
 
 
-bool Model::load(const std::string& filename, bool texture )
+bool Model::load(const std::string& filename, bool texture)
 {
     FILE *tfile;
     long i;
@@ -1429,20 +1429,17 @@ void Model::deallocate()
 }
 
 Model::Model()
+  : vertexNum(0), TriangleNum(0),
+    hastexture(0),
+    type(0), oldtype(0),
+    possible(0),
+    owner(0),
+    vertex(0),
+    normals(0),
+    facenormals(0),
+    Triangles(0),
+    vArray(0)
 {
-    vertexNum = 0, TriangleNum = 0;
-    hastexture = 0;
-
-    type = 0, oldtype = 0;
-
-    possible = 0;
-    owner = 0;
-    vertex = 0;
-    normals = 0;
-    facenormals = 0;
-    Triangles = 0;
-    vArray = 0;
-
     memset(&modelTexture, 0, sizeof(modelTexture));
     numpossible = 0;
     color = 0;
@@ -1464,4 +1461,3 @@ Model::Model()
 
     type = nothing;
 }
-
index db6249f7cd61c15057ce92f2c7cc7c008ecf2d5f..c91e5d8c2b3faf84a973c965856403fcc3168c91 100644 (file)
@@ -689,7 +689,7 @@ void Object::ComputeRadius()
 {
     float maxdistance = 0;
     float tempdist;
-    for (int i = 0; i < objects.size(); i++) {
+    for (unsigned int i = 0; i < objects.size(); i++) {
         tempdist = distsq(&center, &objects[i]->position);
         if (tempdist > maxdistance) {
             maxdistance = tempdist;
@@ -825,9 +825,9 @@ int Object::checkcollide(XYZ startpoint, XYZ endpoint)
     maxy = max(startpoint.y, endpoint.y) + 1;
     maxz = max(startpoint.z, endpoint.z) + 1;
 
-    for (int i = 0; i < objects.size(); i++) {
+    for (unsigned int i = 0; i < objects.size(); i++) {
         if (checkcollide(startpoint, endpoint, i, minx, miny, minz, maxx, maxy, maxz) != -1) {
-            return i;
+            return (int) i;
         }
     }
 
index 9dd5e269cbb04fab7f72d725b2457a35eb42a373..36328a46822d1737e09feb413466cc8ae387e7c0 100644 (file)
@@ -5550,15 +5550,46 @@ void Person::DoStuff()
             }
         }
 
-        if (animTarget == spinkickanim || animTarget == staffspinhitreversalanim || animTarget == staffspinhitreversedanim || animTarget == staffhitreversalanim || animTarget == staffhitreversedanim || animTarget == hurtidleanim || animTarget == winduppunchanim || animTarget == swordslashreversalanim || animTarget == swordslashreversedanim || animTarget == knifeslashreversalanim || animTarget == knifeslashreversedanim || animTarget == knifethrowanim || animTarget == knifefollowanim || animTarget == knifefollowedanim || animTarget == killanim || animTarget == dropkickanim || animTarget == upunchanim || animTarget == knifeslashstartanim || animTarget == swordslashanim || animTarget == staffhitanim || animTarget == staffspinhitanim || animTarget == staffgroundsmashanim || animTarget == spinkickreversalanim || animTarget == sweepreversalanim || animTarget == lowkickanim || animTarget == sweepreversedanim || animTarget == rabbitkickreversalanim || animTarget == rabbitkickreversedanim || animTarget == jumpreversalanim || animTarget == jumpreversedanim) {
+        if (animTarget == spinkickanim ||
+           animTarget == staffspinhitreversalanim ||
+           animTarget == staffspinhitreversedanim ||
+           animTarget == staffhitreversalanim ||
+           animTarget == staffhitreversedanim ||
+           animTarget == hurtidleanim ||
+           animTarget == winduppunchanim ||
+           animTarget == swordslashreversalanim ||
+           animTarget == swordslashreversedanim ||
+           animTarget == knifeslashreversalanim ||
+           animTarget == knifeslashreversedanim ||
+           animTarget == knifethrowanim ||
+           animTarget == knifefollowanim ||
+           animTarget == knifefollowedanim ||
+           animTarget == killanim ||
+           animTarget == dropkickanim ||
+           animTarget == upunchanim ||
+           animTarget == knifeslashstartanim ||
+           animTarget == swordslashanim ||
+           animTarget == staffhitanim ||
+           animTarget == staffspinhitanim ||
+           animTarget == staffgroundsmashanim ||
+           animTarget == spinkickreversalanim ||
+           animTarget == sweepreversalanim ||
+           animTarget == lowkickanim ||
+           animTarget == sweepreversedanim ||
+           animTarget == rabbitkickreversalanim ||
+           animTarget == rabbitkickreversedanim ||
+           animTarget == jumpreversalanim ||
+           animTarget == jumpreversedanim) {
             //close hands and yell
-            if (righthandmorphend != 1 && righthandmorphness == targetrighthandmorphness) {
+            if (righthandmorphend != 1 &&
+               righthandmorphness == targetrighthandmorphness) {
                 righthandmorphness = 0;
                 righthandmorphend = 1;
                 targetrighthandmorphness = 1;
             }
 
-            if (lefthandmorphend != 1 && lefthandmorphness == targetlefthandmorphness) {
+            if (lefthandmorphend != 1 &&
+               lefthandmorphness == targetlefthandmorphness) {
                 lefthandmorphness = 0;
                 lefthandmorphend = 1;
                 targetlefthandmorphness = 1;
@@ -5618,7 +5649,8 @@ void Person::DoStuff()
         ReflectVector(&facing, terrainnormal);
         Normalise(&facing);
 
-        if (isRun() || animTarget == sneakanim || animTarget == rollanim || animTarget == walkanim) {
+        if (isRun() ||
+           animTarget == sneakanim || animTarget == rollanim || animTarget == walkanim) {
             if (onterrain)
                 targettilt2 = -facing.y * 20;
             else