summaryrefslogtreecommitdiff
path: root/game/network/network.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-03-10 01:54:40 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-03-10 01:54:40 +0000
commit789a16e4e97d4050bb8db9cc3aebb01e807ac8c7 (patch)
treea5e0fc0f406c17e1b7b88ba8e16ea0bbb331a6dc /game/network/network.cpp
parentAdd some more helpers to Network (diff)
downloadilt-789a16e4e97d4050bb8db9cc3aebb01e807ac8c7.tar.bz2
ilt-789a16e4e97d4050bb8db9cc3aebb01e807ac8c7.tar.xz
ilt-789a16e4e97d4050bb8db9cc3aebb01e807ac8c7.zip
Push more RailLinks logic down into NetworkOf
Diffstat (limited to 'game/network/network.cpp')
-rw-r--r--game/network/network.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/game/network/network.cpp b/game/network/network.cpp
index 52d88ec..fd61764 100644
--- a/game/network/network.cpp
+++ b/game/network/network.cpp
@@ -1,7 +1,9 @@
#include "network.h"
+#include <array>
#include <cache.h>
#include <game/network/link.h>
#include <gfx/models/texture.h>
+#include <initializer_list>
#include <utility>
Network::Network(const std::string & tn) : texture {Texture::cachedTexture.get(tn)} { }
@@ -27,3 +29,18 @@ Network::findNodeAt(glm::vec3 pos) const
}
return {};
}
+
+void
+Network::joinLinks(const LinkPtr & l, const LinkPtr & ol)
+{
+ if (l != ol) {
+ for (const auto oe : {0, 1}) {
+ for (const auto te : {0, 1}) {
+ 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);
+ }
+ }
+ }
+ }
+}