From dd80098076cda9c103b44356ca07c2c8bc7698d7 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 14 Feb 2021 13:14:32 +0000 Subject: Join links in rail graph --- game/network/rail.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'game/network/rail.cpp') diff --git a/game/network/rail.cpp b/game/network/rail.cpp index fd2ea08..a66bf65 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -15,6 +15,23 @@ RailLinks::RailLinks() : texture {Texture::cachedTexture.get("rails.jpg")} { } void RailLinks::tick(TickDuration) { } +void +RailLinks::joinLinks(LinkPtr l) const +{ + for (const auto & ol : links.objects) { + if (l != ol) { + for (const auto oe : {0, 1}) { + for (const auto te : {0, 1}) { + if (l->ends[te].first == ol->ends[oe].first) { + l->nexts[te].emplace_back(ol.get(), oe); + ol->nexts[oe].emplace_back(l.get(), te); + } + } + } + } + } +} + void RailLinks::render(const Shader & shader) const { -- cgit v1.2.3