aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine/savegame.cpp
diff options
context:
space:
mode:
authorColin Snover2017-04-30 12:38:50 -0500
committerColin Snover2017-04-30 12:47:32 -0500
commit94dc6ae05234b33677b10bca438819e59f6175fa (patch)
treed0088fdf1600f7494a32ad2dfad8082d9de44a89 /engines/sci/engine/savegame.cpp
parent0560a1d04119190535ed887f3dae6590930d9d09 (diff)
downloadscummvm-rg350-94dc6ae05234b33677b10bca438819e59f6175fa.tar.gz
scummvm-rg350-94dc6ae05234b33677b10bca438819e59f6175fa.tar.bz2
scummvm-rg350-94dc6ae05234b33677b10bca438819e59f6175fa.zip
SCI: Hold script data as mutable internally
Script buffer data is modified after a script is loaded by savegame operations, and, in SCI16, by string operations. Casting away const to allow these mutations to happen is not a very good design, so this patch just changes the privately held reference to data to be mutable. (Public accessors still return immutable data.)
Diffstat (limited to 'engines/sci/engine/savegame.cpp')
-rw-r--r--engines/sci/engine/savegame.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 427e32deb3..5ba88d9417 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -467,7 +467,7 @@ void HunkTable::saveLoadWithSerializer(Common::Serializer &s) {
void Script::syncStringHeap(Common::Serializer &s) {
if (getSciVersion() < SCI_VERSION_1_1) {
// Sync all of the SCI_OBJ_STRINGS blocks
- SciSpan<byte> buf = (SciSpan<byte> &)*_buf;
+ SciSpan<byte> buf = *_buf;
bool oldScriptHeader = (getSciVersion() == SCI_VERSION_0_EARLY);
if (oldScriptHeader)
@@ -490,7 +490,7 @@ void Script::syncStringHeap(Common::Serializer &s) {
} else if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1_LATE){
// Strings in SCI1.1 come after the object instances
- SciSpan<byte> buf = _heap.subspan<byte>(4 + _heap.getUint16SEAt(2) * 2);
+ SciSpan<byte> buf = _heap.subspan(4 + _heap.getUint16SEAt(2) * 2);
// Skip all of the objects
while (buf.getUint16SEAt(0) == SCRIPT_OBJECT_MAGIC_NUMBER)
@@ -502,8 +502,7 @@ void Script::syncStringHeap(Common::Serializer &s) {
} else if (getSciVersion() == SCI_VERSION_3) {
const int stringOffset = _buf->getInt32SEAt(4);
const int length = _buf->getInt32SEAt(8) - stringOffset;
- SciSpan<byte> buf = _buf->subspan<byte>(stringOffset, length);
- s.syncBytes(buf.getUnsafeDataAt(0, length), length);
+ s.syncBytes(_buf->getUnsafeDataAt(stringOffset, length), length);
}
}