summaryrefslogtreecommitdiff
path: root/src/newgrf_sound.cpp
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2012-02-04 13:29:04 +0000
committermichi_cc <michi_cc@openttd.org>2012-02-04 13:29:04 +0000
commit6db39410a1ea0bc8ece1f33fb7771e47d39cc2b7 (patch)
treed94bcfca3862721c5e6fccff0ec87b79e757cd24 /src/newgrf_sound.cpp
parenta9b6c5cd86f4f17155695890bfaf2e30404f5921 (diff)
downloadopenttd-6db39410a1ea0bc8ece1f33fb7771e47d39cc2b7.tar.xz
(svn r23887) -Feature: [NewGRF] Support for container version 2.
Diffstat (limited to 'src/newgrf_sound.cpp')
-rw-r--r--src/newgrf_sound.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/newgrf_sound.cpp b/src/newgrf_sound.cpp
index 401c77386..5abd443c9 100644
--- a/src/newgrf_sound.cpp
+++ b/src/newgrf_sound.cpp
@@ -64,9 +64,13 @@ bool LoadNewGRFSound(SoundEntry *sound)
FioSeekToFile(sound->file_slot, sound->file_offset);
+ /* Skip ID for container version >= 2 as we only look at the first
+ * entry and ignore any further entries with the same ID. */
+ if (sound->grf_container_ver >= 2) FioReadDword();
+
/* Format: <num> <FF> <FF> <name_len> <name> '\0' <data> */
- uint16 num = FioReadWord();
+ uint32 num = sound->grf_container_ver >= 2 ? FioReadDword() : FioReadWord();
if (FioReadByte() != 0xFF) return false;
if (FioReadByte() != 0xFF) return false;
@@ -88,7 +92,9 @@ bool LoadNewGRFSound(SoundEntry *sound)
}
uint32 total_size = FioReadDword();
- if (total_size + name_len + 11 > num) { // The first FF in the sprite is not counted for <num>.
+ uint header_size = 11;
+ if (sound->grf_container_ver >= 2) header_size++; // The first FF in the sprite is only counted for container version >= 2.
+ if (total_size + name_len + header_size > num) {
DEBUG(grf, 1, "LoadNewGRFSound [%s]: RIFF was truncated", FioGetFilename(sound->file_slot));
return false;
}