(svn r6611) - Newsounds:
authorpeter1138
Sun, 01 Oct 2006 17:56:38 +0000
changeset 4701 9e83e5ae6de7
parent 4700 78d6149cb6bb
child 4702 c79e9d9f27b3
(svn r6611) - Newsounds:
- If the NewGRF sound effect chosen doesn't exist, then ignore it.
- Play load/unload sound if provided.
economy.c
newgrf_sound.c
--- a/economy.c	Sun Oct 01 17:26:37 2006 +0000
+++ b/economy.c	Sun Oct 01 17:56:38 2006 +0000
@@ -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 @@
 			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);
 		}
--- a/newgrf_sound.c	Sun Oct 01 17:26:37 2006 +0000
+++ b/newgrf_sound.c	Sun Oct 01 17:56:38 2006 +0000
@@ -68,6 +68,6 @@
 	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;
 }