summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rail.h5
-rw-r--r--src/table/railtypes.h12
-rw-r--r--src/train_cmd.cpp27
3 files changed, 28 insertions, 16 deletions
diff --git a/src/rail.h b/src/rail.h
index 69038c205..14dbdb89c 100644
--- a/src/rail.h
+++ b/src/rail.h
@@ -142,6 +142,11 @@ struct RailtypeInfo {
uint8 cost_multiplier;
/**
+ * Acceleration type of this rail type
+ */
+ uint8 acceleration_type;
+
+ /**
* Unique 32 bit rail type identifier
*/
RailTypeLabel label;
diff --git a/src/table/railtypes.h b/src/table/railtypes.h
index c17e5a13c..9eea21ae7 100644
--- a/src/table/railtypes.h
+++ b/src/table/railtypes.h
@@ -81,6 +81,9 @@ static const RailtypeInfo _original_railtypes[] = {
/* cost multiplier */
8,
+ /* accelration type */
+ 0,
+
/* rail type label */
'RAIL',
},
@@ -153,6 +156,9 @@ static const RailtypeInfo _original_railtypes[] = {
/* cost multiplier */
12,
+ /* acceleration type */
+ 0,
+
/* rail type label */
'ELRL',
},
@@ -221,6 +227,9 @@ static const RailtypeInfo _original_railtypes[] = {
/* cost multiplier */
16,
+ /* acceleration type */
+ 1,
+
/* rail type label */
'MONO',
},
@@ -289,6 +298,9 @@ static const RailtypeInfo _original_railtypes[] = {
/* cost multiplier */
24,
+ /* acceleration type */
+ 2,
+
/* rail type label */
'MGLV',
},
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 352e0969e..17dad7aea 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -531,10 +531,12 @@ static int GetTrainAcceleration(Train *v, bool mode)
v->max_speed = max_speed;
+ bool maglev = GetRailTypeInfo(v->railtype)->acceleration_type == 2;
+
const int area = 120;
const int friction = 35; //[1e-3]
int resistance;
- if (v->railtype != RAILTYPE_MAGLEV) {
+ if (!maglev) {
resistance = 13 * mass / 10;
resistance += 60 * num;
resistance += friction * mass * speed / 1000;
@@ -548,24 +550,17 @@ static int GetTrainAcceleration(Train *v, bool mode)
const int max_te = v->tcache.cached_max_te; // [N]
int force;
if (speed > 0) {
- switch (v->railtype) {
- case RAILTYPE_RAIL:
- case RAILTYPE_ELECTRIC:
- case RAILTYPE_MONO:
- force = power / speed; //[N]
- force *= 22;
- force /= 10;
- if (mode == AM_ACCEL && force > max_te) force = max_te;
- break;
-
- default: NOT_REACHED();
- case RAILTYPE_MAGLEV:
- force = power / 25;
- break;
+ if (!maglev) {
+ force = power / speed; //[N]
+ force *= 22;
+ force /= 10;
+ if (mode == AM_ACCEL && force > max_te) force = max_te;
+ } else {
+ force = power / 25;
}
} else {
/* "kickoff" acceleration */
- force = (mode == AM_ACCEL && v->railtype != RAILTYPE_MAGLEV) ? min(max_te, power) : power;
+ force = (mode == AM_ACCEL && !maglev) ? min(max_te, power) : power;
force = max(force, (mass * 8) + resistance);
}