[Scummvm-cvs-logs] SF.net SVN: scummvm:[49125] scummvm/trunk/engines/sci/detection.cpp
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Fri May 21 09:30:37 CEST 2010
Revision: 49125
http://scummvm.svn.sourceforge.net/scummvm/?rev=49125&view=rev
Author: thebluegr
Date: 2010-05-21 07:30:37 +0000 (Fri, 21 May 2010)
Log Message:
-----------
Some further work on the fallback detector, reducing the reliance on the segment manager
Modified Paths:
--------------
scummvm/trunk/engines/sci/detection.cpp
Modified: scummvm/trunk/engines/sci/detection.cpp
===================================================================
--- scummvm/trunk/engines/sci/detection.cpp 2010-05-21 07:22:52 UTC (rev 49124)
+++ scummvm/trunk/engines/sci/detection.cpp 2010-05-21 07:30:37 UTC (rev 49125)
@@ -210,42 +210,59 @@
// Finds the internal ID of the current game from script 0
Common::String getSierraGameId(ResourceManager *resMan) {
Resource *script = resMan->findResource(ResourceId(kResourceTypeScript, 0), false);
- Script *script000 = new Script();
- script000->init(0, resMan);
- script000->mcpyInOut(0, script->data, script->size);
uint16 curOffset = (getSciVersion() == SCI_VERSION_0_EARLY) ? 2 : 0;
uint16 objLength = 0;
int objType = 0;
int16 exportsOffset = 0;
+ int16 magicOffset = (getSciVersion() < SCI_VERSION_1_1) ? 8 : 0;
Common::String sierraId;
+ // TODO: SCI1.1 version
+ if (getSciVersion() >= SCI_VERSION_1_1) {
+ //if (READ_UINT16(script->data + 6) > 0)
+ // exportsOffset = READ_UINT16(script->data + 6 + 2);
+ return "sci";
+ }
+
// Now find the export table of the script
do {
- objType = READ_UINT16(script000->_buf + curOffset);
+ objType = READ_UINT16(script->data + curOffset);
if (!objType)
break;
- objLength = READ_UINT16(script000->_buf + curOffset + 2);
+ objLength = READ_UINT16(script->data + curOffset + 2);
curOffset += 4; // skip header
- if (objType == SCI_OBJ_EXPORTS) {
- exportsOffset = READ_UINT16(script000->_buf + curOffset + 2);
+ switch (objType) {
+ case SCI_OBJ_EXPORTS:
+ exportsOffset = READ_UINT16(script->data + curOffset + 2);
break;
+ case SCI_OBJ_OBJECT:
+ case SCI_OBJ_CLASS:
+ // The game object is the first export. Script 0 is always at segment 1
+ if (curOffset == exportsOffset - magicOffset) {
+ reg_t nameSelector = make_reg(1, READ_UINT16(script->data + curOffset + magicOffset + 3 * 2));
+
+ // TODO: stop using the segment manager and read the object name here
+ SegManager *segMan = new SegManager(resMan);
+ script_instantiate(resMan, segMan, 0);
+ sierraId = segMan->derefString(nameSelector);
+ delete segMan;
+
+ break;
+ }
+ break;
+ case SCI_OBJ_CODE:
+ case SCI_OBJ_SYNONYMS:
+ case SCI_OBJ_LOCALVARS:
+ case SCI_OBJ_POINTERS: // A relocation table
+ // Ignore
+ break;
}
+
curOffset += objLength - 4;
} while (objType != 0 && curOffset < script->size - 2);
- // The game object is the first export. Script 0 is always at segment 1
- reg_t gameObj = make_reg(1, exportsOffset);
-
- // TODO: stop using the segment manager and read the object name here
- SegManager *segMan = new SegManager(resMan);
- script_instantiate(resMan, segMan, 0);
- sierraId = segMan->getObjectName(gameObj);
- delete segMan;
-
- delete script000;
-
return sierraId;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list