diff options
author | Simei Yin | 2018-05-29 22:34:22 +0200 |
---|---|---|
committer | Simei Yin | 2018-05-29 22:37:10 +0200 |
commit | 87e58a9b7e26986c8d396d836a97ad01a5f74c52 (patch) | |
tree | 5302c65b34fa93ccc1c78ebcd01abe6808057802 /engines | |
parent | dc320b86bc0da7026bfd650be6a8450684b54fa9 (diff) | |
download | scummvm-rg350-87e58a9b7e26986c8d396d836a97ad01a5f74c52.tar.gz scummvm-rg350-87e58a9b7e26986c8d396d836a97ad01a5f74c52.tar.bz2 scummvm-rg350-87e58a9b7e26986c8d396d836a97ad01a5f74c52.zip |
SLUDGE: Split runSludge() to runAllFunctions() and handleSaveLoad()
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sludge/function.cpp | 13 | ||||
-rw-r--r-- | engines/sludge/function.h | 3 | ||||
-rw-r--r-- | engines/sludge/loadsave.cpp | 15 | ||||
-rw-r--r-- | engines/sludge/loadsave.h | 2 | ||||
-rw-r--r-- | engines/sludge/main_loop.cpp | 4 |
5 files changed, 22 insertions, 15 deletions
diff --git a/engines/sludge/function.cpp b/engines/sludge/function.cpp index 98f7bf79b1..6905c384bc 100644 --- a/engines/sludge/function.cpp +++ b/engines/sludge/function.cpp @@ -702,7 +702,7 @@ int startNewFunctionNum(uint funcNum, uint numParamsExpected, return 1; } -bool runSludge() { +bool runAllFunctions() { LoadedFunction *thisFunction = allRunningFunctions; LoadedFunction *nextFunction; @@ -732,17 +732,6 @@ bool runSludge() { thisFunction = nextFunction; } - if (!g_sludge->loadNow.empty()) { - if (g_sludge->loadNow[0] == ':') { - saveGame(g_sludge->loadNow.c_str() + 1); - setVariable(saverFunc->reg, SVT_INT, 1); - } else { - if (!loadGame(g_sludge->loadNow)) - return false; - } - g_sludge->loadNow.clear(); - } - return true; } diff --git a/engines/sludge/function.h b/engines/sludge/function.h index ead2adfa0a..6980d6b10c 100644 --- a/engines/sludge/function.h +++ b/engines/sludge/function.h @@ -50,8 +50,7 @@ struct LoadedFunction { byte freezerLevel; }; -bool runSludge(); - +bool runAllFunctions(); int startNewFunctionNum(uint, uint, LoadedFunction *, VariableStack*&, bool = true); void restartFunction(LoadedFunction *fun); bool loadFunctionCode(LoadedFunction *newFunc); diff --git a/engines/sludge/loadsave.cpp b/engines/sludge/loadsave.cpp index 2d29645acd..923c1713e6 100644 --- a/engines/sludge/loadsave.cpp +++ b/engines/sludge/loadsave.cpp @@ -56,6 +56,7 @@ namespace Sludge { // From elsewhere //---------------------------------------------------------------------- +extern LoadedFunction *saverFunc; // In function.cpp extern LoadedFunction *allRunningFunctions; // In sludger.cpp extern const char *typeName[]; // In variable.cpp extern int numGlobals; // In sludger.cpp @@ -336,6 +337,20 @@ LoadedFunction *loadFunction(Common::SeekableReadStream *stream) { // Save everything //---------------------------------------------------------------------- +bool handleSaveLoad() { + if (!g_sludge->loadNow.empty()) { + if (g_sludge->loadNow[0] == ':') { + saveGame(g_sludge->loadNow.c_str() + 1); + setVariable(saverFunc->reg, SVT_INT, 1); + } else { + if (!loadGame(g_sludge->loadNow)) + return false; + } + g_sludge->loadNow.clear(); + } + return true; +} + bool saveGame(const Common::String &fname) { Common::OutSaveFile *fp = g_system->getSavefileManager()->openForSaving(fname); diff --git a/engines/sludge/loadsave.h b/engines/sludge/loadsave.h index 269fadb507..54e0577796 100644 --- a/engines/sludge/loadsave.h +++ b/engines/sludge/loadsave.h @@ -28,6 +28,8 @@ struct LoadedFunction; struct Variable; struct VariableStack; +bool handleSaveLoad(); + bool saveGame(const Common::String &fname); bool loadGame(const Common::String &fname); diff --git a/engines/sludge/main_loop.cpp b/engines/sludge/main_loop.cpp index ee0bae1d1d..8f6e1f9cfb 100644 --- a/engines/sludge/main_loop.cpp +++ b/engines/sludge/main_loop.cpp @@ -31,6 +31,7 @@ #include "sludge/function.h" #include "sludge/graphics.h" #include "sludge/language.h" +#include "sludge/loadsave.h" #include "sludge/newfatal.h" #include "sludge/objtypes.h" #include "sludge/people.h" @@ -63,7 +64,8 @@ int main_loop(Common::String filename) { g_sludge->_evtMan->checkInput(); g_sludge->_peopleMan->walkAllPeople(); if (g_sludge->_evtMan->handleInput()) { - runSludge(); + runAllFunctions(); + handleSaveLoad(); } sludgeDisplay(); g_sludge->_soundMan->handleSoundLists(); |