summaryrefslogtreecommitdiff
path: root/game/network
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-02-14 14:52:04 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-02-14 14:52:04 +0000
commit08f6e874a8930899714e2c0d313a9ed9f4eec35c (patch)
treeaccb6a40100dceb2d5aa4d79b2a96a865b3a65d7 /game/network
parentCode tidy-up (diff)
downloadilt-08f6e874a8930899714e2c0d313a9ed9f4eec35c.tar.bz2
ilt-08f6e874a8930899714e2c0d313a9ed9f4eec35c.tar.xz
ilt-08f6e874a8930899714e2c0d313a9ed9f4eec35c.zip
Link weak_ptrs
Diffstat (limited to 'game/network')
-rw-r--r--game/network/link.h3
-rw-r--r--game/network/rail.cpp4
2 files changed, 4 insertions, 3 deletions
diff --git a/game/network/link.h b/game/network/link.h
index d4ae4c6..207ecd0 100644
--- a/game/network/link.h
+++ b/game/network/link.h
@@ -28,6 +28,7 @@ using NodePtr = std::shared_ptr<Node>;
// it joins 2 nodes
class Link;
using LinkPtr = std::shared_ptr<Link>;
+using LinkWPtr = std::weak_ptr<const Link>;
class Link {
public:
using End = std::pair<NodePtr, float /*dir*/>;
@@ -41,7 +42,7 @@ public:
std::array<End, 2> ends;
float length;
- using Next = std::pair<LinkPtr, unsigned char /*end*/>;
+ using Next = std::pair<LinkWPtr, unsigned char /*end*/>;
std::array<std::vector<Next>, 2> nexts;
};
diff --git a/game/network/rail.cpp b/game/network/rail.cpp
index 1f3cc01..10dfb88 100644
--- a/game/network/rail.cpp
+++ b/game/network/rail.cpp
@@ -24,8 +24,8 @@ RailLinks::joinLinks(const LinkPtr & l) const
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);
+ l->nexts[te].emplace_back(ol, oe);
+ ol->nexts[oe].emplace_back(l, te);
}
}
}