diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-31 01:25:39 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-31 01:25:39 +0000 |
commit | bce9080d6f2997aef398783bc40408cf3f952ec5 (patch) | |
tree | 9e5b1b5e605d04b8b1927fae32b41ce3f08455db | |
parent | Fix train/vehicle constructors to take const links (diff) | |
download | ilt-bce9080d6f2997aef398783bc40408cf3f952ec5.tar.bz2 ilt-bce9080d6f2997aef398783bc40408cf3f952ec5.tar.xz ilt-bce9080d6f2997aef398783bc40408cf3f952ec5.zip |
Extract consts and fix acceleration/decelartions rates
-rw-r--r-- | game/vehicles/train.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/game/vehicles/train.cpp b/game/vehicles/train.cpp index 5bddd61..2461d9c 100644 --- a/game/vehicles/train.cpp +++ b/game/vehicles/train.cpp @@ -2,7 +2,6 @@ #include "game/vehicles/linkHistory.h" #include "game/vehicles/railVehicle.h" #include "game/vehicles/railVehicleClass.h" -#include "gfx/renderable.h" #include "location.h" #include <algorithm> #include <functional> @@ -11,6 +10,9 @@ template<typename> class Ray; +constexpr auto DECELERATION_RATE = 60000.F; +constexpr auto ACCELERATIONS_RATE = 30000.F; + Location Train::getBogiePosition(float linkDist, float dist) const { @@ -41,8 +43,8 @@ Train::doActivity(Go * go, TickDuration dur) const auto maxSpeed = objects.front()->rvClass->maxSpeed; if (go->dist) { *go->dist -= speed * dur.count(); - if (*go->dist < (speed * speed) / 60.F) { - speed -= std::min(speed, 30.F * dur.count()); + if (*go->dist < (speed * speed) / DECELERATION_RATE) { + speed -= std::min(speed, ACCELERATIONS_RATE * dur.count()); } else { if (speed != maxSpeed) { @@ -61,6 +63,6 @@ void Train::doActivity(Idle *, TickDuration dur) { if (speed != 0.F) { - speed -= std::min(speed, 30.F * dur.count()); + speed -= std::min(speed, DECELERATION_RATE * dur.count()); } } |