aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/resource.cpp
diff options
context:
space:
mode:
authorMartin Kiewitz2010-08-21 13:36:09 +0000
committerMartin Kiewitz2010-08-21 13:36:09 +0000
commit864b067f6693867844feec6b56fa5fc8dd124a33 (patch)
tree79f5d36cdbe6d12f9e135bad99f4ba6c782a058b /engines/sci/resource.cpp
parent3faae2a83126a4bb731a49d731f1f6da407549ab (diff)
downloadscummvm-rg350-864b067f6693867844feec6b56fa5fc8dd124a33.tar.gz
scummvm-rg350-864b067f6693867844feec6b56fa5fc8dd124a33.tar.bz2
scummvm-rg350-864b067f6693867844feec6b56fa5fc8dd124a33.zip
SCI: fixing resourcemgr for pharkas/german
pharkas/german has duplicate resource entries inside the main resource files and we used the first ones. This results in half of the game being english and umlauts missing. We now use the last entries, which will fix all those issues (fixes bug #3039551) svn-id: r52259
Diffstat (limited to 'engines/sci/resource.cpp')
-rw-r--r--engines/sci/resource.cpp53
1 files changed, 33 insertions, 20 deletions
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index 72db9102e2..827133b7ac 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -1518,7 +1518,7 @@ int ResourceManager::readResourceMapSCI1(ResourceSource *map) {
} while (type != 0x1F); // the last entry is FF
// reading each type's offsets
- uint32 off = 0;
+ uint32 fileOffset = 0;
for (type = 0; type < 32; type++) {
if (resMap[type].wOffset == 0) // this resource does not exist in map
continue;
@@ -1528,15 +1528,15 @@ int ResourceManager::readResourceMapSCI1(ResourceSource *map) {
int volume_nr = 0;
if (_mapVersion == kResVersionSci11) {
// offset stored in 3 bytes
- off = fileStream->readUint16LE();
- off |= fileStream->readByte() << 16;
- off <<= 1;
+ fileOffset = fileStream->readUint16LE();
+ fileOffset |= fileStream->readByte() << 16;
+ fileOffset <<= 1;
} else {
// offset/volume stored in 4 bytes
- off = fileStream->readUint32LE();
+ fileOffset = fileStream->readUint32LE();
if (_mapVersion < kResVersionSci11) {
- volume_nr = off >> 28; // most significant 4 bits
- off &= 0x0FFFFFFF; // least significant 28 bits
+ volume_nr = fileOffset >> 28; // most significant 4 bits
+ fileOffset &= 0x0FFFFFFF; // least significant 28 bits
} else {
// in SCI32 it's a plain offset
}
@@ -1547,19 +1547,32 @@ int ResourceManager::readResourceMapSCI1(ResourceSource *map) {
return SCI_ERROR_RESMAP_NOT_FOUND;
}
resId = ResourceId(convertResType(type), number);
- // adding new resource only if it does not exist
- if (_resMap.contains(resId) == false) {
- // NOTE: We add the map's volume number here to the specified volume number
- // for SCI2.1 and SCI3 maps that are not resmap.000. The resmap.* files' numbers
- // need to be used in concurrence with the volume specified in the map to get
- // the actual resource file.
- int mapVolumeNr = volume_nr + map->_volumeNumber;
- ResourceSource *source = findVolume(map, mapVolumeNr);
- // FIXME: this code has serious issues with multiple RESMAP.* files (like in unmodified gk2)
- // adding a resource with source == NULL would crash later on
- if (!source)
- error("Unable to find volume for map %s volumeNr %d", map->getLocationName().c_str(), mapVolumeNr);
- addResource(resId, source, off);
+ if (type == 7)
+ warning("%d, %d", type, number);
+ // NOTE: We add the map's volume number here to the specified volume number
+ // for SCI2.1 and SCI3 maps that are not resmap.000. The resmap.* files' numbers
+ // need to be used in concurrence with the volume specified in the map to get
+ // the actual resource file.
+ int mapVolumeNr = volume_nr + map->_volumeNumber;
+ ResourceSource *source = findVolume(map, mapVolumeNr);
+ // FIXME: this code has serious issues with multiple RESMAP.* files (like in unmodified gk2)
+ // adding a resource with source == NULL would crash later on
+ if (!source)
+ error("Unable to find volume for map %s volumeNr %d", map->getLocationName().c_str(), mapVolumeNr);
+
+ Resource *resource = _resMap.getVal(resId, NULL);
+ if (!resource) {
+ addResource(resId, source, fileOffset);
+ } else {
+ // if resource is already present, change it to new content
+ // this is needed at least for pharkas/german. This version
+ // contains several duplicate resources INSIDE the resource
+ // data files like fonts, views, scripts, etc. And if we use
+ // the first entries, half of the game will be english and
+ // umlauts will also be missing :P
+ resource->_source = source;
+ resource->_fileOffset = fileOffset;
+ resource->size = 0;
}
}
}