summaryrefslogtreecommitdiff
path: root/src/train_cmd.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-01-01 14:00:31 +0000
committerpeter1138 <peter1138@openttd.org>2008-01-01 14:00:31 +0000
commita1b482973de4a2d14088710237119e13eb89e60c (patch)
treeae310350119829d8ba97096972466ed0bae3b3ac /src/train_cmd.cpp
parent2194b15fdd127064aea07a2f0a139a59872523ca (diff)
downloadopenttd-a1b482973de4a2d14088710237119e13eb89e60c.tar.xz
(svn r11732) -Fix (r4150): elrail merge gave elrail, monorail & maglev unintended speed bonuses for curves, as the bonus was based on the railtype index. The bonus is now specified by a property of the railtype.
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r--src/train_cmd.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index c47c23dae..b5c9e3c0d 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -311,7 +311,8 @@ static bool TrainShouldStop(const Vehicle* v, TileIndex tile)
/** new acceleration*/
static int GetTrainAcceleration(Vehicle *v, bool mode)
{
- int max_speed = 2000;
+ static const int absolute_max_speed = 2000;
+ int max_speed = absolute_max_speed;
int speed = v->cur_speed * 10 / 16; // km-ish/h -> mp/h
int curvecount[2] = {0, 0};
@@ -352,13 +353,17 @@ static int GetTrainAcceleration(Vehicle *v, bool mode)
int total = curvecount[0] + curvecount[1];
if (curvecount[0] == 1 && curvecount[1] == 1) {
- max_speed = 0xFFFF;
+ max_speed = absolute_max_speed;
} else if (total > 1) {
max_speed = 232 - (13 - Clamp(sum, 1, 12)) * (13 - Clamp(sum, 1, 12));
}
}
- max_speed += (max_speed / 2) * v->u.rail.railtype;
+ if (max_speed != absolute_max_speed) {
+ /* Apply the engine's rail type curve speed advantage, if it slowed by curves */
+ const RailtypeInfo *rti = GetRailTypeInfo(v->u.rail.railtype);
+ max_speed += (max_speed / 2) * rti->curve_speed;
+ }
if (IsTileType(v->tile, MP_STATION) && IsFrontEngine(v)) {
if (TrainShouldStop(v, v->tile)) {