From 4ed9180694cce6964f1a25b63792999a6a3fafed Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Sun, 9 Jun 2019 14:59:17 +0200 Subject: [PATCH] Cleaning some warnings --- src/CMakeLists.txt | 8 +++++++- src/Entity.cpp | 2 +- src/Entity.h | 2 +- src/Level.cpp | 7 ++++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3f9b184..32421ba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,4 +10,10 @@ target_link_libraries(engine sfml-window sfml-graphics sfml-system - pugixml) \ No newline at end of file + pugixml) + +if (CMAKE_COMPILER_IS_GNUCXX) + target_compile_options(engine PRIVATE -Wall -Wpedantic -Wextra) +elseif(MSVC) + target_compile_options(engine PRIVATE /W4) +endif() \ No newline at end of file diff --git a/src/Entity.cpp b/src/Entity.cpp index 9bbb7c2..85e7bf5 100644 --- a/src/Entity.cpp +++ b/src/Entity.cpp @@ -71,7 +71,7 @@ const sf::RectangleShape& Entity::getShape() const return(shape); } -const State Entity::getState() const +State Entity::getState() const { return currentState; } diff --git a/src/Entity.h b/src/Entity.h index d737d86..1e49601 100644 --- a/src/Entity.h +++ b/src/Entity.h @@ -48,7 +48,7 @@ public: void move(Orientation orientation); void update(); - const State getState() const; + State getState() const; const sf::RectangleShape& getShape() const; /// Returns the grid coordinates at the center of the entity diff --git a/src/Level.cpp b/src/Level.cpp index fdf3713..66d2cb5 100644 --- a/src/Level.cpp +++ b/src/Level.cpp @@ -6,8 +6,8 @@ Level::Level(const pugi::xml_document& xmlDoc, const TextureStore& textureStore) - : textures(textureStore), - size(xmlDoc.child("Level").attribute("w").as_int(),xmlDoc.child("Level").attribute("h").as_int()) + : size(xmlDoc.child("Level").attribute("w").as_int(),xmlDoc.child("Level").attribute("h").as_int()), + textures(textureStore) { pugi::xml_node levelNode = xmlDoc.child("Level"); for(const pugi::xml_node& child : levelNode.children()) @@ -45,6 +45,7 @@ void Level::runStep() case State::Moving: { heuristicSign = 1; + [[fallthrough]]; } case State::Fleeing: { @@ -181,7 +182,7 @@ Orientation Level::findPath(pro_maat::GridPos start, pro_maat::GridPos goal, int pathCosts.insert_or_assign(neighbour,newPathCost); estimatedCosts.insert_or_assign(neighbour,newPathCost + pro_maat::manhattanDistance(neighbour,goal)); - auto returnPathIt = paths.insert_or_assign(neighbour,currentNode); + paths.insert_or_assign(neighbour,currentNode); } }