[Scummvm-cvs-logs] SF.net SVN: scummvm:[54986] scummvm/trunk/engines/sci/engine
lskovlun at users.sourceforge.net
lskovlun at users.sourceforge.net
Tue Dec 21 16:36:28 CET 2010
Revision: 54986
http://scummvm.svn.sourceforge.net/scummvm/?rev=54986&view=rev
Author: lskovlun
Date: 2010-12-21 15:36:27 +0000 (Tue, 21 Dec 2010)
Log Message:
-----------
Make Object::_baseMethod a Common::Array. This is intended to clean up
the Object class, and it also plugs a leak.
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/object.cpp
scummvm/trunk/engines/sci/engine/object.h
Modified: scummvm/trunk/engines/sci/engine/object.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/object.cpp 2010-12-21 15:34:02 UTC (rev 54985)
+++ scummvm/trunk/engines/sci/engine/object.cpp 2010-12-21 15:36:27 UTC (rev 54986)
@@ -62,13 +62,15 @@
if (getSciVersion() <= SCI_VERSION_1_LATE) {
_variables.resize(READ_LE_UINT16(data + kOffsetSelectorCounter));
_baseVars = (const uint16 *)(_baseObj + _variables.size() * 2);
- _baseMethod = (const uint16 *)(data + READ_LE_UINT16(data + kOffsetFunctionArea));
- _methodCount = READ_LE_UINT16(_baseMethod - 1);
+ _methodCount = READ_LE_UINT16(data + READ_LE_UINT16(data + kOffsetFunctionArea) - 2);
+ _baseMethod = Common::Array<uint16>((const uint16 *)(data + READ_LE_UINT16(data + kOffsetFunctionArea)),
+ _methodCount*2+2);
} else if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1) {
_variables.resize(READ_SCI11ENDIAN_UINT16(data + 2));
_baseVars = (const uint16 *)(buf + READ_SCI11ENDIAN_UINT16(data + 4));
- _baseMethod = (const uint16 *)(buf + READ_SCI11ENDIAN_UINT16(data + 6));
- _methodCount = READ_SCI11ENDIAN_UINT16(_baseMethod);
+ _methodCount = READ_SCI11ENDIAN_UINT16(buf + READ_SCI11ENDIAN_UINT16(data + 6));
+ _baseMethod = Common::Array<uint16>((const uint16 *) (buf + READ_SCI11ENDIAN_UINT16(data + 6)),
+ _methodCount*2+3);
} else if (getSciVersion() == SCI_VERSION_3) {
initSelectorsSci3(buf);
}
@@ -220,9 +222,8 @@
}
_variables.resize(properties);
- uint16 *methodIds = (uint16*) malloc(sizeof(uint16)*2*methods);
uint16 *propertyIds = (uint16*) malloc(sizeof(uint16)*properties);
- uint16 *methodOffsets = (uint16*) malloc(sizeof(uint16)*2*methods);
+// uint16 *methodOffsets = (uint16*) malloc(sizeof(uint16)*2*methods);
uint16 *propertyOffsets = (uint16*) malloc(sizeof(uint16)*properties);
int propertyCounter = 0;
int methodCounter = 0;
@@ -246,9 +247,9 @@
propertyOffsets[propertyCounter] = (seeker + bit * 2) - buf;
++propertyCounter;
} else if (value != 0xffff) { // Method
- methodIds[methodCounter * 2] = groupBaseId + bit;
- methodIds[methodCounter * 2 + 1] = value + READ_SCI11ENDIAN_UINT32(buf);
- methodOffsets[methodCounter] = (seeker + bit * 2) - buf;
+ _baseMethod.push_back(groupBaseId + bit);
+ _baseMethod.push_back(value + READ_SCI11ENDIAN_UINT32(buf));
+// methodOffsets[methodCounter] = (seeker + bit * 2) - buf;
++methodCounter;
} else /* Undefined selector */ {};
@@ -260,7 +261,6 @@
_superClassPosSci3 = make_reg(0, READ_SCI11ENDIAN_UINT16(_baseObj + 8));
_baseVars = propertyIds;
- _baseMethod = methodIds;
_methodCount = methods;
_propertyOffsetsSci3 = propertyOffsets;
//_methodOffsetsSci3 = methodOffsets;
Modified: scummvm/trunk/engines/sci/engine/object.h
===================================================================
--- scummvm/trunk/engines/sci/engine/object.h 2010-12-21 15:34:02 UTC (rev 54985)
+++ scummvm/trunk/engines/sci/engine/object.h 2010-12-21 15:36:27 UTC (rev 54986)
@@ -65,12 +65,11 @@
_flags = 0;
_baseObj = 0;
_baseVars = 0;
- _baseMethod = 0;
_methodCount = 0;
_propertyOffsetsSci3 = 0;
}
- ~Object() { }
+ ~Object() { free(_propertyOffsetsSci3); }
reg_t getSpeciesSelector() const {
if (getSciVersion() <= SCI_VERSION_2_1)
@@ -162,14 +161,14 @@
uint16 offset = (getSciVersion() < SCI_VERSION_1_1) ? _methodCount + 1 + i : i * 2 + 2;
if (getSciVersion() == SCI_VERSION_3)
offset--;
- return make_reg(_pos.segment, READ_SCI11ENDIAN_UINT16(_baseMethod + offset));
+ return make_reg(_pos.segment, _baseMethod[offset]);
}
Selector getFuncSelector(uint16 i) const {
uint16 offset = (getSciVersion() < SCI_VERSION_1_1) ? i : i * 2 + 1;
if (getSciVersion() == SCI_VERSION_3)
offset--;
- return READ_SCI11ENDIAN_UINT16(_baseMethod + offset);
+ return _baseMethod[offset];
}
/**
@@ -212,7 +211,7 @@
void cloneFromObject(const Object *obj) {
_baseObj = obj ? obj->_baseObj : NULL;
- _baseMethod = obj ? obj->_baseMethod : NULL;
+ _baseMethod = obj ? obj->_baseMethod : Common::Array<uint16>();
_baseVars = obj ? obj->_baseVars : NULL;
}
@@ -231,8 +230,8 @@
const byte *_baseObj; /**< base + object offset within base */
const uint16 *_baseVars; /**< Pointer to the varselector area for this object */
- const uint16 *_baseMethod; /**< Pointer to the method selector area for this object */
- const uint16 *_propertyOffsetsSci3;
+ Common::Array<uint16> _baseMethod; /**< Pointer to the method selector area for this object */
+ uint16 *_propertyOffsetsSci3; /**< This is used to enable relocation of property valuesa in SCI3 */
Common::Array<reg_t> _variables;
uint16 _methodCount;
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