From 04946e0b64e5bafcfb01cca515f5abc34386e15c Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 28 Nov 2021 16:53:57 +0000 Subject: Fix up all remaining warnings --- Jamroot.jam | 37 +++++++++++++++++++------------------ game/activity.h | 2 ++ game/network/rail.cpp | 2 ++ game/terrain.cpp | 15 +++++++++------ game/vehicles/railVehicleClass.cpp | 1 + gfx/gl/camera.cpp | 2 +- gfx/gl/shader.cpp | 1 + gfx/models/obj.impl.cpp | 3 +++ lib/cache.cpp | 1 + lib/cache.h | 5 +++++ lib/persistence.h | 2 ++ lib/special_members.hpp | 18 ++++++++++++++---- 12 files changed, 60 insertions(+), 29 deletions(-) create mode 100644 lib/cache.cpp diff --git a/Jamroot.jam b/Jamroot.jam index f3fd9b6..9e89994 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -15,30 +15,15 @@ lib pthread ; variant coverage : debug ; project : requirements 20 - debug:pedantic - debug:on - debug:-Wnon-virtual-dtor - debug:-Wold-style-cast - debug:-Wcast-align - debug:-Wunused - debug:-Woverloaded-virtual - debug:-Wpedantic - debug:-Wconversion - debug:-Wsign-conversion - debug:-Wnull-dereference - debug:-Wdouble-promotion - debug:-Wformat=2 - gcc,debug:-Wduplicated-cond - gcc,debug:-Wduplicated-branches - gcc,debug:-Wlogical-op - gcc,debug:-Wuseless-cast release:on coverage:on tidy:gfx/models/obj.cpp tidy:lib/jsonParse.cpp tidy:boost-* tidy:bugprone-* + tidy:bugprone-easily-swappable-parameters tidy:clang-* + tidy:clang-analyzer-cplusplus.NewDeleteLeaks tidy:misc-* tidy:misc-non-private-member-variables-in-classes tidy:modernize-* @@ -90,11 +75,27 @@ lib ilt : [ lib generated : [ glob-tree *.ll *.c ] : . lib - release static -fPIC ] : + debug:pedantic + debug:on + debug:-Wnon-virtual-dtor + debug:-Wold-style-cast + debug:-Wcast-align + debug:-Wunused + debug:-Woverloaded-virtual + debug:-Wpedantic + debug:-Wconversion + debug:-Wsign-conversion + debug:-Wnull-dereference + debug:-Wdouble-promotion + debug:-Wformat=2 + gcc,debug:-Wduplicated-cond + gcc,debug:-Wduplicated-branches + gcc,debug:-Wlogical-op + gcc,debug:-Wuseless-cast . lib sdl2 diff --git a/game/activity.h b/game/activity.h index b5fc168..44f8d6f 100644 --- a/game/activity.h +++ b/game/activity.h @@ -23,7 +23,9 @@ template concept ActivityConcept = std::is_base_of_v; template class Can { public: + Can() = default; virtual ~Can() = default; + DEFAULT_MOVE_COPY(Can); virtual void doActivity(AC *, TickDuration) = 0; }; diff --git a/game/network/rail.cpp b/game/network/rail.cpp index 46f11d6..d7f95a8 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -3,10 +3,12 @@ #include #include #include +#include #include #include // IWYU pragma: keep #include #include +#include #include #include #include diff --git a/game/terrain.cpp b/game/terrain.cpp index 79b845d..4c902ef 100644 --- a/game/terrain.cpp +++ b/game/terrain.cpp @@ -1,6 +1,7 @@ #include "terrain.h" #include "gfx/models/texture.h" #include +#include #include #include #include @@ -23,10 +24,11 @@ Terrain::Terrain() : grass {Texture::cachedTexture.get("grass.png")}, water {Tex vertices.resize(verticesCount, {{}, {}, {}}); // Initial coordinates - for (auto y = 0; y < size; y += 1) { - for (auto x = 0; x < size; x += 1) { - auto & vertex = vertices[static_cast(x + (y * size))]; - vertex.pos = {resolution * (x - offset), resolution * (y - offset), -1.5}; + for (auto y = 0U; y < size; y += 1) { + for (auto x = 0U; x < size; x += 1) { + auto & vertex = vertices[x + (y * size)]; + vertex.pos + = {resolution * (static_cast(x) - offset), resolution * (static_cast(y) - offset), -1.5}; vertex.normal = up; vertex.texCoord = {x, y}; } @@ -49,7 +51,8 @@ Terrain::Terrain() : grass {Texture::cachedTexture.get("grass.png")}, water {Tex const glm::ivec2 distsqrd {dist.x * dist.x, dist.y * dist.y}; const auto out {rdiv(sq(x - hpos.x), sq(hsize.x)) + rdiv(sq(y - hpos.y), sq(hsize.y))}; if (out <= 1.0F) { - auto & vertex = vertices[static_cast(x + (y * size))]; + auto & vertex + = vertices[static_cast(x) + (static_cast(y) * size)]; const auto m {1.F / (7.F * out - 8.F) + 1.F}; vertex.pos.z += height * m; } @@ -75,7 +78,7 @@ Terrain::Terrain(const std::string & fileName) : for (auto y = 0U; y < map.height; y += 1) { for (auto x = 0U; x < map.width; x += 1) { vertices.emplace_back(glm::vec3 {resolution * (x - (map.width / 2)), resolution * (y - (map.height / 2)), - (map.data[x + (y * map.width)] * 0.1F) - 1.5F}, + (static_cast(map.data[x + (y * map.width)]) * 0.1F) - 1.5F}, glm::vec2 {(x % 2) / 2.01, (y % 2) / 2.01}, up); } } diff --git a/game/vehicles/railVehicleClass.cpp b/game/vehicles/railVehicleClass.cpp index 406f2d8..8fd504f 100644 --- a/game/vehicles/railVehicleClass.cpp +++ b/game/vehicles/railVehicleClass.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/gfx/gl/camera.cpp b/gfx/gl/camera.cpp index c957b2c..5a90d84 100644 --- a/gfx/gl/camera.cpp +++ b/gfx/gl/camera.cpp @@ -1,5 +1,5 @@ #include "camera.h" -#include +#include // IWYU pragma: keep #include Camera::Camera(glm::vec3 pos, float fov, float aspect, float zNear, float zFar) : diff --git a/gfx/gl/shader.cpp b/gfx/gl/shader.cpp index 14cf404..b8210d1 100644 --- a/gfx/gl/shader.cpp +++ b/gfx/gl/shader.cpp @@ -1,6 +1,7 @@ #include "shader.h" #include "gfx/gl/shader-source.h" #include +#include #include #include #include diff --git a/gfx/models/obj.impl.cpp b/gfx/models/obj.impl.cpp index 745689e..d73d82e 100644 --- a/gfx/models/obj.impl.cpp +++ b/gfx/models/obj.impl.cpp @@ -1,5 +1,8 @@ #include "obj.h" #include +#include +#include +#include #include // IWYU pragma: keep #include #include diff --git a/lib/cache.cpp b/lib/cache.cpp new file mode 100644 index 0000000..05b26b0 --- /dev/null +++ b/lib/cache.cpp @@ -0,0 +1 @@ +#include "cache.h" diff --git a/lib/cache.h b/lib/cache.h index 2a6e3e5..b081c04 100644 --- a/lib/cache.h +++ b/lib/cache.h @@ -1,14 +1,19 @@ #ifndef CACHE_H #define CACHE_H +#include "special_members.hpp" #include #include +#include template class Cache { public: using Ptr = std::shared_ptr; + Cache() = default; virtual ~Cache() = default; + DEFAULT_MOVE(Cache); + NO_COPY(Cache); [[nodiscard]] Ptr get(const std::string & key) diff --git a/lib/persistence.h b/lib/persistence.h index 5468cd3..60b40ca 100644 --- a/lib/persistence.h +++ b/lib/persistence.h @@ -107,7 +107,9 @@ namespace Persistence { struct Persistable; struct PersistenceStore { + PersistenceStore() = default; virtual ~PersistenceStore() = default; + DEFAULT_MOVE_NO_COPY(PersistenceStore); template [[nodiscard]] inline bool persistType(const T * const, const std::type_info & ti); diff --git a/lib/special_members.hpp b/lib/special_members.hpp index 0d63f58..d1dca99 100644 --- a/lib/special_members.hpp +++ b/lib/special_members.hpp @@ -9,10 +9,20 @@ TYPE(TYPE &&) = delete; \ void operator=(TYPE &&) = delete -#define DEFAULT_MOVE_COPY(TYPE) \ +#define DEFAULT_MOVE(TYPE) \ + TYPE(TYPE &&) noexcept = default; \ + TYPE & operator=(TYPE &&) noexcept = default + +#define DEFAULT_COPY(TYPE) \ TYPE(const TYPE &) = default; \ - TYPE(TYPE &&) = default; \ - TYPE & operator=(const TYPE &) = default; \ - TYPE & operator=(TYPE &&) = default + TYPE & operator=(const TYPE &) = default + +#define DEFAULT_MOVE_COPY(TYPE) \ + DEFAULT_MOVE(TYPE); \ + DEFAULT_COPY(TYPE) + +#define DEFAULT_MOVE_NO_COPY(TYPE) \ + DEFAULT_MOVE(TYPE); \ + NO_COPY(TYPE) #endif -- cgit v1.2.3