diff options
-rw-r--r-- | Jamroot.jam | 37 | ||||
-rw-r--r-- | game/activity.h | 2 | ||||
-rw-r--r-- | game/network/rail.cpp | 2 | ||||
-rw-r--r-- | game/terrain.cpp | 15 | ||||
-rw-r--r-- | game/vehicles/railVehicleClass.cpp | 1 | ||||
-rw-r--r-- | gfx/gl/camera.cpp | 2 | ||||
-rw-r--r-- | gfx/gl/shader.cpp | 1 | ||||
-rw-r--r-- | gfx/models/obj.impl.cpp | 3 | ||||
-rw-r--r-- | lib/cache.cpp | 1 | ||||
-rw-r--r-- | lib/cache.h | 5 | ||||
-rw-r--r-- | lib/persistence.h | 2 | ||||
-rw-r--r-- | lib/special_members.hpp | 18 |
12 files changed, 60 insertions, 29 deletions
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 <cxxstd>20 - <variant>debug:<warnings>pedantic - <variant>debug:<warnings-as-errors>on - <variant>debug:<cflags>-Wnon-virtual-dtor - <variant>debug:<cflags>-Wold-style-cast - <variant>debug:<cflags>-Wcast-align - <variant>debug:<cflags>-Wunused - <variant>debug:<cflags>-Woverloaded-virtual - <variant>debug:<cflags>-Wpedantic - <variant>debug:<cflags>-Wconversion - <variant>debug:<cflags>-Wsign-conversion - <variant>debug:<cflags>-Wnull-dereference - <variant>debug:<cflags>-Wdouble-promotion - <variant>debug:<cflags>-Wformat=2 - <toolset>gcc,<variant>debug:<cflags>-Wduplicated-cond - <toolset>gcc,<variant>debug:<cflags>-Wduplicated-branches - <toolset>gcc,<variant>debug:<cflags>-Wlogical-op - <toolset>gcc,<variant>debug:<cflags>-Wuseless-cast <variant>release:<lto>on <variant>coverage:<coverage>on <toolset>tidy:<exclude>gfx/models/obj.cpp <toolset>tidy:<exclude>lib/jsonParse.cpp <toolset>tidy:<checkxx>boost-* <toolset>tidy:<checkxx>bugprone-* + <toolset>tidy:<xcheckxx>bugprone-easily-swappable-parameters <toolset>tidy:<checkxx>clang-* + <toolset>tidy:<xcheckxx>clang-analyzer-cplusplus.NewDeleteLeaks <toolset>tidy:<checkxx>misc-* <toolset>tidy:<xcheckxx>misc-non-private-member-variables-in-classes <toolset>tidy:<checkxx>modernize-* @@ -90,11 +75,27 @@ lib ilt : [ lib generated : [ glob-tree *.ll *.c ] : <include>. <include>lib - <variant>release <link>static <cflags>-fPIC ] : + <variant>debug:<warnings>pedantic + <variant>debug:<warnings-as-errors>on + <variant>debug:<cflags>-Wnon-virtual-dtor + <variant>debug:<cflags>-Wold-style-cast + <variant>debug:<cflags>-Wcast-align + <variant>debug:<cflags>-Wunused + <variant>debug:<cflags>-Woverloaded-virtual + <variant>debug:<cflags>-Wpedantic + <variant>debug:<cflags>-Wconversion + <variant>debug:<cflags>-Wsign-conversion + <variant>debug:<cflags>-Wnull-dereference + <variant>debug:<cflags>-Wdouble-promotion + <variant>debug:<cflags>-Wformat=2 + <toolset>gcc,<variant>debug:<cflags>-Wduplicated-cond + <toolset>gcc,<variant>debug:<cflags>-Wduplicated-branches + <toolset>gcc,<variant>debug:<cflags>-Wlogical-op + <toolset>gcc,<variant>debug:<cflags>-Wuseless-cast <include>. <include>lib <library>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<typename T> concept ActivityConcept = std::is_base_of_v<Activity, T>; template<ActivityConcept AC> 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 <GL/glew.h> #include <array> #include <collection.hpp> +#include <cstddef> #include <game/network/link.h> #include <game/network/network.impl.h> // IWYU pragma: keep #include <gfx/models/vertex.hpp> #include <glm/gtx/transform.hpp> +#include <initializer_list> #include <maths.h> #include <stdexcept> #include <utility> 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 <cache.h> +#include <cstddef> #include <gfx/gl/shader.h> #include <gfx/image.h> #include <gfx/models/mesh.h> @@ -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<std::size_t>(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<int>(x) - offset), resolution * (static_cast<int>(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<std::size_t>(x + (y * size))]; + auto & vertex + = vertices[static_cast<std::size_t>(x) + (static_cast<std::size_t>(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<float>(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 <algorithm> #include <array> #include <cache.h> +#include <cstddef> #include <filesystem> #include <glm/glm.hpp> #include <iterator> 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 <glm/gtx/transform.hpp> +#include <glm/gtx/transform.hpp> // IWYU pragma: keep #include <maths.h> 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 <array>
+#include <cstddef>
#include <gfx/gl/shaders/fs-basicShader.h>
#include <gfx/gl/shaders/fs-landmassShader.h>
#include <gfx/gl/shaders/fs-waterShader.h>
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 <algorithm> +#include <cassert> +#include <filesystem> +#include <fstream> #include <gfx/models/mesh.h> // IWYU pragma: keep #include <gfx/models/vertex.hpp> #include <glm/glm.hpp> 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 <map> #include <memory> +#include <string> template<typename Obj> class Cache { public: using Ptr = std::shared_ptr<Obj>; + 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<typename T> [[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 |