diff options
author | Simei Yin | 2017-08-21 09:07:19 +0200 |
---|---|---|
committer | Simei Yin | 2017-08-21 10:19:19 +0200 |
commit | d9a6791500eef13d64d7b3d11136b9c901af7f2f (patch) | |
tree | 55c562230f8f82b81d2faf0a9c68a1b0d452db30 /engines/sludge | |
parent | 2edd59d0b8e48d354e085beacbe4f2c4a1e16489 (diff) | |
download | scummvm-rg350-d9a6791500eef13d64d7b3d11136b9c901af7f2f.tar.gz scummvm-rg350-d9a6791500eef13d64d7b3d11136b9c901af7f2f.tar.bz2 scummvm-rg350-d9a6791500eef13d64d7b3d11136b9c901af7f2f.zip |
SLUDGE: Add support for some windows-only games
Diffstat (limited to 'engines/sludge')
-rw-r--r-- | engines/sludge/builtin.cpp | 28 | ||||
-rw-r--r-- | engines/sludge/event.h | 1 | ||||
-rw-r--r-- | engines/sludge/imgloader.cpp | 2 | ||||
-rw-r--r-- | engines/sludge/main_loop.cpp | 13 | ||||
-rw-r--r-- | engines/sludge/main_loop.h | 2 | ||||
-rw-r--r-- | engines/sludge/region.cpp | 8 | ||||
-rw-r--r-- | engines/sludge/sludge.cpp | 5 | ||||
-rw-r--r-- | engines/sludge/sludge.h | 1 | ||||
-rw-r--r-- | engines/sludge/sludger.cpp | 11 | ||||
-rw-r--r-- | engines/sludge/sludger.h | 1 |
10 files changed, 58 insertions, 14 deletions
diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp index d63eb972b5..9b4c1b7622 100644 --- a/engines/sludge/builtin.cpp +++ b/engines/sludge/builtin.cpp @@ -20,6 +20,7 @@ * */ +#include "common/config-manager.h" #include "common/savefile.h" #include "sludge/allfiles.h" @@ -2412,11 +2413,29 @@ builtIn(_rem_launchWith) { UNUSEDALL trimStack(fun->stack); + + // To support some windows only games + Common::String filename = getTextFromAnyVar(fun->stack->thisVar); trimStack(fun->stack); - setVariable(fun->reg, SVT_INT, false); - return BR_CONTINUE; + if (filename.hasSuffix(".exe")) { + const Common::FSNode gameDataDir(ConfMan.get("path")); + Common::FSList files; + gameDataDir.getChildren(files, Common::FSNode::kListFilesOnly); + + for (Common::FSList::const_iterator file = files.begin(); file != files.end(); ++file) { + Common::String fileName = file->getName(); + fileName.toLowercase(); + if (fileName.hasSuffix(".dat") || fileName == "data") { + g_sludge->launchNext = file->getName(); + return BR_CONTINUE; + } + } + } + g_sludge->launchNext.clear(); + setVariable(fun->reg, SVT_INT, false); + return BR_CONTINUE; } builtIn(getFramesPerSecond) { @@ -2577,8 +2596,9 @@ BuiltReturn callBuiltIn(int whichFunc, int numParams, LoadedFunction *fun) { } if (builtInFunctionArray[whichFunc].func) { - debugC(1, kSludgeDebugBuiltin, "Run built-in function : %s", - (whichFunc < numBIFNames) ? allBIFNames[whichFunc].c_str() : "Unknown"); + debugC(3, kSludgeDebugBuiltin, + "Run built-in function %i : %s", + whichFunc, (whichFunc < numBIFNames) ? allBIFNames[whichFunc].c_str() : "Unknown"); return builtInFunctionArray[whichFunc].func(numParams, fun); } } diff --git a/engines/sludge/event.h b/engines/sludge/event.h index 691a0daa82..878d363b49 100644 --- a/engines/sludge/event.h +++ b/engines/sludge/event.h @@ -73,6 +73,7 @@ public: void restore(FrozenStuffStruct *frozenStuff); // Quit + void startGame() { _weAreDoneSoQuit = false; } void quitGame() { _weAreDoneSoQuit = true; /* _reallyWantToQuit = true; */ } bool quit() { return _weAreDoneSoQuit; } diff --git a/engines/sludge/imgloader.cpp b/engines/sludge/imgloader.cpp index 64c8d7806f..c909ad5b62 100644 --- a/engines/sludge/imgloader.cpp +++ b/engines/sludge/imgloader.cpp @@ -33,7 +33,7 @@ namespace Sludge { bool ImgLoader::loadImage(Common::SeekableReadStream *stream, Graphics::Surface *dest, int reserve) { - debugC(3, kSludgeDebugDataLoad, "Loading image at position: %i", stream->pos()); + debugC(3, kSludgeDebugGraphics, "Loading image at position: %i", stream->pos()); int32 start_ptr = stream->pos(); if (!loadPNGImage(stream, dest)) { stream->seek(start_ptr); diff --git a/engines/sludge/main_loop.cpp b/engines/sludge/main_loop.cpp index 708d4df910..4524d02304 100644 --- a/engines/sludge/main_loop.cpp +++ b/engines/sludge/main_loop.cpp @@ -34,6 +34,7 @@ #include "sludge/newfatal.h" #include "sludge/objtypes.h" #include "sludge/people.h" +#include "sludge/region.h" #include "sludge/statusba.h" #include "sludge/sound.h" #include "sludge/sludge.h" @@ -48,7 +49,7 @@ extern VariableStack *noStack; int dialogValue = 0; -int main_loop(const char *filename) { +int main_loop(Common::String filename) { if (!initSludge(filename)) { return 0; @@ -75,6 +76,7 @@ int main_loop(const char *filename) { startNewFunctionNum(0, 0, NULL, noStack); + g_sludge->_evtMan->startGame(); g_sludge->_timer.init(); while (!g_sludge->_evtMan->quit()) { @@ -88,8 +90,17 @@ int main_loop(const char *filename) { g_sludge->_timer.waitFrame(); } + killAllFunctions(); + killAllRegions(); g_sludge->_soundMan->killSoundStuff(); + // Load next game + if (!g_sludge->launchNext.empty()) { + Common::String name = g_sludge->launchNext; + g_sludge->launchNext.clear(); + main_loop(name); + } + return (0); } diff --git a/engines/sludge/main_loop.h b/engines/sludge/main_loop.h index b287c8105e..3fe522c925 100644 --- a/engines/sludge/main_loop.h +++ b/engines/sludge/main_loop.h @@ -24,7 +24,7 @@ namespace Sludge { -int main_loop(const char *filename); +int main_loop(Common::String filename); } // End of namespace Sludge diff --git a/engines/sludge/region.cpp b/engines/sludge/region.cpp index af9e2b8cac..7593fe4aee 100644 --- a/engines/sludge/region.cpp +++ b/engines/sludge/region.cpp @@ -33,8 +33,9 @@ namespace Sludge { -ScreenRegion *allScreenRegions = NULL; -ScreenRegion *overRegion = NULL; +ScreenRegion *allScreenRegions = nullptr; +ScreenRegion *overRegion = nullptr; +ScreenRegion *lastRegion = nullptr; void showBoxes() { ScreenRegion*huntRegion = allScreenRegions; @@ -121,7 +122,8 @@ void killAllRegions() { g_sludge->_objMan->removeObjectType(killRegion->thisType); delete killRegion; } - overRegion = NULL; + overRegion = nullptr; + lastRegion = nullptr; } bool addScreenRegion(int x1, int y1, int x2, int y2, int sX, int sY, int di, diff --git a/engines/sludge/sludge.cpp b/engines/sludge/sludge.cpp index 9976652c48..97904e191f 100644 --- a/engines/sludge/sludge.cpp +++ b/engines/sludge/sludge.cpp @@ -55,7 +55,8 @@ SludgeEngine::SludgeEngine(OSystem *syst, const SludgeGameDescription *gameDesc) DebugMan.addDebugChannel(kSludgeDebugZBuffer, "ZBuffer", "ZBuffer debug level"); DebugMan.addDebugChannel(kSludgeDebugSound, "Sound", "Sound debug level"); - DebugMan.enableDebugChannel("Sound"); + DebugMan.enableDebugChannel("Data Load"); + DebugMan.enableDebugChannel("Built-in"); // init graphics _origFormat = new Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); @@ -63,10 +64,10 @@ SludgeEngine::SludgeEngine(OSystem *syst, const SludgeGameDescription *gameDesc) // Init Strings launchMe = ""; + launchNext = ""; loadNow = ""; gamePath = ""; bundleFolder = ""; - fatalMessage = ""; fatalInfo = "Initialisation error! Something went wrong before we even got started!"; diff --git a/engines/sludge/sludge.h b/engines/sludge/sludge.h index d868754014..240045db57 100644 --- a/engines/sludge/sludge.h +++ b/engines/sludge/sludge.h @@ -67,6 +67,7 @@ protected: public: // global String variables Common::String launchMe; + Common::String launchNext; Common::String loadNow; Common::String gamePath; Common::String bundleFolder; diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp index 8e49b32465..a63b8b9923 100644 --- a/engines/sludge/sludger.cpp +++ b/engines/sludge/sludger.cpp @@ -54,7 +54,6 @@ namespace Sludge { extern int dialogValue; -extern Variable *launchResult; int numBIFNames = 0; Common::String *allBIFNames; @@ -74,7 +73,6 @@ extern SpeechStruct *speech; extern LoadedFunction *saverFunc; LoadedFunction *allRunningFunctions = NULL; -ScreenRegion *lastRegion = NULL; VariableStack *noStack = NULL; Variable *globalVars; @@ -913,6 +911,15 @@ bool runSludge() { return true; } +void killAllFunctions() { + LoadedFunction *ptr = allRunningFunctions; + while (ptr) { + LoadedFunction *kill = ptr; + ptr = ptr->next; + abortFunction(kill); + } +} + bool loadFunctionCode(LoadedFunction *newFunc) { uint numLines, numLinesRead; diff --git a/engines/sludge/sludger.h b/engines/sludge/sludger.h index 91efb24ce9..0ab3eb7887 100644 --- a/engines/sludge/sludger.h +++ b/engines/sludge/sludger.h @@ -66,6 +66,7 @@ int startNewFunctionNum(uint, uint, LoadedFunction *, VariableStack*&, bool = tr bool handleInput(); void restartFunction(LoadedFunction *fun); bool loadFunctionCode(LoadedFunction *newFunc); +void killAllFunctions(); void finishFunction(LoadedFunction *fun); void abortFunction(LoadedFunction *fun); |