diff options
Diffstat (limited to 'game')
-rw-r--r-- | game/geoData.cpp | 2 | ||||
-rw-r--r-- | game/network/link.cpp | 2 | ||||
-rw-r--r-- | game/network/network.cpp | 4 | ||||
-rw-r--r-- | game/network/network.h | 6 | ||||
-rw-r--r-- | game/network/rail.cpp | 4 |
5 files changed, 10 insertions, 8 deletions
diff --git a/game/geoData.cpp b/game/geoData.cpp index af39ce3..4dd0c40 100644 --- a/game/geoData.cpp +++ b/game/geoData.cpp @@ -131,7 +131,7 @@ GeoData::RayTracer::byAxis(glm::vec2 p0, glm::vec2 p1, glm::vec2 d, glm::length_ glm::vec2 GeoData::RayTracer::next() { - glm::vec2 cur {p}; + const glm::vec2 cur {p}; static constexpr const glm::vec2 m {1, -1}; const int axis = (error > 0) ? 1 : 0; diff --git a/game/network/link.cpp b/game/network/link.cpp index 19b60ab..aecc2fc 100644 --- a/game/network/link.cpp +++ b/game/network/link.cpp @@ -68,7 +68,7 @@ LinkCurve::intersectRay(const Ray & ray) const points.reserve(segCount); 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})}; - points.push_back(t * glm::vec4 {0, 0, 0, 1}); + points.emplace_back(t * glm::vec4 {0, 0, 0, 1}); } return ray.passesCloseToEdges(points, 1.F); } diff --git a/game/network/network.cpp b/game/network/network.cpp index dd61f9b..59ef7c8 100644 --- a/game/network/network.cpp +++ b/game/network/network.cpp @@ -22,11 +22,11 @@ Network::nodeAt(glm::vec3 pos) Network::NodeInsertion Network::newNodeAt(glm::vec3 pos) { - if (const auto [n, i] = candidateNodeAt(pos); i == NodeIs::NotInNetwork) { + if (auto [n, i] = candidateNodeAt(pos); i == NodeIs::NotInNetwork) { return {*nodes.insert(std::move(n)).first, i}; } else { - return {n, NodeIs::InNetwork}; + return {std::move(n), NodeIs::InNetwork}; } } diff --git a/game/network/network.h b/game/network/network.h index e7a65b5..4b485cc 100644 --- a/game/network/network.h +++ b/game/network/network.h @@ -7,6 +7,7 @@ #include <memory> #include <set> #include <sorting.hpp> +#include <special_members.hpp> #include <string> #include <utility> #include <variant> @@ -23,6 +24,7 @@ public: using LinkEnd = std::pair<Link::Ptr, unsigned char>; explicit Network(const std::string & textureName); virtual ~Network() = default; + DEFAULT_MOVE_NO_COPY(Network); [[nodiscard]] Node::Ptr findNodeAt(glm::vec3) const; [[nodiscard]] Node::Ptr nodeAt(glm::vec3); @@ -43,7 +45,7 @@ public: virtual Link::CCollection addJoins(glm::vec3, glm::vec3) = 0; virtual Link::CCollection addExtend(glm::vec3, glm::vec3) = 0; - virtual float findNodeDirection(Node::AnyCPtr) const = 0; + [[nodiscard]] virtual float findNodeDirection(Node::AnyCPtr) const = 0; protected: static void joinLinks(const Link::Ptr & l, const Link::Ptr & ol); @@ -94,7 +96,7 @@ public: Link::CCollection addJoins(glm::vec3, glm::vec3) override; Link::CCollection addExtend(glm::vec3, glm::vec3) override; - float findNodeDirection(Node::AnyCPtr) const override; + [[nodiscard]] float findNodeDirection(Node::AnyCPtr) const override; void render(const SceneShader &) const override; diff --git a/game/network/rail.cpp b/game/network/rail.cpp index 2f09d88..e7006cf 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -40,7 +40,7 @@ RailLinks::addLinksBetween(glm::vec3 start, glm::vec3 end) std::swap(start, end); } // Find start link/end - opposite entry dir to existing link; so pi +... - float dir = pi + findNodeDirection(node1ins.first); + const float dir = pi + findNodeDirection(node1ins.first); if (dir == vector_yaw(end - start)) { return addLink<RailLinkStraight>(start, end); } @@ -50,7 +50,7 @@ RailLinks::addLinksBetween(glm::vec3 start, glm::vec3 end) const auto sm = glm::distance(flatStart, mid), em = glm::distance(flatEnd, mid); return start.z + ((end.z - start.z) * (sm / (sm + em))); }; - float dir2 = pi + findNodeDirection(node2ins.first); + const float dir2 = pi + findNodeDirection(node2ins.first); if (const auto radii = find_arcs_radius(flatStart, dir, flatEnd, dir2); radii.first < radii.second) { const auto radius {radii.first}; const auto c1 = flatStart + sincosf(dir + half_pi) * radius; |