diff options
author | Johannes Schickel | 2008-12-20 23:08:37 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-12-20 23:08:37 +0000 |
commit | 34368e5650c81cd52ae20d91d475be979359cfe3 (patch) | |
tree | bd9aea31a411271e916ed935df2fb0638942a4ff /engines/tinsel/detection.cpp | |
parent | 83cdce56dbde6e28cfbd58765c89d3d8848585b2 (diff) | |
download | scummvm-rg350-34368e5650c81cd52ae20d91d475be979359cfe3.tar.gz scummvm-rg350-34368e5650c81cd52ae20d91d475be979359cfe3.tar.bz2 scummvm-rg350-34368e5650c81cd52ae20d91d475be979359cfe3.zip |
Fixed loading Discworld 2 savegames from GMM.
svn-id: r35453
Diffstat (limited to 'engines/tinsel/detection.cpp')
-rw-r--r-- | engines/tinsel/detection.cpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/engines/tinsel/detection.cpp b/engines/tinsel/detection.cpp index c1ce5fe83d..5b22659d26 100644 --- a/engines/tinsel/detection.cpp +++ b/engines/tinsel/detection.cpp @@ -535,7 +535,45 @@ void TinselMetaEngine::removeSaveState(const char *target, int slot) const { namespace Tinsel { Common::Error TinselEngine::loadGameState(int slot) { - RestoreGame(slot, true); + // FIXME: Hopefully this is only used when loading games via + // the launcher, since we do a hacky savegame slot to savelist + // entry mapping here. + // + // You might wonder why is needed and here is the answer: + // The save/load dialog of the GMM operates with the physical + // savegame slots, while Tinsel internally uses entry numbers in + // a savelist (which is sorted latest to first). Now to allow + // proper loading of (especially Discworld2) saves we need to + // get a savelist entry number instead of the physical slot. + // + // There are different possible solutions: + // + // One way to fix this would be to pass the filename instead of + // the savelist entry number to RestoreGame, though it could make + // problems how DW2 handles CD switches. Normally DW2 would pass + // '-2' as slot when it changes CDs. + // + // Another way would be to convert all of Tinsel to use physical + // slot numbers instead of savelist entry numbers for loading. + // This would also allow '-2' as slot for CD changes without + // any major hackery. + + int listSlot = -1; + const int numStates = Tinsel::getList(); + for (int i = 0; i < numStates; ++i) { + const char *fileName = Tinsel::ListEntry(i, Tinsel::LE_NAME); + const int saveSlot = atoi(fileName + strlen(fileName) - 2); + + if (saveSlot == slot) { + listSlot = i; + break; + } + } + + if (listSlot == -1) + return Common::kUnknownError; // TODO: proper error code + + RestoreGame(listSlot); return Common::kNoError; // TODO: return success/failure } |