From fdb87619c61c579cc2bb3162ae77b06e13d9cf91 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Tue, 23 May 2017 22:36:16 -0500 Subject: SCI32: Fix selector search for SCI2/2.1 games with missing vocab.997 Fixes Trac#9796. --- engines/sci/engine/static_selectors.cpp | 44 ++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/engines/sci/engine/static_selectors.cpp b/engines/sci/engine/static_selectors.cpp index 8aa1697f07..08c6f5d75a 100644 --- a/engines/sci/engine/static_selectors.cpp +++ b/engines/sci/engine/static_selectors.cpp @@ -151,6 +151,13 @@ static const ClassReference classReferences[] = { { 999, "Script", "init", kSelectorMethod, 0 }, { 999, "Script", "dispose", kSelectorMethod, 2 }, { 999, "Script", "changeState", kSelectorMethod, 3 } +#ifdef ENABLE_SCI32 + , + { 64929, "Sync", "syncTime", kSelectorVariable, 2 }, + { 64929, "Sync", "syncCue", kSelectorVariable, 3 }, + { 64999, "Obj", "init", kSelectorMethod, 1 }, + { 64999, "Obj", "doit", kSelectorMethod, 2 } +#endif }; Common::StringArray Kernel::checkStaticSelectorNames() { @@ -222,27 +229,35 @@ void Kernel::findSpecificSelectors(Common::StringArray &selectorNames) { // We need to initialize script 0 here, to make sure that it's always // located at segment 1. _segMan->instantiateScript(0); - uint16 sci2Offset = (getSciVersion() >= SCI_VERSION_2) ? 64000 : 0; // The Actor class contains the init, xLast and yLast selectors, which // we reference directly. It's always in script 998, so we need to // explicitly load it here. - if ((getSciVersion() >= SCI_VERSION_1_EGA_ONLY)) { + if (getSciVersion() >= SCI_VERSION_1_EGA_ONLY) { uint16 actorScript = 998; +#ifdef ENABLE_SCI32 + if (getSciVersion() >= SCI_VERSION_2) { + actorScript += 64000; + } +#endif - if (_resMan->testResource(ResourceId(kResourceTypeScript, actorScript + sci2Offset))) { - _segMan->instantiateScript(actorScript + sci2Offset); + if (_resMan->testResource(ResourceId(kResourceTypeScript, actorScript))) { + _segMan->instantiateScript(actorScript); const Object *actorClass = _segMan->getObject(_segMan->findObjectByName("Actor")); if (actorClass) { // Find the xLast and yLast selectors, used in kDoBresen - const int offset = (getSciVersion() < SCI_VERSION_1_1) ? 3 : 0; - const int offset2 = (getSciVersion() >= SCI_VERSION_2) ? 12 : 0; + int offset = (getSciVersion() < SCI_VERSION_1_1) ? 3 : 0; +#ifdef ENABLE_SCI32 + if (getSciVersion() >= SCI_VERSION_2) { + offset += 12; + } +#endif // xLast and yLast always come between illegalBits and xStep - int illegalBitsSelectorPos = actorClass->locateVarSelector(_segMan, 15 + offset + offset2); // illegalBits - int xStepSelectorPos = actorClass->locateVarSelector(_segMan, 51 + offset + offset2); // xStep + int illegalBitsSelectorPos = actorClass->locateVarSelector(_segMan, 15 + offset); // illegalBits + int xStepSelectorPos = actorClass->locateVarSelector(_segMan, 51 + offset); // xStep if (xStepSelectorPos - illegalBitsSelectorPos != 3) { error("illegalBits and xStep selectors aren't found in " "known locations. illegalBits = %d, xStep = %d", @@ -257,19 +272,19 @@ void Kernel::findSpecificSelectors(Common::StringArray &selectorNames) { selectorNames[xLastSelectorPos] = "xLast"; selectorNames[yLastSelectorPos] = "yLast"; - } // if (actorClass) + } - _segMan->uninstantiateScript(998); - } // if (_resMan->testResource(ResourceId(kResourceTypeScript, 998))) - } // if ((getSciVersion() >= SCI_VERSION_1_EGA_ONLY)) + _segMan->uninstantiateScript(actorScript); + } + } // Find selectors from specific classes for (int i = 0; i < ARRAYSIZE(classReferences); i++) { - if (!_resMan->testResource(ResourceId(kResourceTypeScript, classReferences[i].script + sci2Offset))) + if (!_resMan->testResource(ResourceId(kResourceTypeScript, classReferences[i].script))) continue; - _segMan->instantiateScript(classReferences[i].script + sci2Offset); + _segMan->instantiateScript(classReferences[i].script); const Object *targetClass = _segMan->getObject(_segMan->findObjectByName(classReferences[i].className)); int targetSelectorPos = 0; @@ -303,7 +318,6 @@ void Kernel::findSpecificSelectors(Common::StringArray &selectorNames) { } } - // Reset the segment manager _segMan->resetSegMan(); } -- cgit v1.2.3