summaryrefslogtreecommitdiff
path: root/game/network/rail.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-10-22 19:06:14 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2022-10-22 19:06:14 +0100
commit873ef1436e233b5b4c542f35838a7cd73432ede6 (patch)
treead5b0f0bba71c5da5791471216855a1af221c26e /game/network/rail.cpp
parentMove -Wold-style-cast to gcc only list, clang triggers in some SDL headers (diff)
downloadilt-873ef1436e233b5b4c542f35838a7cd73432ede6.tar.bz2
ilt-873ef1436e233b5b4c542f35838a7cd73432ede6.tar.xz
ilt-873ef1436e233b5b4c542f35838a7cd73432ede6.zip
Tidy network node insertion/searching
Diffstat (limited to 'game/network/rail.cpp')
-rw-r--r--game/network/rail.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/game/network/rail.cpp b/game/network/rail.cpp
index 635ee6e..95b6d24 100644
--- a/game/network/rail.cpp
+++ b/game/network/rail.cpp
@@ -30,11 +30,11 @@ std::shared_ptr<RailLink>
RailLinks::addLinksBetween(glm::vec3 start, glm::vec3 end)
{
auto node1ins = newNodeAt(start), node2ins = newNodeAt(end);
- if (node1ins.second && node2ins.second) {
+ if (node1ins.second == NodeIs::NotInNetwork && node2ins.second == NodeIs::NotInNetwork) {
// Both nodes are new, direct link, easy
return addLink<RailLinkStraight>(start, end);
}
- if (node1ins.second && !node2ins.second) {
+ if (node1ins.second == NodeIs::NotInNetwork && node2ins.second == NodeIs::InNetwork) {
// node1 is new, node2 exists, but we build from existing outwards
std::swap(node1ins, node2ins);
std::swap(start, end);
@@ -56,7 +56,7 @@ RailLinks::addLinksBetween(glm::vec3 start, glm::vec3 end)
return addLink<RailLinkStraight>(start, end);
}
const glm::vec2 flatStart {!start}, flatEnd {!end};
- if (!node2ins.second) {
+ if (node2ins.second == NodeIs::InNetwork) {
auto midheight = [&](auto mid) {
const auto sm = glm::distance(flatStart, mid), em = glm::distance(flatEnd, mid);
return start.z + ((end.z - start.z) * (sm / (sm + em)));
@@ -128,7 +128,9 @@ round_sleepers(const float v)
return round_frac(v, sleepers);
}
-RailLinkStraight::RailLinkStraight(const Node::Ptr & a, const Node::Ptr & b) : RailLinkStraight(a, b, b->pos - a->pos) { }
+RailLinkStraight::RailLinkStraight(const Node::Ptr & a, const Node::Ptr & b) : RailLinkStraight(a, b, b->pos - a->pos)
+{
+}
RailLinkStraight::RailLinkStraight(Node::Ptr a, Node::Ptr b, const glm::vec3 & diff) :
Link({std::move(a), vector_yaw(diff)}, {std::move(b), vector_yaw(-diff)}, glm::length(diff))