mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 05:38:56 +00:00
TITANIC: Simplify freeing class list on exit
This commit is contained in:
parent
57cd02b048
commit
f6593ce9c0
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user