aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/resource.cpp
diff options
context:
space:
mode:
authorTravis Howell2009-07-10 00:07:26 +0000
committerTravis Howell2009-07-10 00:07:26 +0000
commit4e99bee142899dae1385210012dd34453920fe54 (patch)
tree1ff2f4e640b6aa7cbe8e35b887e55c6c3e063de8 /engines/sci/resource.cpp
parentff208c5387a8566546a384afa9ab48c0a1f356a0 (diff)
parente8e9b882275b8dc5d77db3b1faaf30466c7b7a31 (diff)
downloadscummvm-rg350-4e99bee142899dae1385210012dd34453920fe54.tar.gz
scummvm-rg350-4e99bee142899dae1385210012dd34453920fe54.tar.bz2
scummvm-rg350-4e99bee142899dae1385210012dd34453920fe54.zip
Merged revisions 42277-42278,42286-42290,42292-42293,42297,42300-42301,42303,42305-42306 via svnmerge from
https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk ........ r42277 | drmccoy | 2009-07-09 12:54:10 +1000 (Thu, 09 Jul 2009) | 1 line Giving Font its own real class ........ r42278 | dreammaster | 2009-07-09 13:07:30 +1000 (Thu, 09 Jul 2009) | 1 line Changed the status of the cruise engine to be enabled by default ........ r42286 | drmccoy | 2009-07-09 19:39:51 +1000 (Thu, 09 Jul 2009) | 1 line Warn instead of crash when a video frame part was found although the header says there's no video ........ r42287 | thebluegr | 2009-07-09 23:17:46 +1000 (Thu, 09 Jul 2009) | 1 line Renamed sound/iff.* to sound/iff_sound.* to fix an issue with the upcoming changes to the MSVC project files (sound/iff.* produces iff.obj, which clashes with iff.obj from graphics/iff.*) ........ r42288 | thebluegr | 2009-07-10 01:12:35 +1000 (Fri, 10 Jul 2009) | 3 lines - Rewrote and greatly simplified the MSVC8 and MSVC9 project files so that they use common compilation properties, based on patch #2774908. These common properties make it much simpler to change options and compilation defines globally, similar to how GCC *.mk files do. Also, this fixes problems where an ENABLE_* define was set for one project file but not another (like the situation in revisions 42257 and 42259). It's now much easier to construct a tool which will create the project files dynamically. - Dropped support for MSVC7 and MSVC7.1 for now (as they don't support common compilation properties and it's no longer easy to construct them from the MSVC8 ones) - hopefully, they will return in the future, once we got a more sophisticated tool to create them - Simplified the MSVC9 <-> MSVC8 conversion tools a bit ........ r42289 | thebluegr | 2009-07-10 01:15:49 +1000 (Fri, 10 Jul 2009) | 1 line Reverted commit #42257, as the original issue was with the compilation process of MSVC and the ENABLE_* checks work correctly ........ r42290 | thebluegr | 2009-07-10 01:17:45 +1000 (Fri, 10 Jul 2009) | 1 line Added proper safeguards for shorten.*, thereby fixing commit 42259 ........ r42292 | lordhoto | 2009-07-10 01:32:06 +1000 (Fri, 10 Jul 2009) | 1 line Cleanup. ........ r42293 | lordhoto | 2009-07-10 01:32:25 +1000 (Fri, 10 Jul 2009) | 1 line Cleanup rollDice (the results of the old and the new function are almost identical). ........ r42297 | thebluegr | 2009-07-10 01:46:26 +1000 (Fri, 10 Jul 2009) | 1 line restAdjust should be a signed integer. Fixes crashes with SCI1 games that take absolute lofs parameters (a regression of commit #42260) ........ r42300 | thebluegr | 2009-07-10 01:54:18 +1000 (Fri, 10 Jul 2009) | 1 line Applied patch #2818845 - "SCI: resource.map detection for SCI1/1.1 fixed", with some slight formatting changes ........ r42301 | lordhoto | 2009-07-10 01:59:20 +1000 (Fri, 10 Jul 2009) | 1 line Fix wrong format arugment. ........ r42303 | lordhoto | 2009-07-10 02:16:08 +1000 (Fri, 10 Jul 2009) | 1 line By comparing the commit log of r42300, it seems that "off" was renamed to "lastDirectoryOffset". I changed the SCI32 specific code to use that now. I can't assure this is anyhow correct, so anyone with knowledge of this code please check it. ........ r42305 | lordhoto | 2009-07-10 02:23:22 +1000 (Fri, 10 Jul 2009) | 1 line Add fixme about SCI32 specific code. ........ r42306 | lordhoto | 2009-07-10 02:24:59 +1000 (Fri, 10 Jul 2009) | 1 line Oops specify the correct revsision number in the fixme. ........ svn-id: r42318
Diffstat (limited to 'engines/sci/resource.cpp')
-rw-r--r--engines/sci/resource.cpp62
1 files changed, 42 insertions, 20 deletions
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index 30e917557d..5fdc286894 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -728,32 +728,51 @@ int ResourceManager::detectMapVersion() {
}
return SCI_VERSION_0;
}
- // SCI1E/L and some SCI1.1 maps have last directory entry set to 0xFF
- // and offset set to filesize
- // SCI1 have 6-bytes entries, while SCI1.1 have 5-byte entries
- file.seek(1, SEEK_SET);
- uint16 off1, off = file.readUint16LE();
- uint16 nEntries = off / 3;
- file.seek(1, SEEK_CUR);
- file.seek(off - 3, SEEK_SET);
- if (file.readByte() == 0xFF && file.readUint16LE() == file.size()) {
- file.seek(3, SEEK_SET);
- for (int i = 0; i < nEntries; i++) {
- file.seek(1, SEEK_CUR);
- off1 = file.readUint16LE();
- if ((off1 - off) % 5 && (off1 - off) % 6 == 0)
- return SCI_VERSION_1;
- if ((off1 - off) % 5 == 0 && (off1 - off) % 6)
- return SCI_VERSION_1_1;
- off = off1;
+
+ // SCI1 and SCI1.1 maps consist of a fixed 3-byte header, a directory list (3-bytes each) that has one entry
+ // of id FFh and points to EOF. The actual entries have 6-bytes on SCI1 and 5-bytes on SCI1.1
+ byte directoryType = 0;
+ uint16 directoryOffset = 0;
+ uint16 lastDirectoryOffset = 0;
+ uint16 directorySize = 0;
+ int mapDetected = 0;
+ file.seek(0, SEEK_SET);
+ while (!file.eos()) {
+ directoryType = file.readByte();
+ directoryOffset = file.readUint16LE();
+ if ((directoryType < 0x80) || ((directoryType > 0xA0) && (directoryType != 0xFF)))
+ break;
+ // Offset is above file size? -> definitely not SCI1/SCI1.1
+ if (directoryOffset > file.size())
+ break;
+ if (lastDirectoryOffset) {
+ directorySize = directoryOffset - lastDirectoryOffset;
+ if ((directorySize % 5) && (directorySize % 6 == 0))
+ mapDetected = SCI_VERSION_1;
+ if ((directorySize % 5 == 0) && (directorySize % 6))
+ mapDetected = SCI_VERSION_1_1;
}
- return SCI_VERSION_1;
+ if (directoryType==0xFF) {
+ // FFh entry needs to point to EOF
+ if (directoryOffset != file.size())
+ break;
+ if (mapDetected)
+ return mapDetected;
+ return SCI_VERSION_1;
+ }
+ lastDirectoryOffset = directoryOffset;
}
#ifdef ENABLE_SCI32
// late SCI1.1 and SCI32 maps have last directory entry set to 0xFF
// offset set to filesize and 4 more bytes
- file.seek(off - 7, SEEK_SET);
+
+ // TODO/FIXME: This code was not updated in r42300, which changed the behavior of this
+ // function a lot. To make it compile again "off" was changed to the newly introduced
+ // "lastDirectoryOffset". This is probably not the correct fix, since before r43000
+ // the loop above could not prematurely terminate and thus this would always check the
+ // last directory entry instead of the last checked directory entry.
+ file.seek(lastDirectoryOffset - 7, SEEK_SET);
if (file.readByte() == 0xFF && file.readUint16LE() == file.size())
return SCI_VERSION_32; // TODO : check if there is a difference between these maps
#endif
@@ -974,6 +993,9 @@ int ResourceManager::readResourceMapSCI0(ResourceSource *map) {
res->file_offset = offset & (((~bMask) << 24) | 0xFFFFFF);
res->id = resId;
res->source = getVolume(map, offset >> bShift);
+ if (!res->source) {
+ warning("Could not get volume for resource %d, VolumeID %d\n", id, offset >> bShift);
+ }
_resMap.setVal(resId, res);
}
} while (!file.eos());