diff options
author | Martin Kiewitz | 2013-11-21 22:41:07 +0100 |
---|---|---|
committer | Martin Kiewitz | 2013-11-21 22:41:07 +0100 |
commit | ba3656d84e61ae5f99a9449e81c5d3ff2ffa2565 (patch) | |
tree | a7200e3b5a2c920e37ecc5928567dc712e61c94e /engines/sci/engine | |
parent | ffe242662891f1b29be39e478055534ad37a0fbe (diff) | |
download | scummvm-rg350-ba3656d84e61ae5f99a9449e81c5d3ff2ffa2565.tar.gz scummvm-rg350-ba3656d84e61ae5f99a9449e81c5d3ff2ffa2565.tar.bz2 scummvm-rg350-ba3656d84e61ae5f99a9449e81c5d3ff2ffa2565.zip |
SCI: fix script patcher for games w/o vocab
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/kernel.cpp | 12 | ||||
-rw-r--r-- | engines/sci/engine/kernel.h | 4 | ||||
-rw-r--r-- | engines/sci/engine/script_patches.cpp | 4 |
3 files changed, 18 insertions, 2 deletions
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 8d55790ad2..12746e17d6 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -35,8 +35,6 @@ namespace Sci { Kernel::Kernel(ResourceManager *resMan, SegManager *segMan) : _resMan(resMan), _segMan(segMan), _invalid("<invalid>") { - loadSelectorNames(); - mapSelectors(); // Map a few special selectors for later use } Kernel::~Kernel() { @@ -53,6 +51,11 @@ Kernel::~Kernel() { } } +void Kernel::init() { + loadSelectorNames(); + mapSelectors(); // Map a few special selectors for later use +} + uint Kernel::getSelectorNamesSize() const { return _selectorNames.size(); } @@ -104,6 +107,11 @@ int Kernel::findSelector(const char *selectorName) const { return -1; } +// used by Script patcher to figure out, if it's okay to initialize signature/patch-table +bool Kernel::selectorNamesAvailable() { + return !_selectorNames.empty(); +} + void Kernel::loadSelectorNames() { Resource *r = _resMan->findResource(ResourceId(kResourceTypeVocab, VOCAB_RESOURCE_SELECTORS), 0); bool oldScriptHeader = (getSciVersion() == SCI_VERSION_0_EARLY); diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index 8a021073fc..69c3a6d0c9 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -145,6 +145,8 @@ public: */ Kernel(ResourceManager *resMan, SegManager *segMan); ~Kernel(); + + void init(); uint getSelectorNamesSize() const; const Common::String &getSelectorName(uint selector); @@ -159,6 +161,8 @@ public: * @return The appropriate selector ID, or -1 on error */ int findSelector(const char *selectorName) const; + + bool selectorNamesAvailable(); // Script dissection/dumping functions void dissectScript(int scriptNumber, Vocabulary *vocab); diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp index 0043f21c2c..3b4bb12608 100644 --- a/engines/sci/engine/script_patches.cpp +++ b/engines/sci/engine/script_patches.cpp @@ -2390,6 +2390,10 @@ void Script::patcherProcessScript(uint16 scriptNr, byte *scriptData, const uint3 bool isMacSci11 = (g_sci->getPlatform() == Common::kPlatformMacintosh && getSciVersion() >= SCI_VERSION_1_1); if (!signatureTable->magicDWord) { + // Abort, in case selectors are not yet initialized (happens for games w/o selector-dictionary) + if (!g_sci->getKernel()->selectorNamesAvailable()) + return; + // signature table needs to get initialized (Magic DWORD set, selector table set) patcherInitSignature(signatureTable, isMacSci11); |