summaryrefslogtreecommitdiff
path: root/src/sound.cpp
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2012-02-04 13:28:44 +0000
committermichi_cc <michi_cc@openttd.org>2012-02-04 13:28:44 +0000
commit12f0e80dad7c798ed28990d14f3395ac4478b9c3 (patch)
tree2a4ebb24c40ba89d3d5ab7d357b5ab1da5876996 /src/sound.cpp
parent5af68295b0c71edc62db53c87c89ffc38f5331bf (diff)
downloadopenttd-12f0e80dad7c798ed28990d14f3395ac4478b9c3.tar.xz
(svn r23882) -Codechange: Delay parsing of NewGRF sound effects until first usage.
Diffstat (limited to 'src/sound.cpp')
-rw-r--r--src/sound.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/sound.cpp b/src/sound.cpp
index d572050bf..f792dfdff 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -159,9 +159,18 @@ static void StartSound(SoundID sound_id, float pan, uint volume)
{
if (volume == 0) return;
- const SoundEntry *sound = GetSound(sound_id);
+ SoundEntry *sound = GetSound(sound_id);
if (sound == NULL) return;
+ /* NewGRF sound that wasn't loaded yet? */
+ if (sound->rate == 0 && sound->file_slot != 0) {
+ if (!LoadNewGRFSound(sound)) {
+ /* Mark as invalid. */
+ sound->file_slot = 0;
+ return;
+ }
+ }
+
/* Empty sound? */
if (sound->rate == 0) return;