summaryrefslogtreecommitdiff
path: root/src/train_cmd.cpp
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2010-11-09 17:43:05 +0000
committerterkhen <terkhen@openttd.org>2010-11-09 17:43:05 +0000
commit6a38925ca3d3865f7f9de8cee37a6226d12af4d9 (patch)
tree479ce8e41b6c5cd1e74656d66462205c96e885d0 /src/train_cmd.cpp
parente1ff8aeb09cded7fe1651f0a7fa06d145d723607 (diff)
downloadopenttd-6a38925ca3d3865f7f9de8cee37a6226d12af4d9.tar.xz
(svn r21123) -Codechange: Remove max_speed from the Vehicle class.
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r--src/train_cmd.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 574972694..399fd8253 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -466,8 +466,6 @@ void Train::UpdateAcceleration()
{
assert(this->IsFrontEngine());
- this->max_speed = this->acc_cache.cached_max_track_speed;
-
uint power = this->acc_cache.cached_power;
uint weight = this->acc_cache.cached_weight;
assert(weight != 0);
@@ -733,7 +731,6 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, DoCommandFlag flags, const Engin
v->spritenum = rvi->image_index;
v->cargo_type = e->GetDefaultCargoType();
v->cargo_cap = rvi->capacity;
- v->max_speed = rvi->max_speed;
v->last_station_visited = INVALID_STATION;
v->engine_type = e->index;
@@ -2781,14 +2778,16 @@ void Train::MarkDirty()
int Train::UpdateSpeed()
{
uint accel;
+ uint16 max_speed;
switch (_settings_game.vehicle.train_acceleration_model) {
default: NOT_REACHED();
case AM_ORIGINAL:
+ max_speed = this->acc_cache.cached_max_track_speed;
accel = this->acceleration * (this->GetAccelerationStatus() == AS_BRAKE ? -4 : 2);
break;
case AM_REALISTIC:
- this->max_speed = this->GetCurrentMaxSpeed();
+ max_speed = this->GetCurrentMaxSpeed();
accel = this->GetAcceleration();
break;
}
@@ -2796,8 +2795,8 @@ int Train::UpdateSpeed()
uint spd = this->subspeed + accel;
this->subspeed = (byte)spd;
{
- int tempmax = this->max_speed;
- if (this->cur_speed > this->max_speed) {
+ int tempmax = max_speed;
+ if (this->cur_speed > max_speed) {
tempmax = this->cur_speed - (this->cur_speed / 10) - 1;
}
this->cur_speed = spd = Clamp(this->cur_speed + ((int)spd >> 8), 0, tempmax);
@@ -2876,7 +2875,7 @@ static inline void AffectSpeedByZChange(Train *v, byte old_z)
v->cur_speed -= (v->cur_speed * rsp->z_up >> 8);
} else {
uint16 spd = v->cur_speed + rsp->z_down;
- if (spd <= v->max_speed) v->cur_speed = spd;
+ if (spd <= v->acc_cache.cached_max_track_speed) v->cur_speed = spd;
}
}