Moved all CObject management from CInstanceManager to CObjectManager
parent
e8a0dc8ddb
commit
4fef3af9ef
|
@ -36,6 +36,7 @@
|
||||||
#include "graphics/opengl/gldevice.h"
|
#include "graphics/opengl/gldevice.h"
|
||||||
|
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
|
#include "object/objman.h"
|
||||||
|
|
||||||
#ifdef OPENAL_SOUND
|
#ifdef OPENAL_SOUND
|
||||||
#include "sound/oalsound/alsound.h"
|
#include "sound/oalsound/alsound.h"
|
||||||
|
|
|
@ -33,8 +33,6 @@
|
||||||
#include "graphics/engine/engine.h"
|
#include "graphics/engine/engine.h"
|
||||||
#include "graphics/opengl/gldevice.h"
|
#include "graphics/opengl/gldevice.h"
|
||||||
|
|
||||||
#include "object/objman.h"
|
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -45,6 +43,7 @@ class CEventQueue;
|
||||||
class CRobotMain;
|
class CRobotMain;
|
||||||
class CSoundInterface;
|
class CSoundInterface;
|
||||||
class CInput;
|
class CInput;
|
||||||
|
class CObjectManager;
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
class CModelManager;
|
class CModelManager;
|
||||||
|
|
|
@ -39,17 +39,15 @@
|
||||||
*/
|
*/
|
||||||
enum ManagedClassType
|
enum ManagedClassType
|
||||||
{
|
{
|
||||||
//! CObject
|
|
||||||
CLASS_OBJECT = 0,
|
|
||||||
//! CPhysics
|
//! CPhysics
|
||||||
CLASS_PHYSICS = 1,
|
CLASS_PHYSICS = 0,
|
||||||
//! CBrain
|
//! CBrain
|
||||||
CLASS_BRAIN = 2,
|
CLASS_BRAIN = 1,
|
||||||
//! Gfx::CPyro
|
//! Gfx::CPyro
|
||||||
CLASS_PYRO = 3,
|
CLASS_PYRO = 2,
|
||||||
|
|
||||||
//! Maximum (number of managed classes)
|
//! Maximum (number of managed classes)
|
||||||
CLASS_MAX = 4
|
CLASS_MAX = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
#include "app/input.h"
|
#include "app/input.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "graphics/engine/engine.h"
|
#include "graphics/engine/engine.h"
|
||||||
#include "graphics/engine/terrain.h"
|
#include "graphics/engine/terrain.h"
|
||||||
#include "graphics/engine/water.h"
|
#include "graphics/engine/water.h"
|
||||||
|
@ -33,6 +31,7 @@
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
#include "object/object.h"
|
#include "object/object.h"
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
|
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
@ -242,15 +241,11 @@ void CCamera::SetType(CameraType type)
|
||||||
m_remotePan = 0.0f;
|
m_remotePan = 0.0f;
|
||||||
m_remoteZoom = 0.0f;
|
m_remoteZoom = 0.0f;
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
if ( (m_type == CAM_TYPE_BACK) && m_transparency )
|
if ( (m_type == CAM_TYPE_BACK) && m_transparency )
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 1000000; i++)
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>( iMan->SearchInstance(CLASS_OBJECT, i) );
|
CObject* obj = it.second;
|
||||||
if (obj == NULL)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (obj->GetTruck())
|
if (obj->GetTruck())
|
||||||
continue; // battery or cargo?
|
continue; // battery or cargo?
|
||||||
|
@ -894,13 +889,10 @@ bool CCamera::IsCollisionBack(Math::Vector &eye, Math::Vector lookat)
|
||||||
max.z = Math::Max(m_actualEye.z, m_actualLookat.z);
|
max.z = Math::Max(m_actualEye.z, m_actualLookat.z);
|
||||||
|
|
||||||
m_transparency = false;
|
m_transparency = false;
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for (int i = 0 ;i < 1000000; i++)
|
|
||||||
{
|
{
|
||||||
CObject *obj = static_cast<CObject*>( iMan->SearchInstance(CLASS_OBJECT, i) );
|
CObject* obj = it.second;
|
||||||
if (obj == NULL) break;
|
|
||||||
|
|
||||||
if (obj->GetTruck()) continue; // battery or cargo?
|
if (obj->GetTruck()) continue; // battery or cargo?
|
||||||
|
|
||||||
|
@ -974,12 +966,9 @@ bool CCamera::IsCollisionBack(Math::Vector &eye, Math::Vector lookat)
|
||||||
|
|
||||||
bool CCamera::IsCollisionFix(Math::Vector &eye, Math::Vector lookat)
|
bool CCamera::IsCollisionFix(Math::Vector &eye, Math::Vector lookat)
|
||||||
{
|
{
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for (int i = 0; i < 1000000; i++)
|
|
||||||
{
|
{
|
||||||
CObject *obj = static_cast<CObject*>( iMan->SearchInstance(CLASS_OBJECT, i) );
|
CObject* obj = it.second;
|
||||||
if (obj == NULL) break;
|
|
||||||
|
|
||||||
if (obj == m_cameraObj) continue;
|
if (obj == m_cameraObj) continue;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
|
||||||
#include "common/logger.h"
|
#include "common/logger.h"
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "graphics/core/device.h"
|
#include "graphics/core/device.h"
|
||||||
#include "graphics/engine/camera.h"
|
#include "graphics/engine/camera.h"
|
||||||
|
@ -33,6 +32,7 @@
|
||||||
|
|
||||||
#include "object/object.h"
|
#include "object/object.h"
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
|
#include "object/objman.h"
|
||||||
|
|
||||||
#include "object/auto/autopara.h"
|
#include "object/auto/autopara.h"
|
||||||
|
|
||||||
|
@ -314,15 +314,12 @@ CObject* CLightning::SearchObject(Math::Vector pos)
|
||||||
std::vector<Math::Vector> paraObjPos;
|
std::vector<Math::Vector> paraObjPos;
|
||||||
paraObjPos.reserve(100);
|
paraObjPos.reserve(100);
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
// Seeking the object closest to the point of impact of lightning.
|
// Seeking the object closest to the point of impact of lightning.
|
||||||
CObject* bestObj = 0;
|
CObject* bestObj = 0;
|
||||||
float min = 100000.0f;
|
float min = 100000.0f;
|
||||||
for (int i = 0; i < 1000000; i++)
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>( iMan->SearchInstance(CLASS_OBJECT, i) );
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
if (!obj->GetActif()) continue; // inactive object?
|
if (!obj->GetActif()) continue; // inactive object?
|
||||||
if (obj->GetTruck() != nullptr) continue; // object transported?
|
if (obj->GetTruck() != nullptr) continue; // object transported?
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
#include "object/object.h"
|
#include "object/object.h"
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -3655,14 +3656,11 @@ CObject* CParticle::SearchObjectGun(Math::Vector old, Math::Vector pos,
|
||||||
box2.y += min;
|
box2.y += min;
|
||||||
box2.z += min;
|
box2.z += min;
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
CObject* best = 0;
|
CObject* best = 0;
|
||||||
bool shield = false;
|
bool shield = false;
|
||||||
for (int i = 0; i < 1000000; i++)
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == 0) break;
|
|
||||||
|
|
||||||
if (!obj->GetActif()) continue; // inactive?
|
if (!obj->GetActif()) continue; // inactive?
|
||||||
if (obj == father) continue;
|
if (obj == father) continue;
|
||||||
|
@ -3784,13 +3782,10 @@ CObject* CParticle::SearchObjectRay(Math::Vector pos, Math::Vector goal,
|
||||||
box2.x += min;
|
box2.x += min;
|
||||||
box2.y += min;
|
box2.y += min;
|
||||||
box2.z += min;
|
box2.z += min;
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for (int i = 0; i < 1000000; i++)
|
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>( iMan->SearchInstance(CLASS_OBJECT, i) );
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
if (!obj->GetActif()) continue; // inactive?
|
if (!obj->GetActif()) continue; // inactive?
|
||||||
if (obj == father) continue;
|
if (obj == father) continue;
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
#include "object/motion/motionhuman.h"
|
#include "object/motion/motionhuman.h"
|
||||||
|
|
||||||
|
@ -2202,13 +2203,10 @@ CObject* CPyro::FallSearchBeeExplo()
|
||||||
Math::Vector iPos;
|
Math::Vector iPos;
|
||||||
float iRadius;
|
float iRadius;
|
||||||
m_object->GetCrashSphere(0, iPos, iRadius);
|
m_object->GetCrashSphere(0, iPos, iRadius);
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for (int i = 0; i < 1000000; i++)
|
|
||||||
{
|
{
|
||||||
CObject* pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
ObjectType oType = pObj->GetType();
|
ObjectType oType = pObj->GetType();
|
||||||
if ( oType != OBJECT_HUMAN &&
|
if ( oType != OBJECT_HUMAN &&
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
|
||||||
#include "common/event.h"
|
#include "common/event.h"
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "object/level/parserline.h"
|
#include "object/level/parserline.h"
|
||||||
#include "object/level/parserparam.h"
|
#include "object/level/parserparam.h"
|
||||||
|
@ -43,8 +42,6 @@
|
||||||
|
|
||||||
CAuto::CAuto(CObject* object)
|
CAuto::CAuto(CObject* object)
|
||||||
{
|
{
|
||||||
m_iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
m_object = object;
|
m_object = object;
|
||||||
m_engine = Gfx::CEngine::GetInstancePointer();
|
m_engine = Gfx::CEngine::GetInstancePointer();
|
||||||
m_main = CRobotMain::GetInstancePointer();
|
m_main = CRobotMain::GetInstancePointer();
|
||||||
|
@ -73,8 +70,6 @@ CAuto::CAuto(CObject* object)
|
||||||
|
|
||||||
CAuto::~CAuto()
|
CAuto::~CAuto()
|
||||||
{
|
{
|
||||||
m_iMan = nullptr;
|
|
||||||
|
|
||||||
m_object = nullptr;
|
m_object = nullptr;
|
||||||
m_engine = nullptr;
|
m_engine = nullptr;
|
||||||
m_main = nullptr;
|
m_main = nullptr;
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include "object/object.h"
|
#include "object/object.h"
|
||||||
|
|
||||||
|
|
||||||
class CInstanceManager;
|
|
||||||
class CRobotMain;
|
class CRobotMain;
|
||||||
class CSoundInterface;
|
class CSoundInterface;
|
||||||
class CLevelParserLine;
|
class CLevelParserLine;
|
||||||
|
@ -93,7 +92,6 @@ protected:
|
||||||
void UpdateInterface(float rTime);
|
void UpdateInterface(float rTime);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CInstanceManager* m_iMan; // TODO: to be removed
|
|
||||||
CEventQueue* m_eventQueue;
|
CEventQueue* m_eventQueue;
|
||||||
Gfx::CEngine* m_engine;
|
Gfx::CEngine* m_engine;
|
||||||
Gfx::CParticle* m_particle;
|
Gfx::CParticle* m_particle;
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
|
|
||||||
#include "object/auto/autobase.h"
|
#include "object/auto/autobase.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "graphics/engine/terrain.h"
|
#include "graphics/engine/terrain.h"
|
||||||
#include "graphics/engine/cloud.h"
|
#include "graphics/engine/cloud.h"
|
||||||
#include "graphics/engine/planet.h"
|
#include "graphics/engine/planet.h"
|
||||||
|
@ -31,6 +29,7 @@
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
|
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
@ -1244,12 +1243,10 @@ void CAutoBase::FreezeCargo(bool bFreeze)
|
||||||
CPhysics* physics;
|
CPhysics* physics;
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
float dist;
|
float dist;
|
||||||
int i;
|
|
||||||
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
pObj->SetCargo(false);
|
pObj->SetCargo(false);
|
||||||
|
|
||||||
|
@ -1280,14 +1277,12 @@ void CAutoBase::MoveCargo()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
CObject* pObj;
|
||||||
Math::Vector oPos, sPos;
|
Math::Vector oPos, sPos;
|
||||||
int i;
|
|
||||||
|
|
||||||
sPos = m_object->GetPosition(0);
|
sPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast < CObject* > (m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( !pObj->GetCargo() ) continue;
|
if ( !pObj->GetCargo() ) continue;
|
||||||
|
|
||||||
|
@ -1311,12 +1306,11 @@ Error CAutoBase::CheckCloseDoor()
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float oRad, dist;
|
float oRad, dist;
|
||||||
int i, j;
|
int j;
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* > (m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( pObj == m_object ) continue; // yourself?
|
if ( pObj == m_object ) continue; // yourself?
|
||||||
if ( !pObj->GetActif() ) continue; // inactive?
|
if ( !pObj->GetActif() ) continue; // inactive?
|
||||||
|
|
|
@ -20,10 +20,9 @@
|
||||||
|
|
||||||
#include "object/auto/autoconvert.h"
|
#include "object/auto/autoconvert.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/level/parserline.h"
|
#include "object/level/parserline.h"
|
||||||
#include "object/level/parserparam.h"
|
#include "object/level/parserparam.h"
|
||||||
|
|
||||||
|
@ -399,30 +398,7 @@ bool CAutoConvert::Read(CLevelParserLine* line)
|
||||||
|
|
||||||
CObject* CAutoConvert::SearchStone(ObjectType type)
|
CObject* CAutoConvert::SearchStone(ObjectType type)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
return CObjectManager::GetInstancePointer()->FindNearest(m_object, type, 5.0f/g_unit);
|
||||||
Math::Vector cPos, oPos;
|
|
||||||
ObjectType oType;
|
|
||||||
float dist;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
oType = pObj->GetType();
|
|
||||||
if ( oType != type ) continue;
|
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
|
||||||
dist = Math::Distance(oPos, cPos);
|
|
||||||
|
|
||||||
if ( dist <= 5.0f ) return pObj;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search if a vehicle is too close.
|
// Search if a vehicle is too close.
|
||||||
|
@ -433,14 +409,12 @@ bool CAutoConvert::SearchVehicle()
|
||||||
Math::Vector cPos, oPos;
|
Math::Vector cPos, oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float oRadius, dist;
|
float oRadius, dist;
|
||||||
int i;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
cPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type != OBJECT_HUMAN &&
|
if ( type != OBJECT_HUMAN &&
|
||||||
|
|
|
@ -20,12 +20,11 @@
|
||||||
|
|
||||||
#include "object/auto/autoderrick.h"
|
#include "object/auto/autoderrick.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "graphics/engine/terrain.h"
|
#include "graphics/engine/terrain.h"
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/level/parserline.h"
|
#include "object/level/parserline.h"
|
||||||
#include "object/level/parserparam.h"
|
#include "object/level/parserparam.h"
|
||||||
|
|
||||||
|
@ -468,12 +467,10 @@ CObject* CAutoDerrick::SearchFret()
|
||||||
CObject* pObj;
|
CObject* pObj;
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
int i;
|
|
||||||
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type == OBJECT_DERRICK ) continue;
|
if ( type == OBJECT_DERRICK ) continue;
|
||||||
|
@ -495,12 +492,11 @@ bool CAutoDerrick::SearchFree(Math::Vector pos)
|
||||||
Math::Vector sPos;
|
Math::Vector sPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float sRadius, distance;
|
float sRadius, distance;
|
||||||
int i, j;
|
int j;
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type == OBJECT_DERRICK ) continue;
|
if ( type == OBJECT_DERRICK ) continue;
|
||||||
|
@ -547,25 +543,12 @@ void CAutoDerrick::CreateFret(Math::Vector pos, float angle, ObjectType type,
|
||||||
|
|
||||||
bool CAutoDerrick::ExistKey()
|
bool CAutoDerrick::ExistKey()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
|
||||||
ObjectType type;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if ( m_type != OBJECT_KEYa &&
|
if ( m_type != OBJECT_KEYa &&
|
||||||
m_type != OBJECT_KEYb &&
|
m_type != OBJECT_KEYb &&
|
||||||
m_type != OBJECT_KEYc &&
|
m_type != OBJECT_KEYc &&
|
||||||
m_type != OBJECT_KEYd ) return false;
|
m_type != OBJECT_KEYd ) return false;
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
return CObjectManager::GetInstancePointer()->FindNearest(nullptr, m_type) != nullptr;
|
||||||
{
|
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type == m_type ) return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,7 @@
|
||||||
|
|
||||||
#include "object/auto/autodestroyer.h"
|
#include "object/auto/autodestroyer.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
#include "object/objman.h"
|
||||||
|
|
||||||
#include "object/level/parserline.h"
|
#include "object/level/parserline.h"
|
||||||
#include "object/level/parserparam.h"
|
#include "object/level/parserparam.h"
|
||||||
|
|
||||||
|
@ -277,14 +276,12 @@ CObject* CAutoDestroyer::SearchPlastic()
|
||||||
Math::Vector sPos, oPos;
|
Math::Vector sPos, oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float dist;
|
float dist;
|
||||||
int i;
|
|
||||||
|
|
||||||
sPos = m_object->GetPosition(0);
|
sPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == nullptr ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
//if ( type != OBJECT_SCRAP4 &&
|
//if ( type != OBJECT_SCRAP4 &&
|
||||||
|
|
|
@ -20,10 +20,9 @@
|
||||||
|
|
||||||
#include "object/auto/autoegg.h"
|
#include "object/auto/autoegg.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/level/parserline.h"
|
#include "object/level/parserline.h"
|
||||||
#include "object/level/parserparam.h"
|
#include "object/level/parserparam.h"
|
||||||
|
|
||||||
|
@ -281,15 +280,13 @@ CObject* CAutoEgg::SearchAlien()
|
||||||
Math::Vector cPos, oPos;
|
Math::Vector cPos, oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float dist, min;
|
float dist, min;
|
||||||
int i;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
cPos = m_object->GetPosition(0);
|
||||||
min = 100000.0f;
|
min = 100000.0f;
|
||||||
pBest = 0;
|
pBest = 0;
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( pObj->GetTruck() != 0 ) continue;
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,11 @@
|
||||||
|
|
||||||
#include "object/auto/autoenergy.h"
|
#include "object/auto/autoenergy.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "graphics/engine/terrain.h"
|
#include "graphics/engine/terrain.h"
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/level/parserline.h"
|
#include "object/level/parserline.h"
|
||||||
#include "object/level/parserparam.h"
|
#include "object/level/parserparam.h"
|
||||||
|
|
||||||
|
@ -404,14 +403,12 @@ bool CAutoEnergy::SearchVehicle()
|
||||||
Math::Vector cPos, oPos;
|
Math::Vector cPos, oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float oRadius, dist;
|
float oRadius, dist;
|
||||||
int i;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
cPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type != OBJECT_HUMAN &&
|
if ( type != OBJECT_HUMAN &&
|
||||||
|
@ -489,14 +486,12 @@ CObject* CAutoEnergy::SearchPower()
|
||||||
CObject* pObj;
|
CObject* pObj;
|
||||||
Math::Vector cPos, oPos;
|
Math::Vector cPos, oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
int i;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
cPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( !pObj->GetLock() ) continue;
|
if ( !pObj->GetLock() ) continue;
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,12 @@
|
||||||
#include "object/auto/autofactory.h"
|
#include "object/auto/autofactory.h"
|
||||||
|
|
||||||
#include "common/global.h"
|
#include "common/global.h"
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
#include "object/robotmain.h"
|
|
||||||
#include "object/brain.h"
|
#include "object/brain.h"
|
||||||
|
#include "object/objman.h"
|
||||||
|
#include "object/robotmain.h"
|
||||||
#include "object/level/parserline.h"
|
#include "object/level/parserline.h"
|
||||||
#include "object/level/parserparam.h"
|
#include "object/level/parserparam.h"
|
||||||
|
|
||||||
|
@ -552,28 +552,7 @@ bool CAutoFactory::Read(CLevelParserLine* line)
|
||||||
|
|
||||||
CObject* CAutoFactory::SearchFret()
|
CObject* CAutoFactory::SearchFret()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
return CObjectManager::GetInstancePointer()->FindNearest(nullptr, m_fretPos, OBJECT_METAL, 8.0f/g_unit);
|
||||||
Math::Vector oPos;
|
|
||||||
ObjectType type;
|
|
||||||
float dist;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type != OBJECT_METAL ) continue;
|
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
|
||||||
dist = Math::Distance(oPos, m_fretPos);
|
|
||||||
|
|
||||||
if ( dist < 8.0f ) return pObj;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search if a vehicle is too close.
|
// Search if a vehicle is too close.
|
||||||
|
@ -584,14 +563,12 @@ bool CAutoFactory::NearestVehicle()
|
||||||
Math::Vector cPos, oPos;
|
Math::Vector cPos, oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float oRadius, dist;
|
float oRadius, dist;
|
||||||
int i;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
cPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type != OBJECT_HUMAN &&
|
if ( type != OBJECT_HUMAN &&
|
||||||
|
@ -696,34 +673,10 @@ bool CAutoFactory::CreateVehicle()
|
||||||
// Seeking the vehicle during manufacture.
|
// Seeking the vehicle during manufacture.
|
||||||
|
|
||||||
CObject* CAutoFactory::SearchVehicle()
|
CObject* CAutoFactory::SearchVehicle()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
return CObjectManager::GetInstancePointer()->FindNearest(nullptr, m_fretPos, m_type, 8.0f/g_unit);
|
||||||
Math::Vector oPos;
|
|
||||||
ObjectType type;
|
|
||||||
float dist;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( !pObj->GetLock() ) continue;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type != m_type ) continue;
|
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
|
||||||
dist = Math::Distance(oPos, m_fretPos);
|
|
||||||
|
|
||||||
if ( dist < 8.0f ) return pObj;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Creates all the interface when the object is selected.
|
// Creates all the interface when the object is selected.
|
||||||
|
|
||||||
bool CAutoFactory::CreateInterface(bool bSelect)
|
bool CAutoFactory::CreateInterface(bool bSelect)
|
||||||
|
|
|
@ -20,8 +20,7 @@
|
||||||
|
|
||||||
#include "object/auto/automush.h"
|
#include "object/auto/automush.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
#include "object/objman.h"
|
||||||
|
|
||||||
#include "object/level/parserline.h"
|
#include "object/level/parserline.h"
|
||||||
#include "object/level/parserparam.h"
|
#include "object/level/parserparam.h"
|
||||||
|
|
||||||
|
@ -230,14 +229,12 @@ bool CAutoMush::SearchTarget()
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float dist;
|
float dist;
|
||||||
int i;
|
|
||||||
|
|
||||||
iPos = m_object->GetPosition(0);
|
iPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( pObj->GetLock() ) continue;
|
if ( pObj->GetLock() ) continue;
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,9 @@
|
||||||
|
|
||||||
#include "object/auto/autonest.h"
|
#include "object/auto/autonest.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "graphics/engine/terrain.h"
|
#include "graphics/engine/terrain.h"
|
||||||
|
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/level/parserline.h"
|
#include "object/level/parserline.h"
|
||||||
#include "object/level/parserparam.h"
|
#include "object/level/parserparam.h"
|
||||||
|
|
||||||
|
@ -156,12 +155,11 @@ bool CAutoNest::SearchFree(Math::Vector pos)
|
||||||
Math::Vector sPos;
|
Math::Vector sPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float sRadius, distance;
|
float sRadius, distance;
|
||||||
int i, j;
|
int j;
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type == OBJECT_NEST ) continue;
|
if ( type == OBJECT_NEST ) continue;
|
||||||
|
@ -201,12 +199,10 @@ CObject* CAutoNest::SearchFret()
|
||||||
CObject* pObj;
|
CObject* pObj;
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
int i;
|
|
||||||
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( !pObj->GetLock() ) continue;
|
if ( !pObj->GetLock() ) continue;
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,9 @@
|
||||||
|
|
||||||
#include "object/auto/autonuclear.h"
|
#include "object/auto/autonuclear.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/level/parserline.h"
|
#include "object/level/parserline.h"
|
||||||
#include "object/level/parserparam.h"
|
#include "object/level/parserparam.h"
|
||||||
|
|
||||||
|
@ -340,12 +339,10 @@ bool CAutoNuclear::SearchVehicle()
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float oRadius, dist;
|
float oRadius, dist;
|
||||||
int i;
|
|
||||||
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type != OBJECT_HUMAN &&
|
if ( type != OBJECT_HUMAN &&
|
||||||
|
|
|
@ -21,10 +21,9 @@
|
||||||
#include "object/auto/autopara.h"
|
#include "object/auto/autopara.h"
|
||||||
|
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/level/parserline.h"
|
#include "object/level/parserline.h"
|
||||||
#include "object/level/parserparam.h"
|
#include "object/level/parserparam.h"
|
||||||
|
|
||||||
|
@ -248,14 +247,12 @@ void CAutoPara::ChargeObject(float rTime)
|
||||||
CObject* power;
|
CObject* power;
|
||||||
Math::Vector sPos, oPos;
|
Math::Vector sPos, oPos;
|
||||||
float dist, energy;
|
float dist, energy;
|
||||||
int i;
|
|
||||||
|
|
||||||
sPos = m_object->GetPosition(0);
|
sPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
oPos = pObj->GetPosition(0);
|
||||||
dist = Math::Distance(oPos, sPos);
|
dist = Math::Distance(oPos, sPos);
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
|
|
||||||
#include "object/auto/autoradar.h"
|
#include "object/auto/autoradar.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
|
#include "object/objman.h"
|
||||||
|
|
||||||
#include "ui/interface.h"
|
#include "ui/interface.h"
|
||||||
#include "ui/window.h"
|
#include "ui/window.h"
|
||||||
#include "ui/gauge.h"
|
#include "ui/gauge.h"
|
||||||
|
@ -269,16 +269,14 @@ bool CAutoRadar::SearchEnemy(Math::Vector &pos)
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
ObjectType oType;
|
ObjectType oType;
|
||||||
float distance, min;
|
float distance, min;
|
||||||
int i;
|
|
||||||
|
|
||||||
iPos = m_object->GetPosition(0);
|
iPos = m_object->GetPosition(0);
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
m_totalDetect = 0;
|
m_totalDetect = 0;
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( !pObj->GetActif() ) continue;
|
if ( !pObj->GetActif() ) continue;
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,7 @@
|
||||||
|
|
||||||
#include "object/auto/autorepair.h"
|
#include "object/auto/autorepair.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
#include "object/objman.h"
|
||||||
|
|
||||||
#include "object/level/parserline.h"
|
#include "object/level/parserline.h"
|
||||||
#include "object/level/parserparam.h"
|
#include "object/level/parserparam.h"
|
||||||
|
|
||||||
|
@ -240,14 +239,12 @@ CObject* CAutoRepair::SearchVehicle()
|
||||||
Math::Vector sPos, oPos;
|
Math::Vector sPos, oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float dist;
|
float dist;
|
||||||
int i;
|
|
||||||
|
|
||||||
sPos = m_object->GetPosition(0);
|
sPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type != OBJECT_MOBILEfa &&
|
if ( type != OBJECT_MOBILEfa &&
|
||||||
|
|
|
@ -20,10 +20,9 @@
|
||||||
|
|
||||||
#include "object/auto/autosafe.h"
|
#include "object/auto/autosafe.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
#include "object/level/parserline.h"
|
#include "object/level/parserline.h"
|
||||||
#include "object/level/parserparam.h"
|
#include "object/level/parserparam.h"
|
||||||
|
@ -404,11 +403,10 @@ int CAutoSafe::CountKeys()
|
||||||
m_bKey[index] = false;
|
m_bKey[index] = false;
|
||||||
m_keyPos[index] = cPos;
|
m_keyPos[index] = cPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( pObj->GetTruck() != 0 ) continue;
|
||||||
|
|
||||||
|
@ -478,14 +476,12 @@ void CAutoSafe::LockKeys()
|
||||||
Math::Vector cPos, oPos;
|
Math::Vector cPos, oPos;
|
||||||
ObjectType oType;
|
ObjectType oType;
|
||||||
float dist;
|
float dist;
|
||||||
int i;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
cPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
oType = pObj->GetType();
|
oType = pObj->GetType();
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( pObj->GetTruck() != 0 ) continue;
|
||||||
|
@ -511,14 +507,12 @@ void CAutoSafe::DownKeys(float progress)
|
||||||
Math::Vector cPos, oPos;
|
Math::Vector cPos, oPos;
|
||||||
ObjectType oType;
|
ObjectType oType;
|
||||||
float dist;
|
float dist;
|
||||||
int i;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
cPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
oType = pObj->GetType();
|
oType = pObj->GetType();
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( pObj->GetTruck() != 0 ) continue;
|
||||||
|
@ -545,7 +539,6 @@ void CAutoSafe::DeleteKeys()
|
||||||
Math::Vector cPos, oPos;
|
Math::Vector cPos, oPos;
|
||||||
ObjectType oType;
|
ObjectType oType;
|
||||||
float dist;
|
float dist;
|
||||||
int i;
|
|
||||||
bool bDelete;
|
bool bDelete;
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
cPos = m_object->GetPosition(0);
|
||||||
|
@ -553,10 +546,9 @@ void CAutoSafe::DeleteKeys()
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
bDelete = false;
|
bDelete = false;
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
oType = pObj->GetType();
|
oType = pObj->GetType();
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( pObj->GetTruck() != 0 ) continue;
|
||||||
|
@ -582,25 +574,6 @@ void CAutoSafe::DeleteKeys()
|
||||||
|
|
||||||
CObject* CAutoSafe::SearchVehicle()
|
CObject* CAutoSafe::SearchVehicle()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
return CObjectManager::GetInstancePointer()->FindNearest(m_object, OBJECT_NULL, 4.0f/g_unit);
|
||||||
Math::Vector cPos, oPos;
|
|
||||||
float dist;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( pObj == m_object ) continue;
|
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
|
||||||
dist = Math::DistanceProjected(oPos, cPos);
|
|
||||||
if ( dist <= 4.0f ) return pObj;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,13 @@
|
||||||
|
|
||||||
#include "object/auto/autostation.h"
|
#include "object/auto/autostation.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "graphics/engine/particle.h"
|
#include "graphics/engine/particle.h"
|
||||||
#include "graphics/engine/terrain.h"
|
#include "graphics/engine/terrain.h"
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
|
#include "object/objman.h"
|
||||||
|
|
||||||
#include "ui/interface.h"
|
#include "ui/interface.h"
|
||||||
#include "ui/gauge.h"
|
#include "ui/gauge.h"
|
||||||
#include "ui/window.h"
|
#include "ui/window.h"
|
||||||
|
@ -245,14 +245,12 @@ CObject* CAutoStation::SearchVehicle()
|
||||||
Math::Vector sPos, oPos;
|
Math::Vector sPos, oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float dist;
|
float dist;
|
||||||
int i;
|
|
||||||
|
|
||||||
sPos = m_object->GetPosition(0);
|
sPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type != OBJECT_HUMAN &&
|
if ( type != OBJECT_HUMAN &&
|
||||||
|
|
|
@ -20,10 +20,9 @@
|
||||||
|
|
||||||
#include "object/auto/autotower.h"
|
#include "object/auto/autotower.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/level/parserline.h"
|
#include "object/level/parserline.h"
|
||||||
#include "object/level/parserparam.h"
|
#include "object/level/parserparam.h"
|
||||||
|
|
||||||
|
@ -274,15 +273,13 @@ CObject* CAutoTower::SearchTarget(Math::Vector &impact)
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
ObjectType oType;
|
ObjectType oType;
|
||||||
float distance, min, radius, speed;
|
float distance, min, radius, speed;
|
||||||
int i;
|
|
||||||
|
|
||||||
iPos = m_object->GetPosition(0);
|
iPos = m_object->GetPosition(0);
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
oType = pObj->GetType();
|
oType = pObj->GetType();
|
||||||
if ( oType != OBJECT_MOTHER &&
|
if ( oType != OBJECT_MOTHER &&
|
||||||
|
|
|
@ -223,8 +223,6 @@ void uObject(CBotVar* botThis, void* user)
|
||||||
|
|
||||||
CObject::CObject()
|
CObject::CObject()
|
||||||
{
|
{
|
||||||
CInstanceManager::GetInstancePointer()->AddInstance(CLASS_OBJECT, this, 500);
|
|
||||||
|
|
||||||
m_app = CApplication::GetInstancePointer();
|
m_app = CApplication::GetInstancePointer();
|
||||||
m_sound = m_app->GetSound();
|
m_sound = m_app->GetSound();
|
||||||
m_engine = Gfx::CEngine::GetInstancePointer();
|
m_engine = Gfx::CEngine::GetInstancePointer();
|
||||||
|
@ -372,8 +370,7 @@ CObject::~CObject()
|
||||||
m_motion = nullptr;
|
m_motion = nullptr;
|
||||||
delete m_auto;
|
delete m_auto;
|
||||||
m_auto = nullptr;
|
m_auto = nullptr;
|
||||||
|
|
||||||
CInstanceManager::GetInstancePointer()->DeleteInstance(CLASS_OBJECT, this);
|
|
||||||
CObjectManager::GetInstancePointer()->DeleteObject(this);
|
CObjectManager::GetInstancePointer()->DeleteObject(this);
|
||||||
|
|
||||||
m_app = nullptr;
|
m_app = nullptr;
|
||||||
|
@ -398,13 +395,12 @@ void CObject::DeleteObject(bool bAll)
|
||||||
{
|
{
|
||||||
m_camera->SetControllingObject(0);
|
m_camera->SetControllingObject(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
||||||
|
|
||||||
for (int i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
pObj->DeleteDeselList(this);
|
pObj->DeleteDeselList(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,12 +64,20 @@ bool CObjectManager::DeleteObject(CObject* instance)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CObject* CObjectManager::GetObjectById(int id)
|
CObject* CObjectManager::GetObjectById(unsigned int id)
|
||||||
{
|
{
|
||||||
return m_table[id];
|
return m_table[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::map<int, CObject*>& CObjectManager::GetAllObjects()
|
CObject* CObjectManager::GetObjectByRank(unsigned int id)
|
||||||
|
{
|
||||||
|
if(id >= m_table.size()) return nullptr;
|
||||||
|
auto it = m_table.begin();
|
||||||
|
for(unsigned int i = 0; i < id; i++, ++it);
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::map<unsigned int, CObject*>& CObjectManager::GetAllObjects()
|
||||||
{
|
{
|
||||||
return m_table;
|
return m_table;
|
||||||
}
|
}
|
||||||
|
@ -384,22 +392,34 @@ bool CObjectManager::DestroyObject(int id)
|
||||||
|
|
||||||
CObject* CObjectManager::Radar(CObject* pThis, ObjectType type, float angle, float focus, float minDist, float maxDist, bool furthest, RadarFilter filter, bool cbotTypes)
|
CObject* CObjectManager::Radar(CObject* pThis, ObjectType type, float angle, float focus, float minDist, float maxDist, bool furthest, RadarFilter filter, bool cbotTypes)
|
||||||
{
|
{
|
||||||
return Radar(pThis, std::vector<ObjectType>(1, type), angle, focus, minDist, maxDist, furthest, filter, cbotTypes);
|
std::vector<ObjectType> types;
|
||||||
|
if(type != OBJECT_NULL)
|
||||||
|
types.push_back(type);
|
||||||
|
return Radar(pThis, types, angle, focus, minDist, maxDist, furthest, filter, cbotTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
CObject* CObjectManager::Radar(CObject* pThis, std::vector<ObjectType> type, float angle, float focus, float minDist, float maxDist, bool furthest, RadarFilter filter, bool cbotTypes)
|
CObject* CObjectManager::Radar(CObject* pThis, std::vector<ObjectType> type, float angle, float focus, float minDist, float maxDist, bool furthest, RadarFilter filter, bool cbotTypes)
|
||||||
{
|
{
|
||||||
Math::Vector iPos;
|
Math::Vector iPos;
|
||||||
float iAngle;
|
float iAngle;
|
||||||
iPos = pThis->GetPosition(0);
|
if(pThis != nullptr)
|
||||||
iAngle = pThis->GetAngleY(0);
|
{
|
||||||
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
|
iPos = pThis->GetPosition(0);
|
||||||
|
iAngle = pThis->GetAngleY(0);
|
||||||
|
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
|
||||||
|
} else {
|
||||||
|
iPos = Math::Vector();
|
||||||
|
iAngle = 0.0f;
|
||||||
|
}
|
||||||
return Radar(pThis, iPos, iAngle, type, angle, focus, minDist, maxDist, furthest, filter, cbotTypes);
|
return Radar(pThis, iPos, iAngle, type, angle, focus, minDist, maxDist, furthest, filter, cbotTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
CObject* CObjectManager::Radar(CObject* pThis, Math::Vector thisPosition, float thisAngle, ObjectType type, float angle, float focus, float minDist, float maxDist, bool furthest, RadarFilter filter, bool cbotTypes)
|
CObject* CObjectManager::Radar(CObject* pThis, Math::Vector thisPosition, float thisAngle, ObjectType type, float angle, float focus, float minDist, float maxDist, bool furthest, RadarFilter filter, bool cbotTypes)
|
||||||
{
|
{
|
||||||
return Radar(pThis, thisPosition, thisAngle, std::vector<ObjectType>(1, type), angle, focus, minDist, maxDist, furthest, filter, cbotTypes);
|
std::vector<ObjectType> types;
|
||||||
|
if(type != OBJECT_NULL)
|
||||||
|
types.push_back(type);
|
||||||
|
return Radar(pThis, thisPosition, thisAngle, types, angle, focus, minDist, maxDist, furthest, filter, cbotTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
CObject* CObjectManager::Radar(CObject* pThis, Math::Vector thisPosition, float thisAngle, std::vector<ObjectType> type, float angle, float focus, float minDist, float maxDist, bool furthest, RadarFilter filter, bool cbotTypes)
|
CObject* CObjectManager::Radar(CObject* pThis, Math::Vector thisPosition, float thisAngle, std::vector<ObjectType> type, float angle, float focus, float minDist, float maxDist, bool furthest, RadarFilter filter, bool cbotTypes)
|
||||||
|
@ -423,8 +443,7 @@ CObject* CObjectManager::Radar(CObject* pThis, Math::Vector thisPosition, float
|
||||||
for ( auto it = m_table.begin() ; it != m_table.end() ; ++it )
|
for ( auto it = m_table.begin() ; it != m_table.end() ; ++it )
|
||||||
{
|
{
|
||||||
pObj = it->second;
|
pObj = it->second;
|
||||||
if ( pObj == 0 ) break;
|
if ( pObj == pThis ) continue; // pThis may be nullptr but it doesn't matter
|
||||||
if ( pObj == pThis ) continue;
|
|
||||||
|
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
||||||
if ( !pObj->GetActif() ) continue;
|
if ( !pObj->GetActif() ) continue;
|
||||||
|
@ -490,4 +509,24 @@ CObject* CObjectManager::Radar(CObject* pThis, Math::Vector thisPosition, float
|
||||||
}
|
}
|
||||||
|
|
||||||
return pBest;
|
return pBest;
|
||||||
|
}
|
||||||
|
|
||||||
|
CObject* CObjectManager::FindNearest(CObject* pThis, ObjectType type, float maxDist, bool cbotTypes)
|
||||||
|
{
|
||||||
|
return Radar(pThis, type, 0.0f, Math::PI*2.0f, 0.0f, maxDist, false, FILTER_NONE, cbotTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
CObject* CObjectManager::FindNearest(CObject* pThis, std::vector<ObjectType> type, float maxDist, bool cbotTypes)
|
||||||
|
{
|
||||||
|
return Radar(pThis, type, 0.0f, Math::PI*2.0f, 0.0f, maxDist, false, FILTER_NONE, cbotTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
CObject* CObjectManager::FindNearest(CObject* pThis, Math::Vector thisPosition, ObjectType type, float maxDist, bool cbotTypes)
|
||||||
|
{
|
||||||
|
return Radar(pThis, thisPosition, 0.0f, type, 0.0f, Math::PI*2.0f, 0.0f, maxDist, false, FILTER_NONE, cbotTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
CObject* CObjectManager::FindNearest(CObject* pThis, Math::Vector thisPosition, std::vector<ObjectType> type, float maxDist, bool cbotTypes)
|
||||||
|
{
|
||||||
|
return Radar(pThis, thisPosition, 0.0f, type, 0.0f, Math::PI*2.0f, 0.0f, maxDist, false, FILTER_NONE, cbotTypes);
|
||||||
}
|
}
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
#include "common/singleton.h"
|
#include "common/singleton.h"
|
||||||
|
|
||||||
#include <map>
|
#include <unordered_map>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class ObjectManager
|
* \class ObjectManager
|
||||||
|
@ -44,10 +44,12 @@ public:
|
||||||
bool AddObject(CObject* instance);
|
bool AddObject(CObject* instance);
|
||||||
//! Unregisters the object
|
//! Unregisters the object
|
||||||
bool DeleteObject(CObject* instance);
|
bool DeleteObject(CObject* instance);
|
||||||
//! Finds object by id
|
//! Finds object by id (CObject::GetID())
|
||||||
CObject* GetObjectById(int id);
|
CObject* GetObjectById(unsigned int id);
|
||||||
|
//! Gets object by id in range <0; m_table.size())
|
||||||
|
CObject* GetObjectByRank(unsigned int id);
|
||||||
//! Returns all objects
|
//! Returns all objects
|
||||||
const std::map<int, CObject*>& GetAllObjects();
|
const std::map<unsigned int, CObject*>& GetAllObjects();
|
||||||
//! Removes all objects
|
//! Removes all objects
|
||||||
void Flush();
|
void Flush();
|
||||||
|
|
||||||
|
@ -63,8 +65,15 @@ public:
|
||||||
CObject* Radar(CObject* pThis, Math::Vector thisPosition, float thisAngle, ObjectType type = OBJECT_NULL, float angle = 0.0f, float focus = Math::PI*2.0f, float minDist = 0.0f, float maxDist = 1000.0f, bool furthest = false, RadarFilter filter = FILTER_NONE, bool cbotTypes = false);
|
CObject* Radar(CObject* pThis, Math::Vector thisPosition, float thisAngle, ObjectType type = OBJECT_NULL, float angle = 0.0f, float focus = Math::PI*2.0f, float minDist = 0.0f, float maxDist = 1000.0f, bool furthest = false, RadarFilter filter = FILTER_NONE, bool cbotTypes = false);
|
||||||
CObject* Radar(CObject* pThis, Math::Vector thisPosition, float thisAngle, std::vector<ObjectType> type = {}, float angle = 0.0f, float focus = Math::PI*2.0f, float minDist = 0.0f, float maxDist = 1000.0f, bool furthest = false, RadarFilter filter = FILTER_NONE, bool cbotTypes = false);
|
CObject* Radar(CObject* pThis, Math::Vector thisPosition, float thisAngle, std::vector<ObjectType> type = {}, float angle = 0.0f, float focus = Math::PI*2.0f, float minDist = 0.0f, float maxDist = 1000.0f, bool furthest = false, RadarFilter filter = FILTER_NONE, bool cbotTypes = false);
|
||||||
//@}
|
//@}
|
||||||
|
//! Returns nearest object that's closer than maxDist
|
||||||
|
//@{
|
||||||
|
CObject* FindNearest(CObject* pThis, ObjectType type = OBJECT_NULL, float maxDist = 1000.0f, bool cbotTypes = false);
|
||||||
|
CObject* FindNearest(CObject* pThis, std::vector<ObjectType> type = {}, float maxDist = 1000.0f, bool cbotTypes = false);
|
||||||
|
CObject* FindNearest(CObject* pThis, Math::Vector thisPosition, ObjectType type = OBJECT_NULL, float maxDist = 1000.0f, bool cbotTypes = false);
|
||||||
|
CObject* FindNearest(CObject* pThis, Math::Vector thisPosition, std::vector<ObjectType> type = {}, float maxDist = 1000.0f, bool cbotTypes = false);
|
||||||
|
//@}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::map<int, CObject*> m_table;
|
std::map<unsigned int, CObject*> m_table;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
#include "object/motion/motionhuman.h"
|
#include "object/motion/motionhuman.h"
|
||||||
#include "object/motion/motiontoto.h"
|
#include "object/motion/motiontoto.h"
|
||||||
#include "object/object.h"
|
#include "object/object.h"
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/task/task.h"
|
#include "object/task/task.h"
|
||||||
#include "object/task/taskbuild.h"
|
#include "object/task/taskbuild.h"
|
||||||
#include "object/task/taskmanip.h"
|
#include "object/task/taskmanip.h"
|
||||||
|
@ -459,7 +460,6 @@ void CRobotMain::ChangePhase(Phase phase)
|
||||||
m_shortCut = true;
|
m_shortCut = true;
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
||||||
iMan->Flush(CLASS_OBJECT);
|
|
||||||
iMan->Flush(CLASS_PHYSICS);
|
iMan->Flush(CLASS_PHYSICS);
|
||||||
iMan->Flush(CLASS_BRAIN);
|
iMan->Flush(CLASS_BRAIN);
|
||||||
iMan->Flush(CLASS_PYRO);
|
iMan->Flush(CLASS_PYRO);
|
||||||
|
@ -1761,12 +1761,10 @@ CObject* CRobotMain::GetSelectObject()
|
||||||
//! Deselects everything, and returns the object that was selected
|
//! Deselects everything, and returns the object that was selected
|
||||||
CObject* CRobotMain::DeselectAll()
|
CObject* CRobotMain::DeselectAll()
|
||||||
{
|
{
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
CObject* prev = nullptr;
|
CObject* prev = nullptr;
|
||||||
for (int i = 0; i < 1000000; i++)
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
if (obj->GetSelect()) prev = obj;
|
if (obj->GetSelect()) prev = obj;
|
||||||
obj->SetSelect(false);
|
obj->SetSelect(false);
|
||||||
|
@ -1895,11 +1893,10 @@ void CRobotMain::DeleteAllObjects()
|
||||||
|
|
||||||
for (int i = 0; i < MAXSHOWLIMIT; i++)
|
for (int i = 0; i < MAXSHOWLIMIT; i++)
|
||||||
FlushShowLimit(i);
|
FlushShowLimit(i);
|
||||||
|
|
||||||
while (true)
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, 0));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
obj->DeleteObject(true); // destroys rapidly
|
obj->DeleteObject(true); // destroys rapidly
|
||||||
delete obj;
|
delete obj;
|
||||||
|
@ -1915,45 +1912,23 @@ void CRobotMain::SelectHuman()
|
||||||
//! Returns the object human
|
//! Returns the object human
|
||||||
CObject* CRobotMain::SearchHuman()
|
CObject* CRobotMain::SearchHuman()
|
||||||
{
|
{
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
return CObjectManager::GetInstancePointer()->FindNearest(nullptr, OBJECT_HUMAN);
|
||||||
for (int i = 0; i < 1000000; i++)
|
|
||||||
{
|
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
|
||||||
if (obj == 0) break;
|
|
||||||
|
|
||||||
ObjectType type = obj->GetType();
|
|
||||||
if (type == OBJECT_HUMAN)
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns the object toto
|
//! Returns the object toto
|
||||||
CObject* CRobotMain::SearchToto()
|
CObject* CRobotMain::SearchToto()
|
||||||
{
|
{
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
return CObjectManager::GetInstancePointer()->FindNearest(nullptr, OBJECT_TOTO);
|
||||||
for (int i = 0; i < 1000000; i++)
|
|
||||||
{
|
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
ObjectType type = obj->GetType();
|
|
||||||
if (type == OBJECT_TOTO)
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns the nearest selectable object from a given position
|
//! Returns the nearest selectable object from a given position
|
||||||
CObject* CRobotMain::SearchNearest(Math::Vector pos, CObject* exclu)
|
CObject* CRobotMain::SearchNearest(Math::Vector pos, CObject* exclu)
|
||||||
{
|
{
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
float min = 100000.0f;
|
float min = 100000.0f;
|
||||||
CObject* best = 0;
|
CObject* best = 0;
|
||||||
for (int i = 0; i < 1000000; i++)
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
if (obj == exclu) continue;
|
if (obj == exclu) continue;
|
||||||
if (!IsSelectable(obj)) continue;
|
if (!IsSelectable(obj)) continue;
|
||||||
|
@ -1975,11 +1950,9 @@ CObject* CRobotMain::SearchNearest(Math::Vector pos, CObject* exclu)
|
||||||
//! Returns the selected object
|
//! Returns the selected object
|
||||||
CObject* CRobotMain::GetSelect()
|
CObject* CRobotMain::GetSelect()
|
||||||
{
|
{
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
for (int i = 0; i < 1000000; i++)
|
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
if (obj->GetSelect())
|
if (obj->GetSelect())
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -1989,28 +1962,17 @@ CObject* CRobotMain::GetSelect()
|
||||||
|
|
||||||
CObject* CRobotMain::SearchObject(ObjectType type)
|
CObject* CRobotMain::SearchObject(ObjectType type)
|
||||||
{
|
{
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
return CObjectManager::GetInstancePointer()->FindNearest(nullptr, type);
|
||||||
for (int i = 0; i < 1000000; i++)
|
|
||||||
{
|
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
if (obj->GetType() == type)
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Detects the object aimed by the mouse
|
//! Detects the object aimed by the mouse
|
||||||
CObject* CRobotMain::DetectObject(Math::Point pos)
|
CObject* CRobotMain::DetectObject(Math::Point pos)
|
||||||
{
|
{
|
||||||
int objRank = m_engine->DetectObject(pos);
|
int objRank = m_engine->DetectObject(pos);
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
for (int i = 0; i < 1000000; i++)
|
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
if (!obj->GetActif()) continue;
|
if (!obj->GetActif()) continue;
|
||||||
CObject* truck = obj->GetTruck();
|
CObject* truck = obj->GetTruck();
|
||||||
|
@ -2252,13 +2214,10 @@ void CRobotMain::HiliteClear()
|
||||||
|
|
||||||
int rank = -1;
|
int rank = -1;
|
||||||
m_engine->SetHighlightRank(&rank); // nothing more selected
|
m_engine->SetHighlightRank(&rank); // nothing more selected
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for (int i = 0; i < 1000000; i++)
|
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
obj->SetHilite(false);
|
obj->SetHilite(false);
|
||||||
m_map->SetHighlight(0);
|
m_map->SetHighlight(0);
|
||||||
|
@ -2416,12 +2375,9 @@ void CRobotMain::HelpObject()
|
||||||
//! Change the mode of the camera
|
//! Change the mode of the camera
|
||||||
void CRobotMain::ChangeCamera()
|
void CRobotMain::ChangeCamera()
|
||||||
{
|
{
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for (int i = 0; i < 1000000; i++)
|
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
if (obj->GetSelect())
|
if (obj->GetSelect())
|
||||||
{
|
{
|
||||||
|
@ -2564,12 +2520,9 @@ void CRobotMain::RemoteCamera(float pan, float zoom, float rTime)
|
||||||
//! Cancels the current movie
|
//! Cancels the current movie
|
||||||
void CRobotMain::AbortMovie()
|
void CRobotMain::AbortMovie()
|
||||||
{
|
{
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for (int i = 0; i < 1000000; i++)
|
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
CAuto* automat = obj->GetAuto();
|
CAuto* automat = obj->GetAuto();
|
||||||
if (automat != 0)
|
if (automat != 0)
|
||||||
|
@ -2643,17 +2596,17 @@ bool CRobotMain::EventFrame(const Event &event)
|
||||||
pm = static_cast<Ui::CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
|
pm = static_cast<Ui::CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
|
||||||
if (pm != nullptr) pm->FlushObject();
|
if (pm != nullptr) pm->FlushObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
||||||
|
CObjectManager* objman = CObjectManager::GetInstancePointer();
|
||||||
|
|
||||||
CObject* toto = nullptr;
|
CObject* toto = nullptr;
|
||||||
if (!m_freePhoto)
|
if (!m_freePhoto)
|
||||||
{
|
{
|
||||||
// Advances all the robots, but not toto.
|
// Advances all the robots, but not toto.
|
||||||
for (int i = 0; i < 1000000; i++)
|
for(auto it : objman->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
if (pm != nullptr) pm->UpdateObject(obj);
|
if (pm != nullptr) pm->UpdateObject(obj);
|
||||||
if (obj->GetTruck() != nullptr) continue;
|
if (obj->GetTruck() != nullptr) continue;
|
||||||
ObjectType type = obj->GetType();
|
ObjectType type = obj->GetType();
|
||||||
|
@ -2663,10 +2616,9 @@ bool CRobotMain::EventFrame(const Event &event)
|
||||||
obj->EventProcess(event);
|
obj->EventProcess(event);
|
||||||
}
|
}
|
||||||
// Advances all objects transported by robots.
|
// Advances all objects transported by robots.
|
||||||
for (int i = 0; i < 1000000; i++)
|
for(auto it : objman->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
if (obj->GetTruck() == nullptr) continue;
|
if (obj->GetTruck() == nullptr) continue;
|
||||||
obj->EventProcess(event);
|
obj->EventProcess(event);
|
||||||
}
|
}
|
||||||
|
@ -2823,13 +2775,10 @@ bool CRobotMain::EventObject(const Event &event)
|
||||||
if (m_freePhoto) return true;
|
if (m_freePhoto) return true;
|
||||||
|
|
||||||
m_resetCreate = false;
|
m_resetCreate = false;
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for (int i = 0; i < 1000000; i++)
|
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
obj->EventProcess(event);
|
obj->EventProcess(event);
|
||||||
}
|
}
|
||||||
|
@ -2865,7 +2814,6 @@ void CRobotMain::ScenePerso()
|
||||||
m_particle->FlushParticle();
|
m_particle->FlushParticle();
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
||||||
iMan->Flush(CLASS_OBJECT);
|
|
||||||
iMan->Flush(CLASS_PHYSICS);
|
iMan->Flush(CLASS_PHYSICS);
|
||||||
iMan->Flush(CLASS_BRAIN);
|
iMan->Flush(CLASS_BRAIN);
|
||||||
iMan->Flush(CLASS_PYRO);
|
iMan->Flush(CLASS_PYRO);
|
||||||
|
@ -4219,13 +4167,10 @@ bool CRobotMain::TestGadgetQuantity(int rank)
|
||||||
//! Calculates the distance to the nearest object
|
//! Calculates the distance to the nearest object
|
||||||
float CRobotMain::SearchNearestObject(Math::Vector center, CObject *exclu)
|
float CRobotMain::SearchNearestObject(Math::Vector center, CObject *exclu)
|
||||||
{
|
{
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
float min = 100000.0f;
|
float min = 100000.0f;
|
||||||
for (int i = 0; i < 1000000; i++)
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
if (!obj->GetActif()) continue; // inactive?
|
if (!obj->GetActif()) continue; // inactive?
|
||||||
if (obj->GetTruck() != nullptr) continue; // object carries?
|
if (obj->GetTruck() != nullptr) continue; // object carries?
|
||||||
|
@ -4370,15 +4315,12 @@ void CRobotMain::ShowDropZone(CObject* metal, CObject* truck)
|
||||||
|
|
||||||
Math::Vector center = metal->GetPosition(0);
|
Math::Vector center = metal->GetPosition(0);
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
// Calculates the maximum radius possible depending on other items.
|
// Calculates the maximum radius possible depending on other items.
|
||||||
float oMax = 30.0f; // radius to build the biggest building
|
float oMax = 30.0f; // radius to build the biggest building
|
||||||
float tMax;
|
float tMax;
|
||||||
for (int i = 0; i < 1000000; i++)
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
if (!obj->GetActif()) continue; // inactive?
|
if (!obj->GetActif()) continue; // inactive?
|
||||||
if (obj->GetTruck() != nullptr) continue; // object carried?
|
if (obj->GetTruck() != nullptr) continue; // object carried?
|
||||||
|
@ -4577,17 +4519,16 @@ void CRobotMain::CompileScript(bool soluce)
|
||||||
{
|
{
|
||||||
int nbError = 0;
|
int nbError = 0;
|
||||||
int lastError = 0;
|
int lastError = 0;
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
CObjectManager* objman = CObjectManager::GetInstancePointer();
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
lastError = nbError;
|
lastError = nbError;
|
||||||
nbError = 0;
|
nbError = 0;
|
||||||
for (int i = 0; i < 1000000; i++)
|
for(auto it : objman->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
if (obj->GetTruck() != nullptr) continue;
|
if (obj->GetTruck() != nullptr) continue;
|
||||||
|
|
||||||
CBrain* brain = obj->GetBrain();
|
CBrain* brain = obj->GetBrain();
|
||||||
|
@ -4616,10 +4557,9 @@ void CRobotMain::CompileScript(bool soluce)
|
||||||
// Load all solutions.
|
// Load all solutions.
|
||||||
if (soluce)
|
if (soluce)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 1000000; i++)
|
for(auto it : objman->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == 0) break;
|
|
||||||
if (obj->GetTruck() != 0) continue;
|
if (obj->GetTruck() != 0) continue;
|
||||||
|
|
||||||
CBrain* brain = obj->GetBrain();
|
CBrain* brain = obj->GetBrain();
|
||||||
|
@ -4634,10 +4574,9 @@ void CRobotMain::CompileScript(bool soluce)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start all programs according to the command "run".
|
// Start all programs according to the command "run".
|
||||||
for (int i = 0; i < 1000000; i++)
|
for(auto it : objman->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
if (obj->GetTruck() != nullptr) continue;
|
if (obj->GetTruck() != nullptr) continue;
|
||||||
|
|
||||||
CBrain* brain = obj->GetBrain();
|
CBrain* brain = obj->GetBrain();
|
||||||
|
@ -4707,12 +4646,9 @@ void CRobotMain::LoadFileScript(CObject *obj, const char* filename, int objRank,
|
||||||
//! Saves all programs of all the robots
|
//! Saves all programs of all the robots
|
||||||
void CRobotMain::SaveAllScript()
|
void CRobotMain::SaveAllScript()
|
||||||
{
|
{
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for (int i = 0; i < 1000000; i++)
|
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
SaveOneScript(obj);
|
SaveOneScript(obj);
|
||||||
}
|
}
|
||||||
|
@ -4844,13 +4780,10 @@ char* CRobotMain::GetNewScriptName(ObjectType type, int rank)
|
||||||
bool CRobotMain::IsBusy()
|
bool CRobotMain::IsBusy()
|
||||||
{
|
{
|
||||||
if (CScriptFunctions::m_CompteurFileOpen > 0) return true;
|
if (CScriptFunctions::m_CompteurFileOpen > 0) return true;
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for (int i = 0; i < 1000000; i++)
|
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
CBrain* brain = obj->GetBrain();
|
CBrain* brain = obj->GetBrain();
|
||||||
if (brain != nullptr)
|
if (brain != nullptr)
|
||||||
|
@ -4968,14 +4901,11 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
|
||||||
line->AddParam("progress", new CLevelParserParam(progress));
|
line->AddParam("progress", new CLevelParserParam(progress));
|
||||||
level->AddLine(line);
|
level->AddLine(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
int objRank = 0;
|
int objRank = 0;
|
||||||
for (int i = 0; i < 1000000; i++)
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
if (obj->GetType() == OBJECT_TOTO) continue;
|
if (obj->GetType() == OBJECT_TOTO) continue;
|
||||||
if (obj->GetType() == OBJECT_FIX) continue;
|
if (obj->GetType() == OBJECT_FIX) continue;
|
||||||
|
@ -5024,10 +4954,9 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
|
||||||
fWrite(&version, sizeof(long), 1, file); // version of CBOT
|
fWrite(&version, sizeof(long), 1, file); // version of CBOT
|
||||||
|
|
||||||
objRank = 0;
|
objRank = 0;
|
||||||
for (int i = 0; i < 1000000; i++)
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
if (obj->GetType() == OBJECT_TOTO) continue;
|
if (obj->GetType() == OBJECT_TOTO) continue;
|
||||||
if (obj->GetType() == OBJECT_FIX) continue;
|
if (obj->GetType() == OBJECT_FIX) continue;
|
||||||
|
@ -5167,8 +5096,8 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete level;
|
delete level;
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
CObjectManager* objman = CObjectManager::GetInstancePointer();
|
||||||
|
|
||||||
// Compiles scripts.
|
// Compiles scripts.
|
||||||
int nbError = 0;
|
int nbError = 0;
|
||||||
|
@ -5177,10 +5106,9 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
|
||||||
{
|
{
|
||||||
lastError = nbError;
|
lastError = nbError;
|
||||||
nbError = 0;
|
nbError = 0;
|
||||||
for (int i = 0; i < 1000000; i++)
|
for(auto it : objman->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
if (obj->GetTruck() != nullptr) continue;
|
if (obj->GetTruck() != nullptr) continue;
|
||||||
|
|
||||||
objRank = obj->GetDefRank();
|
objRank = obj->GetDefRank();
|
||||||
|
@ -5203,10 +5131,9 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
|
||||||
if (version == CBotProgram::GetVersion())
|
if (version == CBotProgram::GetVersion())
|
||||||
{
|
{
|
||||||
objRank = 0;
|
objRank = 0;
|
||||||
for (int i = 0; i < 1000000; i++)
|
for(auto it : objman->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
if (obj->GetType() == OBJECT_TOTO) continue;
|
if (obj->GetType() == OBJECT_TOTO) continue;
|
||||||
if (obj->GetType() == OBJECT_FIX) continue;
|
if (obj->GetType() == OBJECT_FIX) continue;
|
||||||
|
@ -5390,7 +5317,6 @@ void CRobotMain::ResetCreate()
|
||||||
m_terrain->FlushBuildingLevel();
|
m_terrain->FlushBuildingLevel();
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
||||||
iMan->Flush(CLASS_OBJECT);
|
|
||||||
iMan->Flush(CLASS_PHYSICS);
|
iMan->Flush(CLASS_PHYSICS);
|
||||||
iMan->Flush(CLASS_BRAIN);
|
iMan->Flush(CLASS_BRAIN);
|
||||||
iMan->Flush(CLASS_PYRO);
|
iMan->Flush(CLASS_PYRO);
|
||||||
|
@ -5403,11 +5329,10 @@ void CRobotMain::ResetCreate()
|
||||||
CreateScene(m_dialog->GetSceneSoluce(), false, true);
|
CreateScene(m_dialog->GetSceneSoluce(), false, true);
|
||||||
|
|
||||||
if (!GetNiceReset()) return;
|
if (!GetNiceReset()) return;
|
||||||
|
|
||||||
for (int i = 0; i < 1000000; i++)
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
ResetCap cap = obj->GetResetCap();
|
ResetCap cap = obj->GetResetCap();
|
||||||
if (cap == RESET_NONE) continue;
|
if (cap == RESET_NONE) continue;
|
||||||
|
@ -5427,8 +5352,6 @@ void CRobotMain::ResetCreate()
|
||||||
//! Updates the audiotracks
|
//! Updates the audiotracks
|
||||||
void CRobotMain::UpdateAudio(bool frame)
|
void CRobotMain::UpdateAudio(bool frame)
|
||||||
{
|
{
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
for (int t = 0; t < m_audioChangeTotal; t++)
|
for (int t = 0; t < m_audioChangeTotal; t++)
|
||||||
{
|
{
|
||||||
if (m_audioChange[t].changed) continue;
|
if (m_audioChange[t].changed) continue;
|
||||||
|
@ -5439,10 +5362,9 @@ void CRobotMain::UpdateAudio(bool frame)
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
|
|
||||||
int nb = 0;
|
int nb = 0;
|
||||||
for (int i = 0; i < 1000000; i++)
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
// Do not use GetActif () because an invisible worm (underground)
|
// Do not use GetActif () because an invisible worm (underground)
|
||||||
// should be regarded as existing here!
|
// should be regarded as existing here!
|
||||||
|
@ -5549,8 +5471,6 @@ Error CRobotMain::CheckEndMission(bool frame)
|
||||||
return m_missionResult;
|
return m_missionResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
for (int t = 0; t < m_endTakeTotal; t++)
|
for (int t = 0; t < m_endTakeTotal; t++)
|
||||||
{
|
{
|
||||||
if (m_endTake[t].message[0] != 0) continue;
|
if (m_endTake[t].message[0] != 0) continue;
|
||||||
|
@ -5561,10 +5481,9 @@ Error CRobotMain::CheckEndMission(bool frame)
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
|
|
||||||
int nb = 0;
|
int nb = 0;
|
||||||
for (int i = 0; i < 1000000; i++)
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
// Do not use GetActif () because an invisible worm (underground)
|
// Do not use GetActif () because an invisible worm (underground)
|
||||||
// should be regarded as existing here!
|
// should be regarded as existing here!
|
||||||
|
@ -5830,13 +5749,10 @@ bool CRobotMain::GetRadar()
|
||||||
{
|
{
|
||||||
if (m_cheatRadar)
|
if (m_cheatRadar)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for (int i = 0; i < 1000000; i++)
|
|
||||||
{
|
{
|
||||||
CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
CObject* obj = it.second;
|
||||||
if (obj == nullptr) break;
|
|
||||||
|
|
||||||
ObjectType type = obj->GetType();
|
ObjectType type = obj->GetType();
|
||||||
if (type == OBJECT_RADAR && !obj->GetLock())
|
if (type == OBJECT_RADAR && !obj->GetLock())
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
|
|
||||||
#include "object/task/taskbuild.h"
|
#include "object/task/taskbuild.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "graphics/core/color.h"
|
#include "graphics/core/color.h"
|
||||||
#include "graphics/core/light.h"
|
#include "graphics/core/light.h"
|
||||||
#include "graphics/engine/lightman.h"
|
#include "graphics/engine/lightman.h"
|
||||||
|
@ -32,6 +30,7 @@
|
||||||
|
|
||||||
#include "object/auto/auto.h"
|
#include "object/auto/auto.h"
|
||||||
#include "object/motion/motionhuman.h"
|
#include "object/motion/motionhuman.h"
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
|
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
@ -560,7 +559,7 @@ Error CTaskBuild::FlatFloor()
|
||||||
Math::Vector center, pos, oPos, bPos;
|
Math::Vector center, pos, oPos, bPos;
|
||||||
Math::Point c, p;
|
Math::Point c, p;
|
||||||
float radius, max, oRadius, bRadius = 0.0f, angle, dist;
|
float radius, max, oRadius, bRadius = 0.0f, angle, dist;
|
||||||
int i, j;
|
int j;
|
||||||
bool bLittleFlat, bBase;
|
bool bLittleFlat, bBase;
|
||||||
|
|
||||||
radius = 0.0f;
|
radius = 0.0f;
|
||||||
|
@ -594,14 +593,11 @@ Error CTaskBuild::FlatFloor()
|
||||||
return bLittleFlat?ERR_BUILD_FLATLIT:ERR_BUILD_FLAT;
|
return bLittleFlat?ERR_BUILD_FLATLIT:ERR_BUILD_FLAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
max = 100000.0f;
|
max = 100000.0f;
|
||||||
bBase = false;
|
bBase = false;
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( !pObj->GetActif() ) continue; // inactive?
|
if ( !pObj->GetActif() ) continue; // inactive?
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
||||||
|
@ -646,10 +642,9 @@ Error CTaskBuild::FlatFloor()
|
||||||
}
|
}
|
||||||
|
|
||||||
max = 100000.0f;
|
max = 100000.0f;
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( !pObj->GetActif() ) continue; // inactive?
|
if ( !pObj->GetActif() ) continue; // inactive?
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
||||||
|
@ -708,22 +703,18 @@ CObject* CTaskBuild::SearchMetalObject(float &angle, float dMin, float dMax,
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float min, iAngle, a, aa, aBest, distance, magic;
|
float min, iAngle, a, aa, aBest, distance, magic;
|
||||||
int i;
|
|
||||||
bool bMetal;
|
bool bMetal;
|
||||||
|
|
||||||
iPos = m_object->GetPosition(0);
|
iPos = m_object->GetPosition(0);
|
||||||
iAngle = m_object->GetAngleY(0);
|
iAngle = m_object->GetAngleY(0);
|
||||||
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
|
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
pBest = 0;
|
pBest = 0;
|
||||||
bMetal = false;
|
bMetal = false;
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( !pObj->GetActif() ) continue; // objet inactive?
|
if ( !pObj->GetActif() ) continue; // objet inactive?
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
||||||
|
@ -779,14 +770,10 @@ void CTaskBuild::DeleteMark(Math::Vector pos, float radius)
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float distance;
|
float distance;
|
||||||
int i;
|
|
||||||
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type != OBJECT_MARKSTONE &&
|
if ( type != OBJECT_MARKSTONE &&
|
||||||
|
@ -803,7 +790,6 @@ void CTaskBuild::DeleteMark(Math::Vector pos, float radius)
|
||||||
{
|
{
|
||||||
pObj->DeleteObject(); // removes the mark
|
pObj->DeleteObject(); // removes the mark
|
||||||
delete pObj;
|
delete pObj;
|
||||||
i --;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,17 +20,17 @@
|
||||||
|
|
||||||
#include "object/task/taskflag.h"
|
#include "object/task/taskflag.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
#include "graphics/engine/particle.h"
|
#include "graphics/engine/particle.h"
|
||||||
#include "graphics/engine/pyro.h"
|
#include "graphics/engine/pyro.h"
|
||||||
#include "graphics/engine/water.h"
|
#include "graphics/engine/water.h"
|
||||||
|
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/motion/motionhuman.h"
|
#include "object/motion/motionhuman.h"
|
||||||
|
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
#include <boost/concept_check.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,46 +136,14 @@ bool CTaskFlag::Abort()
|
||||||
|
|
||||||
CObject* CTaskFlag::SearchNearest(Math::Vector pos, ObjectType type)
|
CObject* CTaskFlag::SearchNearest(Math::Vector pos, ObjectType type)
|
||||||
{
|
{
|
||||||
ObjectType oType;
|
std::vector<ObjectType> types;
|
||||||
CObject *pObj, *pBest;
|
if(type == OBJECT_NULL)
|
||||||
Math::Vector oPos;
|
|
||||||
float min, dist;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
min = 100000.0f;
|
|
||||||
pBest = 0;
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
types = {OBJECT_FLAGb, OBJECT_FLAGr, OBJECT_FLAGg, OBJECT_FLAGy, OBJECT_FLAGv};
|
||||||
if ( pObj == 0 ) break;
|
} else {
|
||||||
|
types = {type};
|
||||||
if ( !pObj->GetEnable() ) continue;
|
|
||||||
|
|
||||||
oType = pObj->GetType();
|
|
||||||
if ( type == OBJECT_NULL )
|
|
||||||
{
|
|
||||||
if ( oType != OBJECT_FLAGb &&
|
|
||||||
oType != OBJECT_FLAGr &&
|
|
||||||
oType != OBJECT_FLAGg &&
|
|
||||||
oType != OBJECT_FLAGy &&
|
|
||||||
oType != OBJECT_FLAGv ) continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( oType != type ) continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
|
||||||
dist = Math::DistanceProjected(oPos, pos);
|
|
||||||
if ( dist < min )
|
|
||||||
{
|
|
||||||
min = dist;
|
|
||||||
pBest = pObj;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return pBest;
|
return CObjectManager::GetInstancePointer()->FindNearest(nullptr, pos, types);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Counts the number of existing objects.
|
// Counts the number of existing objects.
|
||||||
|
@ -185,15 +153,12 @@ int CTaskFlag::CountObject(ObjectType type)
|
||||||
ObjectType oType;
|
ObjectType oType;
|
||||||
CObject *pObj;
|
CObject *pObj;
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
int i, count;
|
int count;
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( !pObj->GetEnable() ) continue;
|
if ( !pObj->GetEnable() ) continue;
|
||||||
|
|
||||||
|
|
|
@ -23,13 +23,14 @@
|
||||||
#include "object/task/taskgoto.h"
|
#include "object/task/taskgoto.h"
|
||||||
|
|
||||||
#include "common/event.h"
|
#include "common/event.h"
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "graphics/engine/terrain.h"
|
#include "graphics/engine/terrain.h"
|
||||||
#include "graphics/engine/water.h"
|
#include "graphics/engine/water.h"
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
|
#include "object/objman.h"
|
||||||
|
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -503,17 +504,13 @@ CObject* CTaskGoto::WormSearch(Math::Vector &impact)
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
ObjectType oType;
|
ObjectType oType;
|
||||||
float distance, min, radius;
|
float distance, min, radius;
|
||||||
int i;
|
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
iPos = m_object->GetPosition(0);
|
iPos = m_object->GetPosition(0);
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
oType = pObj->GetType();
|
oType = pObj->GetType();
|
||||||
if ( oType != OBJECT_MOBILEfa &&
|
if ( oType != OBJECT_MOBILEfa &&
|
||||||
|
@ -1034,34 +1031,7 @@ Error CTaskGoto::IsEnded()
|
||||||
|
|
||||||
CObject* CTaskGoto::SearchTarget(Math::Vector pos, float margin)
|
CObject* CTaskGoto::SearchTarget(Math::Vector pos, float margin)
|
||||||
{
|
{
|
||||||
CObject *pObj, *pBest;
|
return CObjectManager::GetInstancePointer()->FindNearest(nullptr, pos, OBJECT_NULL, margin);;
|
||||||
Math::Vector oPos;
|
|
||||||
float dist, min;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
pBest = 0;
|
|
||||||
min = 1000000.0f;
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( !pObj->GetActif() ) continue;
|
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transtorted?
|
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
|
||||||
dist = Math::DistanceProjected(pos, oPos);
|
|
||||||
|
|
||||||
if ( dist <= margin && dist <= min )
|
|
||||||
{
|
|
||||||
min = dist;
|
|
||||||
pBest = pObj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pBest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjusts the target as a function of the object.
|
// Adjusts the target as a function of the object.
|
||||||
|
@ -1183,14 +1153,10 @@ bool CTaskGoto::AdjustBuilding(Math::Vector &pos, float margin, float &distance)
|
||||||
CObject* pObj;
|
CObject* pObj;
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
float dist, suppl;
|
float dist, suppl;
|
||||||
int i;
|
|
||||||
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( !pObj->GetActif() ) continue;
|
if ( !pObj->GetActif() ) continue;
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
||||||
|
@ -1340,20 +1306,17 @@ bool CTaskGoto::LeakSearch(Math::Vector &pos, float &delay)
|
||||||
CObject *pObj, *pObstacle = nullptr;
|
CObject *pObj, *pObstacle = nullptr;
|
||||||
Math::Vector iPos, oPos, bPos;
|
Math::Vector iPos, oPos, bPos;
|
||||||
float iRadius, oRadius, bRadius, dist, min, dir;
|
float iRadius, oRadius, bRadius, dist, min, dir;
|
||||||
int i, j;
|
int j;
|
||||||
|
|
||||||
if ( !m_physics->GetLand() ) return false; // in flight?
|
if ( !m_physics->GetLand() ) return false; // in flight?
|
||||||
|
|
||||||
m_object->GetCrashSphere(0, iPos, iRadius);
|
m_object->GetCrashSphere(0, iPos, iRadius);
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
min = 100000.0f;
|
min = 100000.0f;
|
||||||
bRadius = 0.0f;
|
bRadius = 0.0f;
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( pObj == m_object ) continue;
|
if ( pObj == m_object ) continue;
|
||||||
if ( !pObj->GetActif() ) continue;
|
if ( !pObj->GetActif() ) continue;
|
||||||
|
@ -1446,7 +1409,7 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir)
|
||||||
Math::Point repulse;
|
Math::Point repulse;
|
||||||
CObject *pObj;
|
CObject *pObj;
|
||||||
float gDist, add, addi, fac, dist, iRadius, oRadius;
|
float gDist, add, addi, fac, dist, iRadius, oRadius;
|
||||||
int i, j;
|
int j;
|
||||||
bool bAlien;
|
bool bAlien;
|
||||||
|
|
||||||
dir.x = 0.0f;
|
dir.x = 0.0f;
|
||||||
|
@ -1530,13 +1493,10 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir)
|
||||||
{
|
{
|
||||||
bAlien = true;
|
bAlien = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( pObj == m_object ) continue;
|
if ( pObj == m_object ) continue;
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( pObj->GetTruck() != 0 ) continue;
|
||||||
|
@ -1617,20 +1577,17 @@ void CTaskGoto::ComputeFlyingRepulse(float &dir)
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
CObject *pObj;
|
CObject *pObj;
|
||||||
float add, fac, dist, iRadius, oRadius, repulse;
|
float add, fac, dist, iRadius, oRadius, repulse;
|
||||||
int i, j;
|
int j;
|
||||||
|
|
||||||
m_object->GetCrashSphere(0, iPos, iRadius);
|
m_object->GetCrashSphere(0, iPos, iRadius);
|
||||||
|
|
||||||
add = 0.0f;
|
add = 0.0f;
|
||||||
fac = 1.5f;
|
fac = 1.5f;
|
||||||
dir = 0.0f;
|
dir = 0.0f;
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( pObj == m_object ) continue;
|
if ( pObj == m_object ) continue;
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( pObj->GetTruck() != 0 ) continue;
|
||||||
|
@ -1937,16 +1894,13 @@ void CTaskGoto::BitmapObject()
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
float iRadius, oRadius, h;
|
float iRadius, oRadius, h;
|
||||||
int i, j;
|
int j;
|
||||||
|
|
||||||
m_object->GetCrashSphere(0, iPos, iRadius);
|
m_object->GetCrashSphere(0, iPos, iRadius);
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,9 @@
|
||||||
|
|
||||||
#include "object/task/taskinfo.h"
|
#include "object/task/taskinfo.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "graphics/engine/particle.h"
|
#include "graphics/engine/particle.h"
|
||||||
|
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/auto/autoinfo.h"
|
#include "object/auto/autoinfo.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -184,38 +183,6 @@ bool CTaskInfo::Abort()
|
||||||
|
|
||||||
CObject* CTaskInfo::SearchInfo(float power)
|
CObject* CTaskInfo::SearchInfo(float power)
|
||||||
{
|
{
|
||||||
CObject *pObj, *pBest;
|
return CObjectManager::GetInstancePointer()->FindNearest(m_object, OBJECT_INFO, power/g_unit);
|
||||||
Math::Vector iPos, oPos;
|
|
||||||
ObjectType type;
|
|
||||||
float dist, min;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
iPos = m_object->GetPosition(0);
|
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
min = 100000.0f;
|
|
||||||
pBest = 0;
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type != OBJECT_INFO ) continue;
|
|
||||||
|
|
||||||
if ( !pObj->GetActif() ) continue;
|
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
|
||||||
dist = Math::Distance(oPos, iPos);
|
|
||||||
if ( dist > power ) continue; // too far?
|
|
||||||
if ( dist < min )
|
|
||||||
{
|
|
||||||
min = dist;
|
|
||||||
pBest = pObj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pBest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,12 @@
|
||||||
|
|
||||||
#include "object/task/taskmanip.h"
|
#include "object/task/taskmanip.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "graphics/engine/terrain.h"
|
#include "graphics/engine/terrain.h"
|
||||||
#include "graphics/engine/pyro.h"
|
#include "graphics/engine/pyro.h"
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
|
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
@ -729,18 +728,14 @@ CObject* CTaskManip::SearchTakeUnderObject(Math::Vector &pos, float dLimit)
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float min, distance;
|
float min, distance;
|
||||||
int i;
|
|
||||||
|
|
||||||
iPos = m_object->GetPosition(0);
|
iPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
pBest = 0;
|
pBest = 0;
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
|
|
||||||
|
@ -787,7 +782,6 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos,
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float min, iAngle, bAngle, aLimit, dLimit, f;
|
float min, iAngle, bAngle, aLimit, dLimit, f;
|
||||||
int i;
|
|
||||||
|
|
||||||
iPos = m_object->GetPosition(0);
|
iPos = m_object->GetPosition(0);
|
||||||
iAngle = m_object->GetAngleY(0);
|
iAngle = m_object->GetAngleY(0);
|
||||||
|
@ -805,15 +799,12 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos,
|
||||||
dLimit = MARGIN_FRONT;
|
dLimit = MARGIN_FRONT;
|
||||||
}
|
}
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
pBest = 0;
|
pBest = 0;
|
||||||
bAngle = 0.0f;
|
bAngle = 0.0f;
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
|
|
||||||
|
@ -881,7 +872,6 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos,
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float min, iAngle, bAngle, aLimit, dLimit, f;
|
float min, iAngle, bAngle, aLimit, dLimit, f;
|
||||||
int i;
|
|
||||||
|
|
||||||
iPos = m_object->GetPosition(0);
|
iPos = m_object->GetPosition(0);
|
||||||
iAngle = m_object->GetAngleY(0)+Math::PI;
|
iAngle = m_object->GetAngleY(0)+Math::PI;
|
||||||
|
@ -898,15 +888,12 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos,
|
||||||
dLimit = MARGIN_BACK;
|
dLimit = MARGIN_BACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
pBest = 0;
|
pBest = 0;
|
||||||
bAngle = 0.0f;
|
bAngle = 0.0f;
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
|
|
||||||
|
@ -978,7 +965,6 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos,
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
ObjectType type, powerType;
|
ObjectType type, powerType;
|
||||||
float iAngle, iRad, oAngle, oLimit, aLimit, dLimit;
|
float iAngle, iRad, oAngle, oLimit, aLimit, dLimit;
|
||||||
int i;
|
|
||||||
|
|
||||||
distance = 1000000.0f;
|
distance = 1000000.0f;
|
||||||
angle = 0.0f;
|
angle = 0.0f;
|
||||||
|
@ -999,13 +985,10 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos,
|
||||||
aLimit = 7.0f*Math::PI/180.0f;
|
aLimit = 7.0f*Math::PI/180.0f;
|
||||||
dLimit = MARGIN_FRIEND;
|
dLimit = MARGIN_FRIEND;
|
||||||
}
|
}
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( pObj == m_object ) continue; // yourself?
|
if ( pObj == m_object ) continue; // yourself?
|
||||||
|
|
||||||
|
@ -1353,17 +1336,14 @@ bool CTaskManip::IsFreeDeposeObject(Math::Vector pos)
|
||||||
Math::Matrix* mat;
|
Math::Matrix* mat;
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
float oRadius;
|
float oRadius;
|
||||||
int i, j;
|
int j;
|
||||||
|
|
||||||
mat = m_object->GetWorldMatrix(0);
|
mat = m_object->GetWorldMatrix(0);
|
||||||
iPos = Transform(*mat, pos);
|
iPos = Transform(*mat, pos);
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( pObj == m_object ) continue;
|
if ( pObj == m_object ) continue;
|
||||||
if ( !pObj->GetActif() ) continue; // inactive?
|
if ( !pObj->GetActif() ) continue; // inactive?
|
||||||
|
|
|
@ -22,14 +22,13 @@
|
||||||
|
|
||||||
#include "object/task/taskrecover.h"
|
#include "object/task/taskrecover.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "graphics/engine/particle.h"
|
#include "graphics/engine/particle.h"
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -385,41 +384,6 @@ bool CTaskRecover::Abort()
|
||||||
|
|
||||||
CObject* CTaskRecover::SearchRuin()
|
CObject* CTaskRecover::SearchRuin()
|
||||||
{
|
{
|
||||||
CObject *pObj, *pBest;
|
return CObjectManager::GetInstancePointer()->FindNearest(nullptr, m_recoverPos, {OBJECT_RUINmobilew1, OBJECT_RUINmobilew2, OBJECT_RUINmobilet1, OBJECT_RUINmobilet2, OBJECT_RUINmobiler1, OBJECT_RUINmobiler2}, 10.0f);
|
||||||
Math::Vector oPos;
|
|
||||||
ObjectType type;
|
|
||||||
float dist, min;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
pBest = 0;
|
|
||||||
min = 100000.0f;
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type == OBJECT_RUINmobilew1 ||
|
|
||||||
type == OBJECT_RUINmobilew2 ||
|
|
||||||
type == OBJECT_RUINmobilet1 ||
|
|
||||||
type == OBJECT_RUINmobilet2 ||
|
|
||||||
type == OBJECT_RUINmobiler1 ||
|
|
||||||
type == OBJECT_RUINmobiler2 ) // vehicle in ruin?
|
|
||||||
{
|
|
||||||
oPos = pObj->GetPosition(0);
|
|
||||||
dist = Math::Distance(oPos, m_recoverPos);
|
|
||||||
if ( dist > 40.0f ) continue;
|
|
||||||
|
|
||||||
if ( dist < min )
|
|
||||||
{
|
|
||||||
min = dist;
|
|
||||||
pBest = pObj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return pBest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,8 @@
|
||||||
|
|
||||||
#include "object/task/taskreset.h"
|
#include "object/task/taskreset.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "object/brain.h"
|
#include "object/brain.h"
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -273,14 +272,10 @@ bool CTaskReset::SearchVehicle()
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float oRadius, dist;
|
float oRadius, dist;
|
||||||
int i;
|
|
||||||
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( pObj == m_object ) continue;
|
if ( pObj == m_object ) continue;
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
|
|
||||||
#include "object/task/tasksearch.h"
|
#include "object/task/tasksearch.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "graphics/engine/particle.h"
|
#include "graphics/engine/particle.h"
|
||||||
#include "graphics/engine/terrain.h"
|
#include "graphics/engine/terrain.h"
|
||||||
|
|
||||||
|
@ -29,6 +27,7 @@
|
||||||
|
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -308,22 +307,8 @@ bool CTaskSearch::CreateMark()
|
||||||
void CTaskSearch::DeleteMark(ObjectType type)
|
void CTaskSearch::DeleteMark(ObjectType type)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
CObject* pObj;
|
||||||
Math::Vector oPos;
|
pObj = CObjectManager::GetInstancePointer()->FindNearest(nullptr, type);
|
||||||
int i;
|
pObj->DeleteObject();
|
||||||
|
delete pObj;
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( type == pObj->GetType() )
|
|
||||||
{
|
|
||||||
pObj->DeleteObject(); // removes the mark
|
|
||||||
delete pObj;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
|
|
||||||
#include "object/task/taskshield.h"
|
#include "object/task/taskshield.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "graphics/core/light.h"
|
#include "graphics/core/light.h"
|
||||||
#include "graphics/engine/particle.h"
|
#include "graphics/engine/particle.h"
|
||||||
#include "graphics/engine/lightman.h"
|
#include "graphics/engine/lightman.h"
|
||||||
|
@ -29,6 +27,7 @@
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
#include "object/brain.h"
|
#include "object/brain.h"
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
|
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
@ -556,14 +555,10 @@ void CTaskShield::IncreaseShield()
|
||||||
CObject* pObj;
|
CObject* pObj;
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
float dist, shield;
|
float dist, shield;
|
||||||
int i;
|
|
||||||
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type == OBJECT_MOTHER ||
|
if ( type == OBJECT_MOTHER ||
|
||||||
|
|
|
@ -20,14 +20,13 @@
|
||||||
|
|
||||||
#include "object/task/tasktake.h"
|
#include "object/task/tasktake.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "graphics/engine/terrain.h"
|
#include "graphics/engine/terrain.h"
|
||||||
#include "graphics/engine/water.h"
|
#include "graphics/engine/water.h"
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
#include "object/motion/motionhuman.h"
|
#include "object/motion/motionhuman.h"
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
|
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
@ -304,21 +303,17 @@ CObject* CTaskTake::SearchTakeObject(float &angle,
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float min, iAngle, bAngle, a, distance;
|
float min, iAngle, bAngle, a, distance;
|
||||||
int i;
|
|
||||||
|
|
||||||
iPos = m_object->GetPosition(0);
|
iPos = m_object->GetPosition(0);
|
||||||
iAngle = m_object->GetAngleY(0);
|
iAngle = m_object->GetAngleY(0);
|
||||||
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
|
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
pBest = 0;
|
pBest = 0;
|
||||||
bAngle = 0.0f;
|
bAngle = 0.0f;
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
|
|
||||||
|
@ -375,18 +370,14 @@ CObject* CTaskTake::SearchFriendObject(float &angle,
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
ObjectType type, powerType;
|
ObjectType type, powerType;
|
||||||
float iAngle, iRad, distance;
|
float iAngle, iRad, distance;
|
||||||
int i;
|
|
||||||
|
|
||||||
if ( !m_object->GetCrashSphere(0, iPos, iRad) ) return 0;
|
if ( !m_object->GetCrashSphere(0, iPos, iRad) ) return 0;
|
||||||
iAngle = m_object->GetAngleY(0);
|
iAngle = m_object->GetAngleY(0);
|
||||||
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
|
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( pObj == m_object ) continue; // yourself?
|
if ( pObj == m_object ) continue; // yourself?
|
||||||
|
|
||||||
|
@ -573,17 +564,14 @@ bool CTaskTake::IsFreeDeposeObject(Math::Vector pos)
|
||||||
Math::Matrix* mat;
|
Math::Matrix* mat;
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
float oRadius;
|
float oRadius;
|
||||||
int i, j;
|
int j;
|
||||||
|
|
||||||
mat = m_object->GetWorldMatrix(0);
|
mat = m_object->GetWorldMatrix(0);
|
||||||
iPos = Transform(*mat, pos);
|
iPos = Transform(*mat, pos);
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( pObj == m_object ) continue;
|
if ( pObj == m_object ) continue;
|
||||||
if ( !pObj->GetActif() ) continue; // inactive?
|
if ( !pObj->GetActif() ) continue; // inactive?
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
|
|
||||||
#include "object/task/taskterraform.h"
|
#include "object/task/taskterraform.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "graphics/engine/pyro.h"
|
#include "graphics/engine/pyro.h"
|
||||||
#include "graphics/engine/particle.h"
|
#include "graphics/engine/particle.h"
|
||||||
#include "graphics/engine/terrain.h"
|
#include "graphics/engine/terrain.h"
|
||||||
|
@ -31,6 +29,7 @@
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
#include "object/brain.h"
|
#include "object/brain.h"
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
#include "object/motion/motionant.h"
|
#include "object/motion/motionant.h"
|
||||||
#include "object/motion/motionspider.h"
|
#include "object/motion/motionspider.h"
|
||||||
|
@ -346,18 +345,14 @@ bool CTaskTerraform::Terraform()
|
||||||
Gfx::CPyro* pyro;
|
Gfx::CPyro* pyro;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float dist;
|
float dist;
|
||||||
int i;
|
|
||||||
|
|
||||||
m_camera->StartEffect(Gfx::CAM_EFFECT_TERRAFORM, m_terraPos, 1.0f);
|
m_camera->StartEffect(Gfx::CAM_EFFECT_TERRAFORM, m_terraPos, 1.0f);
|
||||||
|
|
||||||
m_sound->Play(SOUND_THUMP, m_terraPos);
|
m_sound->Play(SOUND_THUMP, m_terraPos);
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type == OBJECT_NULL ) continue;
|
if ( type == OBJECT_NULL ) continue;
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
#include "common/event.h"
|
#include "common/event.h"
|
||||||
#include "common/global.h"
|
#include "common/global.h"
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "graphics/engine/camera.h"
|
#include "graphics/engine/camera.h"
|
||||||
#include "graphics/engine/engine.h"
|
#include "graphics/engine/engine.h"
|
||||||
|
@ -36,6 +35,7 @@
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
#include "object/brain.h"
|
#include "object/brain.h"
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
#include "object/motion/motion.h"
|
#include "object/motion/motion.h"
|
||||||
#include "object/motion/motionhuman.h"
|
#include "object/motion/motionhuman.h"
|
||||||
|
@ -2514,7 +2514,7 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
|
||||||
Math::Vector iPos, oPos, iiPos, oAngle, oSpeed;
|
Math::Vector iPos, oPos, iiPos, oAngle, oSpeed;
|
||||||
Sound sound;
|
Sound sound;
|
||||||
float iRad, oRad, distance, force, volume;
|
float iRad, oRad, distance, force, volume;
|
||||||
int i, j, colType;
|
int j, colType;
|
||||||
ObjectType iType, oType;
|
ObjectType iType, oType;
|
||||||
|
|
||||||
if ( m_object->GetRuin() ) return 0; // is burning or exploding?
|
if ( m_object->GetRuin() ) return 0; // is burning or exploding?
|
||||||
|
@ -2526,12 +2526,10 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
|
||||||
iPos = iiPos + (pos - m_object->GetPosition(0));
|
iPos = iiPos + (pos - m_object->GetPosition(0));
|
||||||
iType = m_object->GetType();
|
iType = m_object->GetType();
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( pObj == m_object ) continue; // yourself?
|
if ( pObj == m_object ) continue; // yourself?
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
|
|
||||||
#include "common/resources/inputstream.h"
|
#include "common/resources/inputstream.h"
|
||||||
#include "common/resources/resourcemanager.h"
|
#include "common/resources/resourcemanager.h"
|
||||||
|
|
||||||
|
@ -494,8 +492,8 @@ bool CScriptFunctions::rGetObject(CBotVar* var, CBotVar* result, int& exception,
|
||||||
|
|
||||||
rank = var->GetValInt();
|
rank = var->GetValInt();
|
||||||
|
|
||||||
pObj = static_cast<CObject*>(CInstanceManager::GetInstancePointer()->SearchInstance(CLASS_OBJECT, rank));
|
pObj = CObjectManager::GetInstancePointer()->GetObjectByRank(rank);
|
||||||
if ( pObj == 0 )
|
if ( pObj == nullptr )
|
||||||
{
|
{
|
||||||
result->SetPointer(0);
|
result->SetPointer(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
#include "common/misc.h"
|
#include "common/misc.h"
|
||||||
#include "common/restext.h"
|
#include "common/restext.h"
|
||||||
#include "common/stringutils.h"
|
#include "common/stringutils.h"
|
||||||
|
@ -33,6 +32,7 @@
|
||||||
#include "graphics/engine/particle.h"
|
#include "graphics/engine/particle.h"
|
||||||
|
|
||||||
#include "object/object.h"
|
#include "object/object.h"
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
#include "object/motion/motion.h"
|
#include "object/motion/motion.h"
|
||||||
#include "object/motion/motiontoto.h"
|
#include "object/motion/motiontoto.h"
|
||||||
|
@ -913,24 +913,7 @@ void CDisplayInfo::ViewDisplayInfo()
|
||||||
|
|
||||||
CObject* CDisplayInfo::SearchToto()
|
CObject* CDisplayInfo::SearchToto()
|
||||||
{
|
{
|
||||||
ObjectType type;
|
return CObjectManager::GetInstancePointer()->FindNearest(nullptr, OBJECT_TOTO);
|
||||||
CObject* pObj;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type == OBJECT_TOTO )
|
|
||||||
{
|
|
||||||
return pObj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "graphics/engine/engine.h"
|
#include "graphics/engine/engine.h"
|
||||||
|
|
||||||
#include "object/object.h"
|
#include "object/object.h"
|
||||||
|
#include "object/objman.h"
|
||||||
#include "object/motion/motion.h"
|
#include "object/motion/motion.h"
|
||||||
#include "object/motion/motiontoto.h"
|
#include "object/motion/motiontoto.h"
|
||||||
|
|
||||||
|
@ -585,24 +586,7 @@ bool CDisplayText::IsVisit(EventType event)
|
||||||
|
|
||||||
CObject* CDisplayText::SearchToto()
|
CObject* CDisplayText::SearchToto()
|
||||||
{
|
{
|
||||||
ObjectType type;
|
return CObjectManager::GetInstancePointer()->FindNearest(nullptr, OBJECT_TOTO);
|
||||||
CObject* pObj;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type == OBJECT_TOTO )
|
|
||||||
{
|
|
||||||
return pObj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
#include "object/objman.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -137,13 +137,10 @@ bool CMainShort::CreateShortcuts()
|
||||||
pos.x += dim.x*1.2f;
|
pos.x += dim.x*1.2f;
|
||||||
m_shortcuts[rank] = 0;
|
m_shortcuts[rank] = 0;
|
||||||
rank ++;
|
rank ++;
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == nullptr ) break;
|
|
||||||
|
|
||||||
if ( !pObj->GetActif() ) continue;
|
if ( !pObj->GetActif() ) continue;
|
||||||
if ( !pObj->GetSelectable() ) continue;
|
if ( !pObj->GetSelectable() ) continue;
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "ui/target.h"
|
#include "ui/target.h"
|
||||||
|
|
||||||
#include "common/iman.h"
|
#include "object/objman.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -187,16 +187,13 @@ CObject* CTarget::DetectFriendObject(Math::Point pos)
|
||||||
{
|
{
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
CObject *pObj, *pTarget;
|
CObject *pObj, *pTarget;
|
||||||
int objRank, i, j, rank;
|
int objRank, j, rank;
|
||||||
|
|
||||||
objRank = m_engine->DetectObject(pos);
|
objRank = m_engine->DetectObject(pos);
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
|
||||||
{
|
{
|
||||||
pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
|
pObj = it.second;
|
||||||
if ( pObj == 0 ) break;
|
|
||||||
|
|
||||||
if ( !pObj->GetActif() ) continue;
|
if ( !pObj->GetActif() ) continue;
|
||||||
if ( pObj->GetProxyActivate() ) continue;
|
if ( pObj->GetProxyActivate() ) continue;
|
||||||
|
|
Loading…
Reference in New Issue