summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2013-05-06 15:09:21 +0000
committerfrosch <frosch@openttd.org>2013-05-06 15:09:21 +0000
commit266bdfaffe9727afafcec21f2d2fddc8900e1575 (patch)
tree8af8a9212456d0483f3c1d65943a34fc0a073013 /src
parent9dee2f5c1e013c2e4914eb6203d5d56990d889a8 (diff)
downloadopenttd-266bdfaffe9727afafcec21f2d2fddc8900e1575.tar.xz
(svn r25226) -Fix/Change [FS#5538]: [NewGRF] Revise when vehicle running sound effects 04, 07 and 08 are played.
In depot or tunnel, or when crashed or stopped: No sound. Braking: Effect 08 instead of 07.
Diffstat (limited to 'src')
-rw-r--r--src/vehicle.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index de5b89ced..b6545e2ca 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -890,7 +890,16 @@ void CallVehicleTicks()
}
}
- /* Check vehicle sounds */
+ /* Do not play any sound when crashed */
+ if (front->vehstatus & VS_CRASHED) continue;
+
+ /* Do not play any sound when in depot or tunnel */
+ if (v->vehstatus & VS_HIDDEN) continue;
+
+ /* Do not play any sound when stopped */
+ if ((front->vehstatus & VS_STOPPED) && (front->type != VEH_TRAIN || front->cur_speed == 0)) continue;
+
+ /* Check vehicle type specifics */
switch (v->type) {
case VEH_TRAIN:
if (Train::From(v)->IsWagon()) continue;
@@ -913,7 +922,11 @@ void CallVehicleTicks()
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, front->cur_speed > 0 ? VSE_RUNNING_16 : VSE_STOPPED_16);
+ if (GB(v->tick_counter, 0, 4) == 0) {
+ /* Play running sound when speed > 0 and not braking */
+ bool running = (front->cur_speed > 0) && !(front->vehstatus & (VS_STOPPED | VS_TRAIN_SLOWING));
+ PlayVehicleSound(v, running ? VSE_RUNNING_16 : VSE_STOPPED_16);
+ }
break;
}