summaryrefslogtreecommitdiff
path: root/game/vehicles/vehicle.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-03-06 19:44:58 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-03-06 19:44:58 +0000
commite118b1f5d8071460e3a9d4d731c6d69221f785dc (patch)
tree64ea6b1761afba27d36319648e78ddd457670ff8 /game/vehicles/vehicle.cpp
parentIntroduce the Train concept as a literal collection of rail vehicles (diff)
downloadilt-e118b1f5d8071460e3a9d4d731c6d69221f785dc.tar.bz2
ilt-e118b1f5d8071460e3a9d4d731c6d69221f785dc.tar.xz
ilt-e118b1f5d8071460e3a9d4d731c6d69221f785dc.zip
Carve up the mess in game/vehicles
Diffstat (limited to 'game/vehicles/vehicle.cpp')
-rw-r--r--game/vehicles/vehicle.cpp41
1 files changed, 1 insertions, 40 deletions
diff --git a/game/vehicles/vehicle.cpp b/game/vehicles/vehicle.cpp
index 26e33d4..d98533e 100644
--- a/game/vehicles/vehicle.cpp
+++ b/game/vehicles/vehicle.cpp
@@ -1,47 +1,8 @@
#include "vehicle.h"
#include "game/network/link.h"
-#include <memory>
-#include <utility>
+#include "game/vehicles/linkHistory.h"
Vehicle::Vehicle(const LinkPtr & l, float ld) : linkDist {ld}
{
linkHist.add(l, 0);
}
-
-LinkHistory::Entry
-LinkHistory::add(const LinkWPtr & l, unsigned char d)
-{
- links.insert(links.begin(), {l, d});
- const auto lp = l.lock();
- totalLen += lp->length;
- while (totalLen >= 1000.F && !links.empty()) {
- totalLen -= links.back().first.lock()->length;
- links.pop_back();
- }
- return {lp, d};
-}
-
-LinkHistory::Entry
-LinkHistory::getCurrent() const
-{
- return {links.front().first.lock(), links.front().second};
-}
-
-LinkHistory::Entry
-LinkHistory::getAt(float len, float * rem) const
-{
- auto litr = links.begin();
- while (len > 0.F && litr != links.end()) {
- litr++;
- if (litr != links.end()) {
- len -= litr->first.lock()->length;
- }
- }
- if (litr == links.end()) {
- litr--;
- }
- if (rem) {
- *rem = -len;
- }
- return {litr->first.lock(), litr->second};
-}