summaryrefslogtreecommitdiff
path: root/src/roadveh_cmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/roadveh_cmd.cpp')
-rw-r--r--src/roadveh_cmd.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 1254dc269..1b9fef366 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -191,6 +191,8 @@ void RoadVehUpdateCache(RoadVehicle *v)
/* Invalidate the vehicle colour map */
u->colourmap = PAL_NONE;
}
+
+ v->vcache.cached_max_speed = RoadVehInfo(v->engine_type)->max_speed;
}
/**
@@ -384,17 +386,17 @@ void RoadVehicle::UpdateDeltaXY(Direction direction)
*/
FORCEINLINE int RoadVehicle::GetCurrentMaxSpeed() const
{
- if (_settings_game.vehicle.roadveh_acceleration_model == AM_ORIGINAL) return this->max_speed;
+ if (_settings_game.vehicle.roadveh_acceleration_model == AM_ORIGINAL) return this->vcache.cached_max_speed;
- int max_speed = this->max_speed;
+ int max_speed = this->vcache.cached_max_speed;
/* Limit speed to 50% while reversing, 75% in curves. */
for (const RoadVehicle *u = this; u != NULL; u = u->Next()) {
if (this->state <= RVSB_TRACKDIR_MASK && IsReversingRoadTrackdir((Trackdir)this->state)) {
- max_speed = this->max_speed / 2;
+ max_speed = this->vcache.cached_max_speed / 2;
break;
} else if ((u->direction & 1) == 0) {
- max_speed = this->max_speed * 3 / 4;
+ max_speed = this->vcache.cached_max_speed * 3 / 4;
}
}
@@ -753,7 +755,7 @@ static void RoadVehCheckOvertake(RoadVehicle *v, RoadVehicle *u)
od.v = v;
od.u = u;
- if (u->max_speed >= v->max_speed &&
+ if (u->max_speed >= v->vcache.cached_max_speed &&
!(u->vehstatus & VS_STOPPED) &&
u->cur_speed != 0) {
return;
@@ -806,7 +808,7 @@ static void RoadZPosAffectSpeed(RoadVehicle *v, byte old_z)
v->cur_speed = v->cur_speed * 232 / 256; // slow down by ~10%
} else {
uint16 spd = v->cur_speed + 2;
- if (spd <= v->max_speed) v->cur_speed = spd;
+ if (spd <= v->vcache.cached_max_speed) v->cur_speed = spd;
}
}