diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-11-26 20:21:12 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-11-26 20:21:12 +0000 |
commit | 239b3ab10b460da34c490a7e06a21c984e21ffb6 (patch) | |
tree | 4ce09f5d091ffbcf063a9d0fc076659dfe9e3142 /game | |
parent | Don't run the app by default (diff) | |
download | ilt-239b3ab10b460da34c490a7e06a21c984e21ffb6.tar.bz2 ilt-239b3ab10b460da34c490a7e06a21c984e21ffb6.tar.xz ilt-239b3ab10b460da34c490a7e06a21c984e21ffb6.zip |
Enable all Jason Turner recommended warnings
Diffstat (limited to 'game')
-rw-r--r-- | game/activity.h | 5 | ||||
-rw-r--r-- | game/network/network.cpp | 4 | ||||
-rw-r--r-- | game/network/rail.cpp | 8 | ||||
-rw-r--r-- | game/terrain.cpp | 16 | ||||
-rw-r--r-- | game/vehicles/railVehicleClass.cpp | 2 |
5 files changed, 19 insertions, 16 deletions
diff --git a/game/activity.h b/game/activity.h index f6ec609..b5fc168 100644 --- a/game/activity.h +++ b/game/activity.h @@ -19,9 +19,12 @@ public: }; using ActivityPtr = std::unique_ptr<Activity>; -template<typename T> concept ActivityConcept = std::is_base_of_v<Activity, T>; +template<typename T> +concept ActivityConcept = std::is_base_of_v<Activity, T>; template<ActivityConcept AC> class Can { public: + virtual ~Can() = default; + virtual void doActivity(AC *, TickDuration) = 0; }; diff --git a/game/network/network.cpp b/game/network/network.cpp index 6eaccef..47e51e2 100644 --- a/game/network/network.cpp +++ b/game/network/network.cpp @@ -36,8 +36,8 @@ void Network::joinLinks(const LinkPtr & l, const LinkPtr & ol) { if (l != ol) { - for (const auto oe : {0, 1}) { - for (const auto te : {0, 1}) { + for (const auto oe : {0U, 1U}) { + for (const auto te : {0U, 1U}) { if (l->ends[te].node == ol->ends[oe].node) { l->ends[te].nexts.emplace_back(ol, oe); ol->ends[oe].nexts.emplace_back(l, te); diff --git a/game/network/rail.cpp b/game/network/rail.cpp index 5127e34..46f11d6 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -135,7 +135,7 @@ RailLinkStraight::RailLinkStraight(NodePtr a, NodePtr b, const glm::vec3 & diff) vertices.reserve(2 * railCrossSection.size()); const auto len = round_sleepers(length / 2.F); const auto e {flat_orientation(diff)}; - for (int ei : {1, 0}) { + for (auto ei : {1U, 0U}) { const auto trans {glm::translate(ends[ei].node->pos) * e}; for (const auto & rcs : railCrossSection) { const glm::vec3 m {(trans * glm::vec4 {rcs.first, 1})}; @@ -164,10 +164,10 @@ RailLinkCurve::RailLinkCurve(const NodePtr & a, const NodePtr & b, glm::vec3 c, const auto step {glm::vec3 {arc_length(arc), e1p.z - e0p.z, slength} / segs}; const auto trans {glm::translate(centreBase)}; - auto segCount = std::lround(segs); + auto segCount = static_cast<std::size_t>(std::lround(segs)) + 1; std::vector<Vertex> vertices; - vertices.reserve((segCount + 1) * railCrossSection.size()); - for (glm::vec3 swing = {arc.first, centreBase.z - e0p.z, 0.F}; segCount >= 0; swing += step, --segCount) { + vertices.reserve(segCount * railCrossSection.size()); + for (glm::vec3 swing = {arc.first, centreBase.z - e0p.z, 0.F}; segCount; swing += step, --segCount) { const auto t { trans * glm::rotate(half_pi - swing.x, up) * glm::translate(glm::vec3 {radius, 0.F, swing.y})}; for (const auto & rcs : railCrossSection) { diff --git a/game/terrain.cpp b/game/terrain.cpp index a7dd334..79b845d 100644 --- a/game/terrain.cpp +++ b/game/terrain.cpp @@ -25,7 +25,7 @@ Terrain::Terrain() : grass {Texture::cachedTexture.get("grass.png")}, water {Tex // Initial coordinates for (auto y = 0; y < size; y += 1) { for (auto x = 0; x < size; x += 1) { - auto & vertex = vertices[x + (y * size)]; + auto & vertex = vertices[static_cast<std::size_t>(x + (y * size))]; vertex.pos = {resolution * (x - offset), resolution * (y - offset), -1.5}; vertex.normal = up; vertex.texCoord = {x, y}; @@ -35,21 +35,21 @@ Terrain::Terrain() : grass {Texture::cachedTexture.get("grass.png")}, water {Tex std::mt19937 gen(std::random_device {}()); std::uniform_int_distribution<> rpos(2, size - 2); std::uniform_int_distribution<> rsize(10, 30); - std::uniform_int_distribution<> rheight(1, 3); + std::uniform_real_distribution<float> rheight(1, 3); for (int h = 0; h < 500;) { const glm::ivec2 hpos {rpos(gen), rpos(gen)}; const glm::ivec2 hsize {rsize(gen), rsize(gen)}; if (const auto lim1 = hpos - hsize; lim1.x > 0 && lim1.y > 0) { if (const auto lim2 = hpos + hsize; lim2.x < size && lim2.y < size) { - const auto height = (float)rheight(gen); + const auto height = rheight(gen); const glm::ivec2 hsizesqrd {hsize.x * hsize.x, hsize.y * hsize.y}; for (auto y = lim1.y; y < lim2.y; y += 1) { for (auto x = lim1.x; x < lim2.x; x += 1) { const auto dist {hpos - glm::ivec2 {x, y}}; 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.0) { - auto & vertex = vertices[x + (y * size)]; + if (out <= 1.0F) { + auto & vertex = vertices[static_cast<std::size_t>(x + (y * size))]; const auto m {1.F / (7.F * out - 8.F) + 1.F}; vertex.pos.z += height * m; } @@ -72,10 +72,10 @@ Terrain::Terrain(const std::string & fileName) : std::vector<Vertex> vertices; vertices.reserve((map.width * map.height) + 4); - for (auto y = 0; y < map.height; y += 1) { - for (auto x = 0; x < map.width; x += 1) { + 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)), - ((float)map.data[x + (y * map.width)] * 0.1F) - 1.5F}, + (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 52b7dbe..406f2d8 100644 --- a/game/vehicles/railVehicleClass.cpp +++ b/game/vehicles/railVehicleClass.cpp @@ -57,7 +57,7 @@ RailVehicleClass::bogieOffset(ObjParser & o) if (!object.first.starts_with("Bogie")) { continue; } - std::set<std::pair<float, int>> vertexIds; + std::set<std::pair<float, std::size_t>> vertexIds; for (const auto & face : object.second) { for (const auto & faceElement : face) { vertexIds.emplace(o.vertices[faceElement.x - 1].y, faceElement.x - 1); |