diff options
author | krzys-h <krzys_h@interia.pl> | 2014-07-01 12:15:38 +0200 |
---|---|---|
committer | krzys-h <krzys_h@interia.pl> | 2014-07-01 12:16:32 +0200 |
commit | d9fee8b2adad613cf8c10d153cd5cd7b261b7863 (patch) | |
tree | f6b71cc2daa719c10c1ce31cf738e1c6ec934a73 /src/object/objman.cpp | |
parent | 0f2adf05fd2b2b38c2b84aa8d72b3fd756dcfcd4 (diff) | |
parent | 1835d2ae580525603308206f7b8e6b4552b3ca0f (diff) | |
download | colobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.tar.gz colobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.tar.bz2 colobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.zip |
Release 0.1.3-alpha
Diffstat (limited to 'src/object/objman.cpp')
-rw-r--r-- | src/object/objman.cpp | 65 |
1 files changed, 22 insertions, 43 deletions
diff --git a/src/object/objman.cpp b/src/object/objman.cpp index e4102b8..b0bac1a 100644 --- a/src/object/objman.cpp +++ b/src/object/objman.cpp @@ -30,7 +30,7 @@ CObjectManager::CObjectManager() { m_table[i] = nullptr; } - usedCount = 0; + m_usedCount = 0; } CObjectManager::~CObjectManager() @@ -39,16 +39,16 @@ CObjectManager::~CObjectManager() bool CObjectManager::AddInstance(CObject* instance) { - if (usedCount >= MAX_OBJECTS) return false; + if (m_usedCount >= MAX_OBJECTS) return false; m_table[instance->GetID()] = instance; - usedCount++; + m_usedCount++; return true; } bool CObjectManager::DeleteInstance(CObject* instance) { - for (int i = 0; i < usedCount; i++) + for (int i = 0; i < m_usedCount; i++) { if (m_table[i] == instance) m_table[i] = nullptr; @@ -63,10 +63,9 @@ CObject* CObjectManager::SearchInstance(int id) return m_table[id]; } -CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom, float height, - ObjectType type, float power, - bool trainer, bool toy, - int option) +CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, ObjectType type, + float power, float zoom, float height, + bool trainer, bool toy, int option) { CObject* object = nullptr; @@ -161,8 +160,7 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom, if ( type == OBJECT_BARRIER0 || type == OBJECT_BARRIER1 || type == OBJECT_BARRIER2 || - type == OBJECT_BARRIER3 || - type == OBJECT_BARRIER4 ) + type == OBJECT_BARRIER3 ) { object = new CObject(); object->CreateBarrier(pos, angle, height, type); @@ -193,26 +191,14 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom, type == OBJECT_TREE2 || type == OBJECT_TREE3 || type == OBJECT_TREE4 || - type == OBJECT_TREE5 || - type == OBJECT_TREE6 || - type == OBJECT_TREE7 || - type == OBJECT_TREE8 || - type == OBJECT_TREE9 ) + type == OBJECT_TREE5 ) { object = new CObject(); object->CreatePlant(pos, angle, height, type); } else - if ( type == OBJECT_MUSHROOM0 || - type == OBJECT_MUSHROOM1 || - type == OBJECT_MUSHROOM2 || - type == OBJECT_MUSHROOM3 || - type == OBJECT_MUSHROOM4 || - type == OBJECT_MUSHROOM5 || - type == OBJECT_MUSHROOM6 || - type == OBJECT_MUSHROOM7 || - type == OBJECT_MUSHROOM8 || - type == OBJECT_MUSHROOM9 ) + if ( type == OBJECT_MUSHROOM1 || + type == OBJECT_MUSHROOM2 ) { object = new CObject(); object->CreateMushroom(pos, angle, height, type); @@ -262,12 +248,7 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom, type == OBJECT_TEEN41 || type == OBJECT_TEEN42 || type == OBJECT_TEEN43 || - type == OBJECT_TEEN44 || - type == OBJECT_TEEN45 || - type == OBJECT_TEEN46 || - type == OBJECT_TEEN47 || - type == OBJECT_TEEN48 || - type == OBJECT_TEEN49 ) + type == OBJECT_TEEN44 ) { object = new CObject(); object->SetOption(option); @@ -277,13 +258,7 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom, if ( type == OBJECT_QUARTZ0 || type == OBJECT_QUARTZ1 || type == OBJECT_QUARTZ2 || - type == OBJECT_QUARTZ3 || - type == OBJECT_QUARTZ4 || - type == OBJECT_QUARTZ5 || - type == OBJECT_QUARTZ6 || - type == OBJECT_QUARTZ7 || - type == OBJECT_QUARTZ8 || - type == OBJECT_QUARTZ9 ) + type == OBJECT_QUARTZ3 ) { object = new CObject(); object->CreateQuartz(pos, angle, height, type); @@ -294,11 +269,7 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom, type == OBJECT_ROOT2 || type == OBJECT_ROOT3 || type == OBJECT_ROOT4 || - type == OBJECT_ROOT5 || - type == OBJECT_ROOT6 || - type == OBJECT_ROOT7 || - type == OBJECT_ROOT8 || - type == OBJECT_ROOT9 ) + type == OBJECT_ROOT5 ) { object = new CObject(); object->CreateRoot(pos, angle, height, type); @@ -387,3 +358,11 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom, return object; } +void CObjectManager::Flush() +{ + for (int i = 0; i < MAX_OBJECTS; i++) + { + m_table[i] = nullptr; + } + m_usedCount = 0; +} |