aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorColin Snover2016-09-21 16:16:21 -0500
committerColin Snover2016-09-29 19:39:16 -0500
commit1847b0f7059328e195d9fca2372ab2b8a12aad06 (patch)
treee7e20257231c81b6728445ae2084fcc7065c457f /engines
parent3e75f42d85d82cc77d2607def29f4b63208844c1 (diff)
downloadscummvm-rg350-1847b0f7059328e195d9fca2372ab2b8a12aad06.tar.gz
scummvm-rg350-1847b0f7059328e195d9fca2372ab2b8a12aad06.tar.bz2
scummvm-rg350-1847b0f7059328e195d9fca2372ab2b8a12aad06.zip
SCI32: Fix warnings and incompatible save games when built without SCI32
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/file.cpp5
-rw-r--r--engines/sci/engine/file.h11
-rw-r--r--engines/sci/engine/kfile.cpp10
-rw-r--r--engines/sci/engine/savegame.cpp14
-rw-r--r--engines/sci/engine/savegame.h17
-rw-r--r--engines/sci/engine/script_patches.cpp3
-rw-r--r--engines/sci/sci.cpp2
7 files changed, 36 insertions, 26 deletions
diff --git a/engines/sci/engine/file.cpp b/engines/sci/engine/file.cpp
index 717efcb404..d46d68d9df 100644
--- a/engines/sci/engine/file.cpp
+++ b/engines/sci/engine/file.cpp
@@ -335,11 +335,14 @@ bool fillSavegameDesc(const Common::String &filename, SavegameDesc *desc) {
desc->time = meta.saveTime;
desc->version = meta.version;
desc->gameVersion = meta.gameVersion;
+#ifdef ENABLE_SCI32
if (g_sci->getGameId() == GID_SHIVERS) {
- desc->score = meta.score;
+ desc->lowScore = meta.lowScore;
+ desc->highScore = meta.highScore;
} else if (g_sci->getGameId() == GID_MOTHERGOOSEHIRES) {
desc->avatarId = meta.avatarId;
}
+#endif
if (meta.name.lastChar() == '\n')
meta.name.deleteLastChar();
diff --git a/engines/sci/engine/file.h b/engines/sci/engine/file.h
index 7d2461fd7a..0154338f6c 100644
--- a/engines/sci/engine/file.h
+++ b/engines/sci/engine/file.h
@@ -65,12 +65,11 @@ struct SavegameDesc {
char name[SCI_MAX_SAVENAME_LENGTH];
Common::String gameVersion;
#ifdef ENABLE_SCI32
- union {
- // Used by Shivers 1
- uint32 score;
- // Used by MGDX
- uint8 avatarId;
- };
+ // Used by Shivers 1
+ uint16 lowScore;
+ uint16 highScore;
+ // Used by MGDX
+ uint8 avatarId;
#endif
};
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index e983922024..2d2f885b05 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -324,14 +324,12 @@ reg_t kFileIOOpen(EngineState *s, int argc, reg_t *argv) {
SavegameDesc save;
fillSavegameDesc(g_sci->getSavegameName(saveNo), &save);
- Common::String score;
- const uint16 lowScore = save.score & 0xFFFF;
- const uint16 highScore = save.score >> 16;
- if (!highScore) {
- score = Common::String::format("%u", lowScore);
+ Common::String score;
+ if (!save.highScore) {
+ score = Common::String::format("%u", save.lowScore);
} else {
- score = Common::String::format("%u%03u", highScore, lowScore);
+ score = Common::String::format("%u%03u", save.highScore, save.lowScore);
}
const uint nameLength = strlen(save.name);
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index aee11ef998..d50df94f4b 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -331,20 +331,26 @@ static void sync_SavegameMetadata(Common::Serializer &s, SavegameMetadata &obj)
s.syncAsUint32LE(obj.playTime);
}
- // Some games require additional metadata to display the load screen
+ // Some games require additional metadata to display their restore screens
// correctly
if (s.getVersion() >= 38) {
if (s.isSaving()) {
const reg_t *globals = g_sci->getEngineState()->variables[VAR_GLOBAL];
if (g_sci->getGameId() == GID_SHIVERS) {
- obj.score = globals[kScore].toUint16();
- obj.score |= globals[kShivers1Score].toUint16() << 16;
+ obj.lowScore = globals[kScore].toUint16();
+ obj.highScore = globals[kShivers1Score].toUint16();
+ obj.avatarId = 0;
} else if (g_sci->getGameId() == GID_MOTHERGOOSEHIRES) {
+ obj.lowScore = obj.highScore = 0;
obj.avatarId = readSelectorValue(g_sci->getEngineState()->_segMan, globals[kEgo], SELECTOR(view));
+ } else {
+ obj.lowScore = obj.highScore = obj.avatarId = 0;
}
}
- s.syncAsUint32LE(obj.score);
+ s.syncAsUint16LE(obj.lowScore);
+ s.syncAsUint16LE(obj.highScore);
+ s.syncAsByte(obj.avatarId);
}
}
diff --git a/engines/sci/engine/savegame.h b/engines/sci/engine/savegame.h
index 627fc64118..8c54f3b7ce 100644
--- a/engines/sci/engine/savegame.h
+++ b/engines/sci/engine/savegame.h
@@ -37,7 +37,7 @@ struct EngineState;
*
* Version - new/changed feature
* =============================
- * 38 - SCI32 cursor, accurate SCI32 arrays/strings, score metadata
+ * 38 - SCI32 cursor, accurate SCI32 arrays/strings, score metadata, avatar metadata
* 37 - Segment entry data changed to pointers
* 36 - SCI32 bitmap segment
* 35 - SCI32 remap
@@ -77,14 +77,13 @@ struct SavegameMetadata {
uint32 playTime;
uint16 gameObjectOffset;
uint16 script0Size;
-#ifdef ENABLE_SCI32
- union {
- // Used by Shivers 1
- uint32 score;
- // Used by MGDX
- uint8 avatarId;
- };
-#endif
+
+ // Used by Shivers 1
+ uint16 lowScore;
+ uint16 highScore;
+
+ // Used by MGDX
+ uint8 avatarId;
};
/**
diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp
index 1bab106170..9ef0b9e7a1 100644
--- a/engines/sci/engine/script_patches.cpp
+++ b/engines/sci/engine/script_patches.cpp
@@ -1696,6 +1696,7 @@ static const SciScriptPatcherEntry kq6Signatures[] = {
SCI_SIGNATUREENTRY_TERMINATOR
};
+#ifdef ENABLE_SCI32
#pragma mark -
#pragma mark King's Quest 7
@@ -1860,6 +1861,8 @@ static const SciScriptPatcherEntry kq7Signatures[] = {
SCI_SIGNATUREENTRY_TERMINATOR
};
+#endif
+
// ===========================================================================
// Script 210 in the German version of Longbow handles the case where Robin
// hands out the scroll to Marion and then types his name using the hand code.
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index ce6e2640fa..4767b8a9c0 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -495,6 +495,7 @@ static byte patchGameRestoreSave[] = {
0x48, // ret
};
+#ifdef ENABLE_SCI32
// SCI2 version: Same as above, but the second parameter to callk is a word
// and third parameter is a string reference
static byte patchGameRestoreSci2[] = {
@@ -537,6 +538,7 @@ static byte patchGameSaveSci21[] = {
0x43, 0xff, 0x0a, 0x00, // callk kSave (0xFF will be overwritten by patcher)
0x48, // ret
};
+#endif
static void patchGameSaveRestoreCode(SegManager *segMan, reg_t methodAddress, byte id) {
Script *script = segMan->getScript(methodAddress.getSegment());