mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-04 01:46:42 +00:00
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
This commit is contained in:
parent
eb2e457817
commit
7d131627fe
@ -1299,6 +1299,7 @@ void SegManager::freeArray(reg_t addr) {
|
||||
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 @@ void SegManager::freeString(reg_t addr) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
~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) {
|
||||
@ -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);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user