diff options
author | Matthew Hoops | 2009-12-31 05:11:58 +0000 |
---|---|---|
committer | Matthew Hoops | 2009-12-31 05:11:58 +0000 |
commit | 7d131627fe6296ea4ce46db62900e4800b6b6816 (patch) | |
tree | 9391e8a616819ffc2b0bbb844b9abfdf86cf5c0e /engines/sci/engine/segment.h | |
parent | eb2e45781749c31b2bd637fb40b6e0315d2601b6 (diff) | |
download | scummvm-rg350-7d131627fe6296ea4ce46db62900e4800b6b6816.tar.gz scummvm-rg350-7d131627fe6296ea4ce46db62900e4800b6b6816.tar.bz2 scummvm-rg350-7d131627fe6296ea4ce46db62900e4800b6b6816.zip |
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).
svn-id: r46789
Diffstat (limited to 'engines/sci/engine/segment.h')
-rw-r--r-- | engines/sci/engine/segment.h | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/engines/sci/engine/segment.h b/engines/sci/engine/segment.h index a57c9766ae..d8cdd91da8 100644 --- a/engines/sci/engine/segment.h +++ b/engines/sci/engine/segment.h @@ -675,9 +675,40 @@ public: _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; + + 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; + } - ~SciArray() { + virtual ~SciArray() { + destroy(); + } + + virtual void destroy() { delete[] _data; + _data = NULL; + _type = -1; + _size = _actualSize = 0; } void setType(byte type) { @@ -749,6 +780,9 @@ class SciString : public SciArray<char> { 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); }; |