From 33e8c26c38ac228a22868a27687e0a92d1ec9a29 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Sun, 1 Oct 2006 17:56:38 +0000 Subject: [PATCH] (svn r6611) - Newsounds: - If the NewGRF sound effect chosen doesn't exist, then ignore it. - Play load/unload sound if provided. --- economy.c | 5 ++++- newgrf_sound.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/economy.c b/economy.c index c2984123d9..5a66be14c5 100644 --- a/economy.c +++ b/economy.c @@ -28,6 +28,7 @@ #include "ai/ai.h" #include "train.h" #include "newgrf_engine.h" +#include "newgrf_sound.h" #include "unmovable.h" #include "date.h" @@ -1464,7 +1465,9 @@ int LoadUnloadVehicle(Vehicle *v) v->profit_this_year += profit; SubtractMoneyFromPlayer(-profit); - if (IsLocalPlayer()) SndPlayVehicleFx(SND_14_CASHTILL, v); + if (IsLocalPlayer() && !PlayVehicleSound(v, VSE_LOAD_UNLOAD)) { + SndPlayVehicleFx(SND_14_CASHTILL, v); + } ShowCostOrIncomeAnimation(v->x_pos, v->y_pos, v->z_pos, -profit); } diff --git a/newgrf_sound.c b/newgrf_sound.c index 7d746f7121..990629e823 100644 --- a/newgrf_sound.c +++ b/newgrf_sound.c @@ -68,6 +68,6 @@ bool PlayVehicleSound(const Vehicle *v, VehicleSoundEvent event) if (callback == CALLBACK_FAILED) return false; if (callback >= GetNumOriginalSounds()) callback += file->sound_offset - GetNumOriginalSounds(); - SndPlayVehicleFx(callback, v); + if (callback < GetNumSounds()) SndPlayVehicleFx(callback, v); return true; }