[Scummvm-cvs-logs] SF.net SVN: scummvm:[46789] scummvm/trunk/engines/sci/engine
mthreepwood at users.sourceforge.net
mthreepwood at users.sourceforge.net
Thu Dec 31 06:11:59 CET 2009
Revision: 46789
http://scummvm.svn.sourceforge.net/scummvm/?rev=46789&view=rev
Author: mthreepwood
Date: 2009-12-31 05:11:58 +0000 (Thu, 31 Dec 2009)
Log Message:
-----------
Overload the = operator for SciArray which fixes the setType errors in GK1. Some other cleanup too. GK1 can now access the restore menu and get a bit further in the game (until a segfault in the Decompressor code).
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/seg_manager.cpp
scummvm/trunk/engines/sci/engine/segment.h
Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp 2009-12-31 03:20:29 UTC (rev 46788)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp 2009-12-31 05:11:58 UTC (rev 46789)
@@ -1299,6 +1299,7 @@
if (!arrayTable->isValidEntry(addr.offset))
error("Attempt to use non-array %04x:%04x as array", PRINT_REG(addr));
+ arrayTable->_table[addr.offset].destroy();
arrayTable->freeEntry(addr.offset);
}
@@ -1338,6 +1339,7 @@
if (!stringTable->isValidEntry(addr.offset))
error("Attempt to use non-string %04x:%04x as string", PRINT_REG(addr));
+ stringTable->_table[addr.offset].destroy();
stringTable->freeEntry(addr.offset);
}
Modified: scummvm/trunk/engines/sci/engine/segment.h
===================================================================
--- scummvm/trunk/engines/sci/engine/segment.h 2009-12-31 03:20:29 UTC (rev 46788)
+++ scummvm/trunk/engines/sci/engine/segment.h 2009-12-31 05:11:58 UTC (rev 46789)
@@ -675,11 +675,42 @@
_size = 0;
_actualSize = 0;
}
+
+ SciArray(const SciArray<T> &array) {
+ _type = array._type;
+ _size = array._size;
+ _actualSize = array._actualSize;
+ _data = new T[_actualSize];
+ assert(_data);
+ memcpy(_data, array._data, _size * sizeof(T));
+ }
+
+ SciArray<T>& operator=(const SciArray<T> &array) {
+ if (this == &array)
+ return *this;
- ~SciArray() {
delete[] _data;
+ _type = array._type;
+ _size = array._size;
+ _actualSize = array._actualSize;
+ _data = new T[_actualSize];
+ assert(_data);
+ memcpy(_data, array._data, _size * sizeof(T));
+
+ return *this;
}
+ virtual ~SciArray() {
+ destroy();
+ }
+
+ virtual void destroy() {
+ delete[] _data;
+ _data = NULL;
+ _type = -1;
+ _size = _actualSize = 0;
+ }
+
void setType(byte type) {
if (_type >= 0)
error("SciArray::setType(): Type already set");
@@ -749,6 +780,9 @@
public:
SciString() : SciArray<char>() { setType(3); }
+ // We overload destroy to ensure the string type is 3 after destroying
+ void destroy() { _type = 3; }
+
Common::String toString();
void fromString(Common::String string);
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list