aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2015-01-04 19:48:33 +0100
committerEugene Sandulenko2015-01-04 19:48:33 +0100
commit6c97eb4e366a292e91d143861f36c24b3169e06b (patch)
tree6bffb4d9e85c2481b3dafc1fdc484f328f794e51 /engines
parent2587852c88e2fbc52bf702f71738e80628eb43fe (diff)
parent7dc316cced4c7a45a376d76a6ca0c84bd563132f (diff)
downloadscummvm-rg350-6c97eb4e366a292e91d143861f36c24b3169e06b.tar.gz
scummvm-rg350-6c97eb4e366a292e91d143861f36c24b3169e06b.tar.bz2
scummvm-rg350-6c97eb4e366a292e91d143861f36c24b3169e06b.zip
Merge pull request #554 from eriktorbjorn/tentacle-maniac
SCUMM: Day of the Tentacle easter egg
Diffstat (limited to 'engines')
-rw-r--r--engines/engine.cpp31
-rw-r--r--engines/engine.h28
-rw-r--r--engines/scumm/saveload.cpp2
-rw-r--r--engines/scumm/script_v6.cpp6
-rw-r--r--engines/scumm/scumm.cpp49
-rw-r--r--engines/scumm/scumm.h2
6 files changed, 112 insertions, 6 deletions
diff --git a/engines/engine.cpp b/engines/engine.cpp
index c63437f800..24008dd073 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -45,6 +45,7 @@
#include "common/taskbar.h"
#include "common/textconsole.h"
#include "common/translation.h"
+#include "common/singleton.h"
#include "backends/keymapper/keymapper.h"
@@ -101,6 +102,36 @@ static void defaultErrorHandler(const char *msg) {
}
}
+// Chained games manager
+
+ChainedGamesManager::ChainedGamesManager() {
+ clear();
+}
+
+void ChainedGamesManager::clear() {
+ _chainedGames.clear();
+}
+
+void ChainedGamesManager::push(const Common::String target, const int slot) {
+ Game game;
+ game.target = target;
+ game.slot = slot;
+ _chainedGames.push(game);
+}
+
+bool ChainedGamesManager::pop(Common::String &target, int &slot) {
+ if (_chainedGames.empty()) {
+ return false;
+ }
+ Game game = _chainedGames.pop();
+ target = game.target;
+ slot = game.slot;
+ return true;
+}
+
+namespace Common {
+DECLARE_SINGLETON(ChainedGamesManager);
+}
Engine::Engine(OSystem *syst)
: _system(syst),
diff --git a/engines/engine.h b/engines/engine.h
index e325cc1ba2..d3415d584c 100644
--- a/engines/engine.h
+++ b/engines/engine.h
@@ -27,6 +27,8 @@
#include "common/str.h"
#include "common/language.h"
#include "common/platform.h"
+#include "common/queue.h"
+#include "common/singleton.h"
class OSystem;
@@ -334,6 +336,32 @@ protected:
};
+// Chained games
+
+/**
+ * Singleton class which manages chained games. A chained game is one that
+ * starts automatically, optionally loading a saved game, instead of returning
+ * to the launcher.
+ */
+class ChainedGamesManager : public Common::Singleton<ChainedGamesManager> {
+private:
+ struct Game {
+ Common::String target;
+ int slot;
+ };
+
+ Common::Queue<Game> _chainedGames;
+
+public:
+ ChainedGamesManager();
+ void clear();
+ void push(const Common::String target, const int slot = -1);
+ bool pop(Common::String &target, int &slot);
+};
+
+/** Convenience shortcut for accessing the chained games manager. */
+#define ChainedGamesMan ChainedGamesManager::instance()
+
// FIXME: HACK for MidiEmu & error()
extern Engine *g_engine;
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index 0c0f6be73b..e5673c1803 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -149,7 +149,7 @@ void ScummEngine::requestSave(int slot, const Common::String &name) {
void ScummEngine::requestLoad(int slot) {
_saveLoadSlot = slot;
- _saveTemporaryState = false;
+ _saveTemporaryState = (slot == 100);
_saveLoadFlag = 2; // 2 for load
}
diff --git a/engines/scumm/script_v6.cpp b/engines/scumm/script_v6.cpp
index d2f4133f74..6c81f17f2f 100644
--- a/engines/scumm/script_v6.cpp
+++ b/engines/scumm/script_v6.cpp
@@ -2597,7 +2597,11 @@ void ScummEngine_v6::o6_kernelSetFunctions() {
fadeIn(args[1]);
break;
case 8:
- startManiac();
+ if (startManiac()) {
+ // This is so that the surprised exclamation happens
+ // after we return to the game again, not before.
+ o6_breakHere();
+ }
break;
case 9:
killAllScriptsExceptCurrent();
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 6040344c2c..7d927b0cda 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -2597,9 +2597,52 @@ void ScummEngine_v90he::runBootscript() {
}
#endif
-void ScummEngine::startManiac() {
- debug(0, "stub startManiac()");
- displayMessage(0, "%s", _("Usually, Maniac Mansion would start now. But ScummVM doesn't do that yet. To play it, go to 'Add Game' in the ScummVM start menu and select the 'Maniac' directory inside the Tentacle game directory."));
+bool ScummEngine::startManiac() {
+ Common::String currentPath = ConfMan.get("path");
+ Common::String maniacTarget;
+
+ if (!ConfMan.hasKey("easter_egg")) {
+ // Look for a game with a game path pointing to a 'Maniac' directory
+ // as a subdirectory to the current game.
+ Common::ConfigManager::DomainMap::iterator iter = ConfMan.beginGameDomains();
+ for (; iter != ConfMan.endGameDomains(); ++iter) {
+ Common::ConfigManager::Domain &dom = iter->_value;
+ Common::String path = dom.getVal("path");
+
+ if (path.hasPrefix(currentPath)) {
+ path.erase(0, currentPath.size() + 1);
+ if (path.equalsIgnoreCase("maniac")) {
+ maniacTarget = dom.getVal("gameid");
+ break;
+ }
+ }
+ }
+ } else {
+ maniacTarget = ConfMan.get("easter_egg");
+ }
+
+ if (!maniacTarget.empty()) {
+ // Request a temporary save game to be made.
+ _saveLoadFlag = 1;
+ _saveLoadSlot = 100;
+ _saveTemporaryState = true;
+
+ // Set up the chanined games to Maniac Mansion, and then back
+ // to the current game again with that save slot.
+ ChainedGamesMan.push(maniacTarget);
+ ChainedGamesMan.push(ConfMan.getActiveDomainName(), 100);
+
+ // Force a return to the launcher. This will start the first
+ // chained game.
+ Common::EventManager *eventMan = g_system->getEventManager();
+ Common::Event event;
+ event.type = Common::EVENT_RTL;
+ eventMan->pushEvent(event);
+ return true;
+ } else {
+ displayMessage(0, "%s", _("Usually, Maniac Mansion would start now. But for that to work, the game files for Maniac Mansion have to be in the 'Maniac' directory inside the Tentacle game directory, and the game has to be added to ScummVM."));
+ return false;
+ }
}
#pragma mark -
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 967909e505..30b4d61880 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -654,7 +654,7 @@ protected:
int getScriptSlot();
void startScene(int room, Actor *a, int b);
- void startManiac();
+ bool startManiac();
public:
void runScript(int script, bool freezeResistant, bool recursive, int *lvarptr, int cycle = 0);