diff options
author | michi_cc <michi_cc@openttd.org> | 2012-02-04 13:28:44 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2012-02-04 13:28:44 +0000 |
commit | 12f0e80dad7c798ed28990d14f3395ac4478b9c3 (patch) | |
tree | 2a4ebb24c40ba89d3d5ab7d357b5ab1da5876996 /src/sound.cpp | |
parent | 5af68295b0c71edc62db53c87c89ffc38f5331bf (diff) | |
download | openttd-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.cpp | 11 |
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; |