[Scummvm-git-logs] scummvm master -> 00168003fed1ec05164a64bdf4abc821da5b1517
csnover
csnover at users.noreply.github.com
Sun Apr 30 21:32:13 CEST 2017
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
94dc6ae052 SCI: Hold script data as mutable internally
00168003fe SCI: Clean up ugly syncBaseObject call
Commit: 94dc6ae05234b33677b10bca438819e59f6175fa
https://github.com/scummvm/scummvm/commit/94dc6ae05234b33677b10bca438819e59f6175fa
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-04-30T12:47:32-05:00
Commit Message:
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.)
Changed paths:
engines/sci/engine/savegame.cpp
engines/sci/engine/script.cpp
engines/sci/engine/script.h
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 427e32d..5ba88d9 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);
}
}
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp
index 8cf6ad0..7e3a661 100644
--- a/engines/sci/engine/script.cpp
+++ b/engines/sci/engine/script.cpp
@@ -882,7 +882,7 @@ SegmentRef Script::dereference(reg_t pointer) {
SegmentRef ret;
ret.isRaw = true;
ret.maxSize = _buf->size() - pointer.getOffset();
- ret.raw = const_cast<byte *>(_buf->getUnsafeDataAt(pointer.getOffset(), ret.maxSize));
+ ret.raw = _buf->getUnsafeDataAt(pointer.getOffset(), ret.maxSize);
return ret;
}
diff --git a/engines/sci/engine/script.h b/engines/sci/engine/script.h
index e0faa11..f9b3845 100644
--- a/engines/sci/engine/script.h
+++ b/engines/sci/engine/script.h
@@ -68,9 +68,9 @@ typedef Common::Array<offsetLookupArrayEntry> offsetLookupArrayType;
class Script : public SegmentObj {
private:
int _nr; /**< Script number */
- Common::SpanOwner<SciSpan<const byte> > _buf; /**< Static data buffer, or NULL if not used */
- SciSpan<const byte> _script; /**< Script size includes alignment byte */
- SciSpan<const byte> _heap; /**< Start of heap if SCI1.1, NULL otherwise */
+ Common::SpanOwner<SciSpan<byte> > _buf; /**< Static data buffer, or NULL if not used */
+ SciSpan<byte> _script; /**< Script size includes alignment byte */
+ SciSpan<byte> _heap; /**< Start of heap if SCI1.1, NULL otherwise */
int _lockers; /**< Number of classes and objects that require this script */
Commit: 00168003fed1ec05164a64bdf4abc821da5b1517
https://github.com/scummvm/scummvm/commit/00168003fed1ec05164a64bdf4abc821da5b1517
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-04-30T13:44:34-05:00
Commit Message:
SCI: Clean up ugly syncBaseObject call
Changed paths:
engines/sci/engine/savegame.cpp
engines/sci/engine/script.h
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 5ba88d9..e2099a4 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -256,8 +256,9 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) {
_scriptSegMap[scr->getScriptNumber()] = i;
ObjMap objects = scr->getObjectMap();
- for (ObjMap::iterator it = objects.begin(); it != objects.end(); ++it)
- it->_value.syncBaseObject(SciSpan<const byte>(scr->getBuf(it->_value.getPos().getOffset()), scr->getBufSize() - it->_value.getPos().getOffset()));
+ for (ObjMap::iterator it = objects.begin(); it != objects.end(); ++it) {
+ it->_value.syncBaseObject(scr->getSpan(it->_value.getPos().getOffset()));
+ }
}
// Sync the script's string heap
diff --git a/engines/sci/engine/script.h b/engines/sci/engine/script.h
index f9b3845..65f3ffb 100644
--- a/engines/sci/engine/script.h
+++ b/engines/sci/engine/script.h
@@ -107,6 +107,7 @@ public:
uint32 getBufSize() const { return _buf->size(); }
const byte *getBuf(uint offset = 0) const { return _buf->getUnsafeDataAt(offset); }
+ SciSpan<const byte> getSpan(uint offset) const { return _buf->subspan(offset); }
int getScriptNumber() const { return _nr; }
SegmentId getLocalsSegment() const { return _localsSegment; }
More information about the Scummvm-git-logs
mailing list