From 477e31cea69f2ac4f2cf80549d6a773319868a61 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Wed, 14 Dec 2016 11:27:49 -0600 Subject: SCI32: Ignore invalid audio map entries in GK2 The invalid entries, which are on CD 6, appear to correspond to audio that's on CD 4 (though not with the correct offset for CD 4's RESOURCE.AUD). Skipping the invalid map entries on CD 6 should cause these audio files to be loaded from the CD 4 audio bundle if they are requested during chapter six since ScummVM combines resources from all CDs and matches on their IDs. --- engines/sci/resource.h | 2 +- engines/sci/resource_audio.cpp | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/resource.h b/engines/sci/resource.h index a9a7a86c96..3e7a7a5e96 100644 --- a/engines/sci/resource.h +++ b/engines/sci/resource.h @@ -185,7 +185,7 @@ public: } // Convert from a resource ID to a base36 patch name - Common::String toPatchNameBase36() { + Common::String toPatchNameBase36() const { Common::String output; output += (getType() == kResourceTypeAudio36) ? '@' : '#'; // Identifier diff --git a/engines/sci/resource_audio.cpp b/engines/sci/resource_audio.cpp index 7423890903..c70a2a2322 100644 --- a/engines/sci/resource_audio.cpp +++ b/engines/sci/resource_audio.cpp @@ -430,8 +430,20 @@ int ResourceManager::readAudioMapSCI11(IntMapResourceSource *map) { } } + const ResourceId id = ResourceId(kResourceTypeAudio36, map->_mapNumber, n & 0xffffff3f); + + // At least version 1.00 of GK2 has multiple invalid audio36 map + // entries on CD 6 + if (g_sci->getGameId() == GID_GK2 && + map->_volumeNumber == 6 && + offset + syncSize >= srcSize) { + + debugC(kDebugLevelResMan, "Invalid offset %u for %s in map %d for disc %d", offset + syncSize, id.toPatchNameBase36().c_str(), map->_mapNumber, map->_volumeNumber); + continue; + } + assert(offset + syncSize < srcSize); - addResource(ResourceId(kResourceTypeAudio36, map->_mapNumber, n & 0xffffff3f), src, offset + syncSize); + addResource(id, src, offset + syncSize); } } -- cgit v1.2.3