aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/engine/kfile.cpp10
-rw-r--r--engines/sci/sci.cpp31
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() {