summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/object/objman.cpp16
-rw-r--r--src/object/objman.h4
-rw-r--r--src/object/robotmain.cpp6
3 files changed, 21 insertions, 5 deletions
diff --git a/src/object/objman.cpp b/src/object/objman.cpp
index 0471ebf..131d007 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;
@@ -386,3 +386,11 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, ObjectType
return object;
}
+void CObjectManager::Flush()
+{
+ for (int i = 0; i < MAX_OBJECTS; i++)
+ {
+ m_table[i] = nullptr;
+ }
+ m_usedCount = 0;
+}
diff --git a/src/object/objman.h b/src/object/objman.h
index 1d67468..390587b 100644
--- a/src/object/objman.h
+++ b/src/object/objman.h
@@ -45,9 +45,11 @@ public:
CObject* SearchInstance(int id);
//! Creates an object
CObject* CreateObject(Math::Vector pos, float angle, ObjectType type, float power = -1.f, float zoom = 1.f, float height = 0.f, bool trainer = false, bool toy = false, int option = 0);
+ //! Removes all objects
+ void Flush();
protected:
CObject* m_table[MAX_OBJECTS];
- int usedCount;
+ int m_usedCount;
};
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index 0852df0..308b172 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -1148,6 +1148,8 @@ void CRobotMain::ChangePhase(Phase phase)
iMan->Flush(CLASS_PHYSICS);
iMan->Flush(CLASS_BRAIN);
iMan->Flush(CLASS_PYRO);
+
+ CObjectManager::GetInstancePointer()->Flush();
Math::Point dim, pos;
@@ -3869,6 +3871,8 @@ void CRobotMain::ScenePerso()
iMan->Flush(CLASS_PHYSICS);
iMan->Flush(CLASS_BRAIN);
iMan->Flush(CLASS_PYRO);
+
+ CObjectManager::GetInstancePointer()->Flush();
m_dialog->SetSceneName("perso");
m_dialog->SetSceneRank(0);
@@ -6546,6 +6550,8 @@ void CRobotMain::ResetCreate()
iMan->Flush(CLASS_PHYSICS);
iMan->Flush(CLASS_BRAIN);
iMan->Flush(CLASS_PYRO);
+
+ CObjectManager::GetInstancePointer()->Flush();
m_camera->SetType(Gfx::CAM_TYPE_DIALOG);