summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Dziwiński <piotr.dziwinski@nsn.com>2013-02-16 22:37:43 +0100
committerPiotr Dziwiński <piotr.dziwinski@nsn.com>2013-02-17 12:11:56 +0100
commit001d37b257b126dd6ef1dced70f94ff3d2806d28 (patch)
tree1025979c635c899f196d606f7d74170e33ef4f3a
parent45040318b026f8864d244e39f1703685ad688470 (diff)
downloadcolobot-001d37b257b126dd6ef1dced70f94ff3d2806d28.tar.gz
colobot-001d37b257b126dd6ef1dced70f94ff3d2806d28.tar.bz2
colobot-001d37b257b126dd6ef1dced70f94ff3d2806d28.zip
CInstanceManager refactoring
* removed classes managed by CInstanceManager except for CObject, CPyro, CBrain and CPhysics because of dependencies * refactored instance searching to use existing singleton instances of CApplication, CEngine and CRobotMain and calling their getter functions
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/CBot/CBotDll.h6
-rw-r--r--src/CBot/CBotToken.cpp2
-rw-r--r--src/CBot/ClassFILE.cpp2
-rw-r--r--src/app/app.cpp18
-rw-r--r--src/app/app.h10
-rw-r--r--src/common/event.cpp7
-rw-r--r--src/common/event.h5
-rw-r--r--src/common/iman.cpp15
-rw-r--r--src/common/iman.h67
-rw-r--r--src/common/logger.cpp2
-rw-r--r--src/common/profile.cpp2
-rw-r--r--src/common/singleton.h77
-rw-r--r--src/graphics/engine/camera.cpp26
-rw-r--r--src/graphics/engine/camera.h6
-rw-r--r--src/graphics/engine/cloud.cpp19
-rw-r--r--src/graphics/engine/cloud.h11
-rw-r--r--src/graphics/engine/engine.cpp89
-rw-r--r--src/graphics/engine/engine.h31
-rw-r--r--src/graphics/engine/lightman.cpp9
-rw-r--r--src/graphics/engine/lightman.h3
-rw-r--r--src/graphics/engine/lightning.cpp22
-rw-r--r--src/graphics/engine/lightning.h4
-rw-r--r--src/graphics/engine/modelfile.cpp1
-rw-r--r--src/graphics/engine/modelmanager.cpp2
-rw-r--r--src/graphics/engine/particle.cpp29
-rw-r--r--src/graphics/engine/particle.h4
-rw-r--r--src/graphics/engine/planet.cpp8
-rw-r--r--src/graphics/engine/planet.h5
-rw-r--r--src/graphics/engine/pyro.cpp34
-rw-r--r--src/graphics/engine/pyro.h4
-rw-r--r--src/graphics/engine/terrain.cpp13
-rw-r--r--src/graphics/engine/terrain.h6
-rw-r--r--src/graphics/engine/text.cpp11
-rw-r--r--src/graphics/engine/text.h6
-rw-r--r--src/graphics/engine/water.cpp28
-rw-r--r--src/graphics/engine/water.h8
-rw-r--r--src/object/auto/auto.cpp54
-rw-r--r--src/object/auto/auto.h7
-rw-r--r--src/object/auto/autobase.cpp14
-rw-r--r--src/object/auto/autobase.h2
-rw-r--r--src/object/auto/autoconvert.cpp8
-rw-r--r--src/object/auto/autoconvert.h2
-rw-r--r--src/object/auto/autoderrick.cpp9
-rw-r--r--src/object/auto/autoderrick.h2
-rw-r--r--src/object/auto/autodestroyer.cpp7
-rw-r--r--src/object/auto/autodestroyer.h2
-rw-r--r--src/object/auto/autoegg.cpp11
-rw-r--r--src/object/auto/autoegg.h2
-rw-r--r--src/object/auto/autoenergy.cpp9
-rw-r--r--src/object/auto/autoenergy.h2
-rw-r--r--src/object/auto/autofactory.cpp10
-rw-r--r--src/object/auto/autofactory.h2
-rw-r--r--src/object/auto/autoflag.cpp3
-rw-r--r--src/object/auto/autoflag.h2
-rw-r--r--src/object/auto/autohuston.cpp3
-rw-r--r--src/object/auto/autohuston.h2
-rw-r--r--src/object/auto/autoinfo.cpp3
-rw-r--r--src/object/auto/autoinfo.h2
-rw-r--r--src/object/auto/autojostle.cpp3
-rw-r--r--src/object/auto/autojostle.h2
-rw-r--r--src/object/auto/autokid.cpp3
-rw-r--r--src/object/auto/autokid.h2
-rw-r--r--src/object/auto/autolabo.cpp11
-rw-r--r--src/object/auto/autolabo.h2
-rw-r--r--src/object/auto/automush.cpp4
-rw-r--r--src/object/auto/automush.h2
-rw-r--r--src/object/auto/autonest.cpp7
-rw-r--r--src/object/auto/autonest.h2
-rw-r--r--src/object/auto/autonuclear.cpp8
-rw-r--r--src/object/auto/autonuclear.h2
-rw-r--r--src/object/auto/autopara.cpp6
-rw-r--r--src/object/auto/autopara.h2
-rw-r--r--src/object/auto/autoportico.cpp3
-rw-r--r--src/object/auto/autoportico.h2
-rw-r--r--src/object/auto/autoradar.cpp5
-rw-r--r--src/object/auto/autoradar.h2
-rw-r--r--src/object/auto/autorepair.cpp6
-rw-r--r--src/object/auto/autorepair.h2
-rw-r--r--src/object/auto/autoresearch.cpp9
-rw-r--r--src/object/auto/autoresearch.h2
-rw-r--r--src/object/auto/autoroot.cpp4
-rw-r--r--src/object/auto/autoroot.h2
-rw-r--r--src/object/auto/autosafe.cpp7
-rw-r--r--src/object/auto/autosafe.h2
-rw-r--r--src/object/auto/autostation.cpp6
-rw-r--r--src/object/auto/autostation.h2
-rw-r--r--src/object/auto/autotower.cpp7
-rw-r--r--src/object/auto/autotower.h2
-rw-r--r--src/object/brain.cpp83
-rw-r--r--src/object/brain.h4
-rw-r--r--src/object/mainmovie.cpp15
-rw-r--r--src/object/mainmovie.h16
-rw-r--r--src/object/motion/motion.cpp23
-rw-r--r--src/object/motion/motion.h8
-rw-r--r--src/object/motion/motionant.cpp3
-rw-r--r--src/object/motion/motionant.h2
-rw-r--r--src/object/motion/motionbee.cpp3
-rw-r--r--src/object/motion/motionbee.h2
-rw-r--r--src/object/motion/motionhuman.cpp3
-rw-r--r--src/object/motion/motionhuman.h2
-rw-r--r--src/object/motion/motionmother.cpp3
-rw-r--r--src/object/motion/motionmother.h2
-rw-r--r--src/object/motion/motionspider.cpp3
-rw-r--r--src/object/motion/motionspider.h2
-rw-r--r--src/object/motion/motiontoto.cpp3
-rw-r--r--src/object/motion/motiontoto.h2
-rw-r--r--src/object/motion/motionvehicle.cpp5
-rw-r--r--src/object/motion/motionvehicle.h2
-rw-r--r--src/object/motion/motionworm.cpp3
-rw-r--r--src/object/motion/motionworm.h2
-rw-r--r--src/object/object.cpp136
-rw-r--r--src/object/object.h7
-rw-r--r--src/object/robotmain.cpp227
-rw-r--r--src/object/robotmain.h20
-rw-r--r--src/object/task/task.cpp31
-rw-r--r--src/object/task/task.h5
-rw-r--r--src/object/task/taskadvance.cpp5
-rw-r--r--src/object/task/taskadvance.h3
-rw-r--r--src/object/task/taskbuild.cpp25
-rw-r--r--src/object/task/taskbuild.h2
-rw-r--r--src/object/task/taskfire.cpp6
-rw-r--r--src/object/task/taskfire.h2
-rw-r--r--src/object/task/taskfireant.cpp7
-rw-r--r--src/object/task/taskfireant.h2
-rw-r--r--src/object/task/taskflag.cpp26
-rw-r--r--src/object/task/taskflag.h3
-rw-r--r--src/object/task/taskgoto.cpp38
-rw-r--r--src/object/task/taskgoto.h3
-rw-r--r--src/object/task/taskgungoal.cpp4
-rw-r--r--src/object/task/taskgungoal.h2
-rw-r--r--src/object/task/taskinfo.cpp10
-rw-r--r--src/object/task/taskinfo.h2
-rw-r--r--src/object/task/taskmanager.cpp48
-rw-r--r--src/object/task/taskmanager.h7
-rw-r--r--src/object/task/taskmanip.cpp30
-rw-r--r--src/object/task/taskmanip.h2
-rw-r--r--src/object/task/taskpen.cpp8
-rw-r--r--src/object/task/taskpen.h2
-rw-r--r--src/object/task/taskrecover.cpp17
-rw-r--r--src/object/task/taskrecover.h3
-rw-r--r--src/object/task/taskreset.cpp9
-rw-r--r--src/object/task/taskreset.h2
-rw-r--r--src/object/task/tasksearch.cpp16
-rw-r--r--src/object/task/tasksearch.h2
-rw-r--r--src/object/task/taskshield.cpp12
-rw-r--r--src/object/task/taskshield.h3
-rw-r--r--src/object/task/taskspiderexplo.cpp8
-rw-r--r--src/object/task/taskspiderexplo.h2
-rw-r--r--src/object/task/tasktake.cpp22
-rw-r--r--src/object/task/tasktake.h2
-rw-r--r--src/object/task/taskterraform.cpp19
-rw-r--r--src/object/task/taskterraform.h3
-rw-r--r--src/object/task/taskturn.cpp4
-rw-r--r--src/object/task/taskturn.h2
-rw-r--r--src/object/task/taskwait.cpp4
-rw-r--r--src/object/task/taskwait.h2
-rw-r--r--src/physics/physics.cpp51
-rw-r--r--src/physics/physics.h9
-rw-r--r--src/script/script.cpp93
-rw-r--r--src/script/script.h5
-rw-r--r--src/sound/oalsound/alsound.cpp10
-rw-r--r--src/sound/oalsound/alsound.h1
-rw-r--r--src/sound/oalsound/buffer.cpp1
-rw-r--r--src/sound/oalsound/channel.cpp3
-rw-r--r--src/sound/sound.h8
-rw-r--r--src/ui/button.cpp1
-rw-r--r--src/ui/button.h38
-rw-r--r--src/ui/check.cpp1
-rw-r--r--src/ui/check.h25
-rw-r--r--src/ui/color.cpp2
-rw-r--r--src/ui/color.h41
-rw-r--r--src/ui/compass.cpp3
-rw-r--r--src/ui/compass.h31
-rw-r--r--src/ui/control.cpp18
-rw-r--r--src/ui/control.h209
-rw-r--r--src/ui/displayinfo.cpp43
-rw-r--r--src/ui/displayinfo.h120
-rw-r--r--src/ui/displaytext.cpp33
-rw-r--r--src/ui/displaytext.h11
-rw-r--r--src/ui/edit.cpp4
-rw-r--r--src/ui/edit.h1
-rw-r--r--src/ui/editvalue.cpp7
-rw-r--r--src/ui/editvalue.h1
-rw-r--r--src/ui/gauge.cpp3
-rw-r--r--src/ui/gauge.h1
-rw-r--r--src/ui/group.cpp4
-rw-r--r--src/ui/group.h1
-rw-r--r--src/ui/image.cpp10
-rw-r--r--src/ui/image.h1
-rw-r--r--src/ui/interface.cpp44
-rw-r--r--src/ui/interface.h6
-rw-r--r--src/ui/key.cpp1
-rw-r--r--src/ui/key.h1
-rw-r--r--src/ui/label.cpp2
-rw-r--r--src/ui/list.cpp2
-rw-r--r--src/ui/maindialog.cpp31
-rw-r--r--src/ui/maindialog.h14
-rw-r--r--src/ui/mainmap.cpp13
-rw-r--r--src/ui/mainmap.h5
-rw-r--r--src/ui/mainshort.cpp22
-rw-r--r--src/ui/mainshort.h7
-rw-r--r--src/ui/map.cpp8
-rw-r--r--src/ui/map.h7
-rw-r--r--src/ui/scroll.cpp4
-rw-r--r--src/ui/scroll.h3
-rw-r--r--src/ui/shortcut.cpp4
-rw-r--r--src/ui/slider.cpp4
-rw-r--r--src/ui/studio.cpp29
-rw-r--r--src/ui/studio.h122
-rw-r--r--src/ui/target.cpp7
-rw-r--r--src/ui/target.h11
-rw-r--r--src/ui/window.cpp15
-rw-r--r--src/ui/window.h6
-rw-r--r--test/cbot/CBot_console/CBotConsole.h5
-rw-r--r--test/cbot/CBot_console/CBotDoc.h4
-rw-r--r--test/envs/opengl/CMakeLists.txt13
-rw-r--r--test/envs/opengl/light_test.cpp6
-rw-r--r--test/envs/opengl/model_test.cpp3
-rw-r--r--test/envs/opengl/texture_test.cpp2
-rw-r--r--test/envs/opengl/transform_test.cpp5
-rw-r--r--test/unit/math/geometry_test.cpp2
-rw-r--r--test/unit/math/matrix_test.cpp2
-rw-r--r--test/unit/math/vector_test.cpp2
-rw-r--r--test/unit/ui/edit_test.cpp9
-rw-r--r--test/unit/ui/mocks/text_mock.h3
-rw-r--r--test/unit/ui/stubs/app_stub.cpp14
-rw-r--r--test/unit/ui/stubs/engine_stub.cpp16
-rw-r--r--test/unit/ui/stubs/particle_stub.cpp2
-rw-r--r--test/unit/ui/stubs/robotmain_stub.cpp2
230 files changed, 1569 insertions, 1536 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ec457bd..2e25826 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -150,7 +150,7 @@ if(NOT ${ASSERTS})
endif()
if(${TESTS})
- add_definitions(-DTEST_VIRTUAL=virtual)
+ add_definitions(-DTESTS -DTEST_VIRTUAL=virtual)
else()
add_definitions(-DTEST_VIRTUAL=)
endif()
diff --git a/src/CBot/CBotDll.h b/src/CBot/CBotDll.h
index 7af63ca..b401528 100644
--- a/src/CBot/CBotDll.h
+++ b/src/CBot/CBotDll.h
@@ -15,14 +15,13 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
////////////////////////////////////////////////////////////////////////
-#pragma once
-#ifndef _CBOTDLL_H_
-#define _CBOTDLL_H_
/**
* \file CBotDll.h
* \brief Library for interpretation of CBOT language
*/
+#pragma once
+
#include <stdio.h>
#include "resource.h"
#include <map>
@@ -1114,5 +1113,4 @@ bool rDoGoto( CBotVar* pVar, CBotVar* pResult, int& exception )
}
#endif
-#endif //_CBOTDLL_H_
diff --git a/src/CBot/CBotToken.cpp b/src/CBot/CBotToken.cpp
index c6e65e7..f03ca91 100644
--- a/src/CBot/CBotToken.cpp
+++ b/src/CBot/CBotToken.cpp
@@ -15,8 +15,6 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-//CBotToken.cpp
-
//////////////////////////////////////////////////////////////////
// Managing Tokens
// the text of a program is first transformed
diff --git a/src/CBot/ClassFILE.cpp b/src/CBot/ClassFILE.cpp
index e5bc260..b0f7977 100644
--- a/src/CBot/ClassFILE.cpp
+++ b/src/CBot/ClassFILE.cpp
@@ -14,8 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// ClassFile.cpp
-//
// definition of methods for class FILE
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 9886b24..ae5ac88 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -46,7 +46,7 @@
#endif
-template<> CApplication* CSingleton<CApplication>::mInstance = nullptr;
+template<> CApplication* CSingleton<CApplication>::m_instance = nullptr;
//! Static buffer for putenv locale
static char S_LANGUAGE[50] = { 0 };
@@ -94,7 +94,7 @@ CApplication::CApplication()
{
m_private = new ApplicationPrivate();
m_iMan = new CInstanceManager();
- m_eventQueue = new CEventQueue(m_iMan);
+ m_eventQueue = new CEventQueue();
m_profile = new CProfile();
m_engine = nullptr;
@@ -187,6 +187,16 @@ CApplication::~CApplication()
}
}
+CEventQueue* CApplication::GetEventQueue()
+{
+ return m_eventQueue;
+}
+
+CSoundInterface* CApplication::GetSound()
+{
+ return m_sound;
+}
+
ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
{
bool waitDataDir = false;
@@ -410,7 +420,7 @@ bool CApplication::Create()
}
// Create the 3D engine
- m_engine = new Gfx::CEngine(m_iMan, this);
+ m_engine = new Gfx::CEngine(this);
m_engine->SetDevice(m_device);
@@ -425,7 +435,7 @@ bool CApplication::Create()
m_modelManager = new Gfx::CModelManager(m_engine);
// Create the robot application.
- m_robotMain = new CRobotMain(m_iMan, this);
+ m_robotMain = new CRobotMain(this);
m_robotMain->ChangePhase(PHASE_WELCOME1);
diff --git a/src/app/app.h b/src/app/app.h
index 4aa97ce..f3f5601 100644
--- a/src/app/app.h
+++ b/src/app/app.h
@@ -194,6 +194,11 @@ public:
//! Destructor
~CApplication();
+ //! Returns the application's event queue
+ CEventQueue* GetEventQueue();
+ //! Returns the sound subsystem
+ CSoundInterface* GetSound();
+
public:
//! Parses commandline arguments
ParseArgsStatus ParseArguments(int argc, char *argv[]);
@@ -363,10 +368,11 @@ protected:
void UpdatePerformanceCountersData();
protected:
- //! Instance manager
- CInstanceManager* m_iMan;
//! Private (SDL-dependent data)
ApplicationPrivate* m_private;
+ //! Instance manager
+ // TODO: to be removed
+ CInstanceManager* m_iMan;
//! Global event queue
CEventQueue* m_eventQueue;
//! Graphics engine
diff --git a/src/common/event.cpp b/src/common/event.cpp
index b078dc5..ff3fbc7 100644
--- a/src/common/event.cpp
+++ b/src/common/event.cpp
@@ -17,12 +17,12 @@
#include "common/event.h"
-#include "common/iman.h"
#include "common/logger.h"
static EventType g_uniqueEventType = EVENT_USER;
+
EventType GetUniqueEventType()
{
int i = static_cast<int>(g_uniqueEventType+1);
@@ -32,11 +32,8 @@ EventType GetUniqueEventType()
-CEventQueue::CEventQueue(CInstanceManager* iMan)
+CEventQueue::CEventQueue()
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_EVENT, this);
-
Flush();
}
diff --git a/src/common/event.h b/src/common/event.h
index cba167e..ad493e7 100644
--- a/src/common/event.h
+++ b/src/common/event.h
@@ -27,8 +27,6 @@
#include "math/point.h"
#include "math/vector.h"
-class CInstanceManager;
-
/**
\enum EventType
@@ -762,7 +760,7 @@ public:
public:
//! Object's constructor
- CEventQueue(CInstanceManager* iMan);
+ CEventQueue();
//! Object's destructor
~CEventQueue();
@@ -774,7 +772,6 @@ public:
bool GetEvent(Event &event);
protected:
- CInstanceManager* m_iMan;
Event m_fifo[MAX_EVENT_QUEUE];
int m_head;
int m_tail;
diff --git a/src/common/iman.cpp b/src/common/iman.cpp
index 6a0a9eb..e1400fd 100644
--- a/src/common/iman.cpp
+++ b/src/common/iman.cpp
@@ -20,22 +20,9 @@
#include <cassert>
-template<> CInstanceManager* CSingleton<CInstanceManager>::mInstance = nullptr;
+template<> CInstanceManager* CSingleton<CInstanceManager>::m_instance = nullptr;
-CInstanceManager& CInstanceManager::GetInstance()
-{
- assert(mInstance);
- return *mInstance;
-}
-
-
-CInstanceManager* CInstanceManager::GetInstancePointer()
-{
- assert(mInstance);
- return mInstance;
-}
-
CInstanceManager::CInstanceManager()
{
for (int i = 0; i < CLASS_MAX; i++)
diff --git a/src/common/iman.h b/src/common/iman.h
index 53caed7..faabd0c 100644
--- a/src/common/iman.h
+++ b/src/common/iman.h
@@ -30,67 +30,23 @@
* \brief Type of class managed by CInstanceManager
*/
-// TODO: remove unnecessary, refactor to singletons, move to CRobotMain, keep others?
-
+/*
+ * TODO: Non-unique classes have already been removed.
+ * The other class instances along with CInstanceManager will be removed in due course.
+ */
enum ManagedClassType
{
- //! CEventQueue
- CLASS_EVENT = 1,
- //! Ui::CInterface
- CLASS_INTERFACE = 2,
- //! CRobotMain
- CLASS_MAIN = 3,
- //! Gfx::CEngine
- CLASS_ENGINE = 4,
- //! Gfx::CTerrain
- CLASS_TERRAIN = 5,
//! CObject
- CLASS_OBJECT = 6,
+ CLASS_OBJECT = 0,
//! CPhysics
- CLASS_PHYSICS = 7,
+ CLASS_PHYSICS = 1,
//! CBrain
- CLASS_BRAIN = 8,
- //! Gfx::CCamera
- CLASS_CAMERA = 9,
- //! Gfx::CLightManager
- CLASS_LIGHT = 10,
- //! Gfx::CParticle
- CLASS_PARTICULE = 11,
- //! CAuto; TODO: remove (unused)
- CLASS_AUTO = 12,
- //! Ui::CDisplayText
- CLASS_DISPLAYTEXT = 13,
+ CLASS_BRAIN = 2,
//! Gfx::CPyro
- CLASS_PYRO = 14,
- //! Ui::CScript; TODO: remove (unused)
- CLASS_SCRIPT = 15,
- //! Gfx::CText
- CLASS_TEXT = 16,
- //! Ui::CStudio, Ui::CDisplayText; TODO: remove (unused)
- CLASS_STUDIO = 17,
- //! Gfx::CWater
- CLASS_WATER = 18,
- //! Gfx::CCloud; TODO: remove (unused)
- CLASS_CLOUD = 19,
- //! CMotion; TODO: remove (unused)
- CLASS_MOTION = 20,
- //! CSoundInterface
- CLASS_SOUND = 21,
- //! Gfx::CPlanet
- CLASS_PLANET = 22,
- //! CTaskManager; TODO: remove (unused)
- CLASS_TASKMANAGER = 23,
- //! Ui::CMainDialog; TODO: remove (unused)
- CLASS_DIALOG = 24,
- //! Ui::CMainMap; TODO: remove (unused)
- CLASS_MAP = 25,
- //! Ui::CMainShort, CMainMovie; TODO: remove (unused)
- CLASS_SHORT = 26,
- //! Gfx::CLightning; TODO: remove (unused)
- CLASS_BLITZ = 27,
+ CLASS_PYRO = 3,
//! Maximum (number of managed classes)
- CLASS_MAX = 30
+ CLASS_MAX = 4
};
@@ -116,7 +72,7 @@ class CInstanceManager : public CSingleton<CInstanceManager>
{
public:
CInstanceManager();
- ~CInstanceManager();
+ virtual ~CInstanceManager();
//! Remove all managed instances
void Flush();
@@ -129,9 +85,6 @@ public:
//! Seeks a class instance of given type
void* SearchInstance(ManagedClassType classType, int rank=0);
- static CInstanceManager& GetInstance();
- static CInstanceManager* GetInstancePointer();
-
protected:
//! Fills holes in instance table
void Compress(ManagedClassType classType);
diff --git a/src/common/logger.cpp b/src/common/logger.cpp
index 5a78433..3ec9746 100644
--- a/src/common/logger.cpp
+++ b/src/common/logger.cpp
@@ -20,7 +20,7 @@
#include <stdio.h>
-template<> CLogger* CSingleton<CLogger>::mInstance = nullptr;
+template<> CLogger* CSingleton<CLogger>::m_instance = nullptr;
CLogger::CLogger()
diff --git a/src/common/profile.cpp b/src/common/profile.cpp
index 5432489..18cc187 100644
--- a/src/common/profile.cpp
+++ b/src/common/profile.cpp
@@ -25,7 +25,7 @@
#include <boost/regex.hpp>
-template<> CProfile* CSingleton<CProfile>::mInstance = nullptr;
+template<> CProfile* CSingleton<CProfile>::m_instance = nullptr;
namespace bp = boost::property_tree;
diff --git a/src/common/singleton.h b/src/common/singleton.h
index c1b28d9..25e1648 100644
--- a/src/common/singleton.h
+++ b/src/common/singleton.h
@@ -26,34 +26,51 @@
template<typename T> class CSingleton
{
- protected:
- static T* mInstance;
-
- public:
- static T& GetInstance() {
- assert(mInstance != nullptr);
- return *mInstance;
- }
-
- static T* GetInstancePointer() {
- assert(mInstance != nullptr);
- return mInstance;
- }
-
- static bool IsCreated() {
- return mInstance != nullptr;
- }
-
- CSingleton() {
- assert(mInstance == nullptr);
- mInstance = static_cast<T *>(this);
- }
-
- virtual ~CSingleton() {
- mInstance = nullptr;
- }
-
- private:
- CSingleton& operator=(const CSingleton<T> &);
- CSingleton(const CSingleton<T> &);
+protected:
+ static T* m_instance;
+
+public:
+ static T& GetInstance()
+ {
+ assert(m_instance != nullptr);
+ return *m_instance;
+ }
+
+ static T* GetInstancePointer()
+ {
+ assert(m_instance != nullptr);
+ return m_instance;
+ }
+
+ static bool IsCreated()
+ {
+ return m_instance != nullptr;
+ }
+
+ CSingleton()
+ {
+ assert(m_instance == nullptr);
+ m_instance = static_cast<T *>(this);
+ }
+
+ virtual ~CSingleton()
+ {
+ m_instance = nullptr;
+ }
+
+ #ifdef TESTS
+ static void ReplaceInstance(T* newInstance)
+ {
+ assert(newInstance != nullptr);
+
+ if (m_instance != nullptr)
+ delete m_instance;
+
+ m_instance = newInstance;
+ }
+ #endif
+
+private:
+ CSingleton& operator=(const CSingleton<T> &);
+ CSingleton(const CSingleton<T> &);
};
diff --git a/src/graphics/engine/camera.cpp b/src/graphics/engine/camera.cpp
index 8026302..f65a59a 100644
--- a/src/graphics/engine/camera.cpp
+++ b/src/graphics/engine/camera.cpp
@@ -30,6 +30,7 @@
#include "math/geometry.h"
#include "object/object.h"
+#include "object/robotmain.h"
#include "physics/physics.h"
@@ -54,14 +55,13 @@ void SetTransparency(CObject* obj, float value)
-CCamera::CCamera(CInstanceManager* iMan)
+CCamera::CCamera()
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_CAMERA, this);
+ m_engine = CEngine::GetInstancePointer();
+ m_water = m_engine->GetWater();
- m_engine = static_cast<CEngine*> ( m_iMan->SearchInstance(CLASS_ENGINE) );
- m_terrain = static_cast<CTerrain*>( m_iMan->SearchInstance(CLASS_TERRAIN) );
- m_water = static_cast<CWater*> ( m_iMan->SearchInstance(CLASS_WATER) );
+ m_main = CRobotMain::GetInstancePointer();
+ m_terrain = m_main->GetTerrain();
m_type = CAM_TYPE_FREE;
m_smooth = CAM_SMOOTH_NORM;
@@ -227,11 +227,13 @@ void CCamera::SetType(CameraType type)
m_remotePan = 0.0f;
m_remoteZoom = 0.0f;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
if ( (m_type == CAM_TYPE_BACK) && m_transparency )
{
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>( m_iMan->SearchInstance(CLASS_OBJECT, i) );
+ CObject* obj = static_cast<CObject*>( iMan->SearchInstance(CLASS_OBJECT, i) );
if (obj == NULL)
break;
@@ -881,9 +883,11 @@ bool CCamera::IsCollisionBack(Math::Vector &eye, Math::Vector lookat)
m_transparency = false;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0 ;i < 1000000; i++)
{
- CObject *obj = static_cast<CObject*>( m_iMan->SearchInstance(CLASS_OBJECT, i) );
+ CObject *obj = static_cast<CObject*>( iMan->SearchInstance(CLASS_OBJECT, i) );
if (obj == NULL) break;
if (obj->GetTruck()) continue; // battery or cargo?
@@ -958,9 +962,11 @@ bool CCamera::IsCollisionBack(Math::Vector &eye, Math::Vector lookat)
bool CCamera::IsCollisionFix(Math::Vector &eye, Math::Vector lookat)
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject *obj = static_cast<CObject*>( m_iMan->SearchInstance(CLASS_OBJECT, i) );
+ CObject *obj = static_cast<CObject*>( iMan->SearchInstance(CLASS_OBJECT, i) );
if (obj == NULL) break;
if (obj == m_cameraObj) continue;
@@ -1650,7 +1656,7 @@ Math::Vector CCamera::ExcludeObject(Math::Vector eye, Math::Vector lookat,
/*
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>( m_iMan->SearchInstance(CLASS_OBJECT, i) );
+ CObject* obj = static_cast<CObject*>( iMan->SearchInstance(CLASS_OBJECT, i) );
if (obj == NULL)
break;
diff --git a/src/graphics/engine/camera.h b/src/graphics/engine/camera.h
index 20d252d..0ffc2c2 100644
--- a/src/graphics/engine/camera.h
+++ b/src/graphics/engine/camera.h
@@ -28,8 +28,8 @@
#include "graphics/engine/engine.h"
-class CInstanceManager;
class CObject;
+class CRobotMain;
// Graphics module namespace
@@ -130,7 +130,7 @@ enum CameraOverEffect
class CCamera {
public:
- CCamera(CInstanceManager* iMan);
+ CCamera();
~CCamera();
//! Management of an event
@@ -258,8 +258,8 @@ protected:
void OverFrame(const Event &event);
protected:
- CInstanceManager* m_iMan;
CEngine* m_engine;
+ CRobotMain* m_main;
CTerrain* m_terrain;
CWater* m_water;
diff --git a/src/graphics/engine/cloud.cpp b/src/graphics/engine/cloud.cpp
index 0df0d12..d9ebf5a 100644
--- a/src/graphics/engine/cloud.cpp
+++ b/src/graphics/engine/cloud.cpp
@@ -18,12 +18,12 @@
#include "graphics/engine/cloud.h"
-#include "common/iman.h"
-
#include "graphics/core/device.h"
#include "graphics/engine/engine.h"
#include "graphics/engine/terrain.h"
+#include "object/robotmain.h"
+
#include "math/geometry.h"
@@ -37,11 +37,8 @@ const int CLOUD_LINE_PREALLOCATE_COUNT = 100;
const int CLOUD_SIZE_EXPAND = 4;
-CCloud::CCloud(CInstanceManager* iMan, CEngine* engine)
+CCloud::CCloud(CEngine* engine)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_CLOUD, this);
-
m_engine = engine;
m_terrain = nullptr;
@@ -55,7 +52,6 @@ CCloud::CCloud(CInstanceManager* iMan, CEngine* engine)
CCloud::~CCloud()
{
- m_iMan = nullptr;
m_engine = nullptr;
m_terrain = nullptr;
}
@@ -84,7 +80,7 @@ bool CCloud::EventFrame(const Event &event)
}
void CCloud::AdjustLevel(Math::Vector& pos, Math::Vector& eye, float deep,
- Math::Point& uv1, Math::Point& uv2)
+ Math::Point& uv1, Math::Point& uv2)
{
uv1.x = (pos.x+20000.0f)/1280.0f;
uv1.y = (pos.z+20000.0f)/1280.0f;
@@ -211,8 +207,8 @@ void CCloud::CreateLine(int x, int y, int len)
}
void CCloud::Create(const std::string& fileName,
- const Color& diffuse, const Color& ambient,
- float level)
+ const Color& diffuse, const Color& ambient,
+ float level)
{
m_diffuse = diffuse;
m_ambient = ambient;
@@ -225,7 +221,7 @@ void CCloud::Create(const std::string& fileName,
m_engine->LoadTexture(m_fileName);
if (m_terrain == nullptr)
- m_terrain = static_cast<CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_terrain = CRobotMain::GetInstancePointer()->GetTerrain();
m_wind = m_terrain->GetWind();
@@ -250,7 +246,6 @@ void CCloud::Flush()
m_level = 0.0f;
}
-
void CCloud::SetLevel(float level)
{
m_level = level;
diff --git a/src/graphics/engine/cloud.h b/src/graphics/engine/cloud.h
index 6f6985f..8f644f0 100644
--- a/src/graphics/engine/cloud.h
+++ b/src/graphics/engine/cloud.h
@@ -34,9 +34,6 @@
#include <string>
-class CInstanceManager;
-
-
// Graphics module namespace
namespace Gfx {
@@ -79,12 +76,13 @@ struct CloudLine
class CCloud
{
public:
- CCloud(CInstanceManager* iMan, CEngine* engine);
+ CCloud(CEngine* engine);
~CCloud();
bool EventProcess(const Event& event);
//! Removes all the clouds
void Flush();
+
//! Creates all areas of cloud
void Create(const std::string& fileName, const Color& diffuse, const Color& ambient, float level);
//! Draw the clouds
@@ -112,9 +110,8 @@ protected:
void CreateLine(int x, int y, int len);
protected:
- CInstanceManager* m_iMan;
- CEngine* m_engine;
- CTerrain* m_terrain;
+ CEngine* m_engine;
+ CTerrain* m_terrain;
bool m_enabled;
//! Overall level
diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp
index 71b5e7d..d24a3bd 100644
--- a/src/graphics/engine/engine.cpp
+++ b/src/graphics/engine/engine.cpp
@@ -20,7 +20,6 @@
#include "app/app.h"
-#include "common/iman.h"
#include "common/image.h"
#include "common/key.h"
#include "common/logger.h"
@@ -43,20 +42,16 @@
#include "ui/interface.h"
+template<> Gfx::CEngine* CSingleton<Gfx::CEngine>::m_instance = nullptr;
// Graphics module namespace
namespace Gfx {
-CEngine::CEngine(CInstanceManager *iMan, CApplication *app)
+CEngine::CEngine(CApplication *app)
{
- m_iMan = iMan;
m_app = app;
m_device = nullptr;
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_ENGINE, this);
- m_app = app;
-
m_lightMan = nullptr;
m_text = nullptr;
m_particle = nullptr;
@@ -169,11 +164,17 @@ CEngine::CEngine(CInstanceManager *iMan, CApplication *app)
CEngine::~CEngine()
{
- m_iMan = nullptr;
- m_app = nullptr;
- m_device = nullptr;
- m_sound = nullptr;
- m_terrain = nullptr;
+ m_app = nullptr;
+ m_sound = nullptr;
+ m_device = nullptr;
+ m_text = nullptr;
+ m_lightMan = nullptr;
+ m_particle = nullptr;
+ m_water = nullptr;
+ m_cloud = nullptr;
+ m_lightning = nullptr;
+ m_planet = nullptr;
+ m_terrain = nullptr;
DestroyTimeStamp(m_lastFrameTime);
m_lastFrameTime = nullptr;
@@ -191,27 +192,63 @@ CDevice* CEngine::GetDevice()
return m_device;
}
-void CEngine::SetTerrain(CTerrain* terrain)
+CText* CEngine::GetText()
{
- m_terrain = terrain;
+ return m_text;
}
-CText* CEngine::GetText()
+CLightManager* CEngine::GetLightManager()
{
- return m_text;
+ return m_lightMan;
+}
+
+CParticle* CEngine::GetParticle()
+{
+ return m_particle;
+}
+
+CTerrain* CEngine::GetTerrain()
+{
+ return m_terrain;
+}
+
+CWater* CEngine::GetWater()
+{
+ return m_water;
}
+CLightning* CEngine::GetLightning()
+{
+ return m_lightning;
+}
+
+CPlanet* CEngine::GetPlanet()
+{
+ return m_planet;
+}
+
+CCloud* CEngine::GetCloud()
+{
+ return m_cloud;
+}
+
+void CEngine::SetTerrain(CTerrain* terrain)
+{
+ m_terrain = terrain;
+}
+
+
bool CEngine::Create()
{
m_size = m_app->GetVideoConfig().size;
- m_lightMan = new CLightManager(m_iMan, this);
- m_text = new CText(m_iMan, this);
- m_particle = new CParticle(m_iMan, this);
- m_water = new CWater(m_iMan, this);
- m_cloud = new CCloud(m_iMan, this);
- m_lightning = new CLightning(m_iMan, this);
- m_planet = new CPlanet(m_iMan, this);
+ m_lightMan = new CLightManager(this);
+ m_text = new CText(this);
+ m_particle = new CParticle(this);
+ m_water = new CWater(this);
+ m_cloud = new CCloud(this);
+ m_lightning = new CLightning(this);
+ m_planet = new CPlanet(this);
m_lightMan->SetDevice(m_device);
m_particle->SetDevice(m_device);
@@ -2046,7 +2083,7 @@ void CEngine::SetViewParams(const Math::Vector& eyePt, const Math::Vector& looka
Math::LoadViewMatrix(m_matView, eyePt, lookatPt, upVec);
if (m_sound == nullptr)
- m_sound = static_cast<CSoundInterface*>( m_iMan->SearchInstance(CLASS_SOUND) );
+ m_sound = m_app->GetSound();
if (m_sound != nullptr)
m_sound->SetListener(eyePt, lookatPt);
@@ -3184,9 +3221,11 @@ void CEngine::DrawInterface()
SetState(Gfx::ENG_RSTATE_NORMAL);
// Draw the entire interface
- Ui::CInterface* interface = static_cast<Ui::CInterface*>( m_iMan->SearchInstance(CLASS_INTERFACE) );
+ Ui::CInterface* interface = CRobotMain::GetInstancePointer()->GetInterface();
if (interface != nullptr)
+ {
interface->Draw();
+ }
m_interfaceMode = false;
m_lastState = -1;
diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h
index e5c75bc..0647fbd 100644
--- a/src/graphics/engine/engine.h
+++ b/src/graphics/engine/engine.h
@@ -26,6 +26,7 @@
#include "app/system.h"
#include "common/event.h"
+#include "common/singleton.h"
#include "graphics/core/color.h"
#include "graphics/core/material.h"
@@ -47,7 +48,6 @@
class CApplication;
-class CInstanceManager;
class CObject;
class CSoundInterface;
class CImage;
@@ -671,22 +671,36 @@ struct EngineMouse
* which is what OpenGL actually wants. The old method is kept for now, with mapping between texture names
* and texture structs but it will also be subject to refactoring in the future.
*/
-class CEngine
+class CEngine : public CSingleton<CEngine>
{
public:
- CEngine(CInstanceManager* iMan, CApplication* app);
+ CEngine(CApplication* app);
~CEngine();
//! Sets the device to be used
void SetDevice(CDevice* device);
//! Returns the current device
- CDevice* GetDevice();
-
- //! Sets the terrain object
- void SetTerrain(CTerrain* terrain);
+ CDevice* GetDevice();
//! Returns the text rendering engine
CText* GetText();
+ //! Returns the light manager
+ CLightManager* GetLightManager();
+ //! Returns the particle manager
+ CParticle* GetParticle();
+ //! Returns the terrain manager
+ CTerrain* GetTerrain();
+ //! Returns the water manager
+ CWater* GetWater();
+ //! Returns the lighting manager
+ CLightning* GetLightning();
+ //! Returns the planet manager
+ CPlanet* GetPlanet();
+ //! Returns the fog manager
+ CCloud* GetCloud();
+
+ //! Sets the terrain object
+ void SetTerrain(CTerrain* terrain);
//! Performs the initialization; must be called after device was set
@@ -735,8 +749,6 @@ public:
//! Returns current size of viewport window
Math::IntPoint GetWindowSize();
- //! Returns the last size of viewport window
- Math::IntPoint GetLastWindowSize();
//@{
//! Conversion functions between window and interface coordinates
@@ -1251,7 +1263,6 @@ protected:
void UpdateStaticBuffers();
protected:
- CInstanceManager* m_iMan;
CApplication* m_app;
CSoundInterface* m_sound;
CDevice* m_device;
diff --git a/src/graphics/engine/lightman.cpp b/src/graphics/engine/lightman.cpp
index 3055f08..4a8fd60 100644
--- a/src/graphics/engine/lightman.cpp
+++ b/src/graphics/engine/lightman.cpp
@@ -19,7 +19,6 @@
#include "graphics/engine/lightman.h"
#include "common/logger.h"
-#include "common/iman.h"
#include "graphics/core/device.h"
@@ -78,11 +77,8 @@ DynamicLight::DynamicLight()
-CLightManager::CLightManager(CInstanceManager* iMan, CEngine* engine)
+CLightManager::CLightManager(CEngine* engine)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_LIGHT, this);
-
m_device = nullptr;
m_engine = engine;
@@ -91,9 +87,6 @@ CLightManager::CLightManager(CInstanceManager* iMan, CEngine* engine)
CLightManager::~CLightManager()
{
- m_iMan->DeleteInstance(CLASS_LIGHT, this);
-
- m_iMan = nullptr;
m_device = nullptr;
m_engine = nullptr;
}
diff --git a/src/graphics/engine/lightman.h b/src/graphics/engine/lightman.h
index d83dfb3..07dfe6a 100644
--- a/src/graphics/engine/lightman.h
+++ b/src/graphics/engine/lightman.h
@@ -129,7 +129,7 @@ class CLightManager
{
public:
//! Constructor
- CLightManager(CInstanceManager *iMan, CEngine* engine);
+ CLightManager(CEngine* engine);
//! Destructor
virtual ~CLightManager();
@@ -189,7 +189,6 @@ public:
void UpdateDeviceLights(EngineObjectType type);
protected:
- CInstanceManager* m_iMan;
CEngine* m_engine;
CDevice* m_device;
diff --git a/src/graphics/engine/lightning.cpp b/src/graphics/engine/lightning.cpp
index d256599..5fdae51 100644
--- a/src/graphics/engine/lightning.cpp
+++ b/src/graphics/engine/lightning.cpp
@@ -18,6 +18,8 @@
#include "graphics/engine/lightning.h"
+#include "app/app.h"
+
#include "common/logger.h"
#include "common/iman.h"
@@ -25,22 +27,20 @@
#include "graphics/engine/camera.h"
#include "graphics/engine/terrain.h"
+#include "math/geometry.h"
+
#include "object/object.h"
+#include "object/robotmain.h"
#include "object/auto/autopara.h"
-#include "math/geometry.h"
-
// Graphics module namespace
namespace Gfx {
-CLightning::CLightning(CInstanceManager* iMan, CEngine* engine)
+CLightning::CLightning(CEngine* engine)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_BLITZ, this);
-
m_engine = engine;
m_terrain = nullptr;
m_camera = nullptr;
@@ -187,13 +187,13 @@ bool CLightning::Create(float sleep, float delay, float magnetic)
m_speed = 1.0f / m_sleep;
if (m_terrain == nullptr)
- m_terrain = static_cast<CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_terrain = CRobotMain::GetInstancePointer()->GetTerrain();
if (m_camera == nullptr)
- m_camera = static_cast<CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
+ m_camera = CRobotMain::GetInstancePointer()->GetCamera();
if (m_sound == nullptr)
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
+ m_sound = CApplication::GetInstancePointer()->GetSound();
return false;
}
@@ -312,12 +312,14 @@ CObject* CLightning::SearchObject(Math::Vector pos)
std::vector<Math::Vector> paraObjPos;
paraObjPos.reserve(100);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
// Seeking the object closest to the point of impact of lightning.
CObject* bestObj = 0;
float min = 100000.0f;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>( m_iMan->SearchInstance(CLASS_OBJECT, i) );
+ CObject* obj = static_cast<CObject*>( iMan->SearchInstance(CLASS_OBJECT, i) );
if (obj == nullptr) break;
if (!obj->GetActif()) continue; // inactive object?
diff --git a/src/graphics/engine/lightning.h b/src/graphics/engine/lightning.h
index b21f681..7809a6c 100644
--- a/src/graphics/engine/lightning.h
+++ b/src/graphics/engine/lightning.h
@@ -28,7 +28,6 @@
#include "math/vector.h"
-class CInstanceManager;
class CObject;
class CSoundInterface;
@@ -53,7 +52,7 @@ const float LTNG_PROTECTION_RADIUS = 200.0f;
class CLightning
{
public:
- CLightning(CInstanceManager* iMan, CEngine* engine);
+ CLightning(CEngine* engine);
~CLightning();
//! Triggers lightning
@@ -80,7 +79,6 @@ protected:
CObject* SearchObject(Math::Vector pos);
protected:
- CInstanceManager* m_iMan;
CEngine* m_engine;
CTerrain* m_terrain;
CCamera* m_camera;
diff --git a/src/graphics/engine/modelfile.cpp b/src/graphics/engine/modelfile.cpp
index c9d41f3..f6d7a7b 100644
--- a/src/graphics/engine/modelfile.cpp
+++ b/src/graphics/engine/modelfile.cpp
@@ -18,7 +18,6 @@
#include "graphics/engine/modelfile.h"
-#include "common/iman.h"
#include "common/ioutils.h"
#include "common/logger.h"
#include "common/stringutils.h"
diff --git a/src/graphics/engine/modelmanager.cpp b/src/graphics/engine/modelmanager.cpp
index 051922f..c23b79d 100644
--- a/src/graphics/engine/modelmanager.cpp
+++ b/src/graphics/engine/modelmanager.cpp
@@ -8,7 +8,7 @@
#include <cstdio>
-template<> Gfx::CModelManager* CSingleton<Gfx::CModelManager>::mInstance = nullptr;
+template<> Gfx::CModelManager* CSingleton<Gfx::CModelManager>::m_instance = nullptr;
namespace Gfx {
diff --git a/src/graphics/engine/particle.cpp b/src/graphics/engine/particle.cpp
index 388c189..d15ee3b 100644
--- a/src/graphics/engine/particle.cpp
+++ b/src/graphics/engine/particle.cpp
@@ -18,6 +18,9 @@
#include "graphics/engine/particle.h"
+#include "app/app.h"
+
+#include "common/iman.h"
#include "common/logger.h"
#include "graphics/core/device.h"
@@ -117,11 +120,8 @@ float GetDecay(ObjectType type)
-CParticle::CParticle(CInstanceManager *iMan, CEngine* engine)
+CParticle::CParticle(CEngine* engine)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_PARTICULE, this);
-
m_device = nullptr;
m_engine = engine;
m_main = nullptr;
@@ -138,7 +138,6 @@ CParticle::CParticle(CInstanceManager *iMan, CEngine* engine)
CParticle::~CParticle()
{
- m_iMan->DeleteInstance(CLASS_PARTICULE, this);
}
void CParticle::SetDevice(CDevice* device)
@@ -213,7 +212,7 @@ int CParticle::CreateParticle(Math::Vector pos, Math::Vector speed, Math::Point
float windSensitivity, int sheet)
{
if (m_main == nullptr)
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
+ m_main = CRobotMain::GetInstancePointer();
int t = -1;
if ( type == PARTIEXPLOT ||
@@ -649,7 +648,7 @@ void CParticle::CreateWheelTrace(const Math::Vector &p1, const Math::Vector &p2,
m_wheelTrace[i].startTime = m_absTime;
if (m_terrain == nullptr)
- m_terrain = static_cast<CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_terrain = m_main->GetTerrain();
m_terrain->AdjustToFloor(m_wheelTrace[i].pos[0]);
m_wheelTrace[i].pos[0].y += 0.2f; // just above the ground
@@ -808,15 +807,15 @@ void CParticle::SetFrameUpdate(int sheet, bool update)
void CParticle::FrameParticle(float rTime)
{
if (m_main == nullptr)
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
+ m_main = CRobotMain::GetInstancePointer();
bool pause = (m_engine->GetPause() && !m_main->GetInfoLock());
if (m_terrain == nullptr)
- m_terrain = static_cast<CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_terrain = m_main->GetTerrain();
if (m_water == nullptr)
- m_water = static_cast<CWater*>(m_iMan->SearchInstance(CLASS_WATER));
+ m_water = m_engine->GetWater();
if (!pause)
{
@@ -3654,11 +3653,13 @@ CObject* CParticle::SearchObjectGun(Math::Vector old, Math::Vector pos,
box2.y += min;
box2.z += min;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
CObject* best = 0;
bool shield = false;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == 0) break;
if (!obj->GetActif()) continue; // inactive?
@@ -3782,9 +3783,11 @@ CObject* CParticle::SearchObjectRay(Math::Vector pos, Math::Vector goal,
box2.y += min;
box2.z += min;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>( m_iMan->SearchInstance(CLASS_OBJECT, i) );
+ CObject* obj = static_cast<CObject*>( iMan->SearchInstance(CLASS_OBJECT, i) );
if (obj == nullptr) break;
if (!obj->GetActif()) continue; // inactive?
@@ -3822,7 +3825,7 @@ CObject* CParticle::SearchObjectRay(Math::Vector pos, Math::Vector goal,
void CParticle::Play(Sound sound, Math::Vector pos, float amplitude)
{
if (m_sound == nullptr)
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
+ m_sound = CApplication::GetInstancePointer()->GetSound();
m_sound->Play(sound, pos, amplitude);
}
diff --git a/src/graphics/engine/particle.h b/src/graphics/engine/particle.h
index 90aec55..708a04d 100644
--- a/src/graphics/engine/particle.h
+++ b/src/graphics/engine/particle.h
@@ -28,7 +28,6 @@
#include "sound/sound.h"
-class CInstanceManager;
class CRobotMain;
class CObject;
class CSoundInterface;
@@ -267,7 +266,7 @@ struct WheelTrace
class CParticle
{
public:
- CParticle(CInstanceManager* iMan, CEngine* engine);
+ CParticle(CEngine* engine);
~CParticle();
//! Sets the device to use
@@ -371,7 +370,6 @@ protected:
void TrackDraw(int i, ParticleType type);
protected:
- CInstanceManager* m_iMan;
CEngine* m_engine;
CDevice* m_device;
CTerrain* m_terrain;
diff --git a/src/graphics/engine/planet.cpp b/src/graphics/engine/planet.cpp
index 3b9aa6c..49bcb4c 100644
--- a/src/graphics/engine/planet.cpp
+++ b/src/graphics/engine/planet.cpp
@@ -18,8 +18,6 @@
#include "graphics/engine/planet.h"
-#include "common/iman.h"
-
#include "graphics/core/device.h"
#include "graphics/engine/engine.h"
@@ -31,11 +29,8 @@ namespace Gfx {
const int PLANET_PREALLOCATE_COUNT = 10;
-CPlanet::CPlanet(CInstanceManager* iMan, CEngine* engine)
+CPlanet::CPlanet(CEngine* engine)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_PLANET, this);
-
m_planet[0].reserve(PLANET_PREALLOCATE_COUNT);
m_planet[1].reserve(PLANET_PREALLOCATE_COUNT);
@@ -46,7 +41,6 @@ CPlanet::CPlanet(CInstanceManager* iMan, CEngine* engine)
CPlanet::~CPlanet()
{
- m_iMan = nullptr;
}
void CPlanet::Flush()
diff --git a/src/graphics/engine/planet.h b/src/graphics/engine/planet.h
index 1b16da0..3762e1d 100644
--- a/src/graphics/engine/planet.h
+++ b/src/graphics/engine/planet.h
@@ -30,8 +30,6 @@
#include <vector>
-class CInstanceManager;
-
// Graphics module namespace
namespace Gfx {
@@ -82,7 +80,7 @@ struct Planet
class CPlanet
{
public:
- CPlanet(CInstanceManager* iMan, CEngine* engine);
+ CPlanet(CEngine* engine);
~CPlanet();
//! Removes all the planets
@@ -110,7 +108,6 @@ protected:
bool EventFrame(const Event &event);
protected:
- CInstanceManager* m_iMan;
CEngine* m_engine;
float m_time;
diff --git a/src/graphics/engine/pyro.cpp b/src/graphics/engine/pyro.cpp
index e374d6c..1d80fea 100644
--- a/src/graphics/engine/pyro.cpp
+++ b/src/graphics/engine/pyro.cpp
@@ -18,6 +18,9 @@
#include "graphics/engine/pyro.h"
+#include "app/app.h"
+
+#include "common/iman.h"
#include "common/logger.h"
#include "graphics/engine/lightman.h"
@@ -36,20 +39,19 @@
namespace Gfx {
-CPyro::CPyro(CInstanceManager* iMan)
+CPyro::CPyro()
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_PYRO, this, 100);
-
- m_engine = static_cast<CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_terrain = static_cast<CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
- m_camera = static_cast<CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
- m_particle = static_cast<CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_lightMan = static_cast<CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT));
- m_displayText = static_cast<Ui::CDisplayText*>(m_iMan->SearchInstance(CLASS_DISPLAYTEXT));
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
- m_object = 0;
+ CInstanceManager::GetInstancePointer()->AddInstance(CLASS_PYRO, this, 100);
+
+ m_engine = CEngine::GetInstancePointer();
+ m_main = CRobotMain::GetInstancePointer();
+ m_terrain = m_main->GetTerrain();
+ m_camera = m_main->GetCamera();
+ m_particle = m_engine->GetParticle();
+ m_lightMan = m_engine->GetLightManager();
+ m_displayText = m_main->GetDisplayText();
+ m_sound = CApplication::GetInstancePointer()->GetSound();
+ m_object = nullptr;
m_progress = 0.0f;
m_speed = 0.0f;
@@ -60,7 +62,7 @@ CPyro::CPyro(CInstanceManager* iMan)
CPyro::~CPyro()
{
- m_iMan->DeleteInstance(CLASS_PYRO, this);
+ CInstanceManager::GetInstancePointer()->DeleteInstance(CLASS_PYRO, this);
}
void CPyro::DeleteObject()
@@ -2183,9 +2185,11 @@ CObject* CPyro::FallSearchBeeExplo()
float iRadius;
m_object->GetCrashSphere(0, iPos, iRadius);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject* pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
ObjectType oType = pObj->GetType();
diff --git a/src/graphics/engine/pyro.h b/src/graphics/engine/pyro.h
index 0204070..9548a07 100644
--- a/src/graphics/engine/pyro.h
+++ b/src/graphics/engine/pyro.h
@@ -31,7 +31,6 @@
#include "object/object.h"
-class CInstanceManager;
class CObject;
class CRobotMain;
class CSoundInterface;
@@ -111,7 +110,7 @@ struct PyroLightOper
class CPyro
{
public:
- CPyro(CInstanceManager* iMan);
+ CPyro();
~CPyro();
//! Creates pyrotechnic effect
@@ -174,7 +173,6 @@ protected:
void LightOperFrame(float rTime);
protected:
- CInstanceManager* m_iMan;
CEngine* m_engine;
CTerrain* m_terrain;
CCamera* m_camera;
diff --git a/src/graphics/engine/terrain.cpp b/src/graphics/engine/terrain.cpp
index 0be75bc..8f7ad26 100644
--- a/src/graphics/engine/terrain.cpp
+++ b/src/graphics/engine/terrain.cpp
@@ -19,11 +19,13 @@
#include "graphics/engine/terrain.h"
#include "app/app.h"
-#include "common/iman.h"
+
#include "common/image.h"
#include "common/logger.h"
+
#include "graphics/engine/engine.h"
#include "graphics/engine/water.h"
+
#include "math/geometry.h"
#include <sstream>
@@ -35,13 +37,10 @@
namespace Gfx {
-CTerrain::CTerrain(CInstanceManager* iMan)
+CTerrain::CTerrain()
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_TERRAIN, this);
-
- m_engine = static_cast<CEngine*>( m_iMan->SearchInstance(CLASS_ENGINE) );
- m_water = static_cast<CWater*>( m_iMan->SearchInstance(CLASS_WATER) );
+ m_engine = CEngine::GetInstancePointer();
+ m_water = m_engine->GetWater();
m_mosaicCount = 20;
m_brickCount = 1 << 4;
diff --git a/src/graphics/engine/terrain.h b/src/graphics/engine/terrain.h
index 91ddc76..1fa8dec 100644
--- a/src/graphics/engine/terrain.h
+++ b/src/graphics/engine/terrain.h
@@ -26,9 +26,6 @@
#include "graphics/engine/engine.h"
-class CInstanceManager;
-
-
// Graphics module namespace
namespace Gfx {
@@ -223,7 +220,7 @@ struct FlyingLimit
class CTerrain
{
public:
- CTerrain(CInstanceManager* iMan);
+ CTerrain();
~CTerrain();
//! Generates a new flat terrain
@@ -359,7 +356,6 @@ protected:
void AdjustBuildingLevel(Math::Vector &p);
protected:
- CInstanceManager* m_iMan;
CEngine* m_engine;
CWater* m_water;
diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp
index 48af081..424b99b 100644
--- a/src/graphics/engine/text.cpp
+++ b/src/graphics/engine/text.cpp
@@ -19,10 +19,11 @@
#include "graphics/engine/text.h"
#include "app/app.h"
+
#include "common/image.h"
-#include "common/iman.h"
#include "common/logger.h"
#include "common/stringutils.h"
+
#include "math/func.h"
#include <SDL/SDL.h>
@@ -49,11 +50,8 @@ struct CachedFont
const Math::IntPoint REFERENCE_SIZE(800, 600);
-CText::CText(CInstanceManager *iMan, CEngine* engine)
+CText::CText(CEngine* engine)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_TEXT, this);
-
m_device = nullptr;
m_engine = engine;
@@ -66,9 +64,6 @@ CText::CText(CInstanceManager *iMan, CEngine* engine)
CText::~CText()
{
- m_iMan->DeleteInstance(CLASS_TEXT, this);
-
- m_iMan = nullptr;
m_device = nullptr;
m_engine = nullptr;
}
diff --git a/src/graphics/engine/text.h b/src/graphics/engine/text.h
index e7578df..d8e2aff 100644
--- a/src/graphics/engine/text.h
+++ b/src/graphics/engine/text.h
@@ -31,9 +31,6 @@
#include <map>
-class CInstanceManager;
-
-
// Graphics module namespace
namespace Gfx {
@@ -226,7 +223,7 @@ struct MultisizeFont
class CText
{
public:
- CText(CInstanceManager *iMan, CEngine* engine);
+ CText(CEngine* engine);
virtual ~CText();
//! Sets the device to be used
@@ -301,7 +298,6 @@ protected:
void StringToUTFCharList(const std::string &text, std::vector<UTF8Char> &chars);
protected:
- CInstanceManager* m_iMan;
CEngine* m_engine;
CDevice* m_device;
diff --git a/src/graphics/engine/water.cpp b/src/graphics/engine/water.cpp
index 6c822b3..d90652b 100644
--- a/src/graphics/engine/water.cpp
+++ b/src/graphics/engine/water.cpp
@@ -18,7 +18,8 @@
#include "graphics/engine/water.h"
-#include "common/iman.h"
+#include "app/app.h"
+
#include "common/logger.h"
#include "graphics/core/device.h"
@@ -28,6 +29,7 @@
#include "math/geometry.h"
#include "object/object.h"
+#include "object/robotmain.h"
#include "sound/sound.h"
@@ -42,14 +44,11 @@ const int WATERLINE_PREALLOCATE_COUNT = 500;
const int VAPOR_SIZE = 10;
-CWater::CWater(CInstanceManager* iMan, CEngine* engine)
+CWater::CWater(CEngine* engine)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_WATER, this);
-
m_engine = engine;
m_terrain = nullptr;
- m_particule = nullptr;
+ m_particle = nullptr;
m_sound = nullptr;
m_type[0] = WATER_NULL;
@@ -67,10 +66,9 @@ CWater::CWater(CInstanceManager* iMan, CEngine* engine)
CWater::~CWater()
{
- m_iMan = nullptr;
m_engine = nullptr;
m_terrain = nullptr;
- m_particule = nullptr;
+ m_particle = nullptr;
m_sound = nullptr;
}
@@ -99,8 +97,8 @@ bool CWater::EventFrame(const Event &event)
void CWater::LavaFrame(float rTime)
{
- if (m_particule == nullptr)
- m_particule = static_cast<CParticle*>( m_iMan->SearchInstance(CLASS_PARTICULE) );
+ if (m_particle == nullptr)
+ m_particle = m_engine->GetParticle();
for (int i = 0; i < static_cast<int>( m_vapors.size() ); i++)
VaporFrame(i, rTime);
@@ -183,7 +181,7 @@ void CWater::VaporFrame(int i, float rTime)
m_vapors[i].time += rTime;
if (m_sound == nullptr)
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
+ m_sound = CApplication::GetInstancePointer()->GetSound();
if (m_vapors[i].time <= m_vapors[i].delay)
{
@@ -206,7 +204,7 @@ void CWater::VaporFrame(int i, float rTime)
Math::Point dim;
dim.x = Math::Rand()*1.5f+1.5f;
dim.y = dim.x;
- m_particule->CreateParticle(pos, speed, dim, PARTIERROR, 2.0f, 10.0f);
+ m_particle->CreateParticle(pos, speed, dim, PARTIERROR, 2.0f, 10.0f);
}
}
else if (m_vapors[i].type == PARTIFLAME)
@@ -222,7 +220,7 @@ void CWater::VaporFrame(int i, float rTime)
Math::Point dim;
dim.x = Math::Rand()*2.0f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticle(pos, speed, dim, PARTIFLAME);
+ m_particle->CreateParticle(pos, speed, dim, PARTIFLAME);
}
else
{
@@ -237,7 +235,7 @@ void CWater::VaporFrame(int i, float rTime)
Math::Point dim;
dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
- m_particule->CreateParticle(pos, speed, dim, PARTIVAPOR);
+ m_particle->CreateParticle(pos, speed, dim, PARTIVAPOR);
}
}
}
@@ -497,7 +495,7 @@ void CWater::Create(WaterType type1, WaterType type2, const std::string& fileNam
m_engine->LoadTexture(m_fileName);
if (m_terrain == nullptr)
- m_terrain = static_cast<CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_terrain = CRobotMain::GetInstancePointer()->GetTerrain();
m_brickCount = m_terrain->GetBrickCount()*m_terrain->GetMosaicCount();
m_brickSize = m_terrain->GetBrickSize();
diff --git a/src/graphics/engine/water.h b/src/graphics/engine/water.h
index 21d96d4..bb113e0 100644
--- a/src/graphics/engine/water.h
+++ b/src/graphics/engine/water.h
@@ -28,7 +28,6 @@
#include "graphics/engine/particle.h"
-class CInstanceManager;
class CSoundInterface;
@@ -117,8 +116,8 @@ enum WaterType
class CWater
{
public:
- CWater(CInstanceManager* iMan, CEngine* engine);
- ~CWater();
+ CWater(CEngine* engine);
+ virtual ~CWater();
void SetDevice(CDevice* device);
bool EventProcess(const Event &event);
@@ -168,11 +167,10 @@ protected:
void VaporFrame(int i, float rTime);
protected:
- CInstanceManager* m_iMan;
CEngine* m_engine;
CDevice* m_device;
CTerrain* m_terrain;
- CParticle* m_particule;
+ CParticle* m_particle;
CSoundInterface* m_sound;
WaterType m_type[2];
diff --git a/src/object/auto/auto.cpp b/src/object/auto/auto.cpp
index 4003193..3d88012 100644
--- a/src/object/auto/auto.cpp
+++ b/src/object/auto/auto.cpp
@@ -18,8 +18,13 @@
#include "object/auto/auto.h"
+#include "app/app.h"
+
+#include "common/event.h"
#include "common/iman.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/gauge.h"
#include "ui/window.h"
@@ -30,26 +35,24 @@
// Object's constructor.
-CAuto::CAuto(CInstanceManager* iMan, CObject* object)
+CAuto::CAuto(CObject* object)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_AUTO, this, 100);
+ m_iMan = CInstanceManager::GetInstancePointer();
m_object = object;
- m_event = static_cast< CEventQueue* >(m_iMan->SearchInstance(CLASS_EVENT));
- m_engine = static_cast< Gfx::CEngine* >(m_iMan->SearchInstance(CLASS_ENGINE));
- m_particle = static_cast< Gfx::CParticle* >(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_lightMan = static_cast< Gfx::CLightManager* >(m_iMan->SearchInstance(CLASS_LIGHT));
- m_terrain = static_cast< Gfx::CTerrain* >(m_iMan->SearchInstance(CLASS_TERRAIN));
- m_water = static_cast< Gfx::CWater* >(m_iMan->SearchInstance(CLASS_WATER));
- m_cloud = static_cast< Gfx::CCloud* >(m_iMan->SearchInstance(CLASS_CLOUD));
- m_planet = static_cast< Gfx::CPlanet* >(m_iMan->SearchInstance(CLASS_PLANET));
- m_lightning = static_cast< Gfx::CLightning* >(m_iMan->SearchInstance(CLASS_BLITZ));
- m_camera = static_cast< Gfx::CCamera* >(m_iMan->SearchInstance(CLASS_CAMERA));
- m_interface = static_cast< Ui::CInterface* >(m_iMan->SearchInstance(CLASS_INTERFACE));
- m_main = static_cast< CRobotMain* >(m_iMan->SearchInstance(CLASS_MAIN));
- m_displayText = static_cast< Ui::CDisplayText* >(m_iMan->SearchInstance(CLASS_DISPLAYTEXT));
- m_sound = static_cast< CSoundInterface* >(m_iMan->SearchInstance(CLASS_SOUND));
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_main = CRobotMain::GetInstancePointer();
+ m_eventQueue = CApplication::GetInstancePointer()->GetEventQueue();
+ m_sound = CApplication::GetInstancePointer()->GetSound();
+ m_particle = m_engine->GetParticle();
+ m_terrain = m_engine->GetTerrain();
+ m_water = m_engine->GetWater();
+ m_cloud = m_engine->GetCloud();
+ m_planet = m_engine->GetPlanet();
+ m_lightning = m_engine->GetLightning();
+ m_camera = m_main->GetCamera();
+ m_interface = m_main->GetInterface();
+ m_displayText = m_main->GetDisplayText();
m_type = m_object->GetType();
m_time = 0.0f;
@@ -65,7 +68,22 @@ CAuto::CAuto(CInstanceManager* iMan, CObject* object)
CAuto::~CAuto()
{
- m_iMan->DeleteInstance(CLASS_AUTO, this);
+ m_iMan = nullptr;
+
+ m_object = nullptr;
+ m_engine = nullptr;
+ m_main = nullptr;
+ m_eventQueue = nullptr;
+ m_sound = nullptr;
+ m_particle = nullptr;
+ m_terrain = nullptr;
+ m_water = nullptr;
+ m_cloud = nullptr;
+ m_planet = nullptr;
+ m_lightning = nullptr;
+ m_camera = nullptr;
+ m_interface = nullptr;
+ m_displayText = nullptr;
}
diff --git a/src/object/auto/auto.h b/src/object/auto/auto.h
index 2194924..53ccdf9 100644
--- a/src/object/auto/auto.h
+++ b/src/object/auto/auto.h
@@ -50,7 +50,7 @@ class CLightning;
class CAuto
{
public:
- CAuto(CInstanceManager* iMan, CObject* object);
+ CAuto(CObject* object);
virtual ~CAuto();
virtual void DeleteObject(bool bAll=false);
@@ -88,11 +88,10 @@ protected:
void UpdateInterface(float rTime);
protected:
- CInstanceManager* m_iMan;
- CEventQueue* m_event;
+ CInstanceManager* m_iMan; // TODO: to be removed
+ CEventQueue* m_eventQueue;
Gfx::CEngine* m_engine;
Gfx::CParticle* m_particle;
- Gfx::CLightManager* m_lightMan;
Gfx::CTerrain* m_terrain;
Gfx::CWater* m_water;
Gfx::CCloud* m_cloud;
diff --git a/src/object/auto/autobase.cpp b/src/object/auto/autobase.cpp
index 8370517..cb7f04c 100644
--- a/src/object/auto/autobase.cpp
+++ b/src/object/auto/autobase.cpp
@@ -20,13 +20,18 @@
#include "object/auto/autobase.h"
#include "common/iman.h"
+
#include "graphics/engine/terrain.h"
#include "graphics/engine/cloud.h"
#include "graphics/engine/planet.h"
#include "graphics/engine/lightning.h"
+
#include "math/geometry.h"
+
#include "object/robotmain.h"
+
#include "physics/physics.h"
+
#include "ui/interface.h"
#include "ui/window.h"
#include "ui/displaytext.h"
@@ -47,8 +52,7 @@ const float BASE_TRANSIT_TIME = 15.0f; // transit duration
// Object's constructor.
-CAutoBase::CAutoBase(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoBase::CAutoBase(CObject* object) : CAuto(object)
{
m_fogStart = m_engine->GetFogStart();
m_deepView = m_engine->GetDeepView();
@@ -329,7 +333,7 @@ begin:
m_main->DeselectAll();
newEvent.type = EVENT_UPDINTERFACE;
- m_event->AddEvent(newEvent);
+ m_eventQueue->AddEvent(newEvent);
m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
@@ -843,7 +847,7 @@ begin:
{
m_soundChannel = -1;
newEvent.type = EVENT_WIN;
- m_event->AddEvent(newEvent);
+ m_eventQueue->AddEvent(newEvent);
m_phase = ABP_WAIT;
m_progress = 0.0f;
@@ -1176,7 +1180,7 @@ bool CAutoBase::Abort()
m_phase == ABP_TAKEOFF ) // off?
{
newEvent.type = EVENT_WIN;
- m_event->AddEvent(newEvent);
+ m_eventQueue->AddEvent(newEvent);
}
}
diff --git a/src/object/auto/autobase.h b/src/object/auto/autobase.h
index 439d414..422f340 100644
--- a/src/object/auto/autobase.h
+++ b/src/object/auto/autobase.h
@@ -65,7 +65,7 @@ enum AutoBasePhase
class CAutoBase : public CAuto
{
public:
- CAutoBase(CInstanceManager* iMan, CObject* object);
+ CAutoBase(CObject* object);
~CAutoBase();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoconvert.cpp b/src/object/auto/autoconvert.cpp
index a550697..7281ed7 100644
--- a/src/object/auto/autoconvert.cpp
+++ b/src/object/auto/autoconvert.cpp
@@ -19,8 +19,11 @@
#include "object/auto/autoconvert.h"
#include "common/iman.h"
+
#include "math/geometry.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/window.h"
#include "ui/displaytext.h"
@@ -31,8 +34,7 @@
// Object's constructor.
-CAutoConvert::CAutoConvert(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoConvert::CAutoConvert(CObject* object) : CAuto(object)
{
Init();
m_phase = ACP_STOP;
@@ -509,7 +511,7 @@ void CAutoConvert::CreateMetal()
pos = m_object->GetPosition(0);
angle = m_object->GetAngleY(0);
- fret = new CObject(m_iMan);
+ fret = new CObject();
if ( !fret->CreateResource(pos, angle, OBJECT_METAL) )
{
delete fret;
diff --git a/src/object/auto/autoconvert.h b/src/object/auto/autoconvert.h
index b21690f..56591f7 100644
--- a/src/object/auto/autoconvert.h
+++ b/src/object/auto/autoconvert.h
@@ -38,7 +38,7 @@ enum AutoConvertPhase
class CAutoConvert : public CAuto
{
public:
- CAutoConvert(CInstanceManager* iMan, CObject* object);
+ CAutoConvert(CObject* object);
~CAutoConvert();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoderrick.cpp b/src/object/auto/autoderrick.cpp
index 3578c0d..260edcb 100644
--- a/src/object/auto/autoderrick.cpp
+++ b/src/object/auto/autoderrick.cpp
@@ -19,9 +19,13 @@
#include "object/auto/autoderrick.h"
#include "common/iman.h"
+
#include "graphics/engine/terrain.h"
+
#include "math/geometry.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/window.h"
#include "ui/displaytext.h"
@@ -38,8 +42,7 @@ const float DERRICK_DELAYu = 30.0f; // same, but for uranium
// Object's constructor.
-CAutoDerrick::CAutoDerrick(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoDerrick::CAutoDerrick(CObject* object) : CAuto(object)
{
Init();
m_phase = ADP_WAIT; // paused until the first Init ()
@@ -528,7 +531,7 @@ void CAutoDerrick::CreateFret(Math::Vector pos, float angle, ObjectType type,
{
CObject* fret;
- fret = new CObject(m_iMan);
+ fret = new CObject();
if ( !fret->CreateResource(pos, angle, type) )
{
delete fret;
diff --git a/src/object/auto/autoderrick.h b/src/object/auto/autoderrick.h
index b52f93b..81ed8b4 100644
--- a/src/object/auto/autoderrick.h
+++ b/src/object/auto/autoderrick.h
@@ -38,7 +38,7 @@ enum AutoDerrickPhase
class CAutoDerrick : public CAuto
{
public:
- CAutoDerrick(CInstanceManager* iMan, CObject* object);
+ CAutoDerrick(CObject* object);
~CAutoDerrick();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autodestroyer.cpp b/src/object/auto/autodestroyer.cpp
index 644071c..b62a45a 100644
--- a/src/object/auto/autodestroyer.cpp
+++ b/src/object/auto/autodestroyer.cpp
@@ -19,7 +19,9 @@
#include "object/auto/autodestroyer.h"
#include "common/iman.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/window.h"
@@ -29,8 +31,7 @@
// Object's constructor.
-CAutoDestroyer::CAutoDestroyer(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoDestroyer::CAutoDestroyer(CObject* object) : CAuto(object)
{
Init();
m_phase = ADEP_WAIT; // paused until the first Init ()
@@ -156,7 +157,7 @@ bool CAutoDestroyer::EventProcess(const Event &event)
scrap = SearchPlastic();
if ( scrap != nullptr )
{
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FRAGT, scrap);
}
m_bExplo = true;
diff --git a/src/object/auto/autodestroyer.h b/src/object/auto/autodestroyer.h
index 50858d3..26981c3 100644
--- a/src/object/auto/autodestroyer.h
+++ b/src/object/auto/autodestroyer.h
@@ -37,7 +37,7 @@ enum AutoDestroyerPhase
class CAutoDestroyer : public CAuto
{
public:
- CAutoDestroyer(CInstanceManager* iMan, CObject* object);
+ CAutoDestroyer(CObject* object);
~CAutoDestroyer();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoegg.cpp b/src/object/auto/autoegg.cpp
index 5b90ef9..e510ca6 100644
--- a/src/object/auto/autoegg.cpp
+++ b/src/object/auto/autoegg.cpp
@@ -18,8 +18,10 @@
#include "object/auto/autoegg.h"
-#include "math/geometry.h"
#include "common/iman.h"
+
+#include "math/geometry.h"
+
#include "script/cmdtoken.h"
#include <stdio.h>
@@ -28,8 +30,7 @@
// Object's constructor.
-CAutoEgg::CAutoEgg(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoEgg::CAutoEgg(CObject* object) : CAuto(object)
{
m_type = OBJECT_NULL;
m_value = 0.0f;
@@ -174,7 +175,7 @@ bool CAutoEgg::EventProcess(const Event &event)
m_progress += event.rTime*m_speed;
if ( m_progress < 1.0f ) return true;
- alien = new CObject(m_iMan);
+ alien = new CObject();
if ( !alien->CreateInsect(m_object->GetPosition(0), m_object->GetAngleY(0), m_type) )
{
delete alien;
@@ -236,7 +237,7 @@ Error CAutoEgg::IsEnded()
{
if ( m_progress < 1.0f ) return ERR_CONTINUE;
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_EGG, m_object); // exploding egg
alien->SetZoom(0, 1.0f); // this is a big boy now
diff --git a/src/object/auto/autoegg.h b/src/object/auto/autoegg.h
index fec07a6..00725db 100644
--- a/src/object/auto/autoegg.h
+++ b/src/object/auto/autoegg.h
@@ -37,7 +37,7 @@ enum AutoEggPhase
class CAutoEgg : public CAuto
{
public:
- CAutoEgg(CInstanceManager* iMan, CObject* object);
+ CAutoEgg(CObject* object);
~CAutoEgg();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoenergy.cpp b/src/object/auto/autoenergy.cpp
index c63dede..a0b4d85 100644
--- a/src/object/auto/autoenergy.cpp
+++ b/src/object/auto/autoenergy.cpp
@@ -19,9 +19,13 @@
#include "object/auto/autoenergy.h"
#include "common/iman.h"
+
#include "graphics/engine/terrain.h"
+
#include "math/geometry.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/gauge.h"
#include "ui/window.h"
@@ -39,8 +43,7 @@ const float ENERGY_DELAY = 12.0f; // processing time
// Object's constructor.
-CAutoEnergy::CAutoEnergy(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoEnergy::CAutoEnergy(CObject* object) : CAuto(object)
{
m_partiSphere = -1;
Init();
@@ -461,7 +464,7 @@ void CAutoEnergy::CreatePower()
pos = m_object->GetPosition(0);
angle = m_object->GetAngleY(0);
- power = new CObject(m_iMan);
+ power = new CObject();
if ( !power->CreateResource(pos, angle, OBJECT_POWER) )
{
delete power;
diff --git a/src/object/auto/autoenergy.h b/src/object/auto/autoenergy.h
index 53d47b6..d3ed5fe 100644
--- a/src/object/auto/autoenergy.h
+++ b/src/object/auto/autoenergy.h
@@ -38,7 +38,7 @@ enum AutoEnergyPhase
class CAutoEnergy : public CAuto
{
public:
- CAutoEnergy(CInstanceManager* iMan, CObject* object);
+ CAutoEnergy(CObject* object);
~CAutoEnergy();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autofactory.cpp b/src/object/auto/autofactory.cpp
index 0789443..82877c6 100644
--- a/src/object/auto/autofactory.cpp
+++ b/src/object/auto/autofactory.cpp
@@ -20,10 +20,15 @@
#include "common/global.h"
#include "common/iman.h"
+
#include "math/geometry.h"
+
#include "object/robotmain.h"
+
#include "physics/physics.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/window.h"
#include "ui/displaytext.h"
@@ -35,8 +40,7 @@
// Object's constructor.
-CAutoFactory::CAutoFactory(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoFactory::CAutoFactory(CObject* object) : CAuto(object)
{
Init();
m_type = OBJECT_MOBILEws;
@@ -632,7 +636,7 @@ bool CAutoFactory::CreateVehicle()
}
pos = Transform(*mat, pos);
- vehicle = new CObject(m_iMan);
+ vehicle = new CObject();
if ( !vehicle->CreateVehicle(pos, angle, m_type, -1.0f, false, false) )
{
delete vehicle;
diff --git a/src/object/auto/autofactory.h b/src/object/auto/autofactory.h
index f62080d..7c5013d 100644
--- a/src/object/auto/autofactory.h
+++ b/src/object/auto/autofactory.h
@@ -40,7 +40,7 @@ enum AutoFactoryPhase
class CAutoFactory : public CAuto
{
public:
- CAutoFactory(CInstanceManager* iMan, CObject* object);
+ CAutoFactory(CObject* object);
~CAutoFactory();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoflag.cpp b/src/object/auto/autoflag.cpp
index c2dec5c..936546d 100644
--- a/src/object/auto/autoflag.cpp
+++ b/src/object/auto/autoflag.cpp
@@ -37,8 +37,7 @@ static float g_flag3 = 2.00f;
// Object's constructor.
-CAutoFlag::CAutoFlag(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoFlag::CAutoFlag(CObject* object) : CAuto(object)
{
Init();
}
diff --git a/src/object/auto/autoflag.h b/src/object/auto/autoflag.h
index 3c6cf99..c3fd35a 100644
--- a/src/object/auto/autoflag.h
+++ b/src/object/auto/autoflag.h
@@ -27,7 +27,7 @@
class CAutoFlag : public CAuto
{
public:
- CAutoFlag(CInstanceManager* iMan, CObject* object);
+ CAutoFlag(CObject* object);
~CAutoFlag();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autohuston.cpp b/src/object/auto/autohuston.cpp
index 1b6778d..80f9185 100644
--- a/src/object/auto/autohuston.cpp
+++ b/src/object/auto/autohuston.cpp
@@ -26,8 +26,7 @@
// Object's constructor.
-CAutoHuston::CAutoHuston(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoHuston::CAutoHuston(CObject* object) : CAuto(object)
{
Math::Vector pos;
int i;
diff --git a/src/object/auto/autohuston.h b/src/object/auto/autohuston.h
index 27b016b..f99876a 100644
--- a/src/object/auto/autohuston.h
+++ b/src/object/auto/autohuston.h
@@ -42,7 +42,7 @@ const int HUSTONMAXLENS = 20;
class CAutoHuston : public CAuto
{
public:
- CAutoHuston(CInstanceManager* iMan, CObject* object);
+ CAutoHuston(CObject* object);
~CAutoHuston();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoinfo.cpp b/src/object/auto/autoinfo.cpp
index 1245034..56c21d2 100644
--- a/src/object/auto/autoinfo.cpp
+++ b/src/object/auto/autoinfo.cpp
@@ -30,8 +30,7 @@
// Object's constructor.
-CAutoInfo::CAutoInfo(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoInfo::CAutoInfo(CObject* object) : CAuto(object)
{
Init();
}
diff --git a/src/object/auto/autoinfo.h b/src/object/auto/autoinfo.h
index 30481bb..41b74d3 100644
--- a/src/object/auto/autoinfo.h
+++ b/src/object/auto/autoinfo.h
@@ -37,7 +37,7 @@ enum AutoInfoPhase
class CAutoInfo : public CAuto
{
public:
- CAutoInfo(CInstanceManager* iMan, CObject* object);
+ CAutoInfo(CObject* object);
~CAutoInfo();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autojostle.cpp b/src/object/auto/autojostle.cpp
index 788b562..11952c2 100644
--- a/src/object/auto/autojostle.cpp
+++ b/src/object/auto/autojostle.cpp
@@ -23,8 +23,7 @@
// Object's constructor.
-CAutoJostle::CAutoJostle(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoJostle::CAutoJostle(CObject* object) : CAuto(object)
{
Init();
}
diff --git a/src/object/auto/autojostle.h b/src/object/auto/autojostle.h
index c156893..7b700ad 100644
--- a/src/object/auto/autojostle.h
+++ b/src/object/auto/autojostle.h
@@ -27,7 +27,7 @@
class CAutoJostle : public CAuto
{
public:
- CAutoJostle(CInstanceManager* iMan, CObject* object);
+ CAutoJostle(CObject* object);
~CAutoJostle();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autokid.cpp b/src/object/auto/autokid.cpp
index 64cd39a..a9f86b0 100644
--- a/src/object/auto/autokid.cpp
+++ b/src/object/auto/autokid.cpp
@@ -26,8 +26,7 @@
// Object's constructor.
-CAutoKid::CAutoKid(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoKid::CAutoKid(CObject* object) : CAuto(object)
{
m_soundChannel = -1;
Init();
diff --git a/src/object/auto/autokid.h b/src/object/auto/autokid.h
index 3e2fba7..19836a7 100644
--- a/src/object/auto/autokid.h
+++ b/src/object/auto/autokid.h
@@ -27,7 +27,7 @@
class CAutoKid : public CAuto
{
public:
- CAutoKid(CInstanceManager* iMan, CObject* object);
+ CAutoKid(CObject* object);
~CAutoKid();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autolabo.cpp b/src/object/auto/autolabo.cpp
index 70bcc5e..6984fd6 100644
--- a/src/object/auto/autolabo.cpp
+++ b/src/object/auto/autolabo.cpp
@@ -20,9 +20,13 @@
#include "common/global.h"
#include "common/misc.h"
+
#include "math/geometry.h"
+
#include "object/robotmain.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/window.h"
#include "ui/displaytext.h"
@@ -38,8 +42,7 @@ const float LABO_DELAY = 20.0f; // duration of the analysis
// Object's constructor.
-CAutoLabo::CAutoLabo(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+ CAutoLabo::CAutoLabo(CObject* object) : CAuto(object)
{
int i;
@@ -543,8 +546,8 @@ void CAutoLabo::SetResearch(EventType event)
m_main->WriteFreeParam();
Event newEvent(EVENT_UPDINTERFACE);
-// m_event->MakeEvent(newEvent, EVENT_UPDINTERFACE);
- m_event->AddEvent(newEvent);
+// m_eventQueue->MakeEvent(newEvent, EVENT_UPDINTERFACE);
+ m_eventQueue->AddEvent(newEvent);
UpdateInterface();
}
diff --git a/src/object/auto/autolabo.h b/src/object/auto/autolabo.h
index 8225462..b61e8e3 100644
--- a/src/object/auto/autolabo.h
+++ b/src/object/auto/autolabo.h
@@ -41,7 +41,7 @@ enum AutoLaboPhase
class CAutoLabo : public CAuto
{
public:
- CAutoLabo(CInstanceManager* iMan, CObject* object);
+ CAutoLabo(CObject* object);
~CAutoLabo();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/automush.cpp b/src/object/auto/automush.cpp
index cb94590..e97e2a1 100644
--- a/src/object/auto/automush.cpp
+++ b/src/object/auto/automush.cpp
@@ -19,6 +19,7 @@
#include "object/auto/automush.h"
#include "common/iman.h"
+
#include "script/cmdtoken.h"
@@ -28,8 +29,7 @@
// Object's constructor.
-CAutoMush::CAutoMush(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+ CAutoMush::CAutoMush(CObject* object) : CAuto(object)
{
Init();
}
diff --git a/src/object/auto/automush.h b/src/object/auto/automush.h
index 245393a..1697c5a 100644
--- a/src/object/auto/automush.h
+++ b/src/object/auto/automush.h
@@ -38,7 +38,7 @@ enum AutoMushPhase
class CAutoMush : public CAuto
{
public:
- CAutoMush(CInstanceManager* iMan, CObject* object);
+ CAutoMush(CObject* object);
~CAutoMush();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autonest.cpp b/src/object/auto/autonest.cpp
index 99927bd..1cf13d6 100644
--- a/src/object/auto/autonest.cpp
+++ b/src/object/auto/autonest.cpp
@@ -19,7 +19,9 @@
#include "object/auto/autonest.h"
#include "common/iman.h"
+
#include "graphics/engine/terrain.h"
+
#include "script/cmdtoken.h"
#include <stdio.h>
@@ -28,8 +30,7 @@
// Object's constructor.
-CAutoNest::CAutoNest(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+ CAutoNest::CAutoNest(CObject* object) : CAuto(object)
{
Init();
}
@@ -178,7 +179,7 @@ void CAutoNest::CreateFret(Math::Vector pos, float angle, ObjectType type)
{
CObject* fret;
- fret = new CObject(m_iMan);
+ fret = new CObject();
if ( !fret->CreateResource(pos, angle, type) )
{
delete fret;
diff --git a/src/object/auto/autonest.h b/src/object/auto/autonest.h
index 1009457..4d734a8 100644
--- a/src/object/auto/autonest.h
+++ b/src/object/auto/autonest.h
@@ -35,7 +35,7 @@ enum AutoNestPhase
class CAutoNest : public CAuto
{
public:
- CAutoNest(CInstanceManager* iMan, CObject* object);
+ CAutoNest(CObject* object);
~CAutoNest();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autonuclear.cpp b/src/object/auto/autonuclear.cpp
index 375acf0..75bfb45 100644
--- a/src/object/auto/autonuclear.cpp
+++ b/src/object/auto/autonuclear.cpp
@@ -19,8 +19,11 @@
#include "object/auto/autonuclear.h"
#include "common/iman.h"
+
#include "math/geometry.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/window.h"
#include "ui/displaytext.h"
@@ -36,8 +39,7 @@ const float NUCLEAR_DELAY = 30.0f; // duration of the generation
// Object's constructor.
-CAutoNuclear::CAutoNuclear(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoNuclear::CAutoNuclear(CObject* object) : CAuto(object)
{
m_channelSound = -1;
Init();
@@ -396,7 +398,7 @@ void CAutoNuclear::CreatePower()
pos = m_object->GetPosition(0);
angle = m_object->GetAngleY(0);
- power = new CObject(m_iMan);
+ power = new CObject();
if ( !power->CreateResource(pos, angle, OBJECT_ATOMIC) )
{
delete power;
diff --git a/src/object/auto/autonuclear.h b/src/object/auto/autonuclear.h
index 06a99af..5b01bba 100644
--- a/src/object/auto/autonuclear.h
+++ b/src/object/auto/autonuclear.h
@@ -38,7 +38,7 @@ enum AutoNuclearPhase
class CAutoNuclear : public CAuto
{
public:
- CAutoNuclear(CInstanceManager* iMan, CObject* object);
+ CAutoNuclear(CObject* object);
~CAutoNuclear();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autopara.cpp b/src/object/auto/autopara.cpp
index a3082f5..ad6517b 100644
--- a/src/object/auto/autopara.cpp
+++ b/src/object/auto/autopara.cpp
@@ -20,8 +20,11 @@
#include "common/iman.h"
+
#include "math/geometry.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/window.h"
@@ -32,8 +35,7 @@
// Object's constructor.
-CAutoPara::CAutoPara(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoPara::CAutoPara(CObject* object) : CAuto(object)
{
m_channelSound = -1;
Init();
diff --git a/src/object/auto/autopara.h b/src/object/auto/autopara.h
index 10a33a8..1f0b805 100644
--- a/src/object/auto/autopara.h
+++ b/src/object/auto/autopara.h
@@ -36,7 +36,7 @@ enum AutoParaPhase
class CAutoPara : public CAuto
{
public:
- CAutoPara(CInstanceManager* iMan, CObject* object);
+ CAutoPara(CObject* object);
~CAutoPara();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoportico.cpp b/src/object/auto/autoportico.cpp
index c0be784..1646874 100644
--- a/src/object/auto/autoportico.cpp
+++ b/src/object/auto/autoportico.cpp
@@ -55,8 +55,7 @@ float Progress(float a, float b, float progress)
// Object's constructor.
-CAutoPortico::CAutoPortico(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoPortico::CAutoPortico(CObject* object) : CAuto(object)
{
Init();
m_phase = APOP_WAIT;
diff --git a/src/object/auto/autoportico.h b/src/object/auto/autoportico.h
index c211d37..0aa580f 100644
--- a/src/object/auto/autoportico.h
+++ b/src/object/auto/autoportico.h
@@ -40,7 +40,7 @@ enum AutoPorticoPhase
class CAutoPortico : public CAuto
{
public:
- CAutoPortico(CInstanceManager* iMan, CObject* object);
+ CAutoPortico(CObject* object);
~CAutoPortico();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoradar.cpp b/src/object/auto/autoradar.cpp
index 4214d17..1a10aa7 100644
--- a/src/object/auto/autoradar.cpp
+++ b/src/object/auto/autoradar.cpp
@@ -19,7 +19,9 @@
#include "object/auto/autoradar.h"
#include "common/iman.h"
+
#include "math/geometry.h"
+
#include "ui/interface.h"
#include "ui/window.h"
#include "ui/gauge.h"
@@ -29,8 +31,7 @@
// Object's constructor.
-CAutoRadar::CAutoRadar(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoRadar::CAutoRadar(CObject* object) : CAuto(object)
{
Init();
m_phase = ARAP_WAIT;
diff --git a/src/object/auto/autoradar.h b/src/object/auto/autoradar.h
index e2c9df5..86833f9 100644
--- a/src/object/auto/autoradar.h
+++ b/src/object/auto/autoradar.h
@@ -37,7 +37,7 @@ enum AutoRadarPhase
class CAutoRadar : public CAuto
{
public:
- CAutoRadar(CInstanceManager* iMan, CObject* object);
+ CAutoRadar(CObject* object);
~CAutoRadar();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autorepair.cpp b/src/object/auto/autorepair.cpp
index cf4f33e..95b6cc8 100644
--- a/src/object/auto/autorepair.cpp
+++ b/src/object/auto/autorepair.cpp
@@ -19,8 +19,11 @@
#include "object/auto/autorepair.h"
#include "common/iman.h"
+
#include "physics/physics.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/window.h"
@@ -30,8 +33,7 @@
// Object's constructor.
-CAutoRepair::CAutoRepair(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoRepair::CAutoRepair(CObject* object) : CAuto(object)
{
Init();
m_phase = ARP_WAIT; // paused until the first Init ()
diff --git a/src/object/auto/autorepair.h b/src/object/auto/autorepair.h
index e8bb0b1..31a3c65 100644
--- a/src/object/auto/autorepair.h
+++ b/src/object/auto/autorepair.h
@@ -38,7 +38,7 @@ enum AutoRepairPhase
class CAutoRepair : public CAuto
{
public:
- CAutoRepair(CInstanceManager* iMan, CObject* object);
+ CAutoRepair(CObject* object);
~CAutoRepair();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoresearch.cpp b/src/object/auto/autoresearch.cpp
index 9f423ec..3c32307 100644
--- a/src/object/auto/autoresearch.cpp
+++ b/src/object/auto/autoresearch.cpp
@@ -19,9 +19,13 @@
#include "object/auto/autoresearch.h"
#include "common/global.h"
+
#include "math/geometry.h"
+
#include "object/robotmain.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/gauge.h"
#include "ui/window.h"
@@ -37,8 +41,7 @@ const float SEARCH_TIME = 30.0f; // duration of a research
// Object's constructor.
-CAutoResearch::CAutoResearch(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoResearch::CAutoResearch(CObject* object) : CAuto(object)
{
int i;
@@ -488,7 +491,7 @@ void CAutoResearch::SetResearch(EventType event)
m_main->WriteFreeParam();
Event newEvent(EVENT_UPDINTERFACE);
- m_event->AddEvent(newEvent);
+ m_eventQueue->AddEvent(newEvent);
UpdateInterface();
}
diff --git a/src/object/auto/autoresearch.h b/src/object/auto/autoresearch.h
index a838e64..6c804ef 100644
--- a/src/object/auto/autoresearch.h
+++ b/src/object/auto/autoresearch.h
@@ -35,7 +35,7 @@ enum AutoResearchPhase
class CAutoResearch : public CAuto
{
public:
- CAutoResearch(CInstanceManager* iMan, CObject* object);
+ CAutoResearch(CObject* object);
~CAutoResearch();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoroot.cpp b/src/object/auto/autoroot.cpp
index 196ed5d..a390e90 100644
--- a/src/object/auto/autoroot.cpp
+++ b/src/object/auto/autoroot.cpp
@@ -19,6 +19,7 @@
#include "graphics/engine/particle.h"
#include "graphics/engine/terrain.h"
+
#include "math/geometry.h"
#include <stdio.h>
@@ -26,8 +27,7 @@
// Object's constructor.
-CAutoRoot::CAutoRoot(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoRoot::CAutoRoot(CObject* object) : CAuto(object)
{
Init();
}
diff --git a/src/object/auto/autoroot.h b/src/object/auto/autoroot.h
index d80abe8..3eb906c 100644
--- a/src/object/auto/autoroot.h
+++ b/src/object/auto/autoroot.h
@@ -27,7 +27,7 @@
class CAutoRoot : public CAuto
{
public:
- CAutoRoot(CInstanceManager* iMan, CObject* object);
+ CAutoRoot(CObject* object);
~CAutoRoot();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autosafe.cpp b/src/object/auto/autosafe.cpp
index e89acea..fc83400 100644
--- a/src/object/auto/autosafe.cpp
+++ b/src/object/auto/autosafe.cpp
@@ -19,9 +19,13 @@
#include "object/auto/autosafe.h"
#include "common/iman.h"
+
#include "math/geometry.h"
+
#include "object/robotmain.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/window.h"
@@ -34,8 +38,7 @@ const float OPEN_DELAY = 8.0f; // duration of opening
// Object's constructor.
-CAutoSafe::CAutoSafe(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoSafe::CAutoSafe(CObject* object) : CAuto(object)
{
int i;
diff --git a/src/object/auto/autosafe.h b/src/object/auto/autosafe.h
index 3c0bcce..b575b4e 100644
--- a/src/object/auto/autosafe.h
+++ b/src/object/auto/autosafe.h
@@ -36,7 +36,7 @@ enum AutoSafePhase
class CAutoSafe : public CAuto
{
public:
- CAutoSafe(CInstanceManager* iMan, CObject* object);
+ CAutoSafe(CObject* object);
~CAutoSafe();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autostation.cpp b/src/object/auto/autostation.cpp
index e99ae4b..a2f5b6b 100644
--- a/src/object/auto/autostation.cpp
+++ b/src/object/auto/autostation.cpp
@@ -19,9 +19,12 @@
#include "object/auto/autostation.h"
#include "common/iman.h"
+
#include "graphics/engine/particle.h"
#include "graphics/engine/terrain.h"
+
#include "math/geometry.h"
+
#include "ui/interface.h"
#include "ui/gauge.h"
#include "ui/window.h"
@@ -31,8 +34,7 @@
// Object's constructor.
-CAutoStation::CAutoStation(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoStation::CAutoStation(CObject* object) : CAuto(object)
{
Init();
}
diff --git a/src/object/auto/autostation.h b/src/object/auto/autostation.h
index cb8be2b..d8a37b4 100644
--- a/src/object/auto/autostation.h
+++ b/src/object/auto/autostation.h
@@ -27,7 +27,7 @@
class CAutoStation : public CAuto
{
public:
- CAutoStation(CInstanceManager* iMan, CObject* object);
+ CAutoStation(CObject* object);
~CAutoStation();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autotower.cpp b/src/object/auto/autotower.cpp
index 84dcd85..e3b06cf 100644
--- a/src/object/auto/autotower.cpp
+++ b/src/object/auto/autotower.cpp
@@ -19,9 +19,13 @@
#include "object/auto/autotower.h"
#include "common/iman.h"
+
#include "math/geometry.h"
+
#include "physics/physics.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/displaytext.h"
#include "ui/window.h"
@@ -37,8 +41,7 @@ const float ENERGY_FIRE = 0.125f; // energy consumed by fire
// Object's constructor.
-CAutoTower::CAutoTower(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoTower::CAutoTower(CObject* object) : CAuto(object)
{
int i;
diff --git a/src/object/auto/autotower.h b/src/object/auto/autotower.h
index b29ba85..d219fb5 100644
--- a/src/object/auto/autotower.h
+++ b/src/object/auto/autotower.h
@@ -38,7 +38,7 @@ enum AutoTowerPhase
class CAutoTower : public CAuto
{
public:
- CAutoTower(CInstanceManager* iMan, CObject* object);
+ CAutoTower(CObject* object);
~CAutoTower();
void DeleteObject(bool bAll=false);
diff --git a/src/object/brain.cpp b/src/object/brain.cpp
index 1405201..babb38d 100644
--- a/src/object/brain.cpp
+++ b/src/object/brain.cpp
@@ -17,8 +17,10 @@
#include "object/brain.h"
-#include "common/misc.h"
+#include "app/app.h"
+
#include "common/iman.h"
+#include "common/misc.h"
#include "graphics/core/color.h"
#include "graphics/engine/terrain.h"
@@ -47,28 +49,25 @@ const int MAXTRACERECORD = 1000;
// Object's constructor.
-CBrain::CBrain(CInstanceManager* iMan, CObject* object)
+CBrain::CBrain(CObject* object)
{
- int i;
-
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_BRAIN, this, 100);
+ CInstanceManager::GetInstancePointer()->AddInstance(CLASS_BRAIN, this, 100);
m_object = object;
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
- m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
- m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
- m_interface = static_cast<Ui::CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
- m_displayText = static_cast<Ui::CDisplayText*>(m_iMan->SearchInstance(CLASS_DISPLAYTEXT));
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
- m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_physics = 0;
- m_motion = 0;
- m_primaryTask = 0;
- m_secondaryTask = 0;
- m_studio = 0;
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_water = m_engine->GetWater();
+ m_particle = m_engine->GetParticle();
+ m_main = CRobotMain::GetInstancePointer();
+ m_terrain = m_main->GetTerrain();
+ m_camera = m_main->GetCamera();
+ m_interface = m_main->GetInterface();
+ m_displayText = m_main->GetDisplayText();
+ m_sound = CApplication::GetInstancePointer()->GetSound();
+ m_physics = nullptr;
+ m_motion = nullptr;
+ m_primaryTask = nullptr;
+ m_secondaryTask = nullptr;
+ m_studio = nullptr;
m_program = -1;
m_bActivity = true;
@@ -89,7 +88,7 @@ CBrain::CBrain(CInstanceManager* iMan, CObject* object)
m_defaultEnter = EVENT_NULL;
m_manipStyle = EVENT_OBJECT_MFRONT;
- for ( i=0 ; i<BRAINMAXSCRIPT ; i++ )
+ for (int i=0 ; i<BRAINMAXSCRIPT ; i++ )
{
m_script[i] = 0;
m_scriptName[i][0] = 0;
@@ -106,9 +105,7 @@ CBrain::CBrain(CInstanceManager* iMan, CObject* object)
CBrain::~CBrain()
{
- int i;
-
- for ( i=0 ; i<BRAINMAXSCRIPT ; i++ )
+ for (int i=0 ; i<BRAINMAXSCRIPT ; i++ )
{
delete m_script[i];
m_script[i] = nullptr;
@@ -126,7 +123,7 @@ CBrain::~CBrain()
delete[] m_traceRecordBuffer;
m_traceRecordBuffer = nullptr;
- m_iMan->DeleteInstance(CLASS_BRAIN, this);
+ CInstanceManager::GetInstancePointer()->DeleteInstance(CLASS_BRAIN, this);
}
@@ -873,7 +870,7 @@ void CBrain::StartEditScript(int rank, char* name)
if ( m_script[rank] == 0 )
{
- m_script[rank] = new CScript(m_iMan, m_object, &m_secondaryTask);
+ m_script[rank] = new CScript(m_object, &m_secondaryTask);
}
m_studio = new Ui::CStudio();
@@ -908,7 +905,7 @@ Error CBrain::StartTaskTake()
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskTake();
UpdateInterface();
return err;
@@ -926,7 +923,7 @@ Error CBrain::StartTaskManip(TaskManipOrder order, TaskManipArm arm)
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskManip(order, arm);
UpdateInterface();
return err;
@@ -944,7 +941,7 @@ Error CBrain::StartTaskFlag(TaskFlagOrder order, int rank)
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskFlag(order, rank);
UpdateInterface();
return err;
@@ -962,7 +959,7 @@ Error CBrain::StartTaskBuild(ObjectType type)
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskBuild(type);
UpdateInterface();
return err;
@@ -980,7 +977,7 @@ Error CBrain::StartTaskSearch()
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskSearch();
UpdateInterface();
return err;
@@ -998,7 +995,7 @@ Error CBrain::StartTaskTerraform()
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskTerraform();
UpdateInterface();
return err;
@@ -1020,7 +1017,7 @@ Error CBrain::StartTaskPen(bool bDown, int color)
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskPen(bDown, color);
UpdateInterface();
return err;
@@ -1038,7 +1035,7 @@ Error CBrain::StartTaskRecover()
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskRecover();
UpdateInterface();
return err;
@@ -1056,7 +1053,7 @@ Error CBrain::StartTaskShield(TaskShieldMode mode)
m_secondaryTask = 0;
}
- m_secondaryTask = new CTaskManager(m_iMan, m_object);
+ m_secondaryTask = new CTaskManager(m_object);
err = m_secondaryTask->StartTaskShield(mode, 1000.0f);
UpdateInterface();
return err;
@@ -1074,7 +1071,7 @@ Error CBrain::StartTaskFire(float delay)
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskFire(delay);
UpdateInterface();
return err;
@@ -1092,7 +1089,7 @@ Error CBrain::StartTaskFireAnt(Math::Vector impact)
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskFireAnt(impact);
UpdateInterface();
return err;
@@ -1110,7 +1107,7 @@ Error CBrain::StartTaskGunGoal(float dirV, float dirH)
m_secondaryTask = 0;
}
- m_secondaryTask = new CTaskManager(m_iMan, m_object);
+ m_secondaryTask = new CTaskManager(m_object);
err = m_secondaryTask->StartTaskGunGoal(dirV, dirH);
UpdateInterface();
return err;
@@ -1128,7 +1125,7 @@ Error CBrain::StartTaskReset(Math::Vector goal, Math::Vector angle)
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskReset(goal, angle);
UpdateInterface();
return err;
@@ -2698,7 +2695,7 @@ bool CBrain::ReadProgram(int rank, const char* filename)
{
if ( m_script[rank] == 0 )
{
- m_script[rank] = new CScript(m_iMan, m_object, &m_secondaryTask);
+ m_script[rank] = new CScript(m_object, &m_secondaryTask);
}
if ( m_script[rank]->ReadScript(filename) ) return true;
@@ -2723,7 +2720,7 @@ bool CBrain::WriteProgram(int rank, char* filename)
{
if ( m_script[rank] == 0 )
{
- m_script[rank] = new CScript(m_iMan, m_object, &m_secondaryTask);
+ m_script[rank] = new CScript(m_object, &m_secondaryTask);
}
if ( m_script[rank]->WriteScript(filename) ) return true;
@@ -2753,7 +2750,7 @@ bool CBrain::ReadStack(FILE *file)
if ( m_script[op] == 0 )
{
- m_script[op] = new CScript(m_iMan, m_object, &m_secondaryTask);
+ m_script[op] = new CScript(m_object, &m_secondaryTask);
}
if ( !m_script[op]->ReadStack(file) ) return false;
}
@@ -2915,7 +2912,7 @@ void CBrain::TraceRecordStop()
i = m_selScript;
if ( m_script[i] == 0 )
{
- m_script[i] = new CScript(m_iMan, m_object, &m_secondaryTask);
+ m_script[i] = new CScript(m_object, &m_secondaryTask);
}
m_script[i]->SendScript(buffer);
delete[] buffer;
diff --git a/src/object/brain.h b/src/object/brain.h
index ce7116e..5656f62 100644
--- a/src/object/brain.h
+++ b/src/object/brain.h
@@ -31,7 +31,6 @@
#include "object/task/taskshield.h"
-class CInstanceManager;
class CObject;
class CPhysics;
class CMotion;
@@ -80,7 +79,7 @@ struct TraceRecord
class CBrain
{
public:
- CBrain(CInstanceManager* iMan, CObject* object);
+ CBrain(CObject* object);
~CBrain();
void DeleteObject(bool bAll=false);
@@ -167,7 +166,6 @@ protected:
bool TraceRecordPut(char *buffer, int max, TraceOper oper, float param);
protected:
- CInstanceManager* m_iMan;
Gfx::CEngine* m_engine;
Gfx::CTerrain* m_terrain;
Gfx::CWater* m_water;
diff --git a/src/object/mainmovie.cpp b/src/object/mainmovie.cpp
index 9aaf345..04c0d56 100644
--- a/src/object/mainmovie.cpp
+++ b/src/object/mainmovie.cpp
@@ -17,7 +17,7 @@
#include "object/mainmovie.h"
-#include "common/iman.h"
+#include "app/app.h"
#include "math/geometry.h"
@@ -30,15 +30,12 @@
// Constructor of the application card.
-CMainMovie::CMainMovie(CInstanceManager* iMan)
+CMainMovie::CMainMovie()
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_SHORT, this);
-
- m_engine = static_cast< Gfx::CEngine* >(m_iMan->SearchInstance(CLASS_ENGINE));
- m_main = static_cast< CRobotMain* >(m_iMan->SearchInstance(CLASS_MAIN));
- m_camera = static_cast< Gfx::CCamera* >(m_iMan->SearchInstance(CLASS_CAMERA));
- m_sound = static_cast< CSoundInterface* >(m_iMan->SearchInstance(CLASS_SOUND));
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_main = CRobotMain::GetInstancePointer();
+ m_camera = m_main->GetCamera();
+ m_sound = CApplication::GetInstancePointer()->GetSound();
Flush();
}
diff --git a/src/object/mainmovie.h b/src/object/mainmovie.h
index eba21eb..4554431 100644
--- a/src/object/mainmovie.h
+++ b/src/object/mainmovie.h
@@ -23,18 +23,17 @@
#include "common/event.h"
+
#include "math/vector.h"
-class CInstanceManager;
class CRobotMain;
class CSoundInterface;
-namespace Gfx
-{
- class CCamera;
- class CEngine;
-};
+namespace Gfx {
+class CCamera;
+class CEngine;
+}
enum MainMovieType
{
@@ -48,7 +47,7 @@ enum MainMovieType
class CMainMovie
{
public:
- CMainMovie(CInstanceManager* iMan);
+ CMainMovie();
~CMainMovie();
void Flush();
@@ -60,9 +59,6 @@ public:
MainMovieType GetStopType();
protected:
-
-protected:
- CInstanceManager* m_iMan;
Gfx::CEngine* m_engine;
CRobotMain* m_main;
Gfx::CCamera* m_camera;
diff --git a/src/object/motion/motion.cpp b/src/object/motion/motion.cpp
index 605091f..00b3073 100644
--- a/src/object/motion/motion.cpp
+++ b/src/object/motion/motion.cpp
@@ -19,7 +19,7 @@
#include "app/app.h"
-#include "common/iman.h"
+#include "object/robotmain.h"
#include "script/cmdtoken.h"
@@ -30,20 +30,16 @@
// Object's constructor.
-CMotion::CMotion(CInstanceManager* iMan, CObject* object)
+CMotion::CMotion(CObject* object)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_MOTION, this, 100);
-
m_app = CApplication::GetInstancePointer();
- m_engine = static_cast< Gfx::CEngine* >(m_iMan->SearchInstance(CLASS_ENGINE));
- m_light = static_cast< Gfx::CLight* >(m_iMan->SearchInstance(CLASS_LIGHT));
- m_particle = static_cast< Gfx::CParticle* >(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_terrain = static_cast< Gfx::CTerrain* >(m_iMan->SearchInstance(CLASS_TERRAIN));
- m_water = static_cast< Gfx::CWater* >(m_iMan->SearchInstance(CLASS_WATER));
- m_camera = static_cast< Gfx::CCamera* >(m_iMan->SearchInstance(CLASS_CAMERA));
- m_main = static_cast< CRobotMain* >(m_iMan->SearchInstance(CLASS_MAIN));
- m_sound = static_cast< CSoundInterface* >(m_iMan->SearchInstance(CLASS_SOUND));
+ m_sound = m_app->GetSound();
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_particle = m_engine->GetParticle();
+ m_water = m_engine->GetWater();
+ m_main = CRobotMain::GetInstancePointer();
+ m_terrain = m_main->GetTerrain();
+ m_camera = m_main->GetCamera();
m_object = object;
m_physics = 0;
@@ -62,7 +58,6 @@ CMotion::CMotion(CInstanceManager* iMan, CObject* object)
CMotion::~CMotion()
{
- m_iMan->DeleteInstance(CLASS_MOTION, this);
}
// Deletes the object.
diff --git a/src/object/motion/motion.h b/src/object/motion/motion.h
index 81bcb08..d35ee67 100644
--- a/src/object/motion/motion.h
+++ b/src/object/motion/motion.h
@@ -27,14 +27,12 @@
namespace Gfx {
class CEngine;
-class CLight;
class CParticle;
class CTerrain;
class CWater;
class CCamera;
}
-class CInstanceManager;
class CApplication;
class CBrain;
class CPhysics;
@@ -46,7 +44,7 @@ class CSoundInterface;
class CMotion
{
public:
- CMotion(CInstanceManager* iMan, CObject* object);
+ CMotion(CObject* object);
virtual ~CMotion();
void SetPhysics(CPhysics* physics);
@@ -72,12 +70,8 @@ public:
virtual Math::Vector GetInclinaison();
protected:
-
-protected:
- CInstanceManager* m_iMan;
CApplication* m_app;
Gfx::CEngine* m_engine;
- Gfx::CLight* m_light;
Gfx::CParticle* m_particle;
Gfx::CTerrain* m_terrain;
Gfx::CWater* m_water;
diff --git a/src/object/motion/motionant.cpp b/src/object/motion/motionant.cpp
index db8ff37..384d683 100644
--- a/src/object/motion/motionant.cpp
+++ b/src/object/motion/motionant.cpp
@@ -35,8 +35,7 @@ const float START_TIME = 1000.0f; // beginning of the relative time
// Object's constructor.
-CMotionAnt::CMotionAnt(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionAnt::CMotionAnt(CObject* object) : CMotion(object)
{
m_armMember = START_TIME;
m_armTimeAbs = START_TIME;
diff --git a/src/object/motion/motionant.h b/src/object/motion/motionant.h
index 68a3b7f..45d02b3 100644
--- a/src/object/motion/motionant.h
+++ b/src/object/motion/motionant.h
@@ -46,7 +46,7 @@ enum MotionAntSpecialAction
class CMotionAnt : public CMotion
{
public:
- CMotionAnt(CInstanceManager* iMan, CObject* object);
+ CMotionAnt(CObject* object);
~CMotionAnt();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motionbee.cpp b/src/object/motion/motionbee.cpp
index 111339d..8f69945 100644
--- a/src/object/motion/motionbee.cpp
+++ b/src/object/motion/motionbee.cpp
@@ -34,8 +34,7 @@ const float START_TIME = 1000.0f; // beginning of the relative time
// Object's constructor.
-CMotionBee::CMotionBee(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionBee::CMotionBee(CObject* object) : CMotion(object)
{
m_armMember = START_TIME;
m_armTimeAbs = START_TIME;
diff --git a/src/object/motion/motionbee.h b/src/object/motion/motionbee.h
index aa8e5a6..c0347a0 100644
--- a/src/object/motion/motionbee.h
+++ b/src/object/motion/motionbee.h
@@ -40,7 +40,7 @@ enum MotionBeeSpecialAction
class CMotionBee : public CMotion
{
public:
- CMotionBee(CInstanceManager* iMan, CObject* object);
+ CMotionBee(CObject* object);
~CMotionBee();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motionhuman.cpp b/src/object/motion/motionhuman.cpp
index 5ff4af3..dc5ff34 100644
--- a/src/object/motion/motionhuman.cpp
+++ b/src/object/motion/motionhuman.cpp
@@ -43,8 +43,7 @@ const float START_TIME = 1000.0f; // beginning of the relative time
// Object's constructor.
-CMotionHuman::CMotionHuman(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionHuman::CMotionHuman(CObject* object) : CMotion(object)
{
m_partiReactor = -1;
m_armMember = START_TIME;
diff --git a/src/object/motion/motionhuman.h b/src/object/motion/motionhuman.h
index b365a77..ddb0843 100644
--- a/src/object/motion/motionhuman.h
+++ b/src/object/motion/motionhuman.h
@@ -58,7 +58,7 @@ enum MotionHumanSpecialAction
class CMotionHuman : public CMotion
{
public:
- CMotionHuman(CInstanceManager* iMan, CObject* object);
+ CMotionHuman(CObject* object);
~CMotionHuman();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motionmother.cpp b/src/object/motion/motionmother.cpp
index ce1362f..573a2e4 100644
--- a/src/object/motion/motionmother.cpp
+++ b/src/object/motion/motionmother.cpp
@@ -34,8 +34,7 @@ const float START_TIME = 1000.0f; // beginning of the relative time
// Object's constructor.
-CMotionMother::CMotionMother(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionMother::CMotionMother(CObject* object) : CMotion(object)
{
m_armMember = START_TIME;
m_armTimeAbs = START_TIME;
diff --git a/src/object/motion/motionmother.h b/src/object/motion/motionmother.h
index 5060315..a6c7e93 100644
--- a/src/object/motion/motionmother.h
+++ b/src/object/motion/motionmother.h
@@ -26,7 +26,7 @@
class CMotionMother : public CMotion
{
public:
- CMotionMother(CInstanceManager* iMan, CObject* object);
+ CMotionMother(CObject* object);
~CMotionMother();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motionspider.cpp b/src/object/motion/motionspider.cpp
index 3ede492..59bc6e0 100644
--- a/src/object/motion/motionspider.cpp
+++ b/src/object/motion/motionspider.cpp
@@ -35,8 +35,7 @@ const float START_TIME = 1000.0f; // beginning of the relative time
// Object's constructor.
-CMotionSpider::CMotionSpider(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionSpider::CMotionSpider(CObject* object) : CMotion(object)
{
m_armMember = START_TIME;
m_armTimeAbs = START_TIME;
diff --git a/src/object/motion/motionspider.h b/src/object/motion/motionspider.h
index fbf05f9..89745c4 100644
--- a/src/object/motion/motionspider.h
+++ b/src/object/motion/motionspider.h
@@ -44,7 +44,7 @@ enum MotionSpiderSpecialAction
class CMotionSpider : public CMotion
{
public:
- CMotionSpider(CInstanceManager* iMan, CObject* object);
+ CMotionSpider(CObject* object);
~CMotionSpider();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motiontoto.cpp b/src/object/motion/motiontoto.cpp
index 3a7f1ac..ddb1867 100644
--- a/src/object/motion/motiontoto.cpp
+++ b/src/object/motion/motiontoto.cpp
@@ -38,8 +38,7 @@ const float START_TIME = 1000.0f; // beginning of the relative time
// Object's constructor.
-CMotionToto::CMotionToto(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionToto::CMotionToto(CObject* object) : CMotion(object)
{
m_time = 0.0f;
m_bDisplayInfo = false;
diff --git a/src/object/motion/motiontoto.h b/src/object/motion/motiontoto.h
index 4072b62..47baa28 100644
--- a/src/object/motion/motiontoto.h
+++ b/src/object/motion/motiontoto.h
@@ -35,7 +35,7 @@ enum MotionTotoAction
class CMotionToto : public CMotion
{
public:
- CMotionToto(CInstanceManager* iMan, CObject* object);
+ CMotionToto(CObject* object);
~CMotionToto();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motionvehicle.cpp b/src/object/motion/motionvehicle.cpp
index 3c95a27..44b8fdd 100644
--- a/src/object/motion/motionvehicle.cpp
+++ b/src/object/motion/motionvehicle.cpp
@@ -38,8 +38,7 @@
// Object's constructor.
-CMotionVehicle::CMotionVehicle(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionVehicle::CMotionVehicle(CObject* object) : CMotion(object)
{
int i;
@@ -926,7 +925,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_object->CreateEffectLight(20.0f, color);
// Creates the battery.
- pPower = new CObject(m_iMan);
+ pPower = new CObject();
pPower->SetType(power<=1.0f?OBJECT_POWER:OBJECT_ATOMIC);
rank = m_engine->CreateObject();
diff --git a/src/object/motion/motionvehicle.h b/src/object/motion/motionvehicle.h
index ca60c1e..ffb25ef 100644
--- a/src/object/motion/motionvehicle.h
+++ b/src/object/motion/motionvehicle.h
@@ -26,7 +26,7 @@
class CMotionVehicle : public CMotion
{
public:
- CMotionVehicle(CInstanceManager* iMan, CObject* object);
+ CMotionVehicle(CObject* object);
~CMotionVehicle();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motionworm.cpp b/src/object/motion/motionworm.cpp
index f32765d..ee555a8 100644
--- a/src/object/motion/motionworm.cpp
+++ b/src/object/motion/motionworm.cpp
@@ -42,8 +42,7 @@ const int WORM_PART = 7; // number of parts of a worm
// Object's constructor.
-CMotionWorm::CMotionWorm(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionWorm::CMotionWorm(CObject* object) : CMotion(object)
{
m_timeUp = 18.0f;
m_timeDown = 18.0f;
diff --git a/src/object/motion/motionworm.h b/src/object/motion/motionworm.h
index aed5a23..7684faf 100644
--- a/src/object/motion/motionworm.h
+++ b/src/object/motion/motionworm.h
@@ -26,7 +26,7 @@
class CMotionWorm : public CMotion
{
public:
- CMotionWorm(CInstanceManager* iMan, CObject* object);
+ CMotionWorm(CObject* object);
~CMotionWorm();
void DeleteObject(bool bAll=false);
diff --git a/src/object/object.cpp b/src/object/object.cpp
index 317775d..8f2a4cc 100644
--- a/src/object/object.cpp
+++ b/src/object/object.cpp
@@ -209,28 +209,25 @@ void uObject(CBotVar* botThis, void* user)
// Object's constructor.
-CObject::CObject(CInstanceManager* iMan)
+CObject::CObject()
{
- int i;
-
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_OBJECT, this, 500);
+ CInstanceManager::GetInstancePointer()->AddInstance(CLASS_OBJECT, this, 500);
m_app = CApplication::GetInstancePointer();
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_lightMan = static_cast<Gfx::CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT));
- m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
- m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
- m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
- m_displayText = static_cast<Ui::CDisplayText*>(m_iMan->SearchInstance(CLASS_DISPLAYTEXT));
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
- m_physics = 0;
- m_brain = 0;
- m_motion = 0;
- m_auto = 0;
- m_runScript = 0;
+ m_sound = m_app->GetSound();
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_lightMan = m_engine->GetLightManager();
+ m_water = m_engine->GetWater();
+ m_particle = m_engine->GetParticle();
+ m_main = CRobotMain::GetInstancePointer();
+ m_terrain = m_main->GetTerrain();
+ m_camera = m_main->GetCamera();
+ m_displayText = m_main->GetDisplayText();
+ m_physics = nullptr;
+ m_brain = nullptr;
+ m_motion = nullptr;
+ m_auto = nullptr;
+ m_runScript = nullptr;
m_type = OBJECT_FIX;
m_id = ++g_id;
@@ -309,18 +306,18 @@ CObject::CObject(CInstanceManager* iMan)
m_infoReturn = NAN;
m_bInfoUpdate = false;
- for ( i=0 ; i<OBJECTMAXPART ; i++ )
+ for (int i=0 ; i<OBJECTMAXPART ; i++ )
{
m_objectPart[i].bUsed = false;
}
m_totalPart = 0;
- for ( i=0 ; i<4 ; i++ )
+ for (int i=0 ; i<4 ; i++ )
{
m_partiSel[i] = -1;
}
- for ( i=0 ; i<OBJECTMAXCMDLINE ; i++ )
+ for (int i=0 ; i<OBJECTMAXCMDLINE ; i++ )
{
m_cmdLine[i] = NAN;
}
@@ -362,7 +359,7 @@ CObject::~CObject()
delete m_auto;
m_auto = nullptr;
- m_iMan->DeleteInstance(CLASS_OBJECT, this);
+ CInstanceManager::GetInstancePointer()->DeleteInstance(CLASS_OBJECT, this);
m_app = nullptr;
}
@@ -376,7 +373,6 @@ void CObject::DeleteObject(bool bAll)
{
CObject* pObj;
Gfx::CPyro* pPyro;
- int i;
if ( m_botVar != 0 )
{
@@ -388,9 +384,11 @@ void CObject::DeleteObject(bool bAll)
m_camera->SetControllingObject(0);
}
- for ( i=0 ; i<1000000 ; i++ )
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
+ for (int i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
pObj->DeleteDeselList(this);
@@ -419,9 +417,9 @@ void CObject::DeleteObject(bool bAll)
}
}
#endif
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i=0 ; i<1000000 ; i++ )
{
- pPyro = static_cast<Gfx::CPyro*>(m_iMan->SearchInstance(CLASS_PYRO, i));
+ pPyro = static_cast<Gfx::CPyro*>(iMan->SearchInstance(CLASS_PYRO, i));
if ( pPyro == 0 ) break;
pPyro->CutObjectLink(this); // the object no longer exists
@@ -496,7 +494,7 @@ void CObject::DeleteObject(bool bAll)
m_auto->DeleteObject(bAll);
}
- for ( i=0 ; i<OBJECTMAXPART ; i++ )
+ for (int i=0 ; i<OBJECTMAXPART ; i++ )
{
if ( m_objectPart[i].bUsed )
{
@@ -753,7 +751,7 @@ bool CObject::ExploObject(ExploType type, float force, float decay)
loss = 1.0f;
}
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(pyroType, this, loss);
if ( shield == 0.0f ) // dead?
@@ -2091,7 +2089,7 @@ bool CObject::CreateVehicle(Math::Vector pos, float angle, ObjectType type,
if ( type == OBJECT_TOTO )
{
- m_motion = new CMotionToto(m_iMan, this);
+ m_motion = new CMotionToto(this);
m_motion->Create(pos, angle, type, 1.0f);
return true;
}
@@ -2099,8 +2097,8 @@ bool CObject::CreateVehicle(Math::Vector pos, float angle, ObjectType type,
SetTrainer(bTrainer);
SetToy(bToy);
- m_physics = new CPhysics(m_iMan, this);
- m_brain = new CBrain(m_iMan, this);
+ m_physics = new CPhysics(this);
+ m_brain = new CBrain(this);
m_physics->SetBrain(m_brain);
m_brain->SetPhysics(m_physics);
@@ -2137,11 +2135,11 @@ bool CObject::CreateVehicle(Math::Vector pos, float angle, ObjectType type,
if ( type == OBJECT_HUMAN ||
type == OBJECT_TECH )
{
- m_motion = new CMotionHuman(m_iMan, this);
+ m_motion = new CMotionHuman(this);
}
else
{
- m_motion = new CMotionVehicle(m_iMan, this);
+ m_motion = new CMotionVehicle(this);
}
if ( m_motion == 0 ) return false;
@@ -2181,31 +2179,31 @@ bool CObject::CreateInsect(Math::Vector pos, float angle, ObjectType type)
{
m_type = type;
- m_physics = new CPhysics(m_iMan, this);
- m_brain = new CBrain(m_iMan, this);
+ m_physics = new CPhysics(this);
+ m_brain = new CBrain(this);
m_physics->SetBrain(m_brain);
m_brain->SetPhysics(m_physics);
if ( type == OBJECT_MOTHER )
{
- m_motion = new CMotionMother(m_iMan, this);
+ m_motion = new CMotionMother(this);
}
if ( type == OBJECT_ANT )
{
- m_motion = new CMotionAnt(m_iMan, this);
+ m_motion = new CMotionAnt(this);
}
if ( type == OBJECT_SPIDER )
{
- m_motion = new CMotionSpider(m_iMan, this);
+ m_motion = new CMotionSpider(this);
}
if ( type == OBJECT_BEE )
{
- m_motion = new CMotionBee(m_iMan, this);
+ m_motion = new CMotionBee(this);
}
if ( type == OBJECT_WORM )
{
- m_motion = new CMotionWorm(m_iMan, this);
+ m_motion = new CMotionWorm(this);
}
if ( m_motion == 0 ) return false;
@@ -3139,7 +3137,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
{
CObject* pPower;
- pPower = new CObject(m_iMan);
+ pPower = new CObject();
pPower->SetType(power<=1.0f?OBJECT_POWER:OBJECT_ATOMIC);
rank = m_engine->CreateObject();
@@ -5467,91 +5465,91 @@ void CObject::CreateOtherObject(ObjectType type)
{
if ( type == OBJECT_BASE )
{
- m_auto = new CAutoBase(m_iMan, this);
+ m_auto = new CAutoBase(this);
}
if ( type == OBJECT_PORTICO )
{
- m_auto = new CAutoPortico(m_iMan, this);
+ m_auto = new CAutoPortico(this);
}
if ( type == OBJECT_DERRICK )
{
- m_auto = new CAutoDerrick(m_iMan, this);
+ m_auto = new CAutoDerrick(this);
}
if ( type == OBJECT_FACTORY )
{
- m_auto = new CAutoFactory(m_iMan, this);
+ m_auto = new CAutoFactory(this);
}
if ( type == OBJECT_REPAIR )
{
- m_auto = new CAutoRepair(m_iMan, this);
+ m_auto = new CAutoRepair(this);
}
if ( type == OBJECT_DESTROYER )
{
- m_auto = new CAutoDestroyer(m_iMan, this);
+ m_auto = new CAutoDestroyer(this);
}
if ( type == OBJECT_STATION )
{
- m_auto = new CAutoStation(m_iMan, this);
+ m_auto = new CAutoStation(this);
}
if ( type == OBJECT_CONVERT )
{
- m_auto = new CAutoConvert(m_iMan, this);
+ m_auto = new CAutoConvert(this);
}
if ( type == OBJECT_TOWER )
{
- m_auto = new CAutoTower(m_iMan, this);
+ m_auto = new CAutoTower(this);
}
if ( type == OBJECT_RESEARCH )
{
- m_auto = new CAutoResearch(m_iMan, this);
+ m_auto = new CAutoResearch(this);
}
if ( type == OBJECT_RADAR )
{
- m_auto = new CAutoRadar(m_iMan, this);
+ m_auto = new CAutoRadar(this);
}
if ( type == OBJECT_INFO )
{
- m_auto = new CAutoInfo(m_iMan, this);
+ m_auto = new CAutoInfo(this);
}
if ( type == OBJECT_ENERGY )
{
- m_auto = new CAutoEnergy(m_iMan, this);
+ m_auto = new CAutoEnergy(this);
}
if ( type == OBJECT_LABO )
{
- m_auto = new CAutoLabo(m_iMan, this);
+ m_auto = new CAutoLabo(this);
}
if ( type == OBJECT_NUCLEAR )
{
- m_auto = new CAutoNuclear(m_iMan, this);
+ m_auto = new CAutoNuclear(this);
}
if ( type == OBJECT_PARA )
{
- m_auto = new CAutoPara(m_iMan, this);
+ m_auto = new CAutoPara(this);
}
if ( type == OBJECT_SAFE )
{
- m_auto = new CAutoSafe(m_iMan, this);
+ m_auto = new CAutoSafe(this);
}
if ( type == OBJECT_HUSTON )
{
- m_auto = new CAutoHuston(m_iMan, this);
+ m_auto = new CAutoHuston(this);
}
if ( type == OBJECT_EGG )
{
- m_auto = new CAutoEgg(m_iMan, this);
+ m_auto = new CAutoEgg(this);
}
if ( type == OBJECT_NEST )
{
- m_auto = new CAutoNest(m_iMan, this);
+ m_auto = new CAutoNest(this);
}
if ( type == OBJECT_ROOT5 )
{
- m_auto = new CAutoRoot(m_iMan, this);
+ m_auto = new CAutoRoot(this);
}
if ( type == OBJECT_MUSHROOM2 )
{
- m_auto = new CAutoMush(m_iMan, this);
+ m_auto = new CAutoMush(this);
}
if ( type == OBJECT_FLAGb ||
type == OBJECT_FLAGr ||
@@ -5559,13 +5557,13 @@ void CObject::CreateOtherObject(ObjectType type)
type == OBJECT_FLAGy ||
type == OBJECT_FLAGv )
{
- m_auto = new CAutoFlag(m_iMan, this);
+ m_auto = new CAutoFlag(this);
}
if ( type == OBJECT_TEEN36 || // trunk?
type == OBJECT_TEEN37 || // boat?
type == OBJECT_TEEN38 ) // fan?
{
- m_auto = new CAutoKid(m_iMan, this);
+ m_auto = new CAutoKid(this);
}
}
@@ -5979,7 +5977,7 @@ bool CObject::EventFrame(const Event &event)
m_bProxyActivate = false;
m_main->CreateShortcuts();
m_sound->Play(SOUND_FINDING);
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FINDING, this, 0.0f);
m_displayText->DisplayError(INFO_FINDING, this);
}
@@ -6453,7 +6451,7 @@ bool CObject::JostleObject(float force)
{
if ( m_auto != 0 ) return false;
- m_auto = new CAutoJostle(m_iMan, this);
+ m_auto = new CAutoJostle(this);
pa = static_cast<CAutoJostle*>(m_auto);
pa->Start(0, force);
}
diff --git a/src/object/object.h b/src/object/object.h
index 8d8baca..4d8cc02 100644
--- a/src/object/object.h
+++ b/src/object/object.h
@@ -28,7 +28,6 @@
#include "sound/sound.h"
-class CInstanceManager;
class CApplication;
class CPhysics;
class CBrain;
@@ -39,8 +38,7 @@ class CRobotMain;
class CBotVar;
class CScript;
-namespace Ui
-{
+namespace Ui {
class CDisplayText;
}
@@ -377,7 +375,7 @@ enum RadarFilter
class CObject
{
public:
- CObject(CInstanceManager* iMan);
+ CObject();
~CObject();
void DeleteObject(bool bAll=false);
@@ -679,7 +677,6 @@ protected:
void UpdateSelectParticle();
protected:
- CInstanceManager* m_iMan;
CApplication* m_app;
Gfx::CEngine* m_engine;
Gfx::CLightManager* m_lightMan;
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index ca13efc..6efd853 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -80,7 +80,7 @@
#include "ui/window.h"
-template<> CRobotMain* CSingleton<CRobotMain>::mInstance = nullptr;
+template<> CRobotMain* CSingleton<CRobotMain>::m_instance = nullptr;
// TODO: remove once using std::string
@@ -606,29 +606,27 @@ bool rPoint(CBotVar* pThis, CBotVar* var, CBotVar* pResult, int& Exception)
//! Constructor of robot application
-CRobotMain::CRobotMain(CInstanceManager* iMan, CApplication* app)
+CRobotMain::CRobotMain(CApplication* app)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_MAIN, this);
-
m_app = app;
- m_eventQueue = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_lightMan = static_cast<Gfx::CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT));
- m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
- m_cloud = static_cast<Gfx::CCloud*>(m_iMan->SearchInstance(CLASS_CLOUD));
- m_lightning = static_cast<Gfx::CLightning*>(m_iMan->SearchInstance(CLASS_BLITZ));
- m_planet = static_cast<Gfx::CPlanet*>(m_iMan->SearchInstance(CLASS_PLANET));
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
+ m_eventQueue = m_app->GetEventQueue();
+ m_sound = m_app->GetSound();
+
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_lightMan = m_engine->GetLightManager();
+ m_particle = m_engine->GetParticle();
+ m_water = m_engine->GetWater();
+ m_cloud = m_engine->GetCloud();
+ m_lightning = m_engine->GetLightning();
+ m_planet = m_engine->GetPlanet();
m_interface = new Ui::CInterface();
- m_terrain = new Gfx::CTerrain(m_iMan);
- m_camera = new Gfx::CCamera(m_iMan);
+ m_terrain = new Gfx::CTerrain();
+ m_camera = new Gfx::CCamera();
m_displayText = new Ui::CDisplayText();
- m_movie = new CMainMovie(m_iMan);
- m_dialog = new Ui::CMainDialog(m_iMan);
+ m_movie = new CMainMovie();
+ m_dialog = new Ui::CMainDialog();
m_short = new Ui::CMainShort();
m_map = new Ui::CMainMap();
m_displayInfo = nullptr;
@@ -857,10 +855,29 @@ CRobotMain::~CRobotMain()
delete m_map;
m_map = nullptr;
- m_iMan = nullptr;
m_app = nullptr;
}
+Gfx::CCamera* CRobotMain::GetCamera()
+{
+ return m_camera;
+}
+
+Gfx::CTerrain* CRobotMain::GetTerrain()
+{
+ return m_terrain;
+}
+
+Ui::CInterface* CRobotMain::GetInterface()
+{
+ return m_interface;
+}
+
+Ui::CDisplayText* CRobotMain::GetDisplayText()
+{
+ return m_displayText;
+}
+
//! Creates the file colobot.ini at the first time
void CRobotMain::CreateIni()
@@ -1027,10 +1044,6 @@ void CRobotMain::ChangePhase(Phase phase)
m_cloud->Flush();
m_lightning->Flush();
m_planet->Flush();
- m_iMan->Flush(CLASS_OBJECT);
- m_iMan->Flush(CLASS_PHYSICS);
- m_iMan->Flush(CLASS_BRAIN);
- m_iMan->Flush(CLASS_PYRO);
m_interface->Flush();
ClearInterface();
FlushNewScriptName();
@@ -1042,6 +1055,12 @@ void CRobotMain::ChangePhase(Phase phase)
m_cameraZoom = 0.0f;
m_shortCut = true;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+ iMan->Flush(CLASS_OBJECT);
+ iMan->Flush(CLASS_PHYSICS);
+ iMan->Flush(CLASS_BRAIN);
+ iMan->Flush(CLASS_PYRO);
+
Math::Point dim, pos;
// Creates and hide the command console.
@@ -2392,10 +2411,11 @@ CObject* CRobotMain::GetSelectObject()
//! Deselects everything, and returns the object that was selected
CObject* CRobotMain::DeselectAll()
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
CObject* prev = nullptr;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetSelect()) prev = obj;
@@ -2503,10 +2523,12 @@ bool CRobotMain::DeselectObject()
//! Quickly removes all objects
void CRobotMain::DeleteAllObjects()
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
// Removes all pyrotechnic effects in progress.
while (true)
{
- Gfx::CPyro* pyro = static_cast<Gfx::CPyro*>(m_iMan->SearchInstance(CLASS_PYRO, 0));
+ Gfx::CPyro* pyro = static_cast<Gfx::CPyro*>(iMan->SearchInstance(CLASS_PYRO, 0));
if (pyro == nullptr) break;
pyro->DeleteObject();
@@ -2526,7 +2548,7 @@ void CRobotMain::DeleteAllObjects()
while (true)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, 0));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, 0));
if (obj == nullptr) break;
obj->DeleteObject(true); // destroys rapidly
@@ -2543,9 +2565,10 @@ void CRobotMain::SelectHuman()
//! Returns the object human
CObject* CRobotMain::SearchHuman()
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == 0) break;
ObjectType type = obj->GetType();
@@ -2558,9 +2581,10 @@ CObject* CRobotMain::SearchHuman()
//! Returns the object toto
CObject* CRobotMain::SearchToto()
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
ObjectType type = obj->GetType();
@@ -2573,11 +2597,12 @@ CObject* CRobotMain::SearchToto()
//! Returns the nearest selectable object from a given position
CObject* CRobotMain::SearchNearest(Math::Vector pos, CObject* exclu)
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
float min = 100000.0f;
CObject* best = 0;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj == exclu) continue;
@@ -2600,9 +2625,10 @@ CObject* CRobotMain::SearchNearest(Math::Vector pos, CObject* exclu)
//! Returns the selected object
CObject* CRobotMain::GetSelect()
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetSelect())
@@ -2613,9 +2639,10 @@ CObject* CRobotMain::GetSelect()
CObject* CRobotMain::SearchObject(ObjectType type)
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetType() == type)
@@ -2628,10 +2655,11 @@ CObject* CRobotMain::SearchObject(ObjectType type)
CObject* CRobotMain::DetectObject(Math::Point pos)
{
int objRank = m_engine->DetectObject(pos);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (!obj->GetActif()) continue;
@@ -2850,7 +2878,7 @@ bool CRobotMain::DeleteObject()
CObject* obj = GetSelect();
if (obj == nullptr) return false;
- Gfx::CPyro* pyro = new Gfx::CPyro(m_iMan);
+ Gfx::CPyro* pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FRAGT, obj);
obj->SetSelect(false); // deselects the object
@@ -2873,9 +2901,11 @@ void CRobotMain::HiliteClear()
int rank = -1;
m_engine->SetHighlightRank(&rank); // nothing more selected
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
obj->SetHilite(false);
@@ -3035,9 +3065,11 @@ void CRobotMain::HelpObject()
//! Change the mode of the camera
void CRobotMain::ChangeCamera()
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetSelect())
@@ -3191,9 +3223,11 @@ void CRobotMain::RemoteCamera(float pan, float zoom, float rTime)
//! Cancels the current movie
void CRobotMain::AbortMovie()
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
CAuto* automat = obj->GetAuto();
@@ -3261,13 +3295,15 @@ bool CRobotMain::EventFrame(const Event &event)
if (pm != nullptr) pm->FlushObject();
}
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
CObject* toto = nullptr;
if (!m_freePhoto)
{
// Advances all the robots, but not toto.
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (pm != nullptr) pm->UpdateObject(obj);
if (obj->GetTruck() != nullptr) continue;
@@ -3280,7 +3316,7 @@ bool CRobotMain::EventFrame(const Event &event)
// Advances all objects transported by robots.
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetTruck() == nullptr) continue;
obj->EventProcess(event);
@@ -3289,7 +3325,7 @@ bool CRobotMain::EventFrame(const Event &event)
// Advances pyrotechnic effects.
for (int i = 0; i < 1000000; i++)
{
- Gfx::CPyro* pyro = static_cast<Gfx::CPyro*>(m_iMan->SearchInstance(CLASS_PYRO, i));
+ Gfx::CPyro* pyro = static_cast<Gfx::CPyro*>(iMan->SearchInstance(CLASS_PYRO, i));
if (pyro == nullptr) break;
pyro->EventProcess(event);
@@ -3439,9 +3475,11 @@ bool CRobotMain::EventObject(const Event &event)
m_resetCreate = false;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
obj->EventProcess(event);
@@ -3679,10 +3717,12 @@ void CRobotMain::ScenePerso()
m_terrain->FlushFlyingLimit();
m_lightMan->FlushLights();
m_particle->FlushParticle();
- m_iMan->Flush(CLASS_OBJECT);
- m_iMan->Flush(CLASS_PHYSICS);
- m_iMan->Flush(CLASS_BRAIN);
- m_iMan->Flush(CLASS_PYRO);
+
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+ iMan->Flush(CLASS_OBJECT);
+ iMan->Flush(CLASS_PHYSICS);
+ iMan->Flush(CLASS_BRAIN);
+ iMan->Flush(CLASS_PYRO);
m_dialog->SetSceneName("perso");
m_dialog->SetSceneRank(0);
@@ -4155,7 +4195,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
Gfx::PyroType pType = OpPyro(line, "pyro");
if (pType != Gfx::PT_NULL)
{
- Gfx::CPyro* pyro = new Gfx::CPyro(m_iMan);
+ Gfx::CPyro* pyro = new Gfx::CPyro();
pyro->Create(pType, obj);
}
@@ -4572,7 +4612,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_START ||
type == OBJECT_END )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateBuilding(pos, angle, height, type, power);
CAuto* automat = object->GetAuto();
@@ -4614,7 +4654,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_MARKKEYd ||
type == OBJECT_EGG )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateResource(pos, angle, type, power);
}
else
@@ -4624,7 +4664,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_FLAGy ||
type == OBJECT_FLAGv )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateFlag(pos, angle, type);
}
else
@@ -4634,7 +4674,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_BARRIER3 ||
type == OBJECT_BARRIER4 )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateBarrier(pos, angle, height, type);
}
else
@@ -4669,7 +4709,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_TREE8 ||
type == OBJECT_TREE9 )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreatePlant(pos, angle, height, type);
}
else
@@ -4684,7 +4724,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_MUSHROOM8 ||
type == OBJECT_MUSHROOM9 )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateMushroom(pos, angle, height, type);
}
else
@@ -4739,7 +4779,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_TEEN48 ||
type == OBJECT_TEEN49 )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->SetOption(option);
object->CreateTeen(pos, angle, zoom, height, type);
}
@@ -4755,7 +4795,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_QUARTZ8 ||
type == OBJECT_QUARTZ9 )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateQuartz(pos, angle, height, type);
}
else
@@ -4770,13 +4810,13 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_ROOT8 ||
type == OBJECT_ROOT9 )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateRoot(pos, angle, height, type);
}
else
if ( type == OBJECT_HOME1 )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateHome(pos, angle, height, type);
}
else
@@ -4794,7 +4834,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_RUINbase ||
type == OBJECT_RUINhead )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateRuin(pos, angle, height, type);
}
else
@@ -4803,7 +4843,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_APOLLO4 ||
type == OBJECT_APOLLO5 )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateApollo(pos, angle, type);
}
else
@@ -4813,7 +4853,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_BEE ||
type == OBJECT_WORM )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateInsect(pos, angle, type); // no eggs
}
else
@@ -4849,7 +4889,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_MOBILEdr ||
type == OBJECT_APOLLO2 )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->SetOption(option);
object->CreateVehicle(pos, angle, type, power, trainer, toy);
}
@@ -5069,10 +5109,12 @@ bool CRobotMain::TestGadgetQuantity(int rank)
//! Calculates the distance to the nearest object
float CRobotMain::SearchNearestObject(Math::Vector center, CObject *exclu)
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
float min = 100000.0f;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (!obj->GetActif()) continue; // inactive?
@@ -5218,12 +5260,14 @@ void CRobotMain::ShowDropZone(CObject* metal, CObject* truck)
Math::Vector center = metal->GetPosition(0);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
// Calculates the maximum radius possible depending on other items.
float oMax = 30.0f; // radius to build the biggest building
float tMax;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (!obj->GetActif()) continue; // inactive?
@@ -5441,13 +5485,15 @@ void CRobotMain::CompileScript(bool soluce)
int nbError = 0;
int lastError = 0;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
do
{
lastError = nbError;
nbError = 0;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetTruck() != nullptr) continue;
@@ -5476,7 +5522,7 @@ void CRobotMain::CompileScript(bool soluce)
{
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == 0) break;
if (obj->GetTruck() != 0) continue;
@@ -5494,7 +5540,7 @@ void CRobotMain::CompileScript(bool soluce)
// Start all programs according to the command "run".
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetTruck() != nullptr) continue;
@@ -5569,9 +5615,11 @@ void CRobotMain::LoadFileScript(CObject *obj, const char* filename, int objRank,
//! Saves all programs of all the robots
void CRobotMain::SaveAllScript()
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
SaveOneScript(obj);
@@ -5706,9 +5754,11 @@ bool CRobotMain::IsBusy()
{
if (m_CompteurFileOpen > 0) return true;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
CBrain* brain = obj->GetBrain();
@@ -5851,10 +5901,12 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
fputs(line, file);
}
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
int objRank = 0;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetType() == OBJECT_TOTO) continue;
@@ -5892,7 +5944,7 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
objRank = 0;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetType() == OBJECT_TOTO) continue;
@@ -6047,7 +6099,7 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
if (fret != nullptr)
{
obj->SetFret(fret);
- CTaskManip* task = new CTaskManip(m_iMan, obj);
+ CTaskManip* task = new CTaskManip(obj);
task->Start(TMO_AUTO, TMA_GRAB); // holds the object!
delete task;
}
@@ -6065,6 +6117,8 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
fclose(file);
#if CBOT_STACK
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
// Compiles scripts.
int nbError = 0;
int lastError = 0;
@@ -6074,7 +6128,7 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
nbError = 0;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetTruck() != nullptr) continue;
@@ -6100,7 +6154,7 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
objRank = 0;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetType() == OBJECT_TOTO) continue;
@@ -6176,10 +6230,12 @@ void CRobotMain::ResetObject()
Math::Vector pos, angle;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
// Removes all pyrotechnic effects in progress.
while ( true )
{
- pyro = static_cast<CPyro*>(m_iMan->SearchInstance(CLASS_PYRO, 0));
+ pyro = static_cast<CPyro*>(iMan->SearchInstance(CLASS_PYRO, 0));
if ( pyro == 0 ) break;
pyro->DeleteObject();
@@ -6194,7 +6250,7 @@ void CRobotMain::ResetObject()
for ( i=0 ; i<1000000 ; i++ )
{
- obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( obj == 0 ) break;
cap = obj->GetResetCap();
@@ -6243,7 +6299,7 @@ void CRobotMain::ResetObject()
if ( pos == obj->GetPosition(0) &&
angle == obj->GetAngle(0) ) continue;
- pyro = new CPyro(m_iMan);
+ pyro = new CPyro();
pyro->Create(PT_RESET, obj);
brain = obj->GetBrain();
@@ -6273,10 +6329,13 @@ void CRobotMain::ResetCreate()
m_particle->FlushParticle();
m_terrain->FlushBuildingLevel();
- m_iMan->Flush(CLASS_OBJECT);
- m_iMan->Flush(CLASS_PHYSICS);
- m_iMan->Flush(CLASS_BRAIN);
- m_iMan->Flush(CLASS_PYRO);
+
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+ iMan->Flush(CLASS_OBJECT);
+ iMan->Flush(CLASS_PHYSICS);
+ iMan->Flush(CLASS_BRAIN);
+ iMan->Flush(CLASS_PYRO);
+
m_camera->SetType(Gfx::CAM_TYPE_DIALOG);
CreateScene(m_dialog->GetSceneSoluce(), false, true);
@@ -6285,13 +6344,13 @@ void CRobotMain::ResetCreate()
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
ResetCap cap = obj->GetResetCap();
if (cap == RESET_NONE) continue;
- Gfx::CPyro* pyro = new Gfx::CPyro(m_iMan);
+ Gfx::CPyro* pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_RESET, obj);
}
}
@@ -6299,6 +6358,8 @@ void CRobotMain::ResetCreate()
//! Checks if the mission is over
Error CRobotMain::CheckEndMission(bool frame)
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int t = 0; t < m_endTakeTotal; t++)
{
if (m_endTake[t].message[0] != 0) continue;
@@ -6311,7 +6372,7 @@ Error CRobotMain::CheckEndMission(bool frame)
int nb = 0;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
// Do not use GetActif () because an invisible worm (underground)
@@ -6545,9 +6606,11 @@ bool CRobotMain::GetRadar()
if (m_cheatRadar)
return true;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == 0) break;
ObjectType type = obj->GetType();
diff --git a/src/object/robotmain.h b/src/object/robotmain.h
index cb0cd7f..6a45473 100644
--- a/src/object/robotmain.h
+++ b/src/object/robotmain.h
@@ -71,12 +71,10 @@ enum Phase
};
-class CInstanceManager;
class CEventQueue;
class CSoundInterface;
-namespace Gfx
-{
+namespace Gfx {
class CEngine;
class CLightManager;
class CWater;
@@ -84,17 +82,16 @@ class CCloud;
class CLightning;
class CPlanet;
class CTerrain;
-};
+}
-namespace Ui
-{
+namespace Ui {
class CMainDialog;
class CMainShort;
class CMainMap;
class CInterface;
class CDisplayText;
class CDisplayInfo;
-};
+}
struct EndTake
@@ -178,9 +175,14 @@ const int AXIS_INVALID = -1;
class CRobotMain : public CSingleton<CRobotMain>
{
public:
- CRobotMain(CInstanceManager* iMan, CApplication* app);
+ CRobotMain(CApplication* app);
~CRobotMain();
+ Gfx::CCamera* GetCamera();
+ Gfx::CTerrain* GetTerrain();
+ Ui::CInterface* GetInterface();
+ Ui::CDisplayText* GetDisplayText();
+
void CreateIni();
//! Sets the default input bindings (key and axes)
@@ -358,7 +360,6 @@ protected:
void Convert();
void CreateScene(bool soluce, bool fixScene, bool resetObject);
- void CreateModel();
Math::Vector LookatPoint(Math::Vector eye, float angleH, float angleV, float length);
CObject* CreateObject(Math::Vector pos, float angle, float zoom,
float height, ObjectType type, float power=1.0f,
@@ -390,7 +391,6 @@ protected:
void UpdateSpeedLabel();
protected:
- CInstanceManager* m_iMan;
CApplication* m_app;
CEventQueue* m_eventQueue;
CMainMovie* m_movie;
diff --git a/src/object/task/task.cpp b/src/object/task/task.cpp
index b310fd5..39fdccf 100644
--- a/src/object/task/task.cpp
+++ b/src/object/task/task.cpp
@@ -14,33 +14,28 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// task.cpp
-
-
-// #include <stdio.h>
#include "object/task/task.h"
-#include "common/iman.h"
-#include "object/object.h"
+#include "app/app.h"
+#include "object/object.h"
+#include "object/robotmain.h"
// Object's constructor.
-CTask::CTask(CInstanceManager* iMan, CObject* object)
+CTask::CTask(CObject* object)
{
- m_iMan = iMan;
-
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_lightMan = static_cast<Gfx::CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT));
- m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
- m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
- m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
- m_displayText = static_cast<Ui::CDisplayText*>(m_iMan->SearchInstance(CLASS_DISPLAYTEXT));
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
+ m_sound = CApplication::GetInstancePointer()->GetSound();
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_lightMan = m_engine->GetLightManager();
+ m_water = m_engine->GetWater();
+ m_particle = m_engine->GetParticle();
+ m_main = CRobotMain::GetInstancePointer();
+ m_terrain = m_main->GetTerrain();
+ m_camera = m_main->GetCamera();
+ m_displayText = m_main->GetDisplayText();
m_object = object;
m_physics = m_object->GetPhysics();
diff --git a/src/object/task/task.h b/src/object/task/task.h
index 7239d48..12961ef 100644
--- a/src/object/task/task.h
+++ b/src/object/task/task.h
@@ -21,10 +21,10 @@
#include "common/event.h"
#include "common/global.h"
+
#include "math/const.h"
-class CInstanceManager;
class CBrain;
class CPhysics;
class CMotion;
@@ -64,7 +64,7 @@ const float ARM_STOCK_ANGLE3 = -70.0f*Math::PI/180.0f;
class CTask
{
public:
- CTask(CInstanceManager* iMan, CObject* object);
+ CTask(CObject* object);
virtual ~CTask();
virtual bool EventProcess(const Event &event);
@@ -73,7 +73,6 @@ public:
virtual bool Abort();
protected:
- CInstanceManager* m_iMan;
Gfx::CEngine* m_engine;
Gfx::CLightManager* m_lightMan;
Gfx::CParticle* m_particle;
diff --git a/src/object/task/taskadvance.cpp b/src/object/task/taskadvance.cpp
index 0d159d2..58eb939 100644
--- a/src/object/task/taskadvance.cpp
+++ b/src/object/task/taskadvance.cpp
@@ -14,11 +14,11 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskadvance.cpp
#include "object/task/taskadvance.h"
#include "math/geometry.h"
+
#include "physics/physics.h"
@@ -26,8 +26,7 @@
// Object's constructor.
-CTaskAdvance::CTaskAdvance(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskAdvance::CTaskAdvance(CObject* object) : CTask(object)
{
}
diff --git a/src/object/task/taskadvance.h b/src/object/task/taskadvance.h
index dbb80d9..f8c672d 100644
--- a/src/object/task/taskadvance.h
+++ b/src/object/task/taskadvance.h
@@ -20,6 +20,7 @@
#include "object/task/task.h"
+
#include "math/vector.h"
@@ -27,7 +28,7 @@
class CTaskAdvance : public CTask
{
public:
- CTaskAdvance(CInstanceManager* iMan, CObject* object);
+ CTaskAdvance(CObject* object);
~CTaskAdvance();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskbuild.cpp b/src/object/task/taskbuild.cpp
index 5673ea4..f209cd5 100644
--- a/src/object/task/taskbuild.cpp
+++ b/src/object/task/taskbuild.cpp
@@ -14,29 +14,32 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskbuild.cpp
#include "object/task/taskbuild.h"
#include "common/iman.h"
+
#include "graphics/core/color.h"
#include "graphics/core/light.h"
#include "graphics/engine/lightman.h"
#include "graphics/engine/terrain.h"
#include "graphics/engine/water.h"
+
#include "math/geometry.h"
+
#include "object/auto/auto.h"
#include "object/motion/motionhuman.h"
#include "object/robotmain.h"
+
#include "physics/physics.h"
+
#include "ui/displaytext.h"
#include <string.h>
// Object's constructor.
-CTaskBuild::CTaskBuild(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskBuild::CTaskBuild(CObject* object) : CTask(object)
{
int i;
@@ -75,7 +78,7 @@ CTaskBuild::~CTaskBuild()
bool CTaskBuild::CreateBuilding(Math::Vector pos, float angle)
{
- m_building = new CObject(m_iMan);
+ m_building = new CObject();
if ( !m_building->CreateBuilding(pos, angle, 0.0f, m_type, 0.0f) )
{
delete m_building;
@@ -596,11 +599,13 @@ Error CTaskBuild::FlatFloor()
return bLittleFlat?ERR_BUILD_FLATLIT:ERR_BUILD_FLAT;
}
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
max = 100000.0f;
bBase = false;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->GetActif() ) continue; // inactive?
@@ -648,7 +653,7 @@ Error CTaskBuild::FlatFloor()
max = 100000.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->GetActif() ) continue; // inactive?
@@ -715,12 +720,14 @@ CObject* CTaskBuild::SearchMetalObject(float &angle, float dMin, float dMax,
iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 1000000.0f;
pBest = 0;
bMetal = false;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->GetActif() ) continue; // objet inactive?
@@ -779,9 +786,11 @@ void CTaskBuild::DeleteMark(Math::Vector pos, float radius)
float distance;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
diff --git a/src/object/task/taskbuild.h b/src/object/task/taskbuild.h
index 25300b3..b3193a0 100644
--- a/src/object/task/taskbuild.h
+++ b/src/object/task/taskbuild.h
@@ -45,7 +45,7 @@ enum TaskBuildPhase
class CTaskBuild : public CTask
{
public:
- CTaskBuild(CInstanceManager* iMan, CObject* object);
+ CTaskBuild(CObject* object);
~CTaskBuild();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskfire.cpp b/src/object/task/taskfire.cpp
index 99a88b8..beb4944 100644
--- a/src/object/task/taskfire.cpp
+++ b/src/object/task/taskfire.cpp
@@ -14,12 +14,13 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskfire.cpp
#include "object/task/taskfire.h"
#include "graphics/engine/particle.h"
+
#include "math/geometry.h"
+
#include "physics/physics.h"
@@ -31,8 +32,7 @@ const float ENERGY_FIREi = (0.10f/2.5f); // energy consumed/organic
// Object's constructor.
-CTaskFire::CTaskFire(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskFire::CTaskFire(CObject* object) : CTask(object)
{
m_soundChannel = -1;
}
diff --git a/src/object/task/taskfire.h b/src/object/task/taskfire.h
index 5cf4f0c..81058df 100644
--- a/src/object/task/taskfire.h
+++ b/src/object/task/taskfire.h
@@ -26,7 +26,7 @@
class CTaskFire : public CTask
{
public:
- CTaskFire(CInstanceManager* iMan, CObject* object);
+ CTaskFire(CObject* object);
~CTaskFire();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskfireant.cpp b/src/object/task/taskfireant.cpp
index 2044685..c0acf64 100644
--- a/src/object/task/taskfireant.cpp
+++ b/src/object/task/taskfireant.cpp
@@ -14,13 +14,15 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskfireant.cpp
#include "object/task/taskfireant.h"
#include "graphics/engine/particle.h"
+
#include "math/geometry.h"
+
#include "object/motion/motionant.h"
+
#include "physics/physics.h"
@@ -28,8 +30,7 @@
// Object's constructor.
-CTaskFireAnt::CTaskFireAnt(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskFireAnt::CTaskFireAnt(CObject* object) : CTask(object)
{
m_phase = TFA_NULL;
}
diff --git a/src/object/task/taskfireant.h b/src/object/task/taskfireant.h
index 4fa77b8..2a0ead8 100644
--- a/src/object/task/taskfireant.h
+++ b/src/object/task/taskfireant.h
@@ -38,7 +38,7 @@ enum TaskFireAnt
class CTaskFireAnt : public CTask
{
public:
- CTaskFireAnt(CInstanceManager* iMan, CObject* object);
+ CTaskFireAnt(CObject* object);
~CTaskFireAnt();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskflag.cpp b/src/object/task/taskflag.cpp
index c88b5c0..dd5e11d 100644
--- a/src/object/task/taskflag.cpp
+++ b/src/object/task/taskflag.cpp
@@ -14,26 +14,28 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskflag.cpp
#include "object/task/taskflag.h"
-#include "math/geometry.h"
#include "common/iman.h"
+
+#include "math/geometry.h"
+
#include "graphics/engine/particle.h"
#include "graphics/engine/pyro.h"
#include "graphics/engine/water.h"
-#include "physics/physics.h"
+
#include "object/motion/motionhuman.h"
+#include "physics/physics.h"
+
// Object's constructor.
-CTaskFlag::CTaskFlag(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskFlag::CTaskFlag(CObject* object) : CTask(object)
{
}
@@ -137,11 +139,13 @@ CObject* CTaskFlag::SearchNearest(Math::Vector pos, ObjectType type)
float min, dist;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 100000.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->GetEnable() ) continue;
@@ -180,10 +184,12 @@ int CTaskFlag::CountObject(ObjectType type)
Math::Vector oPos;
int i, count;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
count = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->GetEnable() ) continue;
@@ -247,7 +253,7 @@ Error CTaskFlag::CreateFlag(int rank)
return ERR_FLAG_CREATE;
}
- pNew = new CObject(m_iMan);
+ pNew = new CObject();
if ( !pNew->CreateFlag(pos, 0.0f, table[i]) )
{
delete pNew;
@@ -256,7 +262,7 @@ Error CTaskFlag::CreateFlag(int rank)
//pNew->SetZoom(0, 0.0f);
m_sound->Play(SOUND_WAYPOINT, pos);
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FLCREATE, pNew);
return ERR_OK;
@@ -295,7 +301,7 @@ Error CTaskFlag::DeleteFlag()
}
m_sound->Play(SOUND_WAYPOINT, iPos);
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FLDELETE, pObj);
return ERR_OK;
diff --git a/src/object/task/taskflag.h b/src/object/task/taskflag.h
index 5b0a058..7e3e4ef 100644
--- a/src/object/task/taskflag.h
+++ b/src/object/task/taskflag.h
@@ -20,6 +20,7 @@
#include "object/task/task.h"
#include "object/object.h"
+
#include "math/vector.h"
@@ -35,7 +36,7 @@ enum TaskFlagOrder
class CTaskFlag : public CTask
{
public:
- CTaskFlag(CInstanceManager* iMan, CObject* object);
+ CTaskFlag(CObject* object);
~CTaskFlag();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskgoto.cpp b/src/object/task/taskgoto.cpp
index cab57f1..c4a2939 100644
--- a/src/object/task/taskgoto.cpp
+++ b/src/object/task/taskgoto.cpp
@@ -14,8 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskgoto.cpp
-
#include <stdio.h>
@@ -23,9 +21,12 @@
#include "common/event.h"
#include "common/iman.h"
+
#include "graphics/engine/terrain.h"
#include "graphics/engine/water.h"
+
#include "math/geometry.h"
+
#include "physics/physics.h"
#include <string.h>
@@ -40,8 +41,7 @@ const float BM_DIM_STEP = 5.0f;
// Object's constructor.
-CTaskGoto::CTaskGoto(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskGoto::CTaskGoto(CObject* object) : CTask(object)
{
m_bmArray = 0;
}
@@ -494,12 +494,14 @@ CObject* CTaskGoto::WormSearch(Math::Vector &impact)
float distance, min, radius;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
iPos = m_object->GetPosition(0);
min = 1000000.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
oType = pObj->GetType();
@@ -1026,11 +1028,13 @@ CObject* CTaskGoto::SearchTarget(Math::Vector pos, float margin)
float dist, min;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
pBest = 0;
min = 1000000.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->GetActif() ) continue;
@@ -1170,9 +1174,11 @@ bool CTaskGoto::AdjustBuilding(Math::Vector &pos, float margin, float &distance)
float dist, suppl;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->GetActif() ) continue;
@@ -1339,11 +1345,13 @@ bool CTaskGoto::LeakSearch(Math::Vector &pos, float &delay)
m_object->GetCrashSphere(0, iPos, iRadius);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 100000.0f;
bRadius = 0.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
@@ -1401,7 +1409,7 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir)
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
@@ -1522,9 +1530,11 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir)
bAlien = true;
}
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
@@ -1614,9 +1624,11 @@ void CTaskGoto::ComputeFlyingRepulse(float &dir)
fac = 1.5f;
dir = 0.0f;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
@@ -1928,9 +1940,11 @@ void CTaskGoto::BitmapObject()
m_object->GetCrashSphere(0, iPos, iRadius);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
diff --git a/src/object/task/taskgoto.h b/src/object/task/taskgoto.h
index 1382d4c..d2b2d7e 100644
--- a/src/object/task/taskgoto.h
+++ b/src/object/task/taskgoto.h
@@ -20,6 +20,7 @@
#include "object/task/task.h"
+
#include "math/vector.h"
@@ -72,7 +73,7 @@ enum TaskGotoPhase
class CTaskGoto : public CTask
{
public:
- CTaskGoto(CInstanceManager* iMan, CObject* object);
+ CTaskGoto(CObject* object);
~CTaskGoto();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskgungoal.cpp b/src/object/task/taskgungoal.cpp
index aed3355..3373610 100644
--- a/src/object/task/taskgungoal.cpp
+++ b/src/object/task/taskgungoal.cpp
@@ -14,7 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskgungoal.cpp
#include "object/task/taskgungoal.h"
@@ -25,8 +24,7 @@
// Object's constructor.
-CTaskGunGoal::CTaskGunGoal(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskGunGoal::CTaskGunGoal(CObject* object) : CTask(object)
{
}
diff --git a/src/object/task/taskgungoal.h b/src/object/task/taskgungoal.h
index 0c063d1..c6f010b 100644
--- a/src/object/task/taskgungoal.h
+++ b/src/object/task/taskgungoal.h
@@ -26,7 +26,7 @@
class CTaskGunGoal : public CTask
{
public:
- CTaskGunGoal(CInstanceManager* iMan, CObject* object);
+ CTaskGunGoal(CObject* object);
~CTaskGunGoal();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskinfo.cpp b/src/object/task/taskinfo.cpp
index 4e64584..32ac342 100644
--- a/src/object/task/taskinfo.cpp
+++ b/src/object/task/taskinfo.cpp
@@ -14,12 +14,13 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskinfo.cpp
#include "object/task/taskinfo.h"
#include "common/iman.h"
+
#include "graphics/engine/particle.h"
+
#include "object/auto/autoinfo.h"
#include <string.h>
@@ -28,8 +29,7 @@
// Object's constructor.
-CTaskInfo::CTaskInfo(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskInfo::CTaskInfo(CObject* object) : CTask(object)
{
}
@@ -189,11 +189,13 @@ CObject* CTaskInfo::SearchInfo(float power)
iPos = m_object->GetPosition(0);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 100000.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
diff --git a/src/object/task/taskinfo.h b/src/object/task/taskinfo.h
index 036b57d..1ce3dca 100644
--- a/src/object/task/taskinfo.h
+++ b/src/object/task/taskinfo.h
@@ -26,7 +26,7 @@
class CTaskInfo : public CTask
{
public:
- CTaskInfo(CInstanceManager* iMan, CObject* object);
+ CTaskInfo(CObject* object);
~CTaskInfo();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskmanager.cpp b/src/object/task/taskmanager.cpp
index 26e389d..a2ce8b8 100644
--- a/src/object/task/taskmanager.cpp
+++ b/src/object/task/taskmanager.cpp
@@ -14,14 +14,13 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskmanager.cpp
-
#include <stdio.h>
#include "object/task/taskmanager.h"
#include "common/iman.h"
+
#include "object/task/taskwait.h"
#include "object/task/taskadvance.h"
#include "object/task/taskturn.h"
@@ -43,12 +42,9 @@
// Object's constructor.
-CTaskManager::CTaskManager(CInstanceManager* iMan, CObject* object)
+CTaskManager::CTaskManager(CObject* object)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_TASKMANAGER, this, 100);
-
- m_task = 0;
+ m_task = nullptr;
m_object = object;
m_bPilot = false;
}
@@ -66,7 +62,7 @@ CTaskManager::~CTaskManager()
Error CTaskManager::StartTaskWait(float time)
{
- m_task = new CTaskWait(m_iMan, m_object);
+ m_task = new CTaskWait(m_object);
return (static_cast<CTaskWait*>(m_task))->Start(time);
}
@@ -74,7 +70,7 @@ Error CTaskManager::StartTaskWait(float time)
Error CTaskManager::StartTaskAdvance(float length)
{
- m_task = new CTaskAdvance(m_iMan, m_object);
+ m_task = new CTaskAdvance(m_object);
return (static_cast<CTaskAdvance*>(m_task))->Start(length);
}
@@ -82,7 +78,7 @@ Error CTaskManager::StartTaskAdvance(float length)
Error CTaskManager::StartTaskTurn(float angle)
{
- m_task = new CTaskTurn(m_iMan, m_object);
+ m_task = new CTaskTurn(m_object);
return (static_cast<CTaskTurn*>(m_task))->Start(angle);
}
@@ -90,7 +86,7 @@ Error CTaskManager::StartTaskTurn(float angle)
Error CTaskManager::StartTaskGoto(Math::Vector pos, float altitude, TaskGotoGoal goalMode, TaskGotoCrash crashMode)
{
- m_task = new CTaskGoto(m_iMan, m_object);
+ m_task = new CTaskGoto(m_object);
return (static_cast<CTaskGoto*>(m_task))->Start(pos, altitude, goalMode, crashMode);
}
@@ -98,7 +94,7 @@ Error CTaskManager::StartTaskGoto(Math::Vector pos, float altitude, TaskGotoGoal
Error CTaskManager::StartTaskTake()
{
- m_task = new CTaskTake(m_iMan, m_object);
+ m_task = new CTaskTake(m_object);
return (static_cast<CTaskTake*>(m_task))->Start();
}
@@ -106,7 +102,7 @@ Error CTaskManager::StartTaskTake()
Error CTaskManager::StartTaskManip(TaskManipOrder order, TaskManipArm arm)
{
- m_task = new CTaskManip(m_iMan, m_object);
+ m_task = new CTaskManip(m_object);
return (static_cast<CTaskManip*>(m_task))->Start(order, arm);
}
@@ -114,7 +110,7 @@ Error CTaskManager::StartTaskManip(TaskManipOrder order, TaskManipArm arm)
Error CTaskManager::StartTaskFlag(TaskFlagOrder order, int rank)
{
- m_task = new CTaskFlag(m_iMan, m_object);
+ m_task = new CTaskFlag(m_object);
return (static_cast<CTaskFlag*>(m_task))->Start(order, rank);
}
@@ -122,7 +118,7 @@ Error CTaskManager::StartTaskFlag(TaskFlagOrder order, int rank)
Error CTaskManager::StartTaskBuild(ObjectType type)
{
- m_task = new CTaskBuild(m_iMan, m_object);
+ m_task = new CTaskBuild(m_object);
return (static_cast<CTaskBuild*>(m_task))->Start(type);
}
@@ -130,7 +126,7 @@ Error CTaskManager::StartTaskBuild(ObjectType type)
Error CTaskManager::StartTaskSearch()
{
- m_task = new CTaskSearch(m_iMan, m_object);
+ m_task = new CTaskSearch(m_object);
return (static_cast<CTaskSearch*>(m_task))->Start();
}
@@ -138,7 +134,7 @@ Error CTaskManager::StartTaskSearch()
Error CTaskManager::StartTaskInfo(const char *name, float value, float power, bool bSend)
{
- m_task = new CTaskInfo(m_iMan, m_object);
+ m_task = new CTaskInfo(m_object);
return (static_cast<CTaskInfo*>(m_task))->Start(name, value, power, bSend);
}
@@ -146,7 +142,7 @@ Error CTaskManager::StartTaskInfo(const char *name, float value, float power, bo
Error CTaskManager::StartTaskTerraform()
{
- m_task = new CTaskTerraform(m_iMan, m_object);
+ m_task = new CTaskTerraform(m_object);
return (static_cast<CTaskTerraform*>(m_task))->Start();
}
@@ -154,7 +150,7 @@ Error CTaskManager::StartTaskTerraform()
Error CTaskManager::StartTaskPen(bool bDown, int color)
{
- m_task = new CTaskPen(m_iMan, m_object);
+ m_task = new CTaskPen(m_object);
return (static_cast<CTaskPen*>(m_task))->Start(bDown, color);
}
@@ -162,7 +158,7 @@ Error CTaskManager::StartTaskPen(bool bDown, int color)
Error CTaskManager::StartTaskRecover()
{
- m_task = new CTaskRecover(m_iMan, m_object);
+ m_task = new CTaskRecover(m_object);
return (static_cast<CTaskRecover*>(m_task))->Start();
}
@@ -172,7 +168,7 @@ Error CTaskManager::StartTaskShield(TaskShieldMode mode, float delay)
{
if ( mode == TSM_UP )
{
- m_task = new CTaskShield(m_iMan, m_object);
+ m_task = new CTaskShield(m_object);
return (static_cast<CTaskShield*>(m_task))->Start(mode, delay);
}
if ( mode == TSM_DOWN && m_task != 0 )
@@ -191,7 +187,7 @@ Error CTaskManager::StartTaskShield(TaskShieldMode mode, float delay)
Error CTaskManager::StartTaskFire(float delay)
{
m_bPilot = true;
- m_task = new CTaskFire(m_iMan, m_object);
+ m_task = new CTaskFire(m_object);
return (static_cast<CTaskFire*>(m_task))->Start(delay);
}
@@ -199,7 +195,7 @@ Error CTaskManager::StartTaskFire(float delay)
Error CTaskManager::StartTaskFireAnt(Math::Vector impact)
{
- m_task = new CTaskFireAnt(m_iMan, m_object);
+ m_task = new CTaskFireAnt(m_object);
return (static_cast<CTaskFireAnt*>(m_task))->Start(impact);
}
@@ -207,7 +203,7 @@ Error CTaskManager::StartTaskFireAnt(Math::Vector impact)
Error CTaskManager::StartTaskGunGoal(float dirV, float dirH)
{
- m_task = new CTaskGunGoal(m_iMan, m_object);
+ m_task = new CTaskGunGoal(m_object);
return (static_cast<CTaskGunGoal*>(m_task))->Start(dirV, dirH);
}
@@ -215,7 +211,7 @@ Error CTaskManager::StartTaskGunGoal(float dirV, float dirH)
Error CTaskManager::StartTaskSpiderExplo()
{
- m_task = new CTaskSpiderExplo(m_iMan, m_object);
+ m_task = new CTaskSpiderExplo(m_object);
return (static_cast<CTaskSpiderExplo*>(m_task))->Start();
}
@@ -223,7 +219,7 @@ Error CTaskManager::StartTaskSpiderExplo()
Error CTaskManager::StartTaskReset(Math::Vector goal, Math::Vector angle)
{
- m_task = new CTaskReset(m_iMan, m_object);
+ m_task = new CTaskReset(m_object);
return (static_cast<CTaskReset*>(m_task))->Start(goal, angle);
}
diff --git a/src/object/task/taskmanager.h b/src/object/task/taskmanager.h
index 6ce023a..80a78fd 100644
--- a/src/object/task/taskmanager.h
+++ b/src/object/task/taskmanager.h
@@ -19,8 +19,8 @@
#pragma once
-#include "object/task/task.h"
#include "object/object.h"
+#include "object/task/task.h"
#include "object/task/taskmanip.h"
#include "object/task/taskgoto.h"
#include "object/task/taskshield.h"
@@ -31,7 +31,7 @@
class CTaskManager
{
public:
- CTaskManager(CInstanceManager* iMan, CObject* object);
+ CTaskManager(CObject* object);
~CTaskManager();
Error StartTaskWait(float time);
@@ -61,9 +61,6 @@ public:
bool Abort();
protected:
-
-protected:
- CInstanceManager* m_iMan;
CTask* m_task;
CObject* m_object;
bool m_bPilot;
diff --git a/src/object/task/taskmanip.cpp b/src/object/task/taskmanip.cpp
index b0b146c..0608b6e 100644
--- a/src/object/task/taskmanip.cpp
+++ b/src/object/task/taskmanip.cpp
@@ -14,15 +14,18 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskmanip.cpp
#include "object/task/taskmanip.h"
#include "common/iman.h"
+
#include "graphics/engine/terrain.h"
#include "graphics/engine/pyro.h"
+
#include "math/geometry.h"
+
#include "object/robotmain.h"
+
#include "physics/physics.h"
@@ -40,8 +43,7 @@ const float MARGIN_BEE = 5.0f; //OK 1.9
// Object's constructor.
-CTaskManip::CTaskManip(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskManip::CTaskManip(CObject* object) : CTask(object)
{
m_arm = TMA_NEUTRAL;
m_hand = TMH_OPEN;
@@ -338,7 +340,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
pos.y += 2.0f;
m_object->SetPosition(0, pos); // against the top of jump
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FALL, other); // the ball falls
}
@@ -728,11 +730,13 @@ CObject* CTaskManip::SearchTakeUnderObject(Math::Vector &pos, float dLimit)
iPos = m_object->GetPosition(0);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 1000000.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
@@ -798,12 +802,14 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos,
dLimit = MARGIN_FRONT;
}
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 1000000.0f;
pBest = 0;
bAngle = 0.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
@@ -889,12 +895,14 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos,
dLimit = MARGIN_BACK;
}
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 1000000.0f;
pBest = 0;
bAngle = 0.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
@@ -989,9 +997,11 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos,
dLimit = MARGIN_FRIEND;
}
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue; // yourself?
@@ -1345,9 +1355,11 @@ bool CTaskManip::IsFreeDeposeObject(Math::Vector pos)
mat = m_object->GetWorldMatrix(0);
iPos = Transform(*mat, pos);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
diff --git a/src/object/task/taskmanip.h b/src/object/task/taskmanip.h
index 79d9ad5..e80602c 100644
--- a/src/object/task/taskmanip.h
+++ b/src/object/task/taskmanip.h
@@ -54,7 +54,7 @@ enum TaskManipHand
class CTaskManip : public CTask
{
public:
- CTaskManip(CInstanceManager* iMan, CObject* object);
+ CTaskManip(CObject* object);
~CTaskManip();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskpen.cpp b/src/object/task/taskpen.cpp
index 6e04233..03c2322 100644
--- a/src/object/task/taskpen.cpp
+++ b/src/object/task/taskpen.cpp
@@ -14,20 +14,20 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskpen.cpp
#include "object/task/taskpen.h"
#include "graphics/engine/particle.h"
-#include "math/geometry.h"
+
#include "object/object.h"
+#include "math/geometry.h"
+
// Object's constructor.
-CTaskPen::CTaskPen(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskPen::CTaskPen(CObject* object) : CTask(object)
{
}
diff --git a/src/object/task/taskpen.h b/src/object/task/taskpen.h
index 0974322..adaba6c 100644
--- a/src/object/task/taskpen.h
+++ b/src/object/task/taskpen.h
@@ -36,7 +36,7 @@ enum TaskPenPhase
class CTaskPen : public CTask
{
public:
- CTaskPen(CInstanceManager* iMan, CObject* object);
+ CTaskPen(CObject* object);
~CTaskPen();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskrecover.cpp b/src/object/task/taskrecover.cpp
index 4c8ead8..b86e9a5 100644
--- a/src/object/task/taskrecover.cpp
+++ b/src/object/task/taskrecover.cpp
@@ -14,17 +14,19 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskrecover.cpp
-
#include <stdio.h>
#include "object/task/taskrecover.h"
-#include "math/geometry.h"
#include "common/iman.h"
+
#include "graphics/engine/particle.h"
+
+#include "math/geometry.h"
+
#include "physics/physics.h"
+
#include "ui/displaytext.h"
@@ -35,8 +37,7 @@ const float RECOVER_DIST = 11.8f;
// Object's constructor.
-CTaskRecover::CTaskRecover(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskRecover::CTaskRecover(CObject* object) : CTask(object)
{
m_ruin = 0;
m_soundChannel = -1;
@@ -297,7 +298,7 @@ Error CTaskRecover::IsEnded()
if ( m_phase == TRP_DOWN )
{
- m_metal = new CObject(m_iMan);
+ m_metal = new CObject();
if ( !m_metal->CreateResource(m_recoverPos, 0.0f, OBJECT_METAL) )
{
delete m_metal;
@@ -385,11 +386,13 @@ CObject* CTaskRecover::SearchRuin()
float dist, min;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
pBest = 0;
min = 100000.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
diff --git a/src/object/task/taskrecover.h b/src/object/task/taskrecover.h
index 151ab6b..817ed5f 100644
--- a/src/object/task/taskrecover.h
+++ b/src/object/task/taskrecover.h
@@ -20,6 +20,7 @@
#include "object/task/task.h"
+
#include "math/vector.h"
@@ -38,7 +39,7 @@ enum TaskRecoverPhase
class CTaskRecover : public CTask
{
public:
- CTaskRecover(CInstanceManager* iMan, CObject* object);
+ CTaskRecover(CObject* object);
~CTaskRecover();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskreset.cpp b/src/object/task/taskreset.cpp
index 7e097bf..98d9730 100644
--- a/src/object/task/taskreset.cpp
+++ b/src/object/task/taskreset.cpp
@@ -14,11 +14,11 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskreset.cpp
#include "object/task/taskreset.h"
#include "common/iman.h"
+
#include "object/brain.h"
#include "object/robotmain.h"
@@ -32,8 +32,7 @@ const float RESET_DELAY_MOVE = 0.7f;
// Object's constructor.
-CTaskReset::CTaskReset(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskReset::CTaskReset(CObject* object) : CTask(object)
{
}
@@ -273,9 +272,11 @@ bool CTaskReset::SearchVehicle()
float oRadius, dist;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
diff --git a/src/object/task/taskreset.h b/src/object/task/taskreset.h
index e3dacf7..5f1bb34 100644
--- a/src/object/task/taskreset.h
+++ b/src/object/task/taskreset.h
@@ -36,7 +36,7 @@ enum TaskResetPhase
class CTaskReset : public CTask
{
public:
- CTaskReset(CInstanceManager* iMan, CObject* object);
+ CTaskReset(CObject* object);
~CTaskReset();
bool EventProcess(const Event &event);
diff --git a/src/object/task/tasksearch.cpp b/src/object/task/tasksearch.cpp
index 578b41e..b219185 100644
--- a/src/object/task/tasksearch.cpp
+++ b/src/object/task/tasksearch.cpp
@@ -14,15 +14,18 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// tasksearch.cpp
#include "object/task/tasksearch.h"
-#include "math/geometry.h"
#include "common/iman.h"
+
#include "graphics/engine/particle.h"
#include "graphics/engine/terrain.h"
+
+#include "math/geometry.h"
+
#include "physics/physics.h"
+
#include "ui/displaytext.h"
@@ -30,8 +33,7 @@
// Object's constructor.
-CTaskSearch::CTaskSearch(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskSearch::CTaskSearch(CObject* object) : CTask(object)
{
m_hand = TSH_UP;
}
@@ -280,7 +282,7 @@ bool CTaskSearch::CreateMark()
//? DeleteMark(type);
- fret = new CObject(m_iMan);
+ fret = new CObject();
if ( !fret->CreateResource(pos, 0.0f, type) )
{
delete fret;
@@ -301,9 +303,11 @@ void CTaskSearch::DeleteMark(ObjectType type)
Math::Vector oPos;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( type == pObj->GetType() )
diff --git a/src/object/task/tasksearch.h b/src/object/task/tasksearch.h
index bffec16..582d45a 100644
--- a/src/object/task/tasksearch.h
+++ b/src/object/task/tasksearch.h
@@ -42,7 +42,7 @@ enum TaskSearchPhase
class CTaskSearch : public CTask
{
public:
- CTaskSearch(CInstanceManager* iMan, CObject* object);
+ CTaskSearch(CObject* object);
~CTaskSearch();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskshield.cpp b/src/object/task/taskshield.cpp
index 93afd62..4b2fccd 100644
--- a/src/object/task/taskshield.cpp
+++ b/src/object/task/taskshield.cpp
@@ -14,16 +14,19 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskshield.cpp
#include "object/task/taskshield.h"
#include "common/iman.h"
+
#include "graphics/core/light.h"
#include "graphics/engine/particle.h"
#include "graphics/engine/lightman.h"
+
#include "math/geometry.h"
+
#include "object/brain.h"
+
#include "physics/physics.h"
#include <string.h>
@@ -34,8 +37,7 @@ const float ENERGY_TIME = 20.0f; // maximum duration if full battery
// Object's constructor.
-CTaskShield::CTaskShield(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskShield::CTaskShield(CObject* object) : CTask(object)
{
m_rankSphere = -1;
m_soundChannel = -1;
@@ -521,9 +523,11 @@ void CTaskShield::IncreaseShield()
float dist, shield;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
diff --git a/src/object/task/taskshield.h b/src/object/task/taskshield.h
index 4a6811c..36d3819 100644
--- a/src/object/task/taskshield.h
+++ b/src/object/task/taskshield.h
@@ -20,6 +20,7 @@
#include "object/task/task.h"
+
#include "math/vector.h"
@@ -49,7 +50,7 @@ enum TaskShieldMode
class CTaskShield : public CTask
{
public:
- CTaskShield(CInstanceManager* iMan, CObject* object);
+ CTaskShield(CObject* object);
~CTaskShield();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskspiderexplo.cpp b/src/object/task/taskspiderexplo.cpp
index 8110870..f629714 100644
--- a/src/object/task/taskspiderexplo.cpp
+++ b/src/object/task/taskspiderexplo.cpp
@@ -14,12 +14,13 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskspiderexplo.cpp
#include "object/task/taskspiderexplo.h"
#include "graphics/engine/pyro.h"
+
#include "object/motion/motionspider.h"
+
#include "physics/physics.h"
@@ -27,8 +28,7 @@
// Object's constructor.
-CTaskSpiderExplo::CTaskSpiderExplo(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskSpiderExplo::CTaskSpiderExplo(CObject* object) : CTask(object)
{
m_time = 0.0f;
m_bError = false;
@@ -91,7 +91,7 @@ Error CTaskSpiderExplo::IsEnded()
if ( m_time < 1.0f ) return ERR_CONTINUE;
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_SPIDER, m_object); // the spider explodes (suicide)
Abort();
diff --git a/src/object/task/taskspiderexplo.h b/src/object/task/taskspiderexplo.h
index 50f3ad2..0984020 100644
--- a/src/object/task/taskspiderexplo.h
+++ b/src/object/task/taskspiderexplo.h
@@ -26,7 +26,7 @@
class CTaskSpiderExplo : public CTask
{
public:
- CTaskSpiderExplo(CInstanceManager* iMan, CObject* object);
+ CTaskSpiderExplo(CObject* object);
~CTaskSpiderExplo();
bool EventProcess(const Event &event);
diff --git a/src/object/task/tasktake.cpp b/src/object/task/tasktake.cpp
index 2737324..0037f85 100644
--- a/src/object/task/tasktake.cpp
+++ b/src/object/task/tasktake.cpp
@@ -14,16 +14,19 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// tasktake.cpp
#include "object/task/tasktake.h"
#include "common/iman.h"
+
#include "graphics/engine/terrain.h"
#include "graphics/engine/water.h"
+
#include "math/geometry.h"
+
#include "object/motion/motionhuman.h"
#include "object/robotmain.h"
+
#include "physics/physics.h"
@@ -31,10 +34,9 @@
// Object's constructor.
-CTaskTake::CTaskTake(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskTake::CTaskTake(CObject* object) : CTask(object)
{
- m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_terrain = CRobotMain::GetInstancePointer()->GetTerrain();
m_arm = TTA_NEUTRAL;
}
@@ -305,12 +307,14 @@ CObject* CTaskTake::SearchTakeObject(float &angle,
iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 1000000.0f;
pBest = 0;
bAngle = 0.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
@@ -374,9 +378,11 @@ CObject* CTaskTake::SearchFriendObject(float &angle,
iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue; // yourself?
@@ -569,9 +575,11 @@ bool CTaskTake::IsFreeDeposeObject(Math::Vector pos)
mat = m_object->GetWorldMatrix(0);
iPos = Transform(*mat, pos);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
diff --git a/src/object/task/tasktake.h b/src/object/task/tasktake.h
index c7950fe..7f3f831 100644
--- a/src/object/task/tasktake.h
+++ b/src/object/task/tasktake.h
@@ -42,7 +42,7 @@ enum TaskTakeArm
class CTaskTake : public CTask
{
public:
- CTaskTake(CInstanceManager* iMan, CObject* object);
+ CTaskTake(CObject* object);
~CTaskTake();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskterraform.cpp b/src/object/task/taskterraform.cpp
index 6afece4..1f5ef7b 100644
--- a/src/object/task/taskterraform.cpp
+++ b/src/object/task/taskterraform.cpp
@@ -14,23 +14,25 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskterraform.cpp
-
#include <stdio.h>
#include "object/task/taskterraform.h"
-#include "math/geometry.h"
#include "common/iman.h"
+
#include "graphics/engine/pyro.h"
#include "graphics/engine/particle.h"
#include "graphics/engine/terrain.h"
-#include "physics/physics.h"
+
+#include "math/geometry.h"
+
#include "object/brain.h"
#include "object/motion/motionant.h"
#include "object/motion/motionspider.h"
+#include "physics/physics.h"
+
const float ENERGY_TERRA = 0.40f; // energy consumed by blow
const float ACTION_RADIUS = 400.0f;
@@ -39,8 +41,7 @@ const float ACTION_RADIUS = 400.0f;
// Object's constructor.
-CTaskTerraform::CTaskTerraform(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskTerraform::CTaskTerraform(CObject* object) : CTask(object)
{
m_lastParticle = 0.0f;
m_soundChannel = -1;
@@ -370,9 +371,11 @@ bool CTaskTerraform::Terraform()
m_sound->Play(SOUND_THUMP, m_terraPos);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
@@ -383,7 +386,7 @@ bool CTaskTerraform::Terraform()
dist = Math::Distance(m_terraPos, pObj->GetPosition(0));
if ( dist > 20.0f ) continue;
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FRAGT, pObj);
}
else
diff --git a/src/object/task/taskterraform.h b/src/object/task/taskterraform.h
index 91526b6..8ae0d64 100644
--- a/src/object/task/taskterraform.h
+++ b/src/object/task/taskterraform.h
@@ -20,6 +20,7 @@
#include "object/task/task.h"
+
#include "math/vector.h"
@@ -37,7 +38,7 @@ enum TaskTerraPhase
class CTaskTerraform : public CTask
{
public:
- CTaskTerraform(CInstanceManager* iMan, CObject* object);
+ CTaskTerraform(CObject* object);
~CTaskTerraform();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskturn.cpp b/src/object/task/taskturn.cpp
index 8f4bbd2..7a924cb 100644
--- a/src/object/task/taskturn.cpp
+++ b/src/object/task/taskturn.cpp
@@ -14,7 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskturn.cpp
#include "object/task/taskturn.h"
@@ -26,8 +25,7 @@
// Object's constructor.
-CTaskTurn::CTaskTurn(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskTurn::CTaskTurn(CObject* object) : CTask(object)
{
}
diff --git a/src/object/task/taskturn.h b/src/object/task/taskturn.h
index 1ee40d9..11de476 100644
--- a/src/object/task/taskturn.h
+++ b/src/object/task/taskturn.h
@@ -26,7 +26,7 @@
class CTaskTurn : public CTask
{
public:
- CTaskTurn(CInstanceManager* iMan, CObject* object);
+ CTaskTurn(CObject* object);
~CTaskTurn();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskwait.cpp b/src/object/task/taskwait.cpp
index f612c24..3e201e0 100644
--- a/src/object/task/taskwait.cpp
+++ b/src/object/task/taskwait.cpp
@@ -14,7 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskwait.cpp
#include "object/task/taskwait.h"
@@ -22,8 +21,7 @@
// Object's constructor.
-CTaskWait::CTaskWait(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskWait::CTaskWait(CObject* object) : CTask(object)
{
}
diff --git a/src/object/task/taskwait.h b/src/object/task/taskwait.h
index 3434c36..3225c9a 100644
--- a/src/object/task/taskwait.h
+++ b/src/object/task/taskwait.h
@@ -26,7 +26,7 @@
class CTaskWait : public CTask
{
public:
- CTaskWait(CInstanceManager* iMan, CObject* object);
+ CTaskWait(CObject* object);
~CTaskWait();
bool EventProcess(const Event &event);
diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp
index f56f81d..6311ecf 100644
--- a/src/physics/physics.cpp
+++ b/src/physics/physics.cpp
@@ -17,6 +17,8 @@
#include "physics/physics.h"
+#include "app/app.h"
+
#include "common/event.h"
#include "common/global.h"
#include "common/iman.h"
@@ -31,6 +33,7 @@
#include "math/geometry.h"
#include "object/brain.h"
+#include "object/robotmain.h"
#include "object/motion/motion.h"
#include "object/motion/motionhuman.h"
#include "object/task/task.h"
@@ -51,21 +54,18 @@ const float LANDING_ACCELh = 1.5f;
// Object's constructor.
-CPhysics::CPhysics(CInstanceManager* iMan, CObject* object)
+CPhysics::CPhysics(CObject* object)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_PHYSICS, this, 100);
-
m_object = object;
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_lightMan = static_cast<Gfx::CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT));
- m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
- m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
- m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
- m_brain = 0;
- m_motion = 0;
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_lightMan = m_engine->GetLightManager();
+ m_particle = m_engine->GetParticle();
+ m_water = m_engine->GetWater();
+ m_terrain = CRobotMain::GetInstancePointer()->GetTerrain();
+ m_camera = CRobotMain::GetInstancePointer()->GetCamera();
+ m_sound = CApplication::GetInstancePointer()->GetSound();
+ m_brain = nullptr;
+ m_motion = nullptr;
m_type = TYPE_ROLLING;
m_gravity = 9.81f; // default gravity
@@ -116,8 +116,7 @@ CPhysics::CPhysics(CInstanceManager* iMan, CObject* object)
CPhysics::~CPhysics()
{
- m_iMan->DeleteInstance(CLASS_PHYSICS, this);
-}
+ }
// Destroys the object.
@@ -2510,9 +2509,11 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
iPos = iiPos + (pos - m_object->GetPosition(0));
iType = m_object->GetType();
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue; // yourself?
@@ -2578,7 +2579,7 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
if ( distance < 4.0f )
{
m_sound->Play(SOUND_WAYPOINT, m_object->GetPosition(0));
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_WPCHECK, pObj);
}
}
@@ -2590,7 +2591,7 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
if ( distance < 10.0f*1.5f )
{
m_sound->Play(SOUND_WAYPOINT, m_object->GetPosition(0));
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_WPCHECK, pObj);
}
}
@@ -2752,7 +2753,7 @@ bool CPhysics::ExploOther(ObjectType iType,
(oType == OBJECT_FRET ||
oType == OBJECT_METAL ) )
{
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_EXPLOT, pObj); // total destruction
}
@@ -2760,7 +2761,7 @@ bool CPhysics::ExploOther(ObjectType iType,
(oType == OBJECT_POWER ||
oType == OBJECT_ATOMIC ) )
{
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FRAGT, pObj); // total destruction
}
@@ -2768,7 +2769,7 @@ bool CPhysics::ExploOther(ObjectType iType,
(oType == OBJECT_STONE ||
oType == OBJECT_URANIUM ) )
{
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FRAGT, pObj); // total destruction
}
@@ -2829,14 +2830,14 @@ bool CPhysics::ExploOther(ObjectType iType,
(oType == OBJECT_MOBILEtg ||
oType == OBJECT_TNT ) )
{
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FRAGT, pObj); // total destruction
}
if ( force > 0.0f &&
oType == OBJECT_BOMB )
{
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FRAGT, pObj); // total destruction
}
@@ -2859,7 +2860,7 @@ int CPhysics::ExploHimself(ObjectType iType, ObjectType oType, float force)
{
if ( iType == OBJECT_HUMAN ) type = Gfx::PT_DEADG;
else type = Gfx::PT_EXPLOT;
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(type, m_object); // total destruction
return 2;
}
@@ -2881,7 +2882,7 @@ int CPhysics::ExploHimself(ObjectType iType, ObjectType oType, float force)
{
type = Gfx::PT_EXPLOT;
}
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(type, m_object); // total destruction
return 2;
}
diff --git a/src/physics/physics.h b/src/physics/physics.h
index db88e8c..cce57f3 100644
--- a/src/physics/physics.h
+++ b/src/physics/physics.h
@@ -30,21 +30,19 @@
#include "math/vector.h"
-class CInstanceManager;
class CObject;
class CBrain;
class CMotion;
class CSoundInterface;
-namespace Gfx
-{
+namespace Gfx {
class CCamera;
class CEngine;
class CLight;
class CParticle;
class CTerrain;
class CWater;
-};
+}
enum PhysicsType
@@ -97,7 +95,7 @@ struct Motion
class CPhysics
{
public:
- CPhysics(CInstanceManager* iMan, CObject* object);
+ CPhysics(CObject* object);
~CPhysics();
void DeleteObject(bool bAll=false);
@@ -195,7 +193,6 @@ protected:
void WheelParticle(int color, float width);
protected:
- CInstanceManager* m_iMan;
Gfx::CEngine* m_engine;
Gfx::CLightManager* m_lightMan;
Gfx::CParticle* m_particle;
diff --git a/src/script/script.cpp b/src/script/script.cpp
index 199fd43..977070f 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -335,7 +335,9 @@ bool CScript::rGetObject(CBotVar* var, CBotVar* result, int& exception, void* us
rank = var->GetValInt();
- pObj = static_cast<CObject*>(script->m_iMan->SearchInstance(CLASS_OBJECT, rank));
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, rank));
if ( pObj == 0 )
{
result->SetPointer(0);
@@ -404,11 +406,13 @@ bool CScript::rSearch(CBotVar* var, CBotVar* result, int& exception, void* user)
bNearest = true;
}
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 100000.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(script->m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj->GetTruck() != 0 ) continue; // object transported?
@@ -592,12 +596,14 @@ bool CScript::rRadar(CBotVar* var, CBotVar* result, int& exception, void* user)
iAngle = pThis->GetAngleY(0)+angle;
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
if ( sens >= 0.0f ) best = 100000.0f;
else best = 0.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(script->m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == pThis ) continue;
@@ -778,6 +784,8 @@ bool CScript::rDetect(CBotVar* var, CBotVar* result, int& exception, void* user)
iAngle = pThis->GetAngleY(0)+angle;
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
bGoal = 100000.0f;
pGoal = 0;
if ( sens >= 0.0f ) best = 100000.0f;
@@ -785,7 +793,7 @@ bool CScript::rDetect(CBotVar* var, CBotVar* result, int& exception, void* user)
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(script->m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == pThis ) continue;
@@ -885,7 +893,7 @@ bool CScript::rDetect(CBotVar* var, CBotVar* result, int& exception, void* user)
script->m_returnValue = 1.0f;
}
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
err = script->m_primaryTask->StartTaskWait(0.3f);
if ( err != ERR_OK )
{
@@ -1065,7 +1073,7 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user
type == OBJECT_MARKKEYd ||
type == OBJECT_EGG )
{
- object = new CObject(script->m_iMan);
+ object = new CObject();
if ( !object->CreateResource(pos, angle, type) )
{
delete object;
@@ -1083,7 +1091,7 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user
{
CObject* egg;
- object = new CObject(script->m_iMan);
+ object = new CObject();
if ( !object->CreateInsect(pos, angle, type) )
{
delete object;
@@ -1091,7 +1099,7 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user
return true;
}
- egg = new CObject(script->m_iMan);
+ egg = new CObject();
if ( !egg->CreateResource(pos, angle, OBJECT_EGG, 0.0f) )
{
delete egg;
@@ -1123,7 +1131,7 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user
type == OBJECT_START ||
type == OBJECT_END )
{
- object = new CObject(script->m_iMan);
+ object = new CObject();
if ( !object->CreateBuilding(pos, angle, 0, type) )
{
delete object;
@@ -1140,7 +1148,7 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user
type == OBJECT_FLAGy ||
type == OBJECT_FLAGv )
{
- object = new CObject(script->m_iMan);
+ object = new CObject();
if ( !object->CreateFlag(pos, angle, type) )
{
delete object;
@@ -1182,7 +1190,7 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user
type == OBJECT_MOBILEdr ||
type == OBJECT_APOLLO2 )
{
- object = new CObject(script->m_iMan);
+ object = new CObject();
if ( !object->CreateVehicle(pos, angle, type, power, false, false) )
{
delete object;
@@ -1400,7 +1408,7 @@ bool CScript::rWait(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
value = var->GetValFloat();
err = script->m_primaryTask->StartTaskWait(value);
if ( err != ERR_OK )
@@ -1431,7 +1439,7 @@ bool CScript::rMove(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
value = var->GetValFloat();
err = script->m_primaryTask->StartTaskAdvance(value*g_unit);
if ( err != ERR_OK )
@@ -1462,7 +1470,7 @@ bool CScript::rTurn(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
value = var->GetValFloat();
err = script->m_primaryTask->StartTaskTurn(-value*Math::PI/180.0f);
if ( err != ERR_OK )
@@ -1522,7 +1530,7 @@ bool CScript::rGoto(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
if ( !GetPoint(var, exception, pos) ) return true;
goal = TGG_DEFAULT;
@@ -1601,11 +1609,13 @@ bool CScript::rFind(CBotVar* var, CBotVar* result, int& exception, void* user)
bArray = false;
}
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
best = 100000.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(script->m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == pThis ) continue;
@@ -1684,7 +1694,7 @@ bool CScript::rFind(CBotVar* var, CBotVar* result, int& exception, void* user)
crash = TGC_DEFAULT;
altitude = 0.0f*g_unit;
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
err = script->m_primaryTask->StartTaskGoto(pos, altitude, goal, crash);
if ( err != ERR_OK )
{
@@ -1727,7 +1737,7 @@ bool CScript::rGrab(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
if ( var == 0 )
{
type = TMA_FFRONT;
@@ -1778,7 +1788,7 @@ bool CScript::rDrop(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
if ( var == 0 ) type = TMA_FFRONT;
else type = static_cast<TaskManipArm>(var->GetValInt());
@@ -1820,7 +1830,7 @@ bool CScript::rSniff(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
err = script->m_primaryTask->StartTaskSearch();
if ( err != ERR_OK )
{
@@ -1869,7 +1879,7 @@ bool CScript::rReceive(CBotVar* var, CBotVar* result, int& exception, void* user
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
cbs = var->GetValString();
p = cbs;
@@ -1939,7 +1949,7 @@ bool CScript::rSend(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
cbs = var->GetValString();
p = cbs;
@@ -1984,11 +1994,13 @@ CObject* CScript::SearchInfo(CScript* script, CObject* object, float power)
iPos = object->GetPosition(0);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 100000.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(script->m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
@@ -2147,7 +2159,7 @@ bool CScript::rThump(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
err = script->m_primaryTask->StartTaskTerraform();
if ( err != ERR_OK )
{
@@ -2176,7 +2188,7 @@ bool CScript::rRecycle(CBotVar* var, CBotVar* result, int& exception, void* user
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
err = script->m_primaryTask->StartTaskRecover();
if ( err != ERR_OK )
{
@@ -2238,7 +2250,7 @@ bool CScript::rShield(CBotVar* var, CBotVar* result, int& exception, void* user)
{
pThis->SetParam(radius);
- *script->m_secondaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ *script->m_secondaryTask = new CTaskManager(script->m_object);
err = (*script->m_secondaryTask)->StartTaskShield(TSM_UP, 1000.0f);
if ( err != ERR_OK )
{
@@ -2311,7 +2323,7 @@ bool CScript::rFire(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
type = pThis->GetType();
@@ -2372,7 +2384,7 @@ bool CScript::rAim(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
x = var->GetValFloat();
var = var->GetNext();
var == 0 ? y=0.0f : y=var->GetValFloat();
@@ -2689,7 +2701,7 @@ bool CScript::rPenDown(CBotVar* var, CBotVar* result, int& exception, void* user
}
pThis->SetTraceDown(true);
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
err = script->m_primaryTask->StartTaskPen(pThis->GetTraceDown(), pThis->GetTraceColor());
if ( err != ERR_OK )
{
@@ -2746,7 +2758,7 @@ bool CScript::rPenUp(CBotVar* var, CBotVar* result, int& exception, void* user)
{
pThis->SetTraceDown(false);
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
err = script->m_primaryTask->StartTaskPen(pThis->GetTraceDown(), pThis->GetTraceColor());
if ( err != ERR_OK )
{
@@ -2790,7 +2802,7 @@ bool CScript::rPenColor(CBotVar* var, CBotVar* result, int& exception, void* use
if ( color > 17 ) color = 17;
pThis->SetTraceColor(color);
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
err = script->m_primaryTask->StartTaskPen(pThis->GetTraceDown(), pThis->GetTraceColor());
if ( err != ERR_OK )
{
@@ -2836,22 +2848,19 @@ bool CScript::rPenWidth(CBotVar* var, CBotVar* result, int& exception, void* use
// Object's constructor.
-CScript::CScript(CInstanceManager* iMan, CObject* object, CTaskManager** secondaryTask)
+CScript::CScript(CObject* object, CTaskManager** secondaryTask)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_SCRIPT, this, 100);
-
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
- m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
- m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_main = CRobotMain::GetInstancePointer();
+ m_terrain = m_main->GetTerrain();
+ m_water = m_engine->GetWater();
m_botProg = nullptr;
m_object = object;
m_primaryTask = nullptr;
m_secondaryTask = secondaryTask;
- m_interface = static_cast<Ui::CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
- m_displayText = static_cast<Ui::CDisplayText*>(m_iMan->SearchInstance(CLASS_DISPLAYTEXT));
+ m_interface = m_main->GetInterface();
+ m_displayText = m_main->GetDisplayText();
m_ipf = CBOT_IPF;
m_errMode = ERM_STOP;
@@ -2938,8 +2947,6 @@ CScript::~CScript()
m_script = nullptr;
m_len = 0;
-
- m_iMan->DeleteInstance(CLASS_SCRIPT, this);
}
diff --git a/src/script/script.h b/src/script/script.h
index 674a67e..982d12b 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -29,7 +29,6 @@
#include <stdio.h>
-class CInstanceManager;
class CObject;
class CTaskManager;
class CRobotMain;
@@ -52,7 +51,7 @@ class CWater;
class CScript
{
public:
- CScript(CInstanceManager* iMan, CObject* object, CTaskManager** secondaryTask);
+ CScript(CObject* object, CTaskManager** secondaryTask);
~CScript();
static void InitFonctions();
@@ -178,7 +177,7 @@ private:
static bool Process(CScript* script, CBotVar* result, int &exception);
static CObject* SearchInfo(CScript* script, CObject* object, float power);
- CInstanceManager* m_iMan;
+protected:
Gfx::CEngine* m_engine;
Ui::CInterface* m_interface;
Ui::CDisplayText* m_displayText;
diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp
index 2e44eef..83cbeb6 100644
--- a/src/sound/oalsound/alsound.cpp
+++ b/src/sound/oalsound/alsound.cpp
@@ -15,8 +15,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// alsound.cpp
-
#include "alsound.h"
@@ -29,18 +27,12 @@ ALSound::ALSound()
mAudioVolume = 1.0f;
mMusicVolume = 1.0f;
mMute = false;
- mCurrentMusic = nullptr;
- auto pointer = CInstanceManager::GetInstancePointer();
- if (pointer != nullptr)
- CInstanceManager::GetInstancePointer()->AddInstance(CLASS_SOUND, this);
+ mCurrentMusic = nullptr;
}
ALSound::~ALSound()
{
- auto pointer = CInstanceManager::GetInstancePointer();
- if (pointer != nullptr)
- CInstanceManager::GetInstancePointer()->DeleteInstance(CLASS_SOUND, this);
CleanUp();
}
diff --git a/src/sound/oalsound/alsound.h b/src/sound/oalsound/alsound.h
index 530aa5e..bdf06b1 100644
--- a/src/sound/oalsound/alsound.h
+++ b/src/sound/oalsound/alsound.h
@@ -24,7 +24,6 @@
#include <AL/al.h>
-#include "common/iman.h"
#include "common/logger.h"
#include "sound/sound.h"
diff --git a/src/sound/oalsound/buffer.cpp b/src/sound/oalsound/buffer.cpp
index d76b24a..edc3d74 100644
--- a/src/sound/oalsound/buffer.cpp
+++ b/src/sound/oalsound/buffer.cpp
@@ -14,7 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// buffer.cpp
#include "buffer.h"
diff --git a/src/sound/oalsound/channel.cpp b/src/sound/oalsound/channel.cpp
index 2b9af9b..3c8bc50 100644
--- a/src/sound/oalsound/channel.cpp
+++ b/src/sound/oalsound/channel.cpp
@@ -14,7 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// channel.cpp
#include "channel.h"
@@ -349,4 +348,4 @@ void Channel::PopEnvelope()
void Channel::SetLoop(bool loop) {
mLoop = loop;
-} \ No newline at end of file
+}
diff --git a/src/sound/sound.h b/src/sound/sound.h
index d152f76..70139ea 100644
--- a/src/sound/sound.h
+++ b/src/sound/sound.h
@@ -26,7 +26,6 @@
#include "math/vector.h"
-#include "common/iman.h"
#include "common/logger.h"
#include <string>
@@ -156,11 +155,8 @@ enum SoundNext
class CSoundInterface
{
public:
- inline CSoundInterface() {
- CInstanceManager::GetInstance().AddInstance(CLASS_SOUND, this);
- //m_iMan->AddInstance(CLASS_SOUND, this);
- };
- inline virtual ~CSoundInterface() {};
+ inline CSoundInterface() {}
+ inline virtual ~CSoundInterface() {}
/** Function to initialize sound device
* \param b3D - enable support for 3D sound
diff --git a/src/ui/button.cpp b/src/ui/button.cpp
index e3dbc30..a68b34d 100644
--- a/src/ui/button.cpp
+++ b/src/ui/button.cpp
@@ -16,7 +16,6 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-
#include "ui/button.h"
#include "common/event.h"
diff --git a/src/ui/button.h b/src/ui/button.h
index 33a48ee..a9aa020 100644
--- a/src/ui/button.h
+++ b/src/ui/button.h
@@ -25,31 +25,29 @@
namespace Ui {
- class CButton : public CControl
- {
- public:
- CButton();
- virtual ~CButton();
+class CButton : public CControl
+{
+public:
+ CButton();
+ virtual ~CButton();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
- bool EventProcess(const Event &event);
+ bool EventProcess(const Event &event);
- void Draw();
+ void Draw();
- void SetImmediat(bool bRepeat);
- bool GetImmediat();
+ void SetImmediat(bool bRepeat);
+ bool GetImmediat();
- void SetRepeat(bool bRepeat);
- bool GetRepeat();
+ void SetRepeat(bool bRepeat);
+ bool GetRepeat();
- protected:
-
- protected:
- bool m_bCapture;
- bool m_bImmediat;
- bool m_bRepeat;
- float m_repeat;
- };
+protected:
+ bool m_bCapture;
+ bool m_bImmediat;
+ bool m_bRepeat;
+ float m_repeat;
+};
}
diff --git a/src/ui/check.cpp b/src/ui/check.cpp
index bc80b7c..761264d 100644
--- a/src/ui/check.cpp
+++ b/src/ui/check.cpp
@@ -19,7 +19,6 @@
#include "ui/check.h"
#include "common/event.h"
-#include "common/iman.h"
#include "common/misc.h"
#include "common/restext.h"
diff --git a/src/ui/check.h b/src/ui/check.h
index af26add..65bc367 100644
--- a/src/ui/check.h
+++ b/src/ui/check.h
@@ -22,27 +22,24 @@
#include "ui/control.h"
-namespace Gfx{
- class CEngine;
+namespace Gfx {
+class CEngine;
}
namespace Ui {
- class CCheck : public CControl
- {
- public:
- CCheck();
- virtual ~CCheck();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
+class CCheck : public CControl
+{
+public:
+ CCheck();
+ virtual ~CCheck();
- bool EventProcess(const Event &event);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
- void Draw();
+ bool EventProcess(const Event &event);
- protected:
-
- protected:
- };
+ void Draw();
+};
}
diff --git a/src/ui/color.cpp b/src/ui/color.cpp
index 65f9770..fd05bd9 100644
--- a/src/ui/color.cpp
+++ b/src/ui/color.cpp
@@ -19,7 +19,6 @@
#include "ui/color.h"
#include "common/event.h"
-#include "common/iman.h"
#include "common/misc.h"
#include "common/restext.h"
@@ -37,7 +36,6 @@ const float DELAY2 = 0.1f;
// Object's constructor.
-//CColor::CColor(CInstanceManager* iMan) : CControl(iMan)
CColor::CColor() : CControl()
{
m_bRepeat = false;
diff --git a/src/ui/color.h b/src/ui/color.h
index 311a532..ec2c537 100644
--- a/src/ui/color.h
+++ b/src/ui/color.h
@@ -23,37 +23,34 @@
namespace Gfx{
- class CEngine;
- struct Color;
+class CEngine;
+struct Color;
}
namespace Ui {
- class CColor : public CControl
- {
- public:
- // CColor(CInstanceManager* iMan);
- CColor();
- virtual ~CColor();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
+class CColor : public CControl
+{
+public:
+ CColor();
+ virtual ~CColor();
- bool EventProcess(const Event &event);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
- void Draw();
+ bool EventProcess(const Event &event);
- void SetRepeat(bool bRepeat);
- bool GetRepeat();
+ void Draw();
- void SetColor(Gfx::Color color);
- Gfx::Color GetColor();
+ void SetRepeat(bool bRepeat);
+ bool GetRepeat();
- protected:
-
- protected:
- bool m_bRepeat;
- float m_repeat;
- Gfx::Color m_color;
- };
+ void SetColor(Gfx::Color color);
+ Gfx::Color GetColor();
+protected:
+ bool m_bRepeat;
+ float m_repeat;
+ Gfx::Color m_color;
+};
}
diff --git a/src/ui/compass.cpp b/src/ui/compass.cpp
index 1bc0f8c..ac97cb8 100644
--- a/src/ui/compass.cpp
+++ b/src/ui/compass.cpp
@@ -15,10 +15,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
+
#include "ui/compass.h"
#include "common/event.h"
-#include "common/iman.h"
#include "common/misc.h"
#include "graphics/core/device.h"
@@ -29,7 +29,6 @@
namespace Ui {
// Object's constructor.
-//CCompass::CCompass(CInstanceManager* iMan) : CControl(iMan)
CCompass::CCompass() : CControl()
{
m_dir = 0.0f;
diff --git a/src/ui/compass.h b/src/ui/compass.h
index 09eec9d..18546e5 100644
--- a/src/ui/compass.h
+++ b/src/ui/compass.h
@@ -23,32 +23,29 @@
namespace Gfx {
- class CEngine;
+class CEngine;
}
namespace Ui {
- class CCompass : public CControl
- {
- public:
- // CCompass(CInstanceManager* iMan);
- CCompass();
- virtual ~CCompass();
+class CCompass : public CControl
+{
+public:
+ CCompass();
+ virtual ~CCompass();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
- bool EventProcess(const Event &event);
+ bool EventProcess(const Event &event);
- void Draw();
+ void Draw();
- void SetDirection(float dir);
- float GetDirection();
+ void SetDirection(float dir);
+ float GetDirection();
- protected:
-
- protected:
- float m_dir;
- };
+protected:
+ float m_dir;
+};
}
diff --git a/src/ui/control.cpp b/src/ui/control.cpp
index 718ad3b..6dc92cd 100644
--- a/src/ui/control.cpp
+++ b/src/ui/control.cpp
@@ -18,25 +18,23 @@
#include "ui/control.h"
+#include "app/app.h"
+
namespace Ui {
// Object's constructor.
CControl::CControl()
{
- m_iMan = CInstanceManager::GetInstancePointer();
-
- m_engine = static_cast< Gfx::CEngine* > ( m_iMan->SearchInstance(CLASS_ENGINE) );
- m_event = static_cast< CEventQueue* > ( m_iMan->SearchInstance(CLASS_EVENT) );
- m_main = static_cast< CRobotMain* > ( m_iMan->SearchInstance(CLASS_MAIN) );
- m_particle = static_cast< Gfx::CParticle* > (m_iMan->SearchInstance(CLASS_PARTICULE));
- m_sound = static_cast< CSoundInterface* > (m_iMan->SearchInstance(CLASS_SOUND));
- m_eventType = EVENT_NULL;
+ m_event = CApplication::GetInstancePointer()->GetEventQueue();
+ m_sound = CApplication::GetInstancePointer()->GetSound();
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_main = CRobotMain::GetInstancePointer();
+ m_particle = m_engine->GetParticle();
+ m_eventType = EVENT_NULL;
m_state = STATE_ENABLE|STATE_VISIBLE|STATE_GLINT;
m_fontSize = Gfx::FONT_SIZE_SMALL;
-// m_fontStretch = Gfx::FONT_NORM_STRETCH; //there is font stretching no more master
m_fontType = Gfx::FONT_COLOBOT;
m_textAlign = Gfx::TEXT_ALIGN_CENTER; //instead m_justify
-// m_justif = 0;
m_bFocus = false;
m_bCapture = false;
diff --git a/src/ui/control.h b/src/ui/control.h
index 635ae12..7f5077d 100644
--- a/src/ui/control.h
+++ b/src/ui/control.h
@@ -22,7 +22,6 @@
#include <string>
#include "common/event.h"
-#include "common/iman.h"
#include "common/misc.h"
#include "common/restext.h"
@@ -39,108 +38,106 @@
namespace Ui {
- enum ControlState
- {
- STATE_ENABLE = (1<<0), // active
- STATE_CHECK = (1<<1), // pressed
- STATE_HILIGHT = (1<<2), // overflown by mouse
- STATE_PRESS = (1<<3), // pressed by mouse
- STATE_VISIBLE = (1<<4), // visible
- STATE_DEAD = (1<<5), // inaccessible (x)
- STATE_DEFAULT = (1<<6), // actuated by RETURN
- STATE_OKAY = (1<<7), // green point at the bottom right
- STATE_SHADOW = (1<<8), // shadow
- STATE_GLINT = (1<<9), // dynamic reflection
- STATE_CARD = (1<<10), // tab
- STATE_EXTEND = (1<<11), // extended mode
- STATE_SIMPLY = (1<<12), // undecorated
- STATE_FRAME = (1<<13), // framework highlighting
- STATE_WARNING = (1<<14), // framework hatched yellow / black
- STATE_VALUE = (1<<15), // displays the value
- STATE_RUN = (1<<16) // running program
- };
-
-
-
- class CControl
- {
- public:
- CControl();
- virtual ~CControl();
-
- virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
-
- virtual bool EventProcess(const Event &event);
-
- virtual void SetPos(Math::Point pos);
- virtual Math::Point GetPos();
- virtual void SetDim(Math::Point dim);
- virtual Math::Point GetDim();
- virtual bool SetState(int state, bool bState);
- virtual bool SetState(int state);
- virtual bool ClearState(int state);
- virtual bool TestState(int state);
- virtual int GetState();
- virtual void SetIcon(int icon);
- virtual int GetIcon();
- virtual void SetName(std::string name, bool bTooltip=true);
- virtual std::string GetName();
- virtual void SetTextAlign(Gfx::TextAlign mode);
- virtual int GetTextAlign();
- virtual void SetFontSize(float size);
- virtual float GetFontSize();
- virtual void SetFontStretch(float stretch);
- virtual float GetFontStretch();
- virtual void SetFontType(Gfx::FontType font);
- virtual Gfx::FontType GetFontType();
- virtual bool SetTooltip(std::string name);
- virtual bool GetTooltip(Math::Point pos, std::string &name);
- virtual void SetFocus(bool bFocus);
- virtual bool GetFocus();
-
- virtual EventType GetEventType();
-
- virtual void Draw();
-
- protected:
- void GlintDelete();
- void GlintCreate(Math::Point ref, bool bLeft=true, bool bUp=true);
- void GlintFrame(const Event &event);
- void DrawPart(int icon, float zoom, float ex);
- void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, float ex=0.0f);
- void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, Math::Point corner, float ex);
- void DrawWarning(Math::Point pos, Math::Point dim);
- void DrawShadow(Math::Point pos, Math::Point dim, float deep=1.0f);
- virtual bool Detect(Math::Point pos);
-
- protected:
- CInstanceManager* m_iMan;
- Gfx::CEngine* m_engine;
- Gfx::CParticle* m_particle;
- CEventQueue* m_event;
- CRobotMain* m_main;
- CSoundInterface* m_sound;
-
- Math::Point m_pos; // corner upper / left
- Math::Point m_dim; // dimensions
- int m_icon;
- EventType m_eventType; // message to send when clicking
- int m_state; // states (STATE_ *)
- float m_fontSize; // size of the button name
- float m_fontStretch; // stretch of the font
- Gfx::FontType m_fontType; // type of font
- Gfx::TextAlign m_textAlign; //type of alignment //comes in the place of m_justif
- // int m_justif; // type of justification (-1,0,1)
- std::string m_name; // name of the button
- std::string m_tooltip; // name of tooltip
- bool m_bFocus;
- bool m_bCapture;
-
- bool m_bGlint;
- Math::Point m_glintCorner1;
- Math::Point m_glintCorner2;
- float m_glintProgress;
- Math::Point m_glintMouse;
- };
-
-}
+enum ControlState
+{
+ STATE_ENABLE = (1<<0), // active
+ STATE_CHECK = (1<<1), // pressed
+ STATE_HILIGHT = (1<<2), // overflown by mouse
+ STATE_PRESS = (1<<3), // pressed by mouse
+ STATE_VISIBLE = (1<<4), // visible
+ STATE_DEAD = (1<<5), // inaccessible (x)
+ STATE_DEFAULT = (1<<6), // actuated by RETURN
+ STATE_OKAY = (1<<7), // green point at the bottom right
+ STATE_SHADOW = (1<<8), // shadow
+ STATE_GLINT = (1<<9), // dynamic reflection
+ STATE_CARD = (1<<10), // tab
+ STATE_EXTEND = (1<<11), // extended mode
+ STATE_SIMPLY = (1<<12), // undecorated
+ STATE_FRAME = (1<<13), // framework highlighting
+ STATE_WARNING = (1<<14), // framework hatched yellow / black
+ STATE_VALUE = (1<<15), // displays the value
+ STATE_RUN = (1<<16) // running program
+};
+
+
+
+class CControl
+{
+public:
+ CControl();
+ virtual ~CControl();
+
+ virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
+
+ virtual bool EventProcess(const Event &event);
+
+ virtual void SetPos(Math::Point pos);
+ virtual Math::Point GetPos();
+ virtual void SetDim(Math::Point dim);
+ virtual Math::Point GetDim();
+ virtual bool SetState(int state, bool bState);
+ virtual bool SetState(int state);
+ virtual bool ClearState(int state);
+ virtual bool TestState(int state);
+ virtual int GetState();
+ virtual void SetIcon(int icon);
+ virtual int GetIcon();
+ virtual void SetName(std::string name, bool bTooltip=true);
+ virtual std::string GetName();
+ virtual void SetTextAlign(Gfx::TextAlign mode);
+ virtual int GetTextAlign();
+ virtual void SetFontSize(float size);
+ virtual float GetFontSize();
+ virtual void SetFontStretch(float stretch);
+ virtual float GetFontStretch();
+ virtual void SetFontType(Gfx::FontType font);
+ virtual Gfx::FontType GetFontType();
+ virtual bool SetTooltip(std::string name);
+ virtual bool GetTooltip(Math::Point pos, std::string &name);
+ virtual void SetFocus(bool bFocus);
+ virtual bool GetFocus();
+
+ virtual EventType GetEventType();
+
+ virtual void Draw();
+
+protected:
+ void GlintDelete();
+ void GlintCreate(Math::Point ref, bool bLeft=true, bool bUp=true);
+ void GlintFrame(const Event &event);
+ void DrawPart(int icon, float zoom, float ex);
+ void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, float ex=0.0f);
+ void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, Math::Point corner, float ex);
+ void DrawWarning(Math::Point pos, Math::Point dim);
+ void DrawShadow(Math::Point pos, Math::Point dim, float deep=1.0f);
+ virtual bool Detect(Math::Point pos);
+
+protected:
+ Gfx::CEngine* m_engine;
+ Gfx::CParticle* m_particle;
+ CEventQueue* m_event;
+ CRobotMain* m_main;
+ CSoundInterface* m_sound;
+
+ Math::Point m_pos; // corner upper / left
+ Math::Point m_dim; // dimensions
+ int m_icon;
+ EventType m_eventType; // message to send when clicking
+ int m_state; // states (STATE_ *)
+ float m_fontSize; // size of the button name
+ float m_fontStretch; // stretch of the font
+ Gfx::FontType m_fontType; // type of font
+ Gfx::TextAlign m_textAlign; //type of alignment //comes in the place of m_justif
+ std::string m_name; // name of the button
+ std::string m_tooltip; // name of tooltip
+ bool m_bFocus;
+ bool m_bCapture;
+
+ bool m_bGlint;
+ Math::Point m_glintCorner1;
+ Math::Point m_glintCorner2;
+ float m_glintProgress;
+ Math::Point m_glintMouse;
+};
+
+} // namespace Ui
diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp
index 29499bd..a9e754f 100644
--- a/src/ui/displayinfo.cpp
+++ b/src/ui/displayinfo.cpp
@@ -15,17 +15,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// displayinfo.cpp
-
#include "ui/displayinfo.h"
-#include "ui/interface.h"
-#include "ui/button.h"
-#include "ui/slider.h"
-#include "ui/edit.h"
-#include "ui/group.h"
-#include "ui/window.h"
+#include "app/app.h"
#include "common/iman.h"
#include "common/misc.h"
@@ -43,25 +36,28 @@
#include "script/cbottoken.h"
+#include "ui/interface.h"
+#include "ui/button.h"
+#include "ui/slider.h"
+#include "ui/edit.h"
+#include "ui/group.h"
+#include "ui/window.h"
+
#include <string.h>
namespace Ui {
// Object's constructor.
-//CDisplayInfo::CDisplayInfo(CInstanceManager* iMan)
CDisplayInfo::CDisplayInfo()
{
- m_iMan = CInstanceManager::GetInstancePointer();
- m_iMan->AddInstance(CLASS_STUDIO, this);
-
- m_engine = static_cast <Gfx::CEngine*> (m_iMan->SearchInstance(CLASS_ENGINE));
- m_event = static_cast <CEventQueue*> (m_iMan->SearchInstance(CLASS_EVENT));
- m_interface = static_cast <CInterface*> (m_iMan->SearchInstance(CLASS_INTERFACE));
- m_main = static_cast <CRobotMain*> (m_iMan->SearchInstance(CLASS_MAIN));
- m_camera = static_cast <Gfx::CCamera*> (m_iMan->SearchInstance(CLASS_CAMERA));
- m_particle = static_cast <Gfx::CParticle*> (m_iMan->SearchInstance(CLASS_PARTICULE));
- m_light = static_cast <Gfx::CLightManager*> (m_iMan->SearchInstance(CLASS_LIGHT));
+ m_event = CApplication::GetInstancePointer()->GetEventQueue();
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_particle = m_engine->GetParticle();
+ m_light = m_engine->GetLightManager();
+ m_main = CRobotMain::GetInstancePointer();
+ m_interface = m_main->GetInterface();
+ m_camera = m_main->GetCamera();
m_bInfoMaximized = true;
m_bInfoMinimized = false;
@@ -77,7 +73,6 @@ CDisplayInfo::CDisplayInfo()
CDisplayInfo::~CDisplayInfo()
{
- m_iMan->DeleteInstance(CLASS_STUDIO, this);
}
@@ -927,9 +922,11 @@ CObject* CDisplayInfo::SearchToto()
CObject* pObj;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
@@ -1012,6 +1009,8 @@ void CDisplayInfo::CreateObjectsFile()
int i;
bool bRadar, bAtLeast;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
file = fopen("help\\objects.txt", "w");
if ( file == 0 ) return;
@@ -1019,7 +1018,7 @@ void CDisplayInfo::CreateObjectsFile()
bRadar = false;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->GetActif() ) continue;
diff --git a/src/ui/displayinfo.h b/src/ui/displayinfo.h
index 2eabbf2..ab42d62 100644
--- a/src/ui/displayinfo.h
+++ b/src/ui/displayinfo.h
@@ -25,7 +25,6 @@
#include "graphics/engine/camera.h"
-class CInstanceManager;
class CRobotMain;
class CObject;
class CEventQueue;
@@ -33,67 +32,66 @@ class CEventQueue;
struct Event;
namespace Gfx {
- class CEngine;
- class CParticle;
- class CLightManager;
+class CEngine;
+class CParticle;
+class CLightManager;
}
namespace Ui {
- class CInterface;
-
- class CDisplayInfo
- {
- public:
- // CDisplayInfo(CInstanceManager* iMan);
- CDisplayInfo();
- ~CDisplayInfo();
-
- bool EventProcess(const Event &event);
-
- void StartDisplayInfo(std::string filename, int index, bool bSoluce);
- void StopDisplayInfo();
-
- void SetPosition(int pos);
- int GetPosition();
-
- protected:
- bool EventFrame(const Event &event);
- void HyperUpdate();
- void AdjustDisplayInfo(Math::Point wpos, Math::Point wdim);
- void ChangeIndexButton(int index);
- void UpdateIndexButton();
- void UpdateCopyButton();
- void ViewDisplayInfo();
- CObject* SearchToto();
- void CreateObjectsFile();
-
- protected:
- CInstanceManager* m_iMan;
- Gfx::CEngine* m_engine;
- CEventQueue* m_event;
- CRobotMain* m_main;
- Gfx::CCamera* m_camera;
- CInterface* m_interface;
- Gfx::CParticle* m_particle;
- Gfx::CLightManager* m_light;
-
- bool m_bInfoMaximized;
- bool m_bInfoMinimized;
-
- int m_index;
- Gfx::CameraType m_infoCamera;
- Math::Point m_infoNormalPos;
- Math::Point m_infoNormalDim;
- Math::Point m_infoActualPos;
- Math::Point m_infoActualDim;
- Math::Point m_infoFinalPos;
- Math::Point m_infoFinalDim;
- int m_lightSuppl;
- bool m_bEditLock;
- bool m_bInitPause;
- bool m_bSoluce;
- CObject* m_toto;
- };
-
-}
+class CInterface;
+
+class CDisplayInfo
+{
+public:
+ CDisplayInfo();
+ ~CDisplayInfo();
+
+ bool EventProcess(const Event &event);
+
+ void StartDisplayInfo(std::string filename, int index, bool bSoluce);
+ void StopDisplayInfo();
+
+ void SetPosition(int pos);
+ int GetPosition();
+
+protected:
+ bool EventFrame(const Event &event);
+ void HyperUpdate();
+ void AdjustDisplayInfo(Math::Point wpos, Math::Point wdim);
+ void ChangeIndexButton(int index);
+ void UpdateIndexButton();
+ void UpdateCopyButton();
+ void ViewDisplayInfo();
+ CObject* SearchToto();
+ void CreateObjectsFile();
+
+protected:
+ Gfx::CEngine* m_engine;
+ CEventQueue* m_event;
+ CRobotMain* m_main;
+ Gfx::CCamera* m_camera;
+ CInterface* m_interface;
+ Gfx::CParticle* m_particle;
+ Gfx::CLightManager* m_light;
+
+ bool m_bInfoMaximized;
+ bool m_bInfoMinimized;
+
+ int m_index;
+ Gfx::CameraType m_infoCamera;
+ Math::Point m_infoNormalPos;
+ Math::Point m_infoNormalDim;
+ Math::Point m_infoActualPos;
+ Math::Point m_infoActualDim;
+ Math::Point m_infoFinalPos;
+ Math::Point m_infoFinalDim;
+ int m_lightSuppl;
+ bool m_bEditLock;
+ bool m_bInitPause;
+ bool m_bSoluce;
+ CObject* m_toto;
+};
+
+
+} // namespace Ui
diff --git a/src/ui/displaytext.cpp b/src/ui/displaytext.cpp
index 7c60f8b..630b385 100644
--- a/src/ui/displaytext.cpp
+++ b/src/ui/displaytext.cpp
@@ -15,16 +15,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// displaytext.cpp
-
#include "ui/displaytext.h"
-#include "ui/interface.h"
-#include "ui/button.h"
-#include "ui/label.h"
-#include "ui/window.h"
-#include "ui/group.h"
+#include "app/app.h"
#include "common/event.h"
#include "common/iman.h"
@@ -36,6 +30,11 @@
#include "object/motion/motion.h"
#include "object/motion/motiontoto.h"
+#include "ui/interface.h"
+#include "ui/button.h"
+#include "ui/label.h"
+#include "ui/window.h"
+#include "ui/group.h"
@@ -46,20 +45,13 @@ const float FONTSIZE = 12.0f;
// Object's constructor.
-//CDisplayText::CDisplayText(CInstanceManager* iMan)
CDisplayText::CDisplayText()
{
- int i;
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_interface = CRobotMain::GetInstancePointer()->GetInterface();
+ m_sound = CApplication::GetInstancePointer()->GetSound();
-// m_iMan = iMan;
- m_iMan = CInstanceManager::GetInstancePointer();
- m_iMan->AddInstance(CLASS_DISPLAYTEXT, this);
-
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
-
- for ( i=0 ; i<MAXDTLINE ; i++ )
+ for (int i=0 ; i<MAXDTLINE ; i++ )
{
m_bExist[i] = false;
m_visitGoal[i] = Math::Vector(0.0f, 0.0f, 0.0f);
@@ -77,7 +69,6 @@ CDisplayText::CDisplayText()
CDisplayText::~CDisplayText()
{
- m_iMan->DeleteInstance(CLASS_DISPLAYTEXT, this);
}
@@ -598,9 +589,11 @@ CObject* CDisplayText::SearchToto()
CObject* pObj;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
diff --git a/src/ui/displaytext.h b/src/ui/displaytext.h
index 5714cc5..94572a8 100644
--- a/src/ui/displaytext.h
+++ b/src/ui/displaytext.h
@@ -27,16 +27,14 @@
-class CInstanceManager;
-//class CD3DEngine
class CObject;
class CSound;
namespace Gfx {
- class CEngine;
+class CEngine;
}
-namespace Ui {;
+namespace Ui {
class CInterface;
@@ -54,7 +52,6 @@ const int MAXDTLINE = 4;
class CDisplayText
{
public:
-// CDisplayText(CInstanceManager* iMan);
CDisplayText();
~CDisplayText();
@@ -87,7 +84,6 @@ protected:
CObject* SearchToto();
protected:
- CInstanceManager* m_iMan;
Gfx::CEngine* m_engine;
Ui::CInterface* m_interface;
CSoundInterface* m_sound;
@@ -104,4 +100,5 @@ protected:
};
-}
+} // namespace Ui
+
diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp
index 0e50852..64004bb 100644
--- a/src/ui/edit.cpp
+++ b/src/ui/edit.cpp
@@ -15,11 +15,11 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// edit.cpp
-#include "app/app.h"
#include "ui/edit.h"
+#include "app/app.h"
+
#include <string.h>
namespace Ui {
diff --git a/src/ui/edit.h b/src/ui/edit.h
index 75572c7..8f46445 100644
--- a/src/ui/edit.h
+++ b/src/ui/edit.h
@@ -32,7 +32,6 @@
#include "common/event.h"
#include "common/misc.h"
-#include "common/iman.h"
#include "common/restext.h"
#include <set>
diff --git a/src/ui/editvalue.cpp b/src/ui/editvalue.cpp
index 3cc856d..6397a73 100644
--- a/src/ui/editvalue.cpp
+++ b/src/ui/editvalue.cpp
@@ -15,22 +15,21 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// editvalue.cpp
+#include "ui/editvalue.h"
#include "common/event.h"
#include "common/misc.h"
-#include "common/iman.h"
+
#include "ui/edit.h"
#include "ui/button.h"
-#include "ui/editvalue.h"
+
namespace Ui {
// Object's constructor.
-//CEditValue::CEditValue(CInstanceManager* iMan) : CControl(iMan)
CEditValue::CEditValue() : CControl ()
{
m_edit = 0;
diff --git a/src/ui/editvalue.h b/src/ui/editvalue.h
index 1469b69..5d6e643 100644
--- a/src/ui/editvalue.h
+++ b/src/ui/editvalue.h
@@ -44,7 +44,6 @@ class CButton;
class CEditValue : public CControl
{
public:
-// CEditValue(CInstanceManager* iMan);
CEditValue();
virtual ~CEditValue();
diff --git a/src/ui/gauge.cpp b/src/ui/gauge.cpp
index b1fa057..c98e3b6 100644
--- a/src/ui/gauge.cpp
+++ b/src/ui/gauge.cpp
@@ -15,8 +15,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// gauge.cpp
-
#include "ui/gauge.h"
@@ -24,7 +22,6 @@
namespace Ui {
// Object's constructor.
-//CGauge::CGauge(CInstanceManager* iMan) : CControl(iMan)
CGauge::CGauge() : CControl()
{
m_level = 0.0f;
diff --git a/src/ui/gauge.h b/src/ui/gauge.h
index f4a008f..a2b689a 100644
--- a/src/ui/gauge.h
+++ b/src/ui/gauge.h
@@ -32,7 +32,6 @@ namespace Ui {
class CGauge : public CControl
{
public:
- // CGauge(CInstanceManager* iMan);
CGauge();
virtual ~CGauge();
diff --git a/src/ui/group.cpp b/src/ui/group.cpp
index 67369d9..c3c7028 100644
--- a/src/ui/group.cpp
+++ b/src/ui/group.cpp
@@ -14,14 +14,13 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// group.cpp
#include "ui/group.h"
#include "common/event.h"
#include "common/misc.h"
-#include "common/iman.h"
#include "common/restext.h"
+
#include "graphics/engine/engine.h"
@@ -32,7 +31,6 @@
namespace Ui {
// Object's constructor.
-//CGroup::CGroup(CInstanceManager* iMan) : CControl(iMan)
CGroup::CGroup() : CControl()
{
}
diff --git a/src/ui/group.h b/src/ui/group.h
index bfeef74..fd31716 100644
--- a/src/ui/group.h
+++ b/src/ui/group.h
@@ -30,7 +30,6 @@ namespace Ui {
class CGroup : public CControl
{
public:
-// CGroup(CInstanceManager* iMan);
CGroup();
virtual ~CGroup();
diff --git a/src/ui/image.cpp b/src/ui/image.cpp
index ad838fa..94b9586 100644
--- a/src/ui/image.cpp
+++ b/src/ui/image.cpp
@@ -15,16 +15,15 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// image.cpp
-
+#include "ui/image.h"
-#include "graphics/engine/engine.h"
#include "common/event.h"
#include "common/misc.h"
-#include "common/iman.h"
#include "common/restext.h"
-#include "ui/image.h"
+
+#include "graphics/engine/engine.h"
+
#include <string.h>
#include <stdio.h>
@@ -33,7 +32,6 @@
namespace Ui {
// Object's constructor.
-//CImage::CImage(CInstanceManager* iMan) : CControl(iMan)
CImage::CImage() : CControl()
{
m_filename[0] = 0;
diff --git a/src/ui/image.h b/src/ui/image.h
index b73a5ae..c40828c 100644
--- a/src/ui/image.h
+++ b/src/ui/image.h
@@ -32,7 +32,6 @@ namespace Ui {
class CImage : public CControl
{
public:
-// CImage(CInstanceManager* iMan);
CImage ();
virtual ~CImage();
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp
index 885cef4..24d2626 100644
--- a/src/ui/interface.cpp
+++ b/src/ui/interface.cpp
@@ -15,20 +15,18 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// interface.cpp
-
#include "ui/interface.h"
+#include "app/app.h"
+
namespace Ui {
CInterface::CInterface()
{
- m_iMan = CInstanceManager::GetInstancePointer();
- m_iMan->AddInstance(CLASS_INTERFACE, this);
- m_event = static_cast<CEventQueue *>( m_iMan->SearchInstance(CLASS_EVENT) );
- m_engine = static_cast<Gfx::CEngine *>( m_iMan->SearchInstance(CLASS_ENGINE) );
+ m_event = CApplication::GetInstancePointer()->GetEventQueue();
+ m_engine = Gfx::CEngine::GetInstancePointer();
m_camera = nullptr;
for (int i = 0; i < MAXCONTROL; i++ )
@@ -42,7 +40,6 @@ CInterface::CInterface()
CInterface::~CInterface()
{
Flush();
- m_iMan->DeleteInstance(CLASS_INTERFACE, this);
}
@@ -278,15 +275,18 @@ CControl* CInterface::SearchControl(EventType eventMsg)
bool CInterface::EventProcess(const Event &event)
{
- if (event.type == EVENT_MOUSE_MOVE) {
- if (m_camera == nullptr) {
- m_camera = static_cast<Gfx::CCamera *>(m_iMan->SearchInstance(CLASS_CAMERA));
- }
+ if (event.type == EVENT_MOUSE_MOVE)
+ {
+ if (m_camera == nullptr)
+ m_camera = CRobotMain::GetInstancePointer()->GetCamera();
+
m_engine->SetMouseType(m_camera->GetMouseDef(event.mousePos));
}
- for (int i = MAXCONTROL-1; i >= 0; i--) {
- if (m_table[i] != nullptr && m_table[i]->TestState(STATE_ENABLE)) {
+ for (int i = MAXCONTROL-1; i >= 0; i--)
+ {
+ if (m_table[i] != nullptr && m_table[i]->TestState(STATE_ENABLE))
+ {
if ( !m_table[i]->EventProcess(event) )
return false;
}
@@ -300,8 +300,10 @@ bool CInterface::EventProcess(const Event &event)
bool CInterface::GetTooltip(Math::Point pos, std::string &name)
{
- for (int i = MAXCONTROL-1; i >= 0; i--) {
- if (m_table[i] != nullptr) {
+ for (int i = MAXCONTROL-1; i >= 0; i--)
+ {
+ if (m_table[i] != nullptr)
+ {
if (m_table[i]->GetTooltip(pos, name))
return true;
}
@@ -314,16 +316,8 @@ bool CInterface::GetTooltip(Math::Point pos, std::string &name)
void CInterface::Draw()
{
- /*ZeroMemory( &material, sizeof(D3DMATERIAL7) );
- material.diffuse.r = 1.0f;
- material.diffuse.g = 1.0f;
- material.diffuse.b = 1.0f;
- material.ambient.r = 0.5f;
- material.ambient.g = 0.5f;
- material.ambient.b = 0.5f;
- m_engine->SetMaterial(material);*/
-
- for (int i = 0; i < MAXCONTROL; i++) {
+ for (int i = 0; i < MAXCONTROL; i++)
+ {
if ( m_table[i] != nullptr )
m_table[i]->Draw();
}
diff --git a/src/ui/interface.h b/src/ui/interface.h
index 1496541..ebc80e7 100644
--- a/src/ui/interface.h
+++ b/src/ui/interface.h
@@ -19,11 +19,8 @@
#pragma once
-#include <string>
-
#include "common/event.h"
#include "common/misc.h"
-#include "common/iman.h"
#include "math/point.h"
@@ -49,6 +46,8 @@
#include "ui/map.h"
#include "ui/window.h"
+#include <string>
+
namespace Ui {
const int MAXCONTROL = 100;
@@ -92,7 +91,6 @@ class CInterface
int GetNextFreeControl();
template <typename T> inline T* CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
- CInstanceManager* m_iMan;
CEventQueue* m_event;
Gfx::CEngine* m_engine;
Gfx::CCamera* m_camera;
diff --git a/src/ui/key.cpp b/src/ui/key.cpp
index 9a76127..b181f70 100644
--- a/src/ui/key.cpp
+++ b/src/ui/key.cpp
@@ -15,6 +15,7 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
+
#include "ui/key.h"
#include "common/global.h"
diff --git a/src/ui/key.h b/src/ui/key.h
index 2332c9b..d8e935c 100644
--- a/src/ui/key.h
+++ b/src/ui/key.h
@@ -24,7 +24,6 @@
#include "ui/control.h"
-#include "common/iman.h"
#include "common/event.h"
#include "common/restext.h"
#include "common/key.h"
diff --git a/src/ui/label.cpp b/src/ui/label.cpp
index af65ab2..b5195b5 100644
--- a/src/ui/label.cpp
+++ b/src/ui/label.cpp
@@ -15,8 +15,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// label.cpp
-
#include "ui/label.h"
diff --git a/src/ui/list.cpp b/src/ui/list.cpp
index 4356ea4..84aa8ca 100644
--- a/src/ui/list.cpp
+++ b/src/ui/list.cpp
@@ -15,8 +15,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// list.cpp
-
#include "ui/list.h"
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index cf451e5..920d958 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -14,22 +14,24 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// maindialog.cpp
#include "ui/maindialog.h"
#include "app/app.h"
+
#include "common/global.h"
#include "common/event.h"
#include "common/logger.h"
#include "common/misc.h"
#include "common/profile.h"
-#include "common/iman.h"
#include "common/restext.h"
#include "common/logger.h"
+
#include "object/robotmain.h"
+
#include "script/cmdtoken.h"
#include "sound/sound.h"
+
#include "ui/interface.h"
#include "ui/button.h"
#include "ui/color.h"
@@ -54,8 +56,7 @@
//TODO Get rid of all sprintf's
-namespace Ui
-{
+namespace Ui {
const int KEY_VISIBLE = 6; // number of visible keys redefinable
@@ -106,20 +107,16 @@ namespace fs = boost::filesystem;
// Constructor of robot application.
-CMainDialog::CMainDialog(CInstanceManager* iMan)
+CMainDialog::CMainDialog()
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_DIALOG, this);
-
- m_app = CApplication::GetInstancePointer();
-
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
- m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
- m_eventQueue = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
+ m_app = CApplication::GetInstancePointer();
+ m_eventQueue = m_app->GetEventQueue();
+ m_sound = m_app->GetSound();
+ m_main = CRobotMain::GetInstancePointer();
+ m_interface = m_main->GetInterface();
+ m_camera = m_main->GetCamera();
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_particle = m_engine->GetParticle();
m_phase = PHASE_NAME;
m_phaseSetup = PHASE_SETUPg;
diff --git a/src/ui/maindialog.h b/src/ui/maindialog.h
index 51c6f2e..be61299 100644
--- a/src/ui/maindialog.h
+++ b/src/ui/maindialog.h
@@ -20,20 +20,18 @@
#include "graphics/core/color.h"
+
#include "object/robotmain.h"
-class CInstanceManager;
class CEventQueue;
class CSoundInterface;
-namespace Gfx
-{
+namespace Gfx {
class CEngine;
class CParticle;
-};
+}
-namespace Ui
-{
+namespace Ui {
class CInterface;
class CWindow;
@@ -64,7 +62,7 @@ struct GamerPerso
class CMainDialog
{
public:
- CMainDialog(CInstanceManager* iMan);
+ CMainDialog();
~CMainDialog();
bool EventProcess(const Event &event);
@@ -172,7 +170,6 @@ protected:
void ChangeKey(EventType event);
protected:
- CInstanceManager* m_iMan;
CApplication* m_app;
CRobotMain* m_main;
CEventQueue* m_eventQueue;
@@ -260,3 +257,4 @@ protected:
};
} // namespace Ui
+
diff --git a/src/ui/mainmap.cpp b/src/ui/mainmap.cpp
index b70bad9..1143a77 100644
--- a/src/ui/mainmap.cpp
+++ b/src/ui/mainmap.cpp
@@ -15,11 +15,11 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// mainmap.cpp
-
#include "ui/mainmap.h"
+#include "app/app.h"
+
namespace Ui {
@@ -32,12 +32,9 @@ const float ZOOM_MAX = 16.0f;
CMainMap::CMainMap()
{
- m_iMan = CInstanceManager::GetInstancePointer();
- m_iMan->AddInstance(CLASS_MAP, this);
-
- m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
- m_event = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
+ m_interface = CRobotMain::GetInstancePointer()->GetInterface();
+ m_event = CApplication::GetInstancePointer()->GetEventQueue();
+ m_engine = Gfx::CEngine::GetInstancePointer();
m_mapMode = 1;
m_bFixImage = false;
diff --git a/src/ui/mainmap.h b/src/ui/mainmap.h
index 35aae4c..9d0d72f 100644
--- a/src/ui/mainmap.h
+++ b/src/ui/mainmap.h
@@ -20,9 +20,13 @@
#pragma once
#include "common/event.h"
+
#include "graphics/core/color.h"
+
#include "math/point.h"
+
#include "object/object.h"
+
#include "ui/interface.h"
@@ -55,7 +59,6 @@ class CMainMap
void CenterMap();
protected:
- CInstanceManager* m_iMan;
CEventQueue* m_event;
Gfx::CEngine* m_engine;
CInterface* m_interface;
diff --git a/src/ui/mainshort.cpp b/src/ui/mainshort.cpp
index 55b9612..d33482c 100644
--- a/src/ui/mainshort.cpp
+++ b/src/ui/mainshort.cpp
@@ -15,24 +15,24 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// mainshort.cpp
-
#include "ui/mainshort.h"
+#include "app/app.h"
+
+#include "common/iman.h"
+
+
namespace Ui {
// Constructor of the application card.
CMainShort::CMainShort()
{
- m_iMan = CInstanceManager::GetInstancePointer();
- m_iMan->AddInstance(CLASS_SHORT, this);
-
- m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
- m_event = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
+ m_event = CApplication::GetInstancePointer()->GetEventQueue();
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_main = CRobotMain::GetInstancePointer();
+ m_interface = m_main->GetInterface();
FlushShortcuts();
}
@@ -137,9 +137,11 @@ bool CMainShort::CreateShortcuts()
m_shortcuts[rank] = 0;
rank ++;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == nullptr ) break;
if ( !pObj->GetActif() ) continue;
diff --git a/src/ui/mainshort.h b/src/ui/mainshort.h
index 0912e68..d679eb0 100644
--- a/src/ui/mainshort.h
+++ b/src/ui/mainshort.h
@@ -19,12 +19,16 @@
#pragma once
-#include "ui/interface.h"
#include "common/event.h"
+
#include "math/point.h"
+
#include "object/object.h"
+
#include "graphics/engine/engine.h"
+#include "ui/interface.h"
+
namespace Ui {
@@ -46,7 +50,6 @@ class CMainShort
protected:
protected:
- CInstanceManager* m_iMan;
CEventQueue* m_event;
Gfx::CEngine* m_engine;
CInterface* m_interface;
diff --git a/src/ui/map.cpp b/src/ui/map.cpp
index b852976..33d0fb1 100644
--- a/src/ui/map.cpp
+++ b/src/ui/map.cpp
@@ -15,8 +15,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// map.cpp
-
#include "ui/map.h"
@@ -31,9 +29,9 @@ namespace Ui {
CMap::CMap() : CControl()
{
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
- m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
- m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
+ m_main = CRobotMain::GetInstancePointer();
+ m_terrain = m_main->GetTerrain();
+ m_water = Gfx::CEngine::GetInstancePointer()->GetWater();
m_bEnable = true;
m_time = 0.0f;
diff --git a/src/ui/map.h b/src/ui/map.h
index 9e1767c..258dcdf 100644
--- a/src/ui/map.h
+++ b/src/ui/map.h
@@ -22,11 +22,7 @@
#include "ui/control.h"
-#include "object/object.h"
-#include "object/robotmain.h"
-
#include "common/event.h"
-#include "common/iman.h"
#include "graphics/engine/terrain.h"
#include "graphics/engine/water.h"
@@ -36,6 +32,9 @@
#include "math/geometry.h"
+#include "object/object.h"
+#include "object/robotmain.h"
+
namespace Ui {
diff --git a/src/ui/scroll.cpp b/src/ui/scroll.cpp
index 17f210e..ff7451d 100644
--- a/src/ui/scroll.cpp
+++ b/src/ui/scroll.cpp
@@ -15,14 +15,14 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// scroll.cpp
#include "ui/scroll.h"
#include "common/event.h"
#include "common/misc.h"
-#include "common/iman.h"
+
#include "graphics/engine/engine.h"
+
#include "ui/button.h"
diff --git a/src/ui/scroll.h b/src/ui/scroll.h
index 52b60bc..57d6f8f 100644
--- a/src/ui/scroll.h
+++ b/src/ui/scroll.h
@@ -20,9 +20,10 @@
#pragma once
-#include "ui/control.h"
#include "common/event.h"
+#include "ui/control.h"
+
namespace Ui {
class CButton;
diff --git a/src/ui/shortcut.cpp b/src/ui/shortcut.cpp
index 18b8f31..4462140 100644
--- a/src/ui/shortcut.cpp
+++ b/src/ui/shortcut.cpp
@@ -15,13 +15,12 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// shortcut.cpp
#include "ui/shortcut.h"
#include "common/event.h"
#include "common/misc.h"
-#include "common/iman.h"
+
#include "graphics/engine/engine.h"
#include "graphics/core/device.h"
@@ -31,7 +30,6 @@ namespace Ui {
// Object's constructor.
-//CShortcut::CShortcut(CInstanceManager* iMan) : CControl(iMan)
CShortcut::CShortcut() : CControl()
{
m_time = 0.0f;
diff --git a/src/ui/slider.cpp b/src/ui/slider.cpp
index ca907fe..f516e70 100644
--- a/src/ui/slider.cpp
+++ b/src/ui/slider.cpp
@@ -15,15 +15,15 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// slider.cpp
#include "ui/slider.h"
#include "common/event.h"
#include "common/misc.h"
-#include "common/iman.h"
+
#include "graphics/engine/engine.h"
#include "graphics/engine/text.h"
+
#include "ui/button.h"
#include <stdio.h>
diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp
index 7aa2d22..bf2ff33 100644
--- a/src/ui/studio.cpp
+++ b/src/ui/studio.cpp
@@ -15,23 +15,26 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// studio.cpp
-
-#include "studio.h"
+#include "ui/studio.h"
#include "CBot/CBotDll.h"
#include "app/app.h"
+
#include "common/event.h"
-#include "common/iman.h"
#include "common/misc.h"
+
#include "graphics/engine/camera.h"
#include "graphics/engine/engine.h"
+
#include "object/object.h"
+
#include "script/cbottoken.h"
#include "script/script.h"
+
#include "sound/sound.h"
+
#include "ui/check.h"
#include "ui/control.h"
#include "ui/color.h"
@@ -61,16 +64,13 @@ namespace Ui {
CStudio::CStudio()
{
- m_iMan = CInstanceManager::GetInstancePointer();
- m_iMan->AddInstance(CLASS_STUDIO, this);
-
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_event = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
- m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
- m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
- m_app = CApplication::GetInstancePointer();
+ m_app = CApplication::GetInstancePointer();
+ m_sound = m_app->GetSound();
+ m_event = m_app->GetEventQueue();
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_main = CRobotMain::GetInstancePointer();
+ m_interface = m_main->GetInterface();
+ m_camera = m_main->GetCamera();
m_bEditMaximized = false;
m_bEditMinimized = false;
@@ -87,7 +87,6 @@ CStudio::CStudio()
CStudio::~CStudio()
{
- m_iMan->DeleteInstance(CLASS_STUDIO, this);
}
diff --git a/src/ui/studio.h b/src/ui/studio.h
index 905baa6..7c2f652 100644
--- a/src/ui/studio.h
+++ b/src/ui/studio.h
@@ -26,7 +26,6 @@
#include <string>
class CEventQueue;
-class CInstanceManager;
class CRobotMain;
class CScript;
class CSoundInterface;
@@ -54,70 +53,69 @@ enum StudioDialog
class CStudio
{
- public:
- CStudio();
- ~CStudio();
-
- bool EventProcess(const Event &event);
-
- void StartEditScript(CScript *script, std::string name, int rank);
- bool StopEditScript(bool bCancel);
-
- protected:
- bool EventFrame(const Event &event);
- void SearchToken(CEdit* edit);
- void ColorizeScript(CEdit* edit);
- void AdjustEditScript();
- void SetInfoText(std::string text, bool bClickable);
- void ViewEditScript();
- void UpdateFlux();
- void UpdateButtons();
-
- void StartDialog(StudioDialog type);
- void StopDialog();
- void AdjustDialog();
- bool EventDialog(const Event &event);
- void UpdateChangeList();
- void UpdateChangeEdit();
- void UpdateDialogAction();
- void UpdateDialogPublic();
- void UpdateDialogList();
- void SearchDirectory(char* dir, bool bCreate);
- bool ReadProgram();
- bool WriteProgram();
-
- protected:
- CInstanceManager* m_iMan;
- Gfx::CEngine* m_engine;
- CEventQueue* m_event;
- CRobotMain* m_main;
- Gfx::CCamera* m_camera;
- CSoundInterface* m_sound;
- CInterface* m_interface;
- CApplication *m_app;
-
- int m_rank;
- CScript* m_script;
- Gfx::CameraType m_editCamera;
-
- bool m_bEditMaximized;
- bool m_bEditMinimized;
-
- Math::Point m_editActualPos;
- Math::Point m_editActualDim;
- Math::Point m_editFinalPos;
- Math::Point m_editFinalDim;
-
- float m_time;
- float m_fixInfoTextTime;
- bool m_bRunning;
- bool m_bRealTime;
- bool m_bInitPause;
- std::string m_helpFilename;
+public:
+ CStudio();
+ ~CStudio();
+
+ bool EventProcess(const Event &event);
+
+ void StartEditScript(CScript *script, std::string name, int rank);
+ bool StopEditScript(bool bCancel);
+
+protected:
+ bool EventFrame(const Event &event);
+ void SearchToken(CEdit* edit);
+ void ColorizeScript(CEdit* edit);
+ void AdjustEditScript();
+ void SetInfoText(std::string text, bool bClickable);
+ void ViewEditScript();
+ void UpdateFlux();
+ void UpdateButtons();
+
+ void StartDialog(StudioDialog type);
+ void StopDialog();
+ void AdjustDialog();
+ bool EventDialog(const Event &event);
+ void UpdateChangeList();
+ void UpdateChangeEdit();
+ void UpdateDialogAction();
+ void UpdateDialogPublic();
+ void UpdateDialogList();
+ void SearchDirectory(char* dir, bool bCreate);
+ bool ReadProgram();
+ bool WriteProgram();
+
+protected:
+ Gfx::CEngine* m_engine;
+ CEventQueue* m_event;
+ CRobotMain* m_main;
+ Gfx::CCamera* m_camera;
+ CSoundInterface* m_sound;
+ CInterface* m_interface;
+ CApplication* m_app;
+
+ int m_rank;
+ CScript* m_script;
+ Gfx::CameraType m_editCamera;
+
+ bool m_bEditMaximized;
+ bool m_bEditMinimized;
+
+ Math::Point m_editActualPos;
+ Math::Point m_editActualDim;
+ Math::Point m_editFinalPos;
+ Math::Point m_editFinalDim;
+
+ float m_time;
+ float m_fixInfoTextTime;
+ bool m_bRunning;
+ bool m_bRealTime;
+ bool m_bInitPause;
+ std::string m_helpFilename;
StudioDialog m_dialog;
};
-}
+} // namespace Ui
diff --git a/src/ui/target.cpp b/src/ui/target.cpp
index b47ba16..cc74750 100644
--- a/src/ui/target.cpp
+++ b/src/ui/target.cpp
@@ -14,11 +14,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// target.cpp
-
#include "ui/target.h"
+#include "common/iman.h"
namespace Ui {
@@ -189,9 +188,11 @@ CObject* CTarget::DetectFriendObject(Math::Point pos)
objRank = m_engine->DetectObject(pos);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->GetActif() ) continue;
diff --git a/src/ui/target.h b/src/ui/target.h
index 05a3651..054524b 100644
--- a/src/ui/target.h
+++ b/src/ui/target.h
@@ -18,20 +18,19 @@
#pragma once
-#include <string>
-
-#include "ui/control.h"
-
+#include "common/event.h"
#include "common/misc.h"
-#include "common/iman.h"
#include "common/restext.h"
-#include "common/event.h"
#include "graphics/engine/engine.h"
#include "object/robotmain.h"
#include "object/object.h"
+#include "ui/control.h"
+
+#include <string>
+
namespace Ui {
diff --git a/src/ui/window.cpp b/src/ui/window.cpp
index 97daf94..6013d37 100644
--- a/src/ui/window.cpp
+++ b/src/ui/window.cpp
@@ -15,8 +15,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// window.cpp
-
#include "ui/window.h"
@@ -25,7 +23,6 @@
namespace Ui {
// Object's constructor.
-//CWindow::CWindow(CInstanceManager* iMan) : CControl(iMan)
CWindow::CWindow() : CControl()
{
int i;
@@ -122,7 +119,6 @@ CButton* CWindow::CreateButton(Math::Point pos, Math::Point dim, int icon, Event
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CButton(m_iMan);
m_table[i] = new CButton();
pc = static_cast<CButton*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -145,7 +141,6 @@ CColor* CWindow::CreateColor(Math::Point pos, Math::Point dim, int icon, EventTy
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CColor(m_iMan);
m_table[i] = new CColor();
pc = static_cast<CColor*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -168,7 +163,6 @@ CCheck* CWindow::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventTy
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CCheck(m_iMan);
m_table[i] = new CCheck();
pc = static_cast<CCheck*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -191,7 +185,6 @@ CKey* CWindow::CreateKey(Math::Point pos, Math::Point dim, int icon, EventType e
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CKey(m_iMan);
m_table[i] = new CKey();
pc = static_cast<CKey*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -214,7 +207,6 @@ CGroup* CWindow::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventTy
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CGroup(m_iMan);
m_table[i] = new CGroup();
pc = static_cast<CGroup*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -237,7 +229,6 @@ CImage* CWindow::CreateImage(Math::Point pos, Math::Point dim, int icon, EventTy
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CImage(m_iMan);
m_table[i] = new CImage();
pc = static_cast<CImage*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -260,7 +251,6 @@ CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventTy
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CLabel(m_iMan);
m_table[i] = new CLabel();
pc = static_cast<CLabel*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -289,7 +279,6 @@ CEdit* CWindow::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CEdit(m_iMan);
m_table[i] = new CEdit();
pc = static_cast<CEdit*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -312,7 +301,6 @@ CEditValue* CWindow::CreateEditValue(Math::Point pos, Math::Point dim, int icon,
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CEditValue(m_iMan);
m_table[i] = new CEditValue();
pc = static_cast<CEditValue*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -335,7 +323,6 @@ CScroll* CWindow::CreateScroll(Math::Point pos, Math::Point dim, int icon, Event
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CScroll(m_iMan);
m_table[i] = new CScroll();
pc = static_cast<CScroll*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -358,7 +345,6 @@ CSlider* CWindow::CreateSlider(Math::Point pos, Math::Point dim, int icon, Event
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CSlider(m_iMan);
m_table[i] = new CSlider();
pc = static_cast<CSlider*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -382,7 +368,6 @@ CList* CWindow::CreateList(Math::Point pos, Math::Point dim, int icon, EventType
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CList(m_iMan);
m_table[i] = new CList();
pc = static_cast<CList*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg, expand);
diff --git a/src/ui/window.h b/src/ui/window.h
index 8d7090c..e39b8a9 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -19,12 +19,12 @@
#pragma once
-#include <string>
-
#include "common/event.h"
#include "common/misc.h"
#include "common/restext.h"
+#include "graphics/engine/text.h"
+
#include "ui/button.h"
#include "ui/color.h"
#include "ui/check.h"
@@ -44,7 +44,7 @@
#include "ui/target.h"
#include "ui/control.h"
-#include "graphics/engine/text.h"
+#include <string>
namespace Ui {
diff --git a/test/cbot/CBot_console/CBotConsole.h b/test/cbot/CBot_console/CBotConsole.h
index a155399..ac87911 100644
--- a/test/cbot/CBot_console/CBotConsole.h
+++ b/test/cbot/CBot_console/CBotConsole.h
@@ -5,8 +5,8 @@
* Author: michal
*/
-#ifndef CBOTCONSOLE_H_
-#define CBOTCONSOLE_H_
+#pragma once
+
#include "CClass.h"
struct ThreadInfo
@@ -41,4 +41,3 @@ public:
long EndProg() ;
};
-#endif /* CBOTCONSOLE_H_ */
diff --git a/test/cbot/CBot_console/CBotDoc.h b/test/cbot/CBot_console/CBotDoc.h
index c0a3e1d..82af7b0 100644
--- a/test/cbot/CBot_console/CBotDoc.h
+++ b/test/cbot/CBot_console/CBotDoc.h
@@ -6,8 +6,6 @@
*/
#pragma once
-#ifndef CBOTDOC_H_
-#define CBOTDOC_H_
#include "CClass.h"
#include <string>
@@ -35,5 +33,3 @@ public:
};
-
-#endif /* CBOTDOC_H_ */
diff --git a/test/envs/opengl/CMakeLists.txt b/test/envs/opengl/CMakeLists.txt
index 588a864..3de5466 100644
--- a/test/envs/opengl/CMakeLists.txt
+++ b/test/envs/opengl/CMakeLists.txt
@@ -15,7 +15,6 @@ ${SRC_DIR}/graphics/opengl/gldevice.cpp
${SRC_DIR}/graphics/engine/modelfile.cpp
${SRC_DIR}/common/logger.cpp
${SRC_DIR}/common/image.cpp
-${SRC_DIR}/common/iman.cpp
${SRC_DIR}/common/stringutils.cpp
${SRC_DIR}/app/system.cpp
model_test.cpp
@@ -25,7 +24,6 @@ set(TRANSFORM_SOURCES
${SRC_DIR}/graphics/opengl/gldevice.cpp
${SRC_DIR}/common/logger.cpp
${SRC_DIR}/common/image.cpp
-${SRC_DIR}/common/iman.cpp
${SRC_DIR}/app/system.cpp
transform_test.cpp
)
@@ -34,20 +32,27 @@ set(LIGHT_SOURCES
${SRC_DIR}/graphics/opengl/gldevice.cpp
${SRC_DIR}/common/logger.cpp
${SRC_DIR}/common/image.cpp
-${SRC_DIR}/common/iman.cpp
${SRC_DIR}/app/system.cpp
light_test.cpp
)
include_directories(${SRC_DIR} ${CMAKE_CURRENT_BINARY_DIR})
+include_directories(
+SYSTEM
+${SDL_INCLUDE_DIR}
+${SDLIMAGE_INCLUDE_DIR}
+${SDLTTF_INCLUDE_DIR}
+${PNG_INCLUDE_DIRS}
+${GLEW_INCLUDE_PATH}
+)
+
set(LIBS
${SDL_LIBRARY}
${SDLIMAGE_LIBRARY}
${OPENGL_LIBRARY}
${GLEW_LIBRARY}
${PNG_LIBRARIES}
-${ADD_LIBS}
)
add_executable(texture_test ${TEXTURE_SOURCES})
diff --git a/test/envs/opengl/light_test.cpp b/test/envs/opengl/light_test.cpp
index b19ba4b..b1e0151 100644
--- a/test/envs/opengl/light_test.cpp
+++ b/test/envs/opengl/light_test.cpp
@@ -1,8 +1,10 @@
#include "app/system.h"
+
#include "common/logger.h"
#include "common/image.h"
-#include "common/iman.h"
+
#include "graphics/opengl/gldevice.h"
+
#include "math/geometry.h"
#include <SDL/SDL.h>
@@ -365,8 +367,6 @@ int main(int argc, char *argv[])
GetCurrentTimeStamp(PREV_TIME);
GetCurrentTimeStamp(CURR_TIME);
- CInstanceManager iMan;
-
// Without any error checking, for simplicity
SDL_Init(SDL_INIT_VIDEO);
diff --git a/test/envs/opengl/model_test.cpp b/test/envs/opengl/model_test.cpp
index a06a178..882b785 100644
--- a/test/envs/opengl/model_test.cpp
+++ b/test/envs/opengl/model_test.cpp
@@ -1,8 +1,11 @@
#include "app/system.h"
+
#include "common/logger.h"
#include "common/image.h"
+
#include "graphics/engine/modelfile.h"
#include "graphics/opengl/gldevice.h"
+
#include "math/geometry.h"
#include <SDL/SDL.h>
diff --git a/test/envs/opengl/texture_test.cpp b/test/envs/opengl/texture_test.cpp
index de9caf3..b1f352c 100644
--- a/test/envs/opengl/texture_test.cpp
+++ b/test/envs/opengl/texture_test.cpp
@@ -1,6 +1,8 @@
#include "common/logger.h"
#include "common/image.h"
+
#include "graphics/opengl/gldevice.h"
+
#include "math/geometry.h"
#include <SDL/SDL.h>
diff --git a/test/envs/opengl/transform_test.cpp b/test/envs/opengl/transform_test.cpp
index cddd1b8..04c73f7 100644
--- a/test/envs/opengl/transform_test.cpp
+++ b/test/envs/opengl/transform_test.cpp
@@ -1,8 +1,11 @@
#include "app/system.h"
+
#include "common/logger.h"
#include "common/image.h"
#include "common/iman.h"
+
#include "graphics/opengl/gldevice.h"
+
#include "math/geometry.h"
#include <SDL/SDL.h>
@@ -242,8 +245,6 @@ int main(int argc, char *argv[])
GetCurrentTimeStamp(PREV_TIME);
GetCurrentTimeStamp(CURR_TIME);
- CInstanceManager iMan;
-
// Without any error checking, for simplicity
SDL_Init(SDL_INIT_VIDEO);
diff --git a/test/unit/math/geometry_test.cpp b/test/unit/math/geometry_test.cpp
index f50df4e..7c3e26a 100644
--- a/test/unit/math/geometry_test.cpp
+++ b/test/unit/math/geometry_test.cpp
@@ -14,8 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// math/test/geometry_test.cpp
-
/* Unit tests for functions in geometry.h */
#include "math/func.h"
diff --git a/test/unit/math/matrix_test.cpp b/test/unit/math/matrix_test.cpp
index 6ae2c6b..5f5c3af 100644
--- a/test/unit/math/matrix_test.cpp
+++ b/test/unit/math/matrix_test.cpp
@@ -14,8 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// math/test/matrix_test.cpp
-
/*
Unit tests for Matrix struct
diff --git a/test/unit/math/vector_test.cpp b/test/unit/math/vector_test.cpp
index 199f4c3..41bac74 100644
--- a/test/unit/math/vector_test.cpp
+++ b/test/unit/math/vector_test.cpp
@@ -14,8 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// math/test/vector_test.cpp
-
/*
Unit tests for Vector struct
diff --git a/test/unit/ui/edit_test.cpp b/test/unit/ui/edit_test.cpp
index f878f4b..2f31a89 100644
--- a/test/unit/ui/edit_test.cpp
+++ b/test/unit/ui/edit_test.cpp
@@ -13,19 +13,17 @@ public:
virtual void SetUp()
{
- m_engine = new Gfx::CEngine(&m_iMan, NULL);
+ m_engine = new Gfx::CEngine(nullptr);
- m_iMan.AddInstance(CLASS_ENGINE, m_engine);
m_edit = new Ui::CEdit;
}
virtual void TearDown()
{
- m_iMan.DeleteInstance(CLASS_ENGINE, m_engine);
delete m_engine;
- m_engine = NULL;
+ m_engine = nullptr;
delete m_edit;
- m_edit = NULL;
+ m_edit = nullptr;
}
virtual ~CEditTest()
@@ -34,7 +32,6 @@ public:
};
protected:
- CInstanceManager m_iMan;
CApplication m_app;
Gfx::CEngine * m_engine;
Ui::CEdit * m_edit;
diff --git a/test/unit/ui/mocks/text_mock.h b/test/unit/ui/mocks/text_mock.h
index f0ad339..9289481 100644
--- a/test/unit/ui/mocks/text_mock.h
+++ b/test/unit/ui/mocks/text_mock.h
@@ -1,4 +1,5 @@
#include "common/logger.h"
+
#include "graphics/engine/text.h"
#include <gmock/gmock.h>
@@ -6,7 +7,7 @@
class CTextMock : public Gfx::CText
{
public:
- CTextMock(CInstanceManager *iMan, Gfx::CEngine* engine) : CText(iMan, engine)
+ CTextMock(Gfx::CEngine* engine) : CText(engine)
{
}
diff --git a/test/unit/ui/stubs/app_stub.cpp b/test/unit/ui/stubs/app_stub.cpp
index 70d9e82..094806f 100644
--- a/test/unit/ui/stubs/app_stub.cpp
+++ b/test/unit/ui/stubs/app_stub.cpp
@@ -1,7 +1,8 @@
#include "app/app.h"
+
#include "graphics/opengl/gldevice.h"
-template<> CApplication* CSingleton<CApplication>::mInstance = nullptr;
+template<> CApplication* CSingleton<CApplication>::m_instance = nullptr;
namespace Gfx {
@@ -10,6 +11,8 @@ GLDeviceConfig::GLDeviceConfig()
}
} /* Gfx */
+
+
CApplication::CApplication()
{
}
@@ -23,4 +26,13 @@ std::string CApplication::GetDataFilePath(DataDir /* dataDir */, const std::stri
return subpath;
}
+CSoundInterface* CApplication::GetSound()
+{
+ return nullptr;
+}
+
+CEventQueue* CApplication::GetEventQueue()
+{
+ return nullptr;
+}
diff --git a/test/unit/ui/stubs/engine_stub.cpp b/test/unit/ui/stubs/engine_stub.cpp
index de7bbe7..40886da 100644
--- a/test/unit/ui/stubs/engine_stub.cpp
+++ b/test/unit/ui/stubs/engine_stub.cpp
@@ -1,20 +1,28 @@
#include "graphics/engine/engine.h"
#include "graphics/engine/text.h"
+
#include "mocks/text_mock.h"
+template<> Gfx::CEngine* CSingleton<Gfx::CEngine>::m_instance = nullptr;
+
namespace Gfx {
-CEngine::CEngine(CInstanceManager* iMan, CApplication* app) :
- m_iMan(iMan), m_app(app)
+CEngine::CEngine(CApplication* app) :
+ m_app(app)
{
- m_text = new CTextMock(m_iMan, this);
+ m_text = new CTextMock(this);
m_text->Create();
}
CEngine::~CEngine()
{
delete m_text;
- m_text = NULL;
+ m_text = nullptr;
+}
+
+CParticle* CEngine::GetParticle()
+{
+ return nullptr;
}
Math::Point CEngine::WindowToInterfaceSize(Math::IntPoint size)
diff --git a/test/unit/ui/stubs/particle_stub.cpp b/test/unit/ui/stubs/particle_stub.cpp
index c3bf6dc..34cf973 100644
--- a/test/unit/ui/stubs/particle_stub.cpp
+++ b/test/unit/ui/stubs/particle_stub.cpp
@@ -7,7 +7,7 @@
namespace Gfx {
-CParticle::CParticle(CInstanceManager* /*iMan*/, CEngine* /*engine*/)
+CParticle::CParticle(CEngine* /*engine*/)
{
}
diff --git a/test/unit/ui/stubs/robotmain_stub.cpp b/test/unit/ui/stubs/robotmain_stub.cpp
index a36b1a1..c332d5a 100644
--- a/test/unit/ui/stubs/robotmain_stub.cpp
+++ b/test/unit/ui/stubs/robotmain_stub.cpp
@@ -1,7 +1,7 @@
#include "object/robotmain.h"
-template<> CRobotMain* CSingleton<CRobotMain>::mInstance = nullptr;
+template<> CRobotMain* CSingleton<CRobotMain>::m_instance = nullptr;
bool CRobotMain::GetGlint()
{