summaryrefslogtreecommitdiff
path: root/game/vehicles
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-10-31 01:25:39 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-11-05 20:06:02 +0000
commitee88d39b826fa1c40a88b9000739fabe7dcc4360 (patch)
tree9e5b1b5e605d04b8b1927fae32b41ce3f08455db /game/vehicles
parentFix train/vehicle constructors to take const links (diff)
downloadilt-ee88d39b826fa1c40a88b9000739fabe7dcc4360.tar.bz2
ilt-ee88d39b826fa1c40a88b9000739fabe7dcc4360.tar.xz
ilt-ee88d39b826fa1c40a88b9000739fabe7dcc4360.zip
Extract consts and fix acceleration/decelartions rates
Diffstat (limited to 'game/vehicles')
-rw-r--r--game/vehicles/train.cpp10
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());
}
}