aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
authorFilippos Karapetis2007-12-10 18:51:48 +0000
committerFilippos Karapetis2007-12-10 18:51:48 +0000
commitdd2386cde49d42467df520c177d0acf2bdce6ee0 (patch)
tree1b62053aaa512bc265992e68fc67998a63148016 /engines/agi
parent3edb4018971295add66cf89185b0ab59e417dc95 (diff)
downloadscummvm-rg350-dd2386cde49d42467df520c177d0acf2bdce6ee0.tar.gz
scummvm-rg350-dd2386cde49d42467df520c177d0acf2bdce6ee0.tar.bz2
scummvm-rg350-dd2386cde49d42467df520c177d0acf2bdce6ee0.zip
It's now possible again to import saved games from the original interpreter of Winnie the Pooh
svn-id: r29816
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/preagi_winnie.cpp45
1 files changed, 36 insertions, 9 deletions
diff --git a/engines/agi/preagi_winnie.cpp b/engines/agi/preagi_winnie.cpp
index 82be15a0d0..a4cbc12697 100644
--- a/engines/agi/preagi_winnie.cpp
+++ b/engines/agi/preagi_winnie.cpp
@@ -1238,18 +1238,43 @@ void Winnie::loadGame() {
if (!(infile = _vm->getSaveFileMan()->openForLoading(szFile)))
return;
- if (infile->readUint32BE() != MKID_BE('WINN'))
+ if (infile->readUint32BE() != MKID_BE('WINN')) {
error("Winnie::loadGame wrong save game format");
- saveVersion = infile->readByte();
- if (saveVersion != WTP_SAVEGAME_VERSION)
- warning("Old save game version (%d, current version is %d). Will try and read anyway, but don't be surprised if bad things happen", saveVersion, WTP_SAVEGAME_VERSION);
+ saveVersion = infile->readByte();
+ if (saveVersion != WTP_SAVEGAME_VERSION)
+ warning("Old save game version (%d, current version is %d). Will try and read anyway, but don't be surprised if bad things happen", saveVersion, WTP_SAVEGAME_VERSION);
- _game.fSound = infile->readByte();
- _game.nMoves = infile->readByte();
- _game.nObjMiss = infile->readByte();
- _game.nObjRet = infile->readByte();
- _game.iObjHave = infile->readByte();
+ _game.fSound = infile->readByte();
+ _game.nMoves = infile->readByte();
+ _game.nObjMiss = infile->readByte();
+ _game.nObjRet = infile->readByte();
+ _game.iObjHave = infile->readByte();
+ } else {
+ // This is probably a save from the original interpreter, throw a warning and attempt
+ // to read it as LE
+ warning("No header found in save game, assuming it came from the original interpreter");
+ // Note that the original saves variables as 16-bit integers, but only 8 bits are used.
+ // Since we read the save file data as little-endian, we skip the first byte of each
+ // variable
+ infile->readUint16LE(); // skip unused field
+ infile->readByte(); // first 8 bits of fSound
+ _game.fSound = infile->readByte();
+ infile->readByte(); // first 8 bits of nMoves
+ _game.nMoves = infile->readByte();
+ infile->readByte(); // first 8 bits of nObjMiss
+ _game.nObjMiss = infile->readByte();
+ infile->readByte(); // first 8 bits of nObjRet
+ _game.nObjRet = infile->readByte();
+ infile->readUint16LE(); // skip unused field
+ infile->readUint16LE(); // skip unused field
+ infile->readUint16LE(); // skip unused field
+ infile->readByte(); // first 8 bits of iObjHave
+ _game.iObjHave = infile->readByte();
+ infile->readUint16LE(); // skip unused field
+ infile->readUint16LE(); // skip unused field
+ infile->readUint16LE(); // skip unused field
+ }
for(i = 0; i < IDI_WTP_MAX_FLAG; i++)
_game.fGame[i] = infile->readByte();
@@ -1260,6 +1285,8 @@ void Winnie::loadGame() {
for(i = 0; i < IDI_WTP_MAX_ROOM_OBJ; i++)
_game.iObjRoom[i] = infile->readByte();
+ // Note that saved games from the original interpreter have 2 more fields here which are
+ // ignored
delete infile;
}