mirror of https://github.com/OpenTTD/OpenTTD
(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.
parent
7031358cff
commit
a967a7287f
|
@ -89,6 +89,11 @@ struct RailtypeInfo {
|
||||||
* Offset to add to ground sprite when drawing custom waypoints / stations
|
* Offset to add to ground sprite when drawing custom waypoints / stations
|
||||||
*/
|
*/
|
||||||
byte custom_ground_offset;
|
byte custom_ground_offset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiplier for curve maximum speed advantage
|
||||||
|
*/
|
||||||
|
byte curve_speed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,9 @@ RailtypeInfo _railtypes[] = {
|
||||||
|
|
||||||
/* custom ground offset */
|
/* custom ground offset */
|
||||||
0,
|
0,
|
||||||
|
|
||||||
|
/* curve speed advantage (multiplier) */
|
||||||
|
0,
|
||||||
},
|
},
|
||||||
|
|
||||||
/** Electrified railway */
|
/** Electrified railway */
|
||||||
|
@ -110,6 +113,9 @@ RailtypeInfo _railtypes[] = {
|
||||||
|
|
||||||
/* custom ground offset */
|
/* custom ground offset */
|
||||||
0,
|
0,
|
||||||
|
|
||||||
|
/* curve speed advantage (multiplier) */
|
||||||
|
0,
|
||||||
},
|
},
|
||||||
|
|
||||||
/** Monorail */
|
/** Monorail */
|
||||||
|
@ -159,6 +165,9 @@ RailtypeInfo _railtypes[] = {
|
||||||
|
|
||||||
/* custom ground offset */
|
/* custom ground offset */
|
||||||
1,
|
1,
|
||||||
|
|
||||||
|
/* curve speed advantage (multiplier) */
|
||||||
|
1,
|
||||||
},
|
},
|
||||||
|
|
||||||
/** Maglev */
|
/** Maglev */
|
||||||
|
@ -208,6 +217,9 @@ RailtypeInfo _railtypes[] = {
|
||||||
|
|
||||||
/* custom ground offset */
|
/* custom ground offset */
|
||||||
2,
|
2,
|
||||||
|
|
||||||
|
/* curve speed advantage (multiplier) */
|
||||||
|
2,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -311,7 +311,8 @@ static bool TrainShouldStop(const Vehicle* v, TileIndex tile)
|
||||||
/** new acceleration*/
|
/** new acceleration*/
|
||||||
static int GetTrainAcceleration(Vehicle *v, bool mode)
|
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 speed = v->cur_speed * 10 / 16; // km-ish/h -> mp/h
|
||||||
int curvecount[2] = {0, 0};
|
int curvecount[2] = {0, 0};
|
||||||
|
|
||||||
|
@ -352,13 +353,17 @@ static int GetTrainAcceleration(Vehicle *v, bool mode)
|
||||||
int total = curvecount[0] + curvecount[1];
|
int total = curvecount[0] + curvecount[1];
|
||||||
|
|
||||||
if (curvecount[0] == 1 && curvecount[1] == 1) {
|
if (curvecount[0] == 1 && curvecount[1] == 1) {
|
||||||
max_speed = 0xFFFF;
|
max_speed = absolute_max_speed;
|
||||||
} else if (total > 1) {
|
} else if (total > 1) {
|
||||||
max_speed = 232 - (13 - Clamp(sum, 1, 12)) * (13 - Clamp(sum, 1, 12));
|
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 (IsTileType(v->tile, MP_STATION) && IsFrontEngine(v)) {
|
||||||
if (TrainShouldStop(v, v->tile)) {
|
if (TrainShouldStop(v, v->tile)) {
|
||||||
|
|
Loading…
Reference in New Issue