diff options
author | Martin Kiewitz | 2010-08-24 15:11:53 +0000 |
---|---|---|
committer | Martin Kiewitz | 2010-08-24 15:11:53 +0000 |
commit | 01a8fc604b00279be181c0ce8decfc8e44242270 (patch) | |
tree | 333eeeeed01acc34313c60e9b2c0a1f9706d3df6 /engines | |
parent | cd61674010a1e539d0ff5eac69a0bd44c43dff09 (diff) | |
download | scummvm-rg350-01a8fc604b00279be181c0ce8decfc8e44242270.tar.gz scummvm-rg350-01a8fc604b00279be181c0ce8decfc8e44242270.tar.bz2 scummvm-rg350-01a8fc604b00279be181c0ce8decfc8e44242270.zip |
SCI: replacing save dialog as well
experimental feature - enable by putting "scireplacedialog=true" inside scummvm section of scummvm.ini
LSL6 currently loses the ability to quicksave, when using the feature. Although i don't see it as a huge loss. That way it's now possible to save to up to 100 slots instead of just 20.
svn-id: r52345
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/kfile.cpp | 10 | ||||
-rw-r--r-- | engines/sci/sci.cpp | 31 |
2 files changed, 27 insertions, 14 deletions
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp index bb08a0edd4..faef7781f6 100644 --- a/engines/sci/engine/kfile.cpp +++ b/engines/sci/engine/kfile.cpp @@ -556,7 +556,6 @@ reg_t kSaveGame(EngineState *s, int argc, reg_t *argv) { int16 savegameId = -1; Common::String game_description; Common::String version; - bool pausedMusic = false; if (argc > 3) version = s->_segMan->getString(argv[3]); @@ -581,11 +580,9 @@ reg_t kSaveGame(EngineState *s, int argc, reg_t *argv) { savegameId = dialog->runModal(plugin, ConfMan.getActiveDomainName()); game_description = dialog->getResultString(); delete dialog; - if (savegameId < 0) { - g_sci->_soundCmd->pauseAll(false); // unpause music + g_sci->_soundCmd->pauseAll(false); // unpause music ( we can't have it paused during save) + if (savegameId < 0) return NULL_REG; - } - pausedMusic = true; } else { // Real call from script @@ -653,9 +650,6 @@ reg_t kSaveGame(EngineState *s, int argc, reg_t *argv) { } } - if (pausedMusic) - g_sci->_soundCmd->pauseAll(false); // unpause music - return s->r_acc; } diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index 1f4f3bd383..17872a5737 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -340,6 +340,8 @@ static byte patchGameRestoreSave[] = { }; void SciEngine::patchGameSaveRestore(SegManager *segMan) { + const Object *gameObject = segMan->getObject(_gameObjectAddress); + const uint16 gameMethodCount = gameObject->getMethodCount(); const Object *gameSuperObject = segMan->getObject(_gameSuperClassAddress); const uint16 gameSuperMethodCount = gameSuperObject->getMethodCount(); reg_t methodAddress; @@ -372,6 +374,7 @@ void SciEngine::patchGameSaveRestore(SegManager *segMan) { kernelIdSave = kernelNr; } + // Search for gameobject-superclass ::restore for (uint16 methodNr = 0; methodNr < gameSuperMethodCount; methodNr++) { uint16 selectorId = gameSuperObject->getFuncSelector(methodNr); Common::String methodName = _kernel->getSelectorName(selectorId); @@ -379,6 +382,22 @@ void SciEngine::patchGameSaveRestore(SegManager *segMan) { methodAddress = gameSuperObject->getFunction(methodNr); Script *script = segMan->getScript(methodAddress.segment); scriptRestorePtr = script->getBuf(methodAddress.offset); + } + if (methodName == "save") { + methodAddress = gameSuperObject->getFunction(methodNr); + Script *script = segMan->getScript(methodAddress.segment); + scriptSavePtr = script->getBuf(methodAddress.offset); + } + } + + // Search for gameobject ::save, if there is one patch that one instead + for (uint16 methodNr = 0; methodNr < gameMethodCount; methodNr++) { + uint16 selectorId = gameObject->getFuncSelector(methodNr); + Common::String methodName = _kernel->getSelectorName(selectorId); + if (methodName == "save") { + methodAddress = gameObject->getFunction(methodNr); + Script *script = segMan->getScript(methodAddress.segment); + scriptSavePtr = script->getBuf(methodAddress.offset); break; } } @@ -396,12 +415,12 @@ void SciEngine::patchGameSaveRestore(SegManager *segMan) { memcpy(patchPtr, patchGameRestoreSave, sizeof(patchGameRestoreSave)); patchPtr[8] = kernelIdRestore; } - //if (scriptSavePtr) { - // // Now patch in our code - // byte *patchPtr = const_cast<byte *>(scriptSavePtr); - // memcpy(patchPtr, patchGameRestoreSave, sizeof(patchGameRestoreSave)); - // patchPtr[8] = kernelIdSave; - //} + if (scriptSavePtr) { + // Now patch in our code + byte *patchPtr = const_cast<byte *>(scriptSavePtr); + memcpy(patchPtr, patchGameRestoreSave, sizeof(patchGameRestoreSave)); + patchPtr[8] = kernelIdSave; + } } bool SciEngine::initGame() { |