From: Nicola Spanti (RyDroid) Date: Tue, 20 Dec 2016 00:02:04 +0000 (+0100) Subject: Fixing some warnings X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=51a0860281c8978f5404c730eb809fb455d99aea;p=lugaru.git Fixing some warnings --- diff --git a/CMakeLists.txt b/CMakeLists.txt index ef94e17..4b6094c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/Source/GameDraw.cpp b/Source/GameDraw.cpp index 5b3edfa..d14a077 100644 --- a/Source/GameDraw.cpp +++ b/Source/GameDraw.cpp @@ -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) { diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 514ab54..f9a3f88 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -313,11 +313,12 @@ static int findClosestObject() int closest = -1; float closestdist = std::numeric_limits::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) < diff --git a/Source/Graphic/Models.cpp b/Source/Graphic/Models.cpp index 4120864..f58962c 100644 --- a/Source/Graphic/Models.cpp +++ b/Source/Graphic/Models.cpp @@ -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; } - diff --git a/Source/Objects/Object.cpp b/Source/Objects/Object.cpp index db6249f..c91e5d8 100644 --- a/Source/Objects/Object.cpp +++ b/Source/Objects/Object.cpp @@ -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(¢er, &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; } } diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index 9dd5e26..36328a4 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -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