summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2013-05-06 14:08:27 +0000
committerfrosch <frosch@openttd.org>2013-05-06 14:08:27 +0000
commit2030d1cf60e69461db0c7187a11cd19ac6e7f019 (patch)
treeba60f74545adb3df4b4f257a467da603c97ea020 /src
parent341a6f6e959c75b4b6246579dc316e8c43c138f9 (diff)
downloadopenttd-2030d1cf60e69461db0c7187a11cd19ac6e7f019.tar.xz
(svn r25224) -Fix [part of FS#5534]: cur_speed is only valid for the front engine, so make other engines in the consist use the speed of the front.
Diffstat (limited to 'src')
-rw-r--r--src/vehicle.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index edbdd01e3..adea79f86 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -879,7 +879,9 @@ void CallVehicleTicks()
case VEH_TRAIN:
case VEH_ROAD:
case VEH_AIRCRAFT:
- case VEH_SHIP:
+ case VEH_SHIP: {
+ Vehicle *front = v->First();
+
if (v->vcache.cached_cargo_age_period != 0) {
v->cargo_age_counter = min(v->cargo_age_counter, v->vcache.cached_cargo_age_period);
if (--v->cargo_age_counter == 0) {
@@ -892,12 +894,15 @@ void CallVehicleTicks()
if (v->type == VEH_AIRCRAFT && v->subtype != AIR_HELICOPTER) continue;
if (v->type == VEH_ROAD && !RoadVehicle::From(v)->IsFrontEngine()) continue;
- v->motion_counter += v->cur_speed;
+ v->motion_counter += front->cur_speed;
/* Play a running sound if the motion counter passes 256 (Do we not skip sounds?) */
- if (GB(v->motion_counter, 0, 8) < v->cur_speed) PlayVehicleSound(v, VSE_RUNNING);
+ if (GB(v->motion_counter, 0, 8) < front->cur_speed) PlayVehicleSound(v, VSE_RUNNING);
/* Play an alternating running sound every 16 ticks */
- if (GB(v->tick_counter, 0, 4) == 0) PlayVehicleSound(v, v->cur_speed > 0 ? VSE_RUNNING_16 : VSE_STOPPED_16);
+ if (GB(v->tick_counter, 0, 4) == 0) PlayVehicleSound(v, front->cur_speed > 0 ? VSE_RUNNING_16 : VSE_STOPPED_16);
+
+ break;
+ }
}
}