summaryrefslogtreecommitdiff
path: root/game/vehicles/vehicle.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-02-14 17:32:00 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-02-14 17:37:45 +0000
commit41d68b7145ddf5ac0e7b2fd7f0d22e428b356230 (patch)
tree91f2636971e392c67a4fb7e959bff27d388501cd /game/vehicles/vehicle.cpp
parentMaintain a history of links traversed (diff)
downloadilt-41d68b7145ddf5ac0e7b2fd7f0d22e428b356230.tar.bz2
ilt-41d68b7145ddf5ac0e7b2fd7f0d22e428b356230.tar.xz
ilt-41d68b7145ddf5ac0e7b2fd7f0d22e428b356230.zip
Correctly follow rails according to wheelbase
Diffstat (limited to 'game/vehicles/vehicle.cpp')
-rw-r--r--game/vehicles/vehicle.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/game/vehicles/vehicle.cpp b/game/vehicles/vehicle.cpp
index 569063d..f722cff 100644
--- a/game/vehicles/vehicle.cpp
+++ b/game/vehicles/vehicle.cpp
@@ -24,15 +24,26 @@ LinkHistory::add(const LinkWPtr & l, unsigned char d)
}
LinkHistory::Return
-LinkHistory::getAt(float len) const
+LinkHistory::getCurrent() const
+{
+ return {links.front().first.lock(), links.front().second};
+}
+
+LinkHistory::Return
+LinkHistory::getAt(float len, float * rem) const
{
auto litr = links.begin();
while (len > 0.F && litr != links.end()) {
- len -= litr->first.lock()->length;
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};
}