[Scummvm-cvs-logs] scummvm master -> 6c97eb4e366a292e91d143861f36c24b3169e06b
sev-
sev at scummvm.org
Sun Jan 4 19:49:37 CET 2015
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
f74ba29753 SCUMM: Enable Day of the Tentacle easter egg
cc916625d9 SCUMM: Add a "chained games manager"
7dc316cced SCUMM: Add secret "easter_egg" config key
6c97eb4e36 Merge pull request #554 from eriktorbjorn/tentacle-maniac
Commit: f74ba29753de23bad9a07f531fc4c03ea3375594
https://github.com/scummvm/scummvm/commit/f74ba29753de23bad9a07f531fc4c03ea3375594
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2014-12-30T03:45:14+01:00
Commit Message:
SCUMM: Enable Day of the Tentacle easter egg
Instead of returning to the launcher, a game may now specify a list
of "chained" games and optional save slots. The first game is popped
from the list and started. Quitting still quits the entire ScummVM.
It seemed like the sensible thing to do.
Changed paths:
base/main.cpp
engines/scumm/saveload.cpp
engines/scumm/script_v6.cpp
engines/scumm/scumm.cpp
engines/scumm/scumm.h
diff --git a/base/main.cpp b/base/main.cpp
index b5de7d9..b9bd97d 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -523,22 +523,64 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
}
#endif
+ // At this point, we usually return to the launcher. However, the
+ // game may have requested that one or more other games be "chained"
+ // to the current one, with optional save slots to start the games
+ // at. At the time of writing, this is used for the Maniac Mansion
+ // easter egg in Day of the Tentacle.
+
+ Common::String chainedGames, nextGame, saveSlot;
+
+ if (ConfMan.hasKey("chained_games", Common::ConfigManager::kTransientDomain)) {
+ chainedGames = ConfMan.get("chained_games", Common::ConfigManager::kTransientDomain);
+ }
+
// Discard any command line options. It's unlikely that the user
// wanted to apply them to *all* games ever launched.
ConfMan.getDomain(Common::ConfigManager::kTransientDomain)->clear();
- // Clear the active config domain
- ConfMan.setActiveDomain("");
+ if (!chainedGames.empty()) {
+ if (chainedGames.contains(',')) {
+ for (uint i = 0; i < chainedGames.size(); i++) {
+ if (chainedGames[i] == ',') {
+ chainedGames.erase(0, i + 1);
+ break;
+ }
+ nextGame += chainedGames[i];
+ }
+ ConfMan.set("chained_games", chainedGames, Common::ConfigManager::kTransientDomain);
+ } else {
+ nextGame = chainedGames;
+ chainedGames.clear();
+ ConfMan.removeKey("chained_games", Common::ConfigManager::kTransientDomain);
+ }
+ if (nextGame.contains(':')) {
+ for (int i = nextGame.size() - 1; i >= 0; i--) {
+ if (nextGame[i] == ':') {
+ nextGame.erase(i);
+ break;
+ }
+ saveSlot = nextGame[i] + saveSlot;
+ }
+ ConfMan.setInt("save_slot", atoi(saveSlot.c_str()), Common::ConfigManager::kTransientDomain);
+ }
+ // Start the next game
+ ConfMan.setActiveDomain(nextGame);
+ } else {
+ // Clear the active config domain
+ ConfMan.setActiveDomain("");
+ }
PluginManager::instance().loadAllPlugins(); // only for cached manager
-
} else {
GUI::displayErrorDialog(_("Could not find any engine capable of running the selected game"));
}
// reset the graphics to default
setupGraphics(system);
- launcherDialog();
+ if (0 == ConfMan.getActiveDomain()) {
+ launcherDialog();
+ }
}
PluginManager::instance().unloadAllPlugins();
PluginManager::destroy();
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index 0c0f6be..e5673c1 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 d2f4133..6c81f17 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 6040344..34ae957 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -2597,9 +2597,47 @@ 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;
+
+ // 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;
+ }
+ }
+ }
+
+ 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.
+ ConfMan.set("chained_games", maniacTarget + "," + ConfMan.getActiveDomainName() + ":100", Common::ConfigManager::kTransientDomain);
+
+ // 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 967909e..30b4d61 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);
Commit: cc916625d9025ffaa898854c4de19da5dc2e2925
https://github.com/scummvm/scummvm/commit/cc916625d9025ffaa898854c4de19da5dc2e2925
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2014-12-30T10:47:51+01:00
Commit Message:
SCUMM: Add a "chained games manager"
This replaces the somewhat ugly use of the config manager to store
the chained games.
Changed paths:
base/main.cpp
engines/engine.cpp
engines/engine.h
engines/scumm/scumm.cpp
diff --git a/base/main.cpp b/base/main.cpp
index b9bd97d..0f5ebc7 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -529,43 +529,21 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
// at. At the time of writing, this is used for the Maniac Mansion
// easter egg in Day of the Tentacle.
- Common::String chainedGames, nextGame, saveSlot;
+ Common::String chainedGame;
+ int saveSlot = -1;
- if (ConfMan.hasKey("chained_games", Common::ConfigManager::kTransientDomain)) {
- chainedGames = ConfMan.get("chained_games", Common::ConfigManager::kTransientDomain);
- }
+ ChainedGamesMan.pop(chainedGame, saveSlot);
// Discard any command line options. It's unlikely that the user
// wanted to apply them to *all* games ever launched.
ConfMan.getDomain(Common::ConfigManager::kTransientDomain)->clear();
- if (!chainedGames.empty()) {
- if (chainedGames.contains(',')) {
- for (uint i = 0; i < chainedGames.size(); i++) {
- if (chainedGames[i] == ',') {
- chainedGames.erase(0, i + 1);
- break;
- }
- nextGame += chainedGames[i];
- }
- ConfMan.set("chained_games", chainedGames, Common::ConfigManager::kTransientDomain);
- } else {
- nextGame = chainedGames;
- chainedGames.clear();
- ConfMan.removeKey("chained_games", Common::ConfigManager::kTransientDomain);
- }
- if (nextGame.contains(':')) {
- for (int i = nextGame.size() - 1; i >= 0; i--) {
- if (nextGame[i] == ':') {
- nextGame.erase(i);
- break;
- }
- saveSlot = nextGame[i] + saveSlot;
- }
- ConfMan.setInt("save_slot", atoi(saveSlot.c_str()), Common::ConfigManager::kTransientDomain);
+ if (!chainedGame.empty()) {
+ if (saveSlot != -1) {
+ ConfMan.setInt("save_slot", saveSlot, Common::ConfigManager::kTransientDomain);
}
- // Start the next game
- ConfMan.setActiveDomain(nextGame);
+ // Start the chained game
+ ConfMan.setActiveDomain(chainedGame);
} else {
// Clear the active config domain
ConfMan.setActiveDomain("");
diff --git a/engines/engine.cpp b/engines/engine.cpp
index c63437f..24008dd 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 e325cc1b..d3415d5 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/scumm.cpp b/engines/scumm/scumm.cpp
index 34ae957..9518ed4 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -2625,7 +2625,8 @@ bool ScummEngine::startManiac() {
// Set up the chanined games to Maniac Mansion, and then back
// to the current game again with that save slot.
- ConfMan.set("chained_games", maniacTarget + "," + ConfMan.getActiveDomainName() + ":100", Common::ConfigManager::kTransientDomain);
+ ChainedGamesMan.push(maniacTarget);
+ ChainedGamesMan.push(ConfMan.getActiveDomainName(), 100);
// Force a return to the launcher. This will start the first
// chained game.
Commit: 7dc316cced4c7a45a376d76a6ca0c84bd563132f
https://github.com/scummvm/scummvm/commit/7dc316cced4c7a45a376d76a6ca0c84bd563132f
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2014-12-30T10:54:49+01:00
Commit Message:
SCUMM: Add secret "easter_egg" config key
This makes it possible to override the detection of Maniac Mansion
when starting the Day of the Tentacle easter egg. There is no GUI
for setting this, no error handling, and setting it to Day of the
Tentacle itself is probably a bad idea...
Changed paths:
engines/scumm/scumm.cpp
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 9518ed4..7d927b0 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -2601,20 +2601,24 @@ bool ScummEngine::startManiac() {
Common::String currentPath = ConfMan.get("path");
Common::String maniacTarget;
- // 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;
+ 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()) {
Commit: 6c97eb4e366a292e91d143861f36c24b3169e06b
https://github.com/scummvm/scummvm/commit/6c97eb4e366a292e91d143861f36c24b3169e06b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-01-04T19:48:33+01:00
Commit Message:
Merge pull request #554 from eriktorbjorn/tentacle-maniac
SCUMM: Day of the Tentacle easter egg
Changed paths:
base/main.cpp
engines/engine.cpp
engines/engine.h
engines/scumm/saveload.cpp
engines/scumm/script_v6.cpp
engines/scumm/scumm.cpp
engines/scumm/scumm.h
More information about the Scummvm-git-logs
mailing list