aboutsummaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorTorbjörn Andersson2014-12-30 10:47:51 +0100
committerTorbjörn Andersson2014-12-30 10:47:51 +0100
commitcc916625d9025ffaa898854c4de19da5dc2e2925 (patch)
tree8986dbcee3db5b8850680f42e9b2117c13822e25 /base
parentf74ba29753de23bad9a07f531fc4c03ea3375594 (diff)
downloadscummvm-rg350-cc916625d9025ffaa898854c4de19da5dc2e2925.tar.gz
scummvm-rg350-cc916625d9025ffaa898854c4de19da5dc2e2925.tar.bz2
scummvm-rg350-cc916625d9025ffaa898854c4de19da5dc2e2925.zip
SCUMM: Add a "chained games manager"
This replaces the somewhat ugly use of the config manager to store the chained games.
Diffstat (limited to 'base')
-rw-r--r--base/main.cpp38
1 files changed, 8 insertions, 30 deletions
diff --git a/base/main.cpp b/base/main.cpp
index b9bd97dbef..0f5ebc7845 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("");