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