diff options
author | Paul Gilbert | 2016-11-07 07:36:52 -0500 |
---|---|---|
committer | Paul Gilbert | 2016-11-07 07:36:52 -0500 |
commit | f6593ce9c0db62d16af051f7ad98128cfe41bd2c (patch) | |
tree | 1c327839b58f17a8efedcacd65b60376467f149d | |
parent | 57cd02b04877d6a6dd78743b4baa5d2b28dcc69a (diff) | |
download | scummvm-rg350-f6593ce9c0db62d16af051f7ad98128cfe41bd2c.tar.gz scummvm-rg350-f6593ce9c0db62d16af051f7ad98128cfe41bd2c.tar.bz2 scummvm-rg350-f6593ce9c0db62d16af051f7ad98128cfe41bd2c.zip |
TITANIC: Simplify freeing class list on exit
-rw-r--r-- | engines/titanic/core/saveable_object.cpp | 10 | ||||
-rw-r--r-- | engines/titanic/core/saveable_object.h | 2 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_npc_script.cpp | 2 |
3 files changed, 3 insertions, 11 deletions
diff --git a/engines/titanic/core/saveable_object.cpp b/engines/titanic/core/saveable_object.cpp index b0009c3bc1..73b4bf861f 100644 --- a/engines/titanic/core/saveable_object.cpp +++ b/engines/titanic/core/saveable_object.cpp @@ -421,15 +421,14 @@ CSaveableObject *ClassDef::create() { /*------------------------------------------------------------------------*/ -CSaveableObject::ClassListMap *CSaveableObject::_classList = nullptr; +CSaveableObject::ClassListMap *CSaveableObject::_classList; CSaveableObject::ClassDefList *CSaveableObject::_classDefs; -CSaveableObject::VoidArray *CSaveableObject::_typesToFree; #define DEFFN(T) CSaveableObject *Function##T() { return new T(); } \ ClassDef *T::_type #define ADDFN(CHILD, PARENT) \ CHILD::_type = new TypeTemplate<CHILD>(#CHILD, PARENT::_type); \ - _typesToFree->push_back(CHILD::_type); \ + _classDefs->push_back(CHILD::_type); \ (*_classList)[#CHILD] = Function##CHILD DEFFN(CArm); @@ -1023,7 +1022,6 @@ DEFFN(CTimeEventInfo); void CSaveableObject::initClassList() { _classDefs = new ClassDefList(); _classList = new ClassListMap(); - _typesToFree = new VoidArray(); ADDFN(CArm, CCarry); ADDFN(CAuditoryCentre, CBrain); ADDFN(CBowlEar, CEar); @@ -1623,12 +1621,8 @@ void CSaveableObject::freeClassList() { for (i = _classDefs->begin(); i != _classDefs->end(); ++i) delete *i; - for (uint idx = 0; idx < _typesToFree->size(); ++idx) - delete (*_typesToFree)[idx]; - delete _classDefs; delete _classList; - delete _typesToFree; } CSaveableObject *CSaveableObject::createInstance(const Common::String &name) { diff --git a/engines/titanic/core/saveable_object.h b/engines/titanic/core/saveable_object.h index 0591f0930c..80525f1156 100644 --- a/engines/titanic/core/saveable_object.h +++ b/engines/titanic/core/saveable_object.h @@ -61,10 +61,8 @@ class CSaveableObject { private: typedef Common::List<ClassDef *> ClassDefList; typedef Common::HashMap<Common::String, CreateFunction> ClassListMap; - typedef Common::Array<void *> VoidArray; static ClassDefList *_classDefs; static ClassListMap *_classList; - static VoidArray *_typesToFree; public: /** * Sets up the list of saveable object classes diff --git a/engines/titanic/true_talk/tt_npc_script.cpp b/engines/titanic/true_talk/tt_npc_script.cpp index bfb97c8c37..ffa9d7f102 100644 --- a/engines/titanic/true_talk/tt_npc_script.cpp +++ b/engines/titanic/true_talk/tt_npc_script.cpp @@ -340,7 +340,7 @@ uint TTnpcScript::getRangeValue(uint id) { int index = (int)getRandomNumber(count) - 1; if (count > 1 && range->_values[index] == range->_priorIndex) { - for (int retry = 0; retry < 8 && index != range->_priorIndex; ++retry) + for (int retry = 0; retry < 8 && index != (int)range->_priorIndex; ++retry) index = (int)getRandomNumber(count) - 1; } |