aboutsummaryrefslogtreecommitdiff
path: root/engines/tinsel/detection.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2008-12-20 23:08:37 +0000
committerJohannes Schickel2008-12-20 23:08:37 +0000
commit34368e5650c81cd52ae20d91d475be979359cfe3 (patch)
treebd9aea31a411271e916ed935df2fb0638942a4ff /engines/tinsel/detection.cpp
parent83cdce56dbde6e28cfbd58765c89d3d8848585b2 (diff)
downloadscummvm-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.cpp40
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
}