diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-02-14 17:32:00 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-02-14 17:37:45 +0000 |
commit | 41d68b7145ddf5ac0e7b2fd7f0d22e428b356230 (patch) | |
tree | 91f2636971e392c67a4fb7e959bff27d388501cd /game/vehicles/vehicle.cpp | |
parent | Maintain a history of links traversed (diff) | |
download | ilt-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.cpp | 15 |
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}; } |