25 #include "waypoint.h" |
25 #include "waypoint.h" |
26 #include "vehicle_gui.h" |
26 #include "vehicle_gui.h" |
27 #include "train.h" |
27 #include "train.h" |
28 #include "newgrf_callbacks.h" |
28 #include "newgrf_callbacks.h" |
29 #include "newgrf_engine.h" |
29 #include "newgrf_engine.h" |
|
30 #include "newgrf_sound.h" |
30 #include "newgrf_text.h" |
31 #include "newgrf_text.h" |
31 #include "direction.h" |
32 #include "direction.h" |
32 #include "yapf/yapf.h" |
33 #include "yapf/yapf.h" |
33 #include "date.h" |
34 #include "date.h" |
34 |
35 |
2066 switch (effect_type) { |
2068 switch (effect_type) { |
2067 case 0: |
2069 case 0: |
2068 // steam smoke. |
2070 // steam smoke. |
2069 if (GB(v->tick_counter, 0, 4) == 0) { |
2071 if (GB(v->tick_counter, 0, 4) == 0) { |
2070 CreateEffectVehicleRel(v, x, y, 10, EV_STEAM_SMOKE); |
2072 CreateEffectVehicleRel(v, x, y, 10, EV_STEAM_SMOKE); |
|
2073 sound = true; |
2071 } |
2074 } |
2072 break; |
2075 break; |
2073 |
2076 |
2074 case 1: |
2077 case 1: |
2075 // diesel smoke |
2078 // diesel smoke |
2076 if (u->cur_speed <= 40 && CHANCE16(15, 128)) { |
2079 if (u->cur_speed <= 40 && CHANCE16(15, 128)) { |
2077 CreateEffectVehicleRel(v, 0, 0, 10, EV_DIESEL_SMOKE); |
2080 CreateEffectVehicleRel(v, 0, 0, 10, EV_DIESEL_SMOKE); |
|
2081 sound = true; |
2078 } |
2082 } |
2079 break; |
2083 break; |
2080 |
2084 |
2081 case 2: |
2085 case 2: |
2082 // blue spark |
2086 // blue spark |
2083 if (GB(v->tick_counter, 0, 2) == 0 && CHANCE16(1, 45)) { |
2087 if (GB(v->tick_counter, 0, 2) == 0 && CHANCE16(1, 45)) { |
2084 CreateEffectVehicleRel(v, 0, 0, 10, EV_ELECTRIC_SPARK); |
2088 CreateEffectVehicleRel(v, 0, 0, 10, EV_ELECTRIC_SPARK); |
|
2089 sound = true; |
2085 } |
2090 } |
2086 break; |
2091 break; |
2087 } |
2092 } |
2088 } while ((v = v->next) != NULL); |
2093 } while ((v = v->next) != NULL); |
|
2094 |
|
2095 if (sound) PlayVehicleSound(u, VSE_TRAIN_EFFECT); |
2089 } |
2096 } |
2090 |
2097 |
2091 static void TrainPlayLeaveStationSound(const Vehicle* v) |
2098 static void TrainPlayLeaveStationSound(const Vehicle* v) |
2092 { |
2099 { |
2093 static const SoundFx sfx[] = { |
2100 static const SoundFx sfx[] = { |
2095 SND_0A_TRAIN_HORN, |
2102 SND_0A_TRAIN_HORN, |
2096 SND_0A_TRAIN_HORN |
2103 SND_0A_TRAIN_HORN |
2097 }; |
2104 }; |
2098 |
2105 |
2099 EngineID engtype = v->engine_type; |
2106 EngineID engtype = v->engine_type; |
|
2107 |
|
2108 if (PlayVehicleSound(v, VSE_START)) return; |
2100 |
2109 |
2101 switch (GetEngine(engtype)->railtype) { |
2110 switch (GetEngine(engtype)->railtype) { |
2102 case RAILTYPE_RAIL: |
2111 case RAILTYPE_RAIL: |
2103 case RAILTYPE_ELECTRIC: |
2112 case RAILTYPE_ELECTRIC: |
2104 SndPlayVehicleFx(sfx[RailVehInfo(engtype)->engclass], v); |
2113 SndPlayVehicleFx(sfx[RailVehInfo(engtype)->engclass], v); |
3260 v->breakdowns_since_last_service++; |
3269 v->breakdowns_since_last_service++; |
3261 |
3270 |
3262 InvalidateWindow(WC_VEHICLE_VIEW, v->index); |
3271 InvalidateWindow(WC_VEHICLE_VIEW, v->index); |
3263 InvalidateWindow(WC_VEHICLE_DETAILS, v->index); |
3272 InvalidateWindow(WC_VEHICLE_DETAILS, v->index); |
3264 |
3273 |
3265 SndPlayVehicleFx((_opt.landscape != LT_CANDY) ? |
3274 if (!PlayVehicleSound(v, VSE_BREAKDOWN)) { |
3266 SND_10_TRAIN_BREAKDOWN : SND_3A_COMEDY_BREAKDOWN_2, v); |
3275 SndPlayVehicleFx((_opt.landscape != LT_CANDY) ? |
|
3276 SND_10_TRAIN_BREAKDOWN : SND_3A_COMEDY_BREAKDOWN_2, v); |
|
3277 } |
3267 |
3278 |
3268 if (!(v->vehstatus & VS_HIDDEN)) { |
3279 if (!(v->vehstatus & VS_HIDDEN)) { |
3269 Vehicle *u = CreateEffectVehicleRel(v, 4, 4, 5, EV_BREAKDOWN_SMOKE); |
3280 Vehicle *u = CreateEffectVehicleRel(v, 4, 4, 5, EV_BREAKDOWN_SMOKE); |
3270 if (u != NULL) u->u.special.unk0 = v->breakdown_delay * 2; |
3281 if (u != NULL) u->u.special.unk0 = v->breakdown_delay * 2; |
3271 } |
3282 } |