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
dev-ui
Piotr Dziwiński 2013-02-16 22:37:43 +01:00
parent 45040318b0
commit 001d37b257
230 changed files with 1533 additions and 1500 deletions

View File

@ -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()

View File

@ -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_

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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();
}

View File

@ -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;

View File

@ -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++)

View File

@ -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);

View File

@ -20,7 +20,7 @@
#include <stdio.h>
template<> CLogger* CSingleton<CLogger>::mInstance = nullptr;
template<> CLogger* CSingleton<CLogger>::m_instance = nullptr;
CLogger::CLogger()

View File

@ -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;

View File

@ -26,34 +26,51 @@
template<typename T> class CSingleton
{
protected:
static T* mInstance;
protected:
static T* m_instance;
public:
static T& GetInstance() {
assert(mInstance != nullptr);
return *mInstance;
public:
static T& GetInstance()
{
assert(m_instance != nullptr);
return *m_instance;
}
static T* GetInstancePointer() {
assert(mInstance != nullptr);
return mInstance;
static T* GetInstancePointer()
{
assert(m_instance != nullptr);
return m_instance;
}
static bool IsCreated() {
return mInstance != nullptr;
static bool IsCreated()
{
return m_instance != nullptr;
}
CSingleton() {
assert(mInstance == nullptr);
mInstance = static_cast<T *>(this);
CSingleton()
{
assert(m_instance == nullptr);
m_instance = static_cast<T *>(this);
}
virtual ~CSingleton() {
mInstance = nullptr;
virtual ~CSingleton()
{
m_instance = nullptr;
}
private:
#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> &);
};

View File

@ -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;

View File

@ -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;

View File

@ -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;
}
@ -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;

View File

@ -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,7 +110,6 @@ protected:
void CreateLine(int x, int y, int len);
protected:
CInstanceManager* m_iMan;
CEngine* m_engine;
CTerrain* m_terrain;

View File

@ -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,10 +164,16 @@ CEngine::CEngine(CInstanceManager *iMan, CApplication *app)
CEngine::~CEngine()
{
m_iMan = nullptr;
m_app = nullptr;
m_device = 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);
@ -191,27 +192,63 @@ CDevice* CEngine::GetDevice()
return m_device;
}
void CEngine::SetTerrain(CTerrain* terrain)
{
m_terrain = terrain;
}
CText* CEngine::GetText()
{
return m_text;
}
CLightManager* CEngine::GetLightManager()
{
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;

View File

@ -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,10 +671,10 @@ 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
@ -682,11 +682,25 @@ public:
//! Returns the current device
CDevice* GetDevice();
//! Sets the terrain object
void SetTerrain(CTerrain* terrain);
//! 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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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?

View File

@ -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;

View File

@ -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"

View File

@ -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 {

View File

@ -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);
}

View File

@ -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;

View File

@ -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()

View File

@ -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;

View File

@ -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);
CInstanceManager::GetInstancePointer()->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;
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();

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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();

View File

@ -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];

View File

@ -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;
}

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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();
}

View File

@ -27,7 +27,7 @@
class CAutoFlag : public CAuto
{
public:
CAutoFlag(CInstanceManager* iMan, CObject* object);
CAutoFlag(CObject* object);
~CAutoFlag();
void DeleteObject(bool bAll=false);

View File

@ -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;

View File

@ -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);

View File

@ -30,8 +30,7 @@
// Object's constructor.
CAutoInfo::CAutoInfo(CInstanceManager* iMan, CObject* object)
: CAuto(iMan, object)
CAutoInfo::CAutoInfo(CObject* object) : CAuto(object)
{
Init();
}

View File

@ -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);

View File

@ -23,8 +23,7 @@
// Object's constructor.
CAutoJostle::CAutoJostle(CInstanceManager* iMan, CObject* object)
: CAuto(iMan, object)
CAutoJostle::CAutoJostle(CObject* object) : CAuto(object)
{
Init();
}

View File

@ -27,7 +27,7 @@
class CAutoJostle : public CAuto
{
public:
CAutoJostle(CInstanceManager* iMan, CObject* object);
CAutoJostle(CObject* object);
~CAutoJostle();
void DeleteObject(bool bAll=false);

View File

@ -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();

View File

@ -27,7 +27,7 @@
class CAutoKid : public CAuto
{
public:
CAutoKid(CInstanceManager* iMan, CObject* object);
CAutoKid(CObject* object);
~CAutoKid();
void DeleteObject(bool bAll=false);

View File

@ -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();
}

View File

@ -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);

View File

@ -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();
}

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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();

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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 ()

View File

@ -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);

View File

@ -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();
}

View File

@ -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);

View File

@ -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();
}

View File

@ -27,7 +27,7 @@
class CAutoRoot : public CAuto
{
public:
CAutoRoot(CInstanceManager* iMan, CObject* object);
CAutoRoot(CObject* object);
~CAutoRoot();
void DeleteObject(bool bAll=false);

View File

@ -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;

View File

@ -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);

View File

@ -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();
}

View File

@ -27,7 +27,7 @@
class CAutoStation : public CAuto
{
public:
CAutoStation(CInstanceManager* iMan, CObject* object);
CAutoStation(CObject* object);
~CAutoStation();
void DeleteObject(bool bAll=false);

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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();
}

View File

@ -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;

View File

@ -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.

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;

Some files were not shown because too many files have changed in this diff Show More