diff options
author | Martin Kiewitz | 2010-07-31 22:45:38 +0000 |
---|---|---|
committer | Martin Kiewitz | 2010-07-31 22:45:38 +0000 |
commit | d5e4efa0258ff27b48dd4ce5bb12bc05787098cb (patch) | |
tree | 92e69ea37f3e76a395d4e0e4075fb1f02e4af758 /engines | |
parent | 4b9df2203f065293ac4067f76fd58afe87d4e3c8 (diff) | |
download | scummvm-rg350-d5e4efa0258ff27b48dd4ce5bb12bc05787098cb.tar.gz scummvm-rg350-d5e4efa0258ff27b48dd4ce5bb12bc05787098cb.tar.bz2 scummvm-rg350-d5e4efa0258ff27b48dd4ce5bb12bc05787098cb.zip |
SCI: fix lofs autodetection
makes polish lsl1 work (its game superclass name got translated, so no "Game" object available) - bug #3037194 thx to dam-soft for his patient help
svn-id: r51557
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/features.cpp | 35 | ||||
-rw-r--r-- | engines/sci/engine/features.h | 2 |
2 files changed, 26 insertions, 11 deletions
diff --git a/engines/sci/engine/features.cpp b/engines/sci/engine/features.cpp index 315c86c56c..ad6d4d728d 100644 --- a/engines/sci/engine/features.cpp +++ b/engines/sci/engine/features.cpp @@ -216,9 +216,9 @@ SciVersion GameFeatures::detectSetCursorType() { return _setCursorType; } -bool GameFeatures::autoDetectLofsType(int methodNum) { +bool GameFeatures::autoDetectLofsType(Common::String gameSuperClassName, int methodNum) { // Look up the script address - reg_t addr = getDetectionAddr("Game", -1, methodNum); + reg_t addr = getDetectionAddr(gameSuperClassName.c_str(), -1, methodNum); if (!addr.segment) return false; @@ -275,20 +275,35 @@ SciVersion GameFeatures::detectLofsType() { return _lofsType; } + // Find the "Game" object, super class of the actual game-object + const reg_t game = g_sci->getGameObject(); + const Object *gameObject = _segMan->getObject(game); + reg_t gameSuperClass = NULL_REG; + if (gameObject) { + gameSuperClass = gameObject->getSuperClassSelector(); + } + // Find a function of the game object which invokes lofsa/lofss - reg_t gameClass = _segMan->findObjectByName("Game"); - const Object *obj = _segMan->getObject(gameClass); bool found = false; + if (!gameSuperClass.isNull()) { + Common::String gameSuperClassName = _segMan->getObjectName(gameSuperClass); + const Object *gameSuperObject = _segMan->getObject(gameSuperClass); - for (uint m = 0; m < obj->getMethodCount(); m++) { - found = autoDetectLofsType(m); - - if (found) - break; + if (gameSuperObject) { + for (uint m = 0; m < gameSuperObject->getMethodCount(); m++) { + found = autoDetectLofsType(gameSuperClassName, m); + if (found) + break; + } + } else { + warning("detectLofsType(): Could not get superclass object"); + } + } else { + warning("detectLofsType(): Could not find superclass of game object"); } if (!found) { - warning("Lofs detection failed, taking an educated guess"); + warning("detectLofsType(): failed, taking an educated guess"); if (getSciVersion() >= SCI_VERSION_1_MIDDLE) _lofsType = SCI_VERSION_1_MIDDLE; diff --git a/engines/sci/engine/features.h b/engines/sci/engine/features.h index 167c207437..755054fb25 100644 --- a/engines/sci/engine/features.h +++ b/engines/sci/engine/features.h @@ -103,7 +103,7 @@ public: private: reg_t getDetectionAddr(const Common::String &objName, Selector slc, int methodNum = -1); - bool autoDetectLofsType(int methodNum); + bool autoDetectLofsType(Common::String gameSuperClassName, int methodNum); bool autoDetectGfxFunctionsType(int methodNum = -1); bool autoDetectSoundType(); bool autoDetectMoveCountType(); |