diff options
Diffstat (limited to 'src/object')
120 files changed, 697 insertions, 566 deletions
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); |