Proper CObject lifetime management
CObjectManager is now the only class responsible for storing CObjectsmaster
parent
fed67e6640
commit
0c9a9bce98
|
@ -231,7 +231,6 @@ enum ResearchType
|
||||||
|
|
||||||
|
|
||||||
// TODO: move to CRobotMain
|
// TODO: move to CRobotMain
|
||||||
extern long g_id; // unique identifier
|
|
||||||
extern int g_build; // constructible buildings
|
extern int g_build; // constructible buildings
|
||||||
extern int g_researchDone; // research done
|
extern int g_researchDone; // research done
|
||||||
extern long g_researchEnable; // research available
|
extern long g_researchEnable; // research available
|
||||||
|
|
|
@ -243,10 +243,9 @@ void CCamera::SetType(CameraType type)
|
||||||
|
|
||||||
if ( (m_type == CAM_TYPE_BACK) && m_transparency )
|
if ( (m_type == CAM_TYPE_BACK) && m_transparency )
|
||||||
{
|
{
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
if (obj->GetTruck())
|
if (obj->GetTruck())
|
||||||
continue; // battery or cargo?
|
continue; // battery or cargo?
|
||||||
|
|
||||||
|
@ -890,9 +889,9 @@ bool CCamera::IsCollisionBack(Math::Vector &eye, Math::Vector lookat)
|
||||||
|
|
||||||
m_transparency = false;
|
m_transparency = false;
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
if (obj->GetTruck()) continue; // battery or cargo?
|
if (obj->GetTruck()) continue; // battery or cargo?
|
||||||
|
|
||||||
|
@ -966,10 +965,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)
|
||||||
{
|
{
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
if (obj == m_cameraObj) continue;
|
if (obj == m_cameraObj) continue;
|
||||||
|
|
||||||
ObjectType type = obj->GetType();
|
ObjectType type = obj->GetType();
|
||||||
|
|
|
@ -317,10 +317,9 @@ CObject* CLightning::SearchObject(Math::Vector pos)
|
||||||
// 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(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
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?
|
||||||
|
|
||||||
|
|
|
@ -3658,10 +3658,9 @@ CObject* CParticle::SearchObjectGun(Math::Vector old, Math::Vector pos,
|
||||||
|
|
||||||
CObject* best = 0;
|
CObject* best = 0;
|
||||||
bool shield = false;
|
bool shield = false;
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
if (!obj->GetActif()) continue; // inactive?
|
if (!obj->GetActif()) continue; // inactive?
|
||||||
if (obj == father) continue;
|
if (obj == father) continue;
|
||||||
|
|
||||||
|
@ -3783,9 +3782,9 @@ CObject* CParticle::SearchObjectRay(Math::Vector pos, Math::Vector goal,
|
||||||
box2.y += min;
|
box2.y += min;
|
||||||
box2.z += min;
|
box2.z += min;
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
if (!obj->GetActif()) continue; // inactive?
|
if (!obj->GetActif()) continue; // inactive?
|
||||||
if (obj == father) continue;
|
if (obj == father) continue;
|
||||||
|
|
|
@ -1372,18 +1372,16 @@ void CPyro::DeleteObject(bool primary, bool secondary)
|
||||||
type != OBJECT_ENERGY )
|
type != OBJECT_ENERGY )
|
||||||
{
|
{
|
||||||
CObject* sub = m_object->GetPower();
|
CObject* sub = m_object->GetPower();
|
||||||
if ( sub != 0 )
|
if ( sub != nullptr )
|
||||||
{
|
{
|
||||||
sub->DeleteObject(); // removes the battery
|
CObjectManager::GetInstancePointer()->DeleteObject(sub);
|
||||||
delete sub;
|
m_object->SetPower(nullptr);
|
||||||
m_object->SetPower(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub = m_object->GetFret();
|
sub = m_object->GetFret();
|
||||||
if ( sub != 0 )
|
if ( sub != nullptr )
|
||||||
{
|
{
|
||||||
sub->DeleteObject(); // removes the object transported
|
CObjectManager::GetInstancePointer()->DeleteObject(sub);
|
||||||
delete sub;
|
|
||||||
m_object->SetFret(nullptr);
|
m_object->SetFret(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1391,7 +1389,7 @@ void CPyro::DeleteObject(bool primary, bool secondary)
|
||||||
if (primary)
|
if (primary)
|
||||||
{
|
{
|
||||||
CObject* truck = m_object->GetTruck();
|
CObject* truck = m_object->GetTruck();
|
||||||
if ( truck != 0 ) // object carries?
|
if ( truck != nullptr ) // object carries?
|
||||||
{
|
{
|
||||||
if (truck->GetPower() == m_object)
|
if (truck->GetPower() == m_object)
|
||||||
truck->SetPower(nullptr);
|
truck->SetPower(nullptr);
|
||||||
|
@ -1400,9 +1398,7 @@ void CPyro::DeleteObject(bool primary, bool secondary)
|
||||||
truck->SetFret(nullptr);
|
truck->SetFret(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
CObject* sub = m_object;
|
CObjectManager::GetInstancePointer()->DeleteObject(m_object);
|
||||||
sub->DeleteObject(); // removes the object (*)
|
|
||||||
delete sub;
|
|
||||||
m_object = nullptr;
|
m_object = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2218,9 +2214,9 @@ CObject* CPyro::FallSearchBeeExplo()
|
||||||
float iRadius;
|
float iRadius;
|
||||||
m_object->GetCrashSphere(0, iPos, iRadius);
|
m_object->GetCrashSphere(0, iPos, iRadius);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* pObj = it.second;
|
CObject* pObj = it.second.get();
|
||||||
|
|
||||||
ObjectType oType = pObj->GetType();
|
ObjectType oType = pObj->GetType();
|
||||||
if ( oType != OBJECT_HUMAN &&
|
if ( oType != OBJECT_HUMAN &&
|
||||||
|
|
|
@ -1244,9 +1244,9 @@ void CAutoBase::FreezeCargo(bool bFreeze)
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
float dist;
|
float dist;
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
pObj->SetCargo(false);
|
pObj->SetCargo(false);
|
||||||
|
|
||||||
|
@ -1280,9 +1280,9 @@ void CAutoBase::MoveCargo()
|
||||||
|
|
||||||
sPos = m_object->GetPosition(0);
|
sPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( !pObj->GetCargo() ) continue;
|
if ( !pObj->GetCargo() ) continue;
|
||||||
|
|
||||||
|
@ -1308,9 +1308,9 @@ Error CAutoBase::CheckCloseDoor()
|
||||||
float oRad, dist;
|
float oRad, dist;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( pObj == m_object ) continue; // yourself?
|
if ( pObj == m_object ) continue; // yourself?
|
||||||
if ( !pObj->GetActif() ) continue; // inactive?
|
if ( !pObj->GetActif() ) continue; // inactive?
|
||||||
|
|
|
@ -54,17 +54,14 @@ CAutoConvert::~CAutoConvert()
|
||||||
|
|
||||||
// Destroys the object.
|
// Destroys the object.
|
||||||
|
|
||||||
void CAutoConvert::DeleteObject(bool bAll)
|
void CAutoConvert::DeleteObject(bool all)
|
||||||
{
|
{
|
||||||
CObject* fret;
|
if ( !all )
|
||||||
|
|
||||||
if ( !bAll )
|
|
||||||
{
|
{
|
||||||
fret = SearchStone(OBJECT_STONE);
|
CObject* fret = SearchStone(OBJECT_STONE);
|
||||||
if ( fret != 0 )
|
if ( fret != nullptr )
|
||||||
{
|
{
|
||||||
fret->DeleteObject(); // destroy the stone
|
CObjectManager::GetInstancePointer()->DeleteObject(fret);
|
||||||
delete fret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +72,7 @@ void CAutoConvert::DeleteObject(bool bAll)
|
||||||
m_soundChannel = -1;
|
m_soundChannel = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAuto::DeleteObject(bAll);
|
CAuto::DeleteObject(all);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -233,11 +230,11 @@ bool CAutoConvert::EventProcess(const Event &event)
|
||||||
m_object->SetAngleY(3, Math::PI);
|
m_object->SetAngleY(3, Math::PI);
|
||||||
|
|
||||||
fret = SearchStone(OBJECT_STONE);
|
fret = SearchStone(OBJECT_STONE);
|
||||||
if ( fret != 0 )
|
if ( fret != nullptr )
|
||||||
{
|
{
|
||||||
m_bResetDelete = ( fret->GetResetCap() != RESET_NONE );
|
m_bResetDelete = ( fret->GetResetCap() != RESET_NONE );
|
||||||
fret->DeleteObject(); // destroy the stone
|
|
||||||
delete fret;
|
CObjectManager::GetInstancePointer()->DeleteObject(fret);
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateMetal(); // Create the metal
|
CreateMetal(); // Create the metal
|
||||||
|
@ -405,9 +402,9 @@ CObject* CAutoConvert::SearchStone(ObjectType type)
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
cPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
oType = pObj->GetType();
|
oType = pObj->GetType();
|
||||||
if ( oType != type ) continue;
|
if ( oType != type ) continue;
|
||||||
|
@ -433,9 +430,9 @@ bool CAutoConvert::SearchVehicle()
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
cPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type != OBJECT_HUMAN &&
|
if ( type != OBJECT_HUMAN &&
|
||||||
|
|
|
@ -61,17 +61,14 @@ CAutoDerrick::~CAutoDerrick()
|
||||||
|
|
||||||
// Destroys the object.
|
// Destroys the object.
|
||||||
|
|
||||||
void CAutoDerrick::DeleteObject(bool bAll)
|
void CAutoDerrick::DeleteObject(bool all)
|
||||||
{
|
{
|
||||||
CObject* fret;
|
if ( !all )
|
||||||
|
|
||||||
if ( !bAll )
|
|
||||||
{
|
{
|
||||||
fret = SearchFret();
|
CObject* fret = SearchFret();
|
||||||
if ( fret != 0 && fret->GetLock() )
|
if ( fret != nullptr && fret->GetLock() )
|
||||||
{
|
{
|
||||||
fret->DeleteObject();
|
CObjectManager::GetInstancePointer()->DeleteObject(fret);
|
||||||
delete fret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +79,7 @@ void CAutoDerrick::DeleteObject(bool bAll)
|
||||||
m_soundChannel = -1;
|
m_soundChannel = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAuto::DeleteObject(bAll);
|
CAuto::DeleteObject(all);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -468,9 +465,9 @@ CObject* CAutoDerrick::SearchFret()
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type == OBJECT_DERRICK ) continue;
|
if ( type == OBJECT_DERRICK ) continue;
|
||||||
|
@ -494,9 +491,9 @@ bool CAutoDerrick::SearchFree(Math::Vector pos)
|
||||||
float sRadius, distance;
|
float sRadius, distance;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type == OBJECT_DERRICK ) continue;
|
if ( type == OBJECT_DERRICK ) continue;
|
||||||
|
|
|
@ -279,9 +279,9 @@ CObject* CAutoDestroyer::SearchPlastic()
|
||||||
|
|
||||||
sPos = m_object->GetPosition(0);
|
sPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
//if ( type != OBJECT_SCRAP4 &&
|
//if ( type != OBJECT_SCRAP4 &&
|
||||||
|
|
|
@ -55,16 +55,14 @@ CAutoEgg::~CAutoEgg()
|
||||||
|
|
||||||
// Destroys the object.
|
// Destroys the object.
|
||||||
|
|
||||||
void CAutoEgg::DeleteObject(bool bAll)
|
void CAutoEgg::DeleteObject(bool all)
|
||||||
{
|
{
|
||||||
CObject* alien;
|
CAuto::DeleteObject(all);
|
||||||
|
|
||||||
CAuto::DeleteObject(bAll);
|
if ( !all )
|
||||||
|
|
||||||
if ( !bAll )
|
|
||||||
{
|
{
|
||||||
alien = SearchAlien();
|
CObject* alien = SearchAlien();
|
||||||
if ( alien != 0 )
|
if ( alien != nullptr )
|
||||||
{
|
{
|
||||||
// Probably the intended action
|
// Probably the intended action
|
||||||
// Original code: ( alien->GetZoom(0) == 1.0f )
|
// Original code: ( alien->GetZoom(0) == 1.0f )
|
||||||
|
@ -75,8 +73,7 @@ void CAutoEgg::DeleteObject(bool bAll)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
alien->DeleteObject();
|
CObjectManager::GetInstancePointer()->DeleteObject(alien);
|
||||||
delete alien;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,9 +280,9 @@ CObject* CAutoEgg::SearchAlien()
|
||||||
cPos = m_object->GetPosition(0);
|
cPos = m_object->GetPosition(0);
|
||||||
min = 100000.0f;
|
min = 100000.0f;
|
||||||
pBest = 0;
|
pBest = 0;
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( pObj->GetTruck() != 0 ) continue;
|
||||||
|
|
||||||
|
|
|
@ -61,34 +61,30 @@ CAutoEnergy::~CAutoEnergy()
|
||||||
|
|
||||||
// Destroys the object.
|
// Destroys the object.
|
||||||
|
|
||||||
void CAutoEnergy::DeleteObject(bool bAll)
|
void CAutoEnergy::DeleteObject(bool all)
|
||||||
{
|
{
|
||||||
CObject* fret;
|
|
||||||
|
|
||||||
if ( m_partiSphere != -1 )
|
if ( m_partiSphere != -1 )
|
||||||
{
|
{
|
||||||
m_particle->DeleteParticle(m_partiSphere);
|
m_particle->DeleteParticle(m_partiSphere);
|
||||||
m_partiSphere = -1;
|
m_partiSphere = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !bAll )
|
if ( !all )
|
||||||
{
|
{
|
||||||
fret = SearchMetal();
|
CObject* fret = SearchMetal();
|
||||||
if ( fret != 0 )
|
if ( fret != nullptr )
|
||||||
{
|
{
|
||||||
fret->DeleteObject(); // destroys the metal
|
CObjectManager::GetInstancePointer()->DeleteObject(fret);
|
||||||
delete fret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fret = SearchPower();
|
fret = SearchPower();
|
||||||
if ( fret != 0 )
|
if ( fret != nullptr )
|
||||||
{
|
{
|
||||||
fret->DeleteObject(); // destroys the cell
|
CObjectManager::GetInstancePointer()->DeleteObject(fret);
|
||||||
delete fret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CAuto::DeleteObject(bAll);
|
CAuto::DeleteObject(all);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -312,11 +308,10 @@ bool CAutoEnergy::EventProcess(const Event &event)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fret = SearchMetal();
|
fret = SearchMetal();
|
||||||
if ( fret != 0 )
|
if ( fret != nullptr )
|
||||||
{
|
{
|
||||||
m_object->SetPower(0);
|
m_object->SetPower(nullptr);
|
||||||
fret->DeleteObject(); // destroys the metal
|
CObjectManager::GetInstancePointer()->DeleteObject(fret);
|
||||||
delete fret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fret = SearchPower();
|
fret = SearchPower();
|
||||||
|
@ -406,9 +401,9 @@ bool CAutoEnergy::SearchVehicle()
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
cPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type != OBJECT_HUMAN &&
|
if ( type != OBJECT_HUMAN &&
|
||||||
|
@ -479,9 +474,9 @@ CObject* CAutoEnergy::SearchPower()
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
cPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( !pObj->GetLock() ) continue;
|
if ( !pObj->GetLock() ) continue;
|
||||||
|
|
||||||
|
|
|
@ -62,25 +62,20 @@ CAutoFactory::~CAutoFactory()
|
||||||
|
|
||||||
// Destroys the object.
|
// Destroys the object.
|
||||||
|
|
||||||
void CAutoFactory::DeleteObject(bool bAll)
|
void CAutoFactory::DeleteObject(bool all)
|
||||||
{
|
{
|
||||||
CObject* fret;
|
if ( !all )
|
||||||
CObject* vehicle;
|
|
||||||
|
|
||||||
if ( !bAll )
|
|
||||||
{
|
{
|
||||||
fret = SearchFret(); // transform metal?
|
CObject* fret = SearchFret(); // transform metal?
|
||||||
if ( fret != 0 )
|
if ( fret != nullptr )
|
||||||
{
|
{
|
||||||
fret->DeleteObject(); // destroys the metal
|
CObjectManager::GetInstancePointer()->DeleteObject(fret);
|
||||||
delete fret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vehicle = SearchVehicle();
|
CObject* vehicle = SearchVehicle();
|
||||||
if ( vehicle != 0 )
|
if ( vehicle != nullptr )
|
||||||
{
|
{
|
||||||
vehicle->DeleteObject(); // destroys the vehicle
|
CObjectManager::GetInstancePointer()->DeleteObject(vehicle);
|
||||||
delete vehicle;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +86,7 @@ void CAutoFactory::DeleteObject(bool bAll)
|
||||||
m_channelSound = -1;
|
m_channelSound = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAuto::DeleteObject(bAll);
|
CAuto::DeleteObject(all);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -387,10 +382,9 @@ bool CAutoFactory::EventProcess(const Event &event)
|
||||||
SoundManip(2.0f, 1.0f, 1.2f);
|
SoundManip(2.0f, 1.0f, 1.2f);
|
||||||
|
|
||||||
fret = SearchFret(); // transform metal?
|
fret = SearchFret(); // transform metal?
|
||||||
if ( fret != 0 )
|
if ( fret != nullptr )
|
||||||
{
|
{
|
||||||
fret->DeleteObject(); // removes the metal
|
CObjectManager::GetInstancePointer()->DeleteObject(fret);
|
||||||
delete fret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vehicle = vehicle = SearchVehicle();
|
m_vehicle = vehicle = SearchVehicle();
|
||||||
|
@ -558,9 +552,9 @@ CObject* CAutoFactory::SearchFret()
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float dist;
|
float dist;
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type != OBJECT_METAL ) continue;
|
if ( type != OBJECT_METAL ) continue;
|
||||||
|
@ -586,9 +580,9 @@ bool CAutoFactory::NearestVehicle()
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
cPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type != OBJECT_HUMAN &&
|
if ( type != OBJECT_HUMAN &&
|
||||||
|
@ -692,9 +686,9 @@ CObject* CAutoFactory::SearchVehicle()
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float dist;
|
float dist;
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( !pObj->GetLock() ) continue;
|
if ( !pObj->GetLock() ) continue;
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
|
#include "object/object_manager.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"
|
||||||
|
@ -366,11 +367,10 @@ bool CAutoLabo::EventProcess(const Event &event)
|
||||||
UpdateInterface();
|
UpdateInterface();
|
||||||
|
|
||||||
power = m_object->GetPower();
|
power = m_object->GetPower();
|
||||||
if ( power != 0 )
|
if ( power != nullptr )
|
||||||
{
|
{
|
||||||
m_object->SetPower(0);
|
m_object->SetPower(nullptr);
|
||||||
power->DeleteObject(); // destroys the ball
|
CObjectManager::GetInstancePointer()->DeleteObject(power);
|
||||||
delete power;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_main->DisplayError(INFO_LABO, m_object);
|
m_main->DisplayError(INFO_LABO, m_object);
|
||||||
|
|
|
@ -232,9 +232,9 @@ bool CAutoMush::SearchTarget()
|
||||||
|
|
||||||
iPos = m_object->GetPosition(0);
|
iPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( pObj->GetLock() ) continue;
|
if ( pObj->GetLock() ) continue;
|
||||||
|
|
||||||
|
|
|
@ -48,21 +48,18 @@ CAutoNest::~CAutoNest()
|
||||||
|
|
||||||
// Destroys the object.
|
// Destroys the object.
|
||||||
|
|
||||||
void CAutoNest::DeleteObject(bool bAll)
|
void CAutoNest::DeleteObject(bool all)
|
||||||
{
|
{
|
||||||
CObject* fret;
|
if ( !all )
|
||||||
|
|
||||||
if ( !bAll )
|
|
||||||
{
|
{
|
||||||
fret = SearchFret();
|
CObject* fret = SearchFret();
|
||||||
if ( fret != 0 )
|
if ( fret != nullptr )
|
||||||
{
|
{
|
||||||
fret->DeleteObject();
|
CObjectManager::GetInstancePointer()->DeleteObject(fret);
|
||||||
delete fret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CAuto::DeleteObject(bAll);
|
CAuto::DeleteObject(all);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,9 +154,9 @@ bool CAutoNest::SearchFree(Math::Vector pos)
|
||||||
float sRadius, distance;
|
float sRadius, distance;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type == OBJECT_NEST ) continue;
|
if ( type == OBJECT_NEST ) continue;
|
||||||
|
@ -193,9 +190,9 @@ CObject* CAutoNest::SearchFret()
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( !pObj->GetLock() ) continue;
|
if ( !pObj->GetLock() ) continue;
|
||||||
|
|
||||||
|
|
|
@ -57,17 +57,14 @@ CAutoNuclear::~CAutoNuclear()
|
||||||
|
|
||||||
// Destroys the object.
|
// Destroys the object.
|
||||||
|
|
||||||
void CAutoNuclear::DeleteObject(bool bAll)
|
void CAutoNuclear::DeleteObject(bool all)
|
||||||
{
|
{
|
||||||
CObject* fret;
|
if ( !all )
|
||||||
|
|
||||||
if ( !bAll )
|
|
||||||
{
|
{
|
||||||
fret = SearchUranium();
|
CObject* fret = SearchUranium();
|
||||||
if ( fret != 0 )
|
if ( fret != nullptr )
|
||||||
{
|
{
|
||||||
fret->DeleteObject(); // destroys the metal
|
CObjectManager::GetInstancePointer()->DeleteObject(fret);
|
||||||
delete fret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +75,7 @@ void CAutoNuclear::DeleteObject(bool bAll)
|
||||||
m_channelSound = -1;
|
m_channelSound = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAuto::DeleteObject(bAll);
|
CAuto::DeleteObject(all);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -231,11 +228,10 @@ bool CAutoNuclear::EventProcess(const Event &event)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fret = SearchUranium();
|
fret = SearchUranium();
|
||||||
if ( fret != 0 )
|
if ( fret != nullptr )
|
||||||
{
|
{
|
||||||
fret->DeleteObject(); // destroyed uranium
|
CObjectManager::GetInstancePointer()->DeleteObject(fret);
|
||||||
delete fret;
|
m_object->SetPower(nullptr);
|
||||||
m_object->SetPower(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CreatePower(); // creates the atomic cell
|
CreatePower(); // creates the atomic cell
|
||||||
|
@ -340,9 +336,9 @@ bool CAutoNuclear::SearchVehicle()
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float oRadius, dist;
|
float oRadius, dist;
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type != OBJECT_HUMAN &&
|
if ( type != OBJECT_HUMAN &&
|
||||||
|
|
|
@ -250,9 +250,9 @@ void CAutoPara::ChargeObject(float rTime)
|
||||||
|
|
||||||
sPos = m_object->GetPosition(0);
|
sPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
oPos = pObj->GetPosition(0);
|
||||||
dist = Math::Distance(oPos, sPos);
|
dist = Math::Distance(oPos, sPos);
|
||||||
|
|
|
@ -274,9 +274,9 @@ bool CAutoRadar::SearchEnemy(Math::Vector &pos)
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
m_totalDetect = 0;
|
m_totalDetect = 0;
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( !pObj->GetActif() ) continue;
|
if ( !pObj->GetActif() ) continue;
|
||||||
|
|
||||||
|
|
|
@ -242,9 +242,9 @@ CObject* CAutoRepair::SearchVehicle()
|
||||||
|
|
||||||
sPos = m_object->GetPosition(0);
|
sPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type != OBJECT_MOBILEfa &&
|
if ( type != OBJECT_MOBILEfa &&
|
||||||
|
|
|
@ -68,13 +68,10 @@ CAutoSafe::~CAutoSafe()
|
||||||
|
|
||||||
void CAutoSafe::DeleteObject(bool bAll)
|
void CAutoSafe::DeleteObject(bool bAll)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
CObject* obj = SearchVehicle();
|
||||||
|
if ( obj != nullptr )
|
||||||
pObj = SearchVehicle();
|
|
||||||
if ( pObj != 0 )
|
|
||||||
{
|
{
|
||||||
pObj->DeleteObject();
|
CObjectManager::GetInstancePointer()->DeleteObject(obj);
|
||||||
delete pObj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_channelSound != -1 )
|
if ( m_channelSound != -1 )
|
||||||
|
@ -403,10 +400,10 @@ int CAutoSafe::CountKeys()
|
||||||
m_bKey[index] = false;
|
m_bKey[index] = false;
|
||||||
m_keyPos[index] = cPos;
|
m_keyPos[index] = cPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( pObj->GetTruck() != 0 ) continue;
|
||||||
|
|
||||||
|
@ -479,9 +476,9 @@ void CAutoSafe::LockKeys()
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
cPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
oType = pObj->GetType();
|
oType = pObj->GetType();
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( pObj->GetTruck() != 0 ) continue;
|
||||||
|
@ -510,9 +507,9 @@ void CAutoSafe::DownKeys(float progress)
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
cPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
oType = pObj->GetType();
|
oType = pObj->GetType();
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( pObj->GetTruck() != 0 ) continue;
|
||||||
|
@ -535,39 +532,34 @@ void CAutoSafe::DownKeys(float progress)
|
||||||
|
|
||||||
void CAutoSafe::DeleteKeys()
|
void CAutoSafe::DeleteKeys()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector cPos = m_object->GetPosition(0);
|
||||||
Math::Vector cPos, oPos;
|
|
||||||
ObjectType oType;
|
|
||||||
float dist;
|
|
||||||
bool bDelete;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
|
||||||
|
|
||||||
|
bool haveDeleted = false;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
bDelete = false;
|
haveDeleted = false;
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
oType = pObj->GetType();
|
ObjectType oType = obj->GetType();
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( obj->GetTruck() != nullptr ) continue;
|
||||||
|
|
||||||
if ( oType != OBJECT_KEYa &&
|
if ( oType != OBJECT_KEYa &&
|
||||||
oType != OBJECT_KEYb &&
|
oType != OBJECT_KEYb &&
|
||||||
oType != OBJECT_KEYc &&
|
oType != OBJECT_KEYc &&
|
||||||
oType != OBJECT_KEYd ) continue;
|
oType != OBJECT_KEYd ) continue;
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
dist = Math::DistanceProjected(oPos, cPos);
|
float dist = Math::DistanceProjected(oPos, cPos);
|
||||||
if ( dist > 20.0f ) continue;
|
if ( dist > 20.0f ) continue;
|
||||||
|
|
||||||
pObj->DeleteObject();
|
CObjectManager::GetInstancePointer()->DeleteObject(obj);
|
||||||
delete pObj;
|
|
||||||
bDelete = true;
|
haveDeleted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ( bDelete );
|
while ( haveDeleted );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Seeking a vehicle in the safe.
|
// Seeking a vehicle in the safe.
|
||||||
|
@ -580,9 +572,9 @@ CObject* CAutoSafe::SearchVehicle()
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
cPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( pObj == m_object ) continue;
|
if ( pObj == m_object ) continue;
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( pObj->GetTruck() != 0 ) continue;
|
||||||
|
|
|
@ -247,10 +247,10 @@ CObject* CAutoStation::SearchVehicle()
|
||||||
float dist;
|
float dist;
|
||||||
|
|
||||||
sPos = m_object->GetPosition(0);
|
sPos = m_object->GetPosition(0);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type != OBJECT_HUMAN &&
|
if ( type != OBJECT_HUMAN &&
|
||||||
|
|
|
@ -277,9 +277,9 @@ CObject* CAutoTower::SearchTarget(Math::Vector &impact)
|
||||||
iPos = m_object->GetPosition(0);
|
iPos = m_object->GetPosition(0);
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
oType = pObj->GetType();
|
oType = pObj->GetType();
|
||||||
if ( oType != OBJECT_MOTHER &&
|
if ( oType != OBJECT_MOTHER &&
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "graphics/core/color.h"
|
#include "graphics/core/color.h"
|
||||||
#include "graphics/engine/terrain.h"
|
#include "graphics/engine/terrain.h"
|
||||||
|
|
||||||
|
#include "object/object_manager.h"
|
||||||
#include "object/motion/motion.h"
|
#include "object/motion/motion.h"
|
||||||
#include "object/task/taskmanager.h"
|
#include "object/task/taskmanager.h"
|
||||||
#include "object/level/parserline.h"
|
#include "object/level/parserline.h"
|
||||||
|
@ -130,7 +131,7 @@ CBrain::~CBrain()
|
||||||
|
|
||||||
// Destroys the object.
|
// Destroys the object.
|
||||||
|
|
||||||
void CBrain::DeleteObject(bool bAll)
|
void CBrain::DeleteObject(bool all)
|
||||||
{
|
{
|
||||||
if ( m_soundChannelAlarm != -1 )
|
if ( m_soundChannelAlarm != -1 )
|
||||||
{
|
{
|
||||||
|
@ -139,13 +140,12 @@ void CBrain::DeleteObject(bool bAll)
|
||||||
m_soundChannelAlarm = -1;
|
m_soundChannelAlarm = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !bAll )
|
if ( !all )
|
||||||
{
|
{
|
||||||
if ( m_beeBullet != 0 )
|
if ( m_beeBullet != nullptr )
|
||||||
{
|
{
|
||||||
m_beeBullet->DeleteObject();
|
CObjectManager::GetInstancePointer()->DeleteObject(m_beeBullet);
|
||||||
delete m_beeBullet;
|
m_beeBullet = nullptr;
|
||||||
m_beeBullet = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
#include "object/brain.h"
|
#include "object/brain.h"
|
||||||
|
#include "object/object_manager.h"
|
||||||
|
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
|
||||||
|
@ -94,7 +95,6 @@ void CMotionVehicle::DeleteObject(bool bAll)
|
||||||
void CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
|
void CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
float power, Gfx::CModelManager* modelManager)
|
float power, Gfx::CModelManager* modelManager)
|
||||||
{
|
{
|
||||||
CObject* pPower;
|
|
||||||
int rank, i, j, parent;
|
int rank, i, j, parent;
|
||||||
Gfx::Color color;
|
Gfx::Color color;
|
||||||
char name[50];
|
char name[50];
|
||||||
|
@ -925,27 +925,20 @@ void CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
color.a = 0.0f;
|
color.a = 0.0f;
|
||||||
m_object->CreateEffectLight(20.0f, color);
|
m_object->CreateEffectLight(20.0f, color);
|
||||||
|
|
||||||
// Creates the battery.
|
CObject* powerCell = nullptr;
|
||||||
pPower = new CObject();
|
Math::Vector powerCellPos = m_object->GetCharacter()->posPower;
|
||||||
pPower->SetType(power<=1.0f?OBJECT_POWER:OBJECT_ATOMIC);
|
float powerCellAngle = 0.0f;
|
||||||
|
if (power <= 1.0f)
|
||||||
|
{
|
||||||
|
powerCell = CObjectManager::GetInstancePointer()->CreateObject(powerCellPos, powerCellAngle, OBJECT_POWER, power);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
powerCell = CObjectManager::GetInstancePointer()->CreateObject(powerCellPos, powerCellAngle, OBJECT_ATOMIC, power / 100.0f);
|
||||||
|
}
|
||||||
|
|
||||||
rank = m_engine->CreateObject();
|
powerCell->SetTruck(m_object);
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
|
m_object->SetPower(powerCell);
|
||||||
pPower->SetObjectRank(0, rank);
|
|
||||||
pPower->CreateShadowCircle(1.5f, 1.0f); //create a shadow for battary
|
|
||||||
|
|
||||||
if ( power <= 1.0f ) modelManager->AddModelCopy("power.mod", false, rank);
|
|
||||||
else modelManager->AddModelCopy("atomic.mod", false, rank);
|
|
||||||
|
|
||||||
pPower->SetPosition(0, m_object->GetCharacter()->posPower);
|
|
||||||
pPower->CreateCrashSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f);
|
|
||||||
pPower->SetGlobalSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.5f);
|
|
||||||
|
|
||||||
pPower->SetTruck(m_object);
|
|
||||||
m_object->SetPower(pPower);
|
|
||||||
|
|
||||||
if ( power <= 1.0f ) pPower->SetEnergy(power);
|
|
||||||
else pPower->SetEnergy(power/100.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = m_object->GetPosition(0);
|
pos = m_object->GetPosition(0);
|
||||||
|
|
|
@ -189,7 +189,8 @@ void uObject(CBotVar* botThis, void* user)
|
||||||
|
|
||||||
// Object's constructor.
|
// Object's constructor.
|
||||||
|
|
||||||
CObject::CObject()
|
CObject::CObject(int id)
|
||||||
|
: m_id(id)
|
||||||
{
|
{
|
||||||
m_app = CApplication::GetInstancePointer();
|
m_app = CApplication::GetInstancePointer();
|
||||||
m_sound = m_app->GetSound();
|
m_sound = m_app->GetSound();
|
||||||
|
@ -207,7 +208,6 @@ CObject::CObject()
|
||||||
m_runScript = nullptr;
|
m_runScript = nullptr;
|
||||||
|
|
||||||
m_type = OBJECT_FIX;
|
m_type = OBJECT_FIX;
|
||||||
m_id = ++g_id;
|
|
||||||
m_option = 0;
|
m_option = 0;
|
||||||
m_name[0] = 0;
|
m_name[0] = 0;
|
||||||
m_partiReactor = -1;
|
m_partiReactor = -1;
|
||||||
|
@ -315,8 +315,6 @@ CObject::CObject()
|
||||||
m_botVar = CBotVar::Create("", CBotTypResult(CBotTypClass, "object"));
|
m_botVar = CBotVar::Create("", CBotTypResult(CBotTypClass, "object"));
|
||||||
m_botVar->SetUserPtr(this);
|
m_botVar->SetUserPtr(this);
|
||||||
m_botVar->SetIdent(m_id);
|
m_botVar->SetIdent(m_id);
|
||||||
|
|
||||||
CObjectManager::GetInstancePointer()->AddObject(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Object's destructor.
|
// Object's destructor.
|
||||||
|
@ -338,8 +336,6 @@ CObject::~CObject()
|
||||||
m_motion = nullptr;
|
m_motion = nullptr;
|
||||||
delete m_auto;
|
delete m_auto;
|
||||||
m_auto = nullptr;
|
m_auto = nullptr;
|
||||||
|
|
||||||
CObjectManager::GetInstancePointer()->DeleteObject(this);
|
|
||||||
|
|
||||||
m_app = nullptr;
|
m_app = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -353,7 +349,6 @@ void CObject::DeleteObject(bool bAll)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
CObject* pObj;
|
||||||
Gfx::CPyro* pPyro;
|
Gfx::CPyro* pPyro;
|
||||||
|
|
||||||
if ( m_botVar != 0 )
|
if ( m_botVar != 0 )
|
||||||
{
|
{
|
||||||
m_botVar->SetUserPtr(OBJECTDELETED);
|
m_botVar->SetUserPtr(OBJECTDELETED);
|
||||||
|
@ -363,12 +358,13 @@ void CObject::DeleteObject(bool bAll)
|
||||||
{
|
{
|
||||||
m_camera->SetControllingObject(0);
|
m_camera->SetControllingObject(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
pObj->DeleteDeselList(this);
|
pObj->DeleteDeselList(this);
|
||||||
}
|
}
|
||||||
|
@ -943,19 +939,6 @@ int CObject::GetOption()
|
||||||
return m_option;
|
return m_option;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Management of the unique identifier of an object.
|
|
||||||
|
|
||||||
void CObject::SetID(int id)
|
|
||||||
{
|
|
||||||
m_id = id;
|
|
||||||
|
|
||||||
if ( m_botVar != 0 )
|
|
||||||
{
|
|
||||||
m_botVar->SetIdent(m_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int CObject::GetID()
|
int CObject::GetID()
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_id;
|
||||||
|
|
|
@ -135,11 +135,18 @@ enum ResetCap
|
||||||
|
|
||||||
class CObject
|
class CObject
|
||||||
{
|
{
|
||||||
|
friend class CObjectFactory;
|
||||||
|
friend class CObjectManager;
|
||||||
|
protected:
|
||||||
|
CObject(int id);
|
||||||
|
void DeleteObject(bool bAll=false);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CObject();
|
CObject(const CObject&) = delete;
|
||||||
|
CObject& operator=(const CObject&) = delete;
|
||||||
|
|
||||||
~CObject();
|
~CObject();
|
||||||
|
|
||||||
void DeleteObject(bool bAll=false);
|
|
||||||
void Simplify();
|
void Simplify();
|
||||||
bool ExploObject(ExploType type, float force, float decay=1.0f);
|
bool ExploObject(ExploType type, float force, float decay=1.0f);
|
||||||
|
|
||||||
|
@ -157,7 +164,6 @@ public:
|
||||||
void SetOption(int option);
|
void SetOption(int option);
|
||||||
int GetOption();
|
int GetOption();
|
||||||
|
|
||||||
void SetID(int id);
|
|
||||||
int GetID();
|
int GetID();
|
||||||
|
|
||||||
bool Write(CLevelParserLine* line);
|
bool Write(CLevelParserLine* line);
|
||||||
|
@ -446,7 +452,7 @@ protected:
|
||||||
CScript* m_runScript;
|
CScript* m_runScript;
|
||||||
|
|
||||||
ObjectType m_type; // OBJECT_*
|
ObjectType m_type; // OBJECT_*
|
||||||
int m_id; // unique identifier
|
const int m_id; // unique identifier
|
||||||
char m_name[50]; // name of the object
|
char m_name[50]; // name of the object
|
||||||
Character m_character; // characteristic
|
Character m_character; // characteristic
|
||||||
int m_option; // option
|
int m_option; // option
|
||||||
|
|
|
@ -77,11 +77,9 @@ CObjectFactory::CObjectFactory(Gfx::CEngine* engine,
|
||||||
, m_main(main)
|
, m_main(main)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CObject* CObjectFactory::CreateObject(Math::Vector pos, float angle, ObjectType type,
|
CObjectUPtr CObjectFactory::CreateObject(const ObjectCreateParams& params)
|
||||||
float power, float zoom, float height,
|
|
||||||
bool trainer, bool toy, int option)
|
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (params.type)
|
||||||
{
|
{
|
||||||
case OBJECT_NULL:
|
case OBJECT_NULL:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -109,7 +107,7 @@ CObject* CObjectFactory::CreateObject(Math::Vector pos, float angle, ObjectType
|
||||||
case OBJECT_TARGET2:
|
case OBJECT_TARGET2:
|
||||||
case OBJECT_START:
|
case OBJECT_START:
|
||||||
case OBJECT_END:
|
case OBJECT_END:
|
||||||
return CreateBuilding(pos, angle, height, type, power);
|
return CreateBuilding(params);
|
||||||
|
|
||||||
case OBJECT_FRET:
|
case OBJECT_FRET:
|
||||||
case OBJECT_STONE:
|
case OBJECT_STONE:
|
||||||
|
@ -142,20 +140,20 @@ CObject* CObjectFactory::CreateObject(Math::Vector pos, float angle, ObjectType
|
||||||
case OBJECT_MARKKEYc:
|
case OBJECT_MARKKEYc:
|
||||||
case OBJECT_MARKKEYd:
|
case OBJECT_MARKKEYd:
|
||||||
case OBJECT_EGG:
|
case OBJECT_EGG:
|
||||||
return CreateResource(pos, angle, type, power);
|
return CreateResource(params);
|
||||||
|
|
||||||
case OBJECT_FLAGb:
|
case OBJECT_FLAGb:
|
||||||
case OBJECT_FLAGr:
|
case OBJECT_FLAGr:
|
||||||
case OBJECT_FLAGg:
|
case OBJECT_FLAGg:
|
||||||
case OBJECT_FLAGy:
|
case OBJECT_FLAGy:
|
||||||
case OBJECT_FLAGv:
|
case OBJECT_FLAGv:
|
||||||
return CreateFlag(pos, angle, type);
|
return CreateFlag(params);
|
||||||
|
|
||||||
case OBJECT_BARRIER0:
|
case OBJECT_BARRIER0:
|
||||||
case OBJECT_BARRIER1:
|
case OBJECT_BARRIER1:
|
||||||
case OBJECT_BARRIER2:
|
case OBJECT_BARRIER2:
|
||||||
case OBJECT_BARRIER3:
|
case OBJECT_BARRIER3:
|
||||||
return CreateBarrier(pos, angle, height, type);
|
return CreateBarrier(params);
|
||||||
|
|
||||||
case OBJECT_PLANT0:
|
case OBJECT_PLANT0:
|
||||||
case OBJECT_PLANT1:
|
case OBJECT_PLANT1:
|
||||||
|
@ -183,11 +181,11 @@ CObject* CObjectFactory::CreateObject(Math::Vector pos, float angle, ObjectType
|
||||||
case OBJECT_TREE3:
|
case OBJECT_TREE3:
|
||||||
case OBJECT_TREE4:
|
case OBJECT_TREE4:
|
||||||
case OBJECT_TREE5:
|
case OBJECT_TREE5:
|
||||||
return CreatePlant(pos, angle, height, type);
|
return CreatePlant(params);
|
||||||
|
|
||||||
case OBJECT_MUSHROOM1:
|
case OBJECT_MUSHROOM1:
|
||||||
case OBJECT_MUSHROOM2:
|
case OBJECT_MUSHROOM2:
|
||||||
return CreateMushroom(pos, angle, height, type);
|
return CreateMushroom(params);
|
||||||
|
|
||||||
case OBJECT_TEEN0:
|
case OBJECT_TEEN0:
|
||||||
case OBJECT_TEEN1:
|
case OBJECT_TEEN1:
|
||||||
|
@ -234,13 +232,13 @@ CObject* CObjectFactory::CreateObject(Math::Vector pos, float angle, ObjectType
|
||||||
case OBJECT_TEEN42:
|
case OBJECT_TEEN42:
|
||||||
case OBJECT_TEEN43:
|
case OBJECT_TEEN43:
|
||||||
case OBJECT_TEEN44:
|
case OBJECT_TEEN44:
|
||||||
return CreateTeen(pos, angle, zoom, height, type, option);
|
return CreateTeen(params);
|
||||||
|
|
||||||
case OBJECT_QUARTZ0:
|
case OBJECT_QUARTZ0:
|
||||||
case OBJECT_QUARTZ1:
|
case OBJECT_QUARTZ1:
|
||||||
case OBJECT_QUARTZ2:
|
case OBJECT_QUARTZ2:
|
||||||
case OBJECT_QUARTZ3:
|
case OBJECT_QUARTZ3:
|
||||||
return CreateQuartz(pos, angle, height, type);
|
return CreateQuartz(params);
|
||||||
|
|
||||||
case OBJECT_ROOT0:
|
case OBJECT_ROOT0:
|
||||||
case OBJECT_ROOT1:
|
case OBJECT_ROOT1:
|
||||||
|
@ -248,10 +246,10 @@ CObject* CObjectFactory::CreateObject(Math::Vector pos, float angle, ObjectType
|
||||||
case OBJECT_ROOT3:
|
case OBJECT_ROOT3:
|
||||||
case OBJECT_ROOT4:
|
case OBJECT_ROOT4:
|
||||||
case OBJECT_ROOT5:
|
case OBJECT_ROOT5:
|
||||||
return CreateRoot(pos, angle, height, type);
|
return CreateRoot(params);
|
||||||
|
|
||||||
case OBJECT_HOME1:
|
case OBJECT_HOME1:
|
||||||
return CreateHome(pos, angle, height, type);
|
return CreateHome(params);
|
||||||
|
|
||||||
case OBJECT_RUINmobilew1:
|
case OBJECT_RUINmobilew1:
|
||||||
case OBJECT_RUINmobilew2:
|
case OBJECT_RUINmobilew2:
|
||||||
|
@ -266,20 +264,20 @@ CObject* CObjectFactory::CreateObject(Math::Vector pos, float angle, ObjectType
|
||||||
case OBJECT_RUINconvert:
|
case OBJECT_RUINconvert:
|
||||||
case OBJECT_RUINbase:
|
case OBJECT_RUINbase:
|
||||||
case OBJECT_RUINhead:
|
case OBJECT_RUINhead:
|
||||||
return CreateRuin(pos, angle, height, type);
|
return CreateRuin(params);
|
||||||
|
|
||||||
case OBJECT_APOLLO1:
|
case OBJECT_APOLLO1:
|
||||||
case OBJECT_APOLLO3:
|
case OBJECT_APOLLO3:
|
||||||
case OBJECT_APOLLO4:
|
case OBJECT_APOLLO4:
|
||||||
case OBJECT_APOLLO5:
|
case OBJECT_APOLLO5:
|
||||||
return CreateApollo(pos, angle, type);
|
return CreateApollo(params);
|
||||||
|
|
||||||
case OBJECT_MOTHER:
|
case OBJECT_MOTHER:
|
||||||
case OBJECT_ANT:
|
case OBJECT_ANT:
|
||||||
case OBJECT_SPIDER:
|
case OBJECT_SPIDER:
|
||||||
case OBJECT_BEE:
|
case OBJECT_BEE:
|
||||||
case OBJECT_WORM:
|
case OBJECT_WORM:
|
||||||
return CreateInsect(pos, angle, type); // no eggs
|
return CreateInsect(params); // no eggs
|
||||||
|
|
||||||
case OBJECT_HUMAN:
|
case OBJECT_HUMAN:
|
||||||
case OBJECT_TECH:
|
case OBJECT_TECH:
|
||||||
|
@ -312,7 +310,7 @@ CObject* CObjectFactory::CreateObject(Math::Vector pos, float angle, ObjectType
|
||||||
case OBJECT_MOBILEit:
|
case OBJECT_MOBILEit:
|
||||||
case OBJECT_MOBILEdr:
|
case OBJECT_MOBILEdr:
|
||||||
case OBJECT_APOLLO2:
|
case OBJECT_APOLLO2:
|
||||||
return CreateVehicle(pos, angle, type, power, trainer, toy, option);
|
return CreateVehicle(params);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -323,9 +321,15 @@ CObject* CObjectFactory::CreateObject(Math::Vector pos, float angle, ObjectType
|
||||||
|
|
||||||
// Creates a building laying on the ground.
|
// Creates a building laying on the ground.
|
||||||
|
|
||||||
CObject* CObjectFactory::CreateBuilding(Math::Vector pos, float angle, float height, ObjectType type, float power)
|
CObjectUPtr CObjectFactory::CreateBuilding(const ObjectCreateParams& params)
|
||||||
{
|
{
|
||||||
CObject* obj = new CObject();
|
Math::Vector pos = params.pos;
|
||||||
|
float angle = params.angle;
|
||||||
|
float height = params.height;
|
||||||
|
ObjectType type = params.type;
|
||||||
|
float power = params.power;
|
||||||
|
|
||||||
|
CObjectUPtr obj(new CObject(params.id));
|
||||||
|
|
||||||
obj->SetType(type);
|
obj->SetType(type);
|
||||||
|
|
||||||
|
@ -1124,7 +1128,7 @@ CObject* CObjectFactory::CreateBuilding(Math::Vector pos, float angle, float hei
|
||||||
pPower->obj->CreateCrashSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f);
|
pPower->obj->CreateCrashSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f);
|
||||||
pPower->obj->SetGlobalSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.5f);
|
pPower->obj->SetGlobalSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.5f);
|
||||||
|
|
||||||
pPower->SetTruck(obj);
|
pPower->SetTruck(obj.get());
|
||||||
SetPower(pPower);
|
SetPower(pPower);
|
||||||
|
|
||||||
if ( power <= 1.0f ) pPower->obj->SetEnergy(power);
|
if ( power <= 1.0f ) pPower->obj->SetEnergy(power);
|
||||||
|
@ -1136,7 +1140,7 @@ CObject* CObjectFactory::CreateBuilding(Math::Vector pos, float angle, float hei
|
||||||
pos.y += height;
|
pos.y += height;
|
||||||
obj->SetPosition(0, pos); // to display the shadows immediately
|
obj->SetPosition(0, pos); // to display the shadows immediately
|
||||||
|
|
||||||
AddObjectAuto(obj);
|
AddObjectAuto(obj.get());
|
||||||
m_engine->LoadAllTextures();
|
m_engine->LoadAllTextures();
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -1144,9 +1148,14 @@ CObject* CObjectFactory::CreateBuilding(Math::Vector pos, float angle, float hei
|
||||||
|
|
||||||
// Creates a small resource set on the ground.
|
// Creates a small resource set on the ground.
|
||||||
|
|
||||||
CObject* CObjectFactory::CreateResource(Math::Vector pos, float angle, ObjectType type, float power)
|
CObjectUPtr CObjectFactory::CreateResource(const ObjectCreateParams& params)
|
||||||
{
|
{
|
||||||
CObject* obj = new CObject();
|
Math::Vector pos = params.pos;
|
||||||
|
float angle = params.angle;
|
||||||
|
ObjectType type = params.type;
|
||||||
|
float power = params.power;
|
||||||
|
|
||||||
|
CObjectUPtr obj(new CObject(params.id));
|
||||||
|
|
||||||
obj->SetType(type);
|
obj->SetType(type);
|
||||||
|
|
||||||
|
@ -1242,10 +1251,11 @@ CObject* CObjectFactory::CreateResource(Math::Vector pos, float angle, ObjectTyp
|
||||||
obj->CreateCrashSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f);
|
obj->CreateCrashSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f);
|
||||||
obj->SetGlobalSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.5f);
|
obj->SetGlobalSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
obj->CreateShadowCircle(radius, 1.0f);
|
obj->CreateShadowCircle(radius, 1.0f);
|
||||||
|
|
||||||
obj->SetFloorHeight(0.0f);
|
obj->SetFloorHeight(0.0f);
|
||||||
AddObjectAuto(obj);
|
AddObjectAuto(obj.get());
|
||||||
m_engine->LoadAllTextures();
|
m_engine->LoadAllTextures();
|
||||||
obj->FloorAdjust();
|
obj->FloorAdjust();
|
||||||
|
|
||||||
|
@ -1258,9 +1268,13 @@ CObject* CObjectFactory::CreateResource(Math::Vector pos, float angle, ObjectTyp
|
||||||
|
|
||||||
// Creates a flag placed on the ground.
|
// Creates a flag placed on the ground.
|
||||||
|
|
||||||
CObject* CObjectFactory::CreateFlag(Math::Vector pos, float angle, ObjectType type)
|
CObjectUPtr CObjectFactory::CreateFlag(const ObjectCreateParams& params)
|
||||||
{
|
{
|
||||||
CObject* obj = new CObject();
|
Math::Vector pos = params.pos;
|
||||||
|
float angle = params.angle;
|
||||||
|
ObjectType type = params.type;
|
||||||
|
|
||||||
|
CObjectUPtr obj(new CObject(params.id));
|
||||||
|
|
||||||
obj->SetType(type);
|
obj->SetType(type);
|
||||||
|
|
||||||
|
@ -1302,7 +1316,7 @@ CObject* CObjectFactory::CreateFlag(Math::Vector pos, float angle, ObjectType ty
|
||||||
obj->CreateShadowCircle(2.0f, 0.3f);
|
obj->CreateShadowCircle(2.0f, 0.3f);
|
||||||
|
|
||||||
obj->SetFloorHeight(0.0f);
|
obj->SetFloorHeight(0.0f);
|
||||||
AddObjectAuto(obj);
|
AddObjectAuto(obj.get());
|
||||||
m_engine->LoadAllTextures();
|
m_engine->LoadAllTextures();
|
||||||
obj->FloorAdjust();
|
obj->FloorAdjust();
|
||||||
|
|
||||||
|
@ -1314,9 +1328,14 @@ CObject* CObjectFactory::CreateFlag(Math::Vector pos, float angle, ObjectType ty
|
||||||
|
|
||||||
// Creates a barrier placed on the ground.
|
// Creates a barrier placed on the ground.
|
||||||
|
|
||||||
CObject* CObjectFactory::CreateBarrier(Math::Vector pos, float angle, float height, ObjectType type)
|
CObjectUPtr CObjectFactory::CreateBarrier(const ObjectCreateParams& params)
|
||||||
{
|
{
|
||||||
CObject* obj = new CObject();
|
Math::Vector pos = params.pos;
|
||||||
|
float angle = params.angle;
|
||||||
|
float height = params.height;
|
||||||
|
ObjectType type = params.type;
|
||||||
|
|
||||||
|
CObjectUPtr obj(new CObject(params.id));
|
||||||
|
|
||||||
obj->SetType(type);
|
obj->SetType(type);
|
||||||
|
|
||||||
|
@ -1394,7 +1413,7 @@ CObject* CObjectFactory::CreateBarrier(Math::Vector pos, float angle, float heig
|
||||||
obj->SetPosition(0, pos); // to display the shadows immediately
|
obj->SetPosition(0, pos); // to display the shadows immediately
|
||||||
|
|
||||||
obj->SetFloorHeight(0.0f);
|
obj->SetFloorHeight(0.0f);
|
||||||
AddObjectAuto(obj);
|
AddObjectAuto(obj.get());
|
||||||
obj->FloorAdjust();
|
obj->FloorAdjust();
|
||||||
|
|
||||||
pos = obj->GetPosition(0);
|
pos = obj->GetPosition(0);
|
||||||
|
@ -1406,9 +1425,14 @@ CObject* CObjectFactory::CreateBarrier(Math::Vector pos, float angle, float heig
|
||||||
|
|
||||||
// Creates a plant placed on the ground.
|
// Creates a plant placed on the ground.
|
||||||
|
|
||||||
CObject* CObjectFactory::CreatePlant(Math::Vector pos, float angle, float height, ObjectType type)
|
CObjectUPtr CObjectFactory::CreatePlant(const ObjectCreateParams& params)
|
||||||
{
|
{
|
||||||
CObject* obj = new CObject();
|
Math::Vector pos = params.pos;
|
||||||
|
float angle = params.angle;
|
||||||
|
float height = params.height;
|
||||||
|
ObjectType type = params.type;
|
||||||
|
|
||||||
|
CObjectUPtr obj(new CObject(params.id));
|
||||||
|
|
||||||
obj->SetType(type);
|
obj->SetType(type);
|
||||||
|
|
||||||
|
@ -1631,7 +1655,7 @@ CObject* CObjectFactory::CreatePlant(Math::Vector pos, float angle, float height
|
||||||
obj->SetPosition(0, pos); // to display the shadows immediately
|
obj->SetPosition(0, pos); // to display the shadows immediately
|
||||||
|
|
||||||
obj->SetFloorHeight(0.0f);
|
obj->SetFloorHeight(0.0f);
|
||||||
AddObjectAuto(obj);
|
AddObjectAuto(obj.get());
|
||||||
|
|
||||||
pos = obj->GetPosition(0);
|
pos = obj->GetPosition(0);
|
||||||
pos.y += height;
|
pos.y += height;
|
||||||
|
@ -1642,9 +1666,14 @@ CObject* CObjectFactory::CreatePlant(Math::Vector pos, float angle, float height
|
||||||
|
|
||||||
// Creates a mushroom placed on the ground.
|
// Creates a mushroom placed on the ground.
|
||||||
|
|
||||||
CObject* CObjectFactory::CreateMushroom(Math::Vector pos, float angle, float height, ObjectType type)
|
CObjectUPtr CObjectFactory::CreateMushroom(const ObjectCreateParams& params)
|
||||||
{
|
{
|
||||||
CObject* obj = new CObject();
|
Math::Vector pos = params.pos;
|
||||||
|
float angle = params.angle;
|
||||||
|
float height = params.height;
|
||||||
|
ObjectType type = params.type;
|
||||||
|
|
||||||
|
CObjectUPtr obj(new CObject(params.id));
|
||||||
|
|
||||||
obj->SetType(type);
|
obj->SetType(type);
|
||||||
|
|
||||||
|
@ -1684,7 +1713,7 @@ CObject* CObjectFactory::CreateMushroom(Math::Vector pos, float angle, float hei
|
||||||
obj->SetPosition(0, pos); // to display the shadows immediately
|
obj->SetPosition(0, pos); // to display the shadows immediately
|
||||||
|
|
||||||
obj->SetFloorHeight(0.0f);
|
obj->SetFloorHeight(0.0f);
|
||||||
AddObjectAuto(obj);
|
AddObjectAuto(obj.get());
|
||||||
|
|
||||||
pos = obj->GetPosition(0);
|
pos = obj->GetPosition(0);
|
||||||
pos.y += height;
|
pos.y += height;
|
||||||
|
@ -1695,9 +1724,16 @@ CObject* CObjectFactory::CreateMushroom(Math::Vector pos, float angle, float hei
|
||||||
|
|
||||||
// Creates a toy placed on the ground.
|
// Creates a toy placed on the ground.
|
||||||
|
|
||||||
CObject* CObjectFactory::CreateTeen(Math::Vector pos, float angle, float zoom, float height, ObjectType type, int option)
|
CObjectUPtr CObjectFactory::CreateTeen(const ObjectCreateParams& params)
|
||||||
{
|
{
|
||||||
CObject* obj = new CObject();
|
Math::Vector pos = params.pos;
|
||||||
|
float angle = params.angle;
|
||||||
|
float zoom = params.zoom;
|
||||||
|
float height = params.height;
|
||||||
|
ObjectType type = params.type;
|
||||||
|
int option = params.option;
|
||||||
|
|
||||||
|
CObjectUPtr obj(new CObject(params.id));
|
||||||
|
|
||||||
obj->SetType(type);
|
obj->SetType(type);
|
||||||
obj->SetOption(option);
|
obj->SetOption(option);
|
||||||
|
@ -2511,7 +2547,7 @@ CObject* CObjectFactory::CreateTeen(Math::Vector pos, float angle, float zoom, f
|
||||||
obj->FloorAdjust();
|
obj->FloorAdjust();
|
||||||
}
|
}
|
||||||
|
|
||||||
AddObjectAuto(obj);
|
AddObjectAuto(obj.get());
|
||||||
|
|
||||||
pos = obj->GetPosition(0);
|
pos = obj->GetPosition(0);
|
||||||
pos.y += height;
|
pos.y += height;
|
||||||
|
@ -2522,9 +2558,14 @@ CObject* CObjectFactory::CreateTeen(Math::Vector pos, float angle, float zoom, f
|
||||||
|
|
||||||
// Creates a crystal placed on the ground.
|
// Creates a crystal placed on the ground.
|
||||||
|
|
||||||
CObject* CObjectFactory::CreateQuartz(Math::Vector pos, float angle, float height, ObjectType type)
|
CObjectUPtr CObjectFactory::CreateQuartz(const ObjectCreateParams& params)
|
||||||
{
|
{
|
||||||
CObject* obj = new CObject();
|
Math::Vector pos = params.pos;
|
||||||
|
float angle = params.angle;
|
||||||
|
float height = params.height;
|
||||||
|
ObjectType type = params.type;
|
||||||
|
|
||||||
|
CObjectUPtr obj(new CObject(params.id));
|
||||||
|
|
||||||
obj->SetType(type);
|
obj->SetType(type);
|
||||||
|
|
||||||
|
@ -2589,7 +2630,7 @@ CObject* CObjectFactory::CreateQuartz(Math::Vector pos, float angle, float heigh
|
||||||
obj->SetPosition(0, pos); // to display the shadows immediately
|
obj->SetPosition(0, pos); // to display the shadows immediately
|
||||||
|
|
||||||
obj->SetFloorHeight(0.0f);
|
obj->SetFloorHeight(0.0f);
|
||||||
AddObjectAuto(obj);
|
AddObjectAuto(obj.get());
|
||||||
|
|
||||||
pos = obj->GetPosition(0);
|
pos = obj->GetPosition(0);
|
||||||
pos.y += height;
|
pos.y += height;
|
||||||
|
@ -2623,10 +2664,14 @@ CObject* CObjectFactory::CreateQuartz(Math::Vector pos, float angle, float heigh
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a root placed on the ground.
|
// Creates a root placed on the ground.
|
||||||
|
CObjectUPtr CObjectFactory::CreateRoot(const ObjectCreateParams& params)
|
||||||
CObject* CObjectFactory::CreateRoot(Math::Vector pos, float angle, float height, ObjectType type)
|
|
||||||
{
|
{
|
||||||
CObject* obj = new CObject();
|
Math::Vector pos = params.pos;
|
||||||
|
float angle = params.angle;
|
||||||
|
float height = params.height;
|
||||||
|
ObjectType type = params.type;
|
||||||
|
|
||||||
|
CObjectUPtr obj(new CObject(params.id));
|
||||||
|
|
||||||
obj->SetType(type);
|
obj->SetType(type);
|
||||||
|
|
||||||
|
@ -2776,7 +2821,7 @@ CObject* CObjectFactory::CreateRoot(Math::Vector pos, float angle, float height,
|
||||||
obj->SetPosition(0, pos); // to display the shadows immediately
|
obj->SetPosition(0, pos); // to display the shadows immediately
|
||||||
|
|
||||||
obj->SetFloorHeight(0.0f);
|
obj->SetFloorHeight(0.0f);
|
||||||
AddObjectAuto(obj);
|
AddObjectAuto(obj.get());
|
||||||
|
|
||||||
pos = obj->GetPosition(0);
|
pos = obj->GetPosition(0);
|
||||||
pos.y += height;
|
pos.y += height;
|
||||||
|
@ -2786,10 +2831,14 @@ CObject* CObjectFactory::CreateRoot(Math::Vector pos, float angle, float height,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a small home.
|
// Creates a small home.
|
||||||
|
CObjectUPtr CObjectFactory::CreateHome(const ObjectCreateParams& params)
|
||||||
CObject* CObjectFactory::CreateHome(Math::Vector pos, float angle, float height, ObjectType type)
|
|
||||||
{
|
{
|
||||||
CObject* obj = new CObject();
|
Math::Vector pos = params.pos;
|
||||||
|
float angle = params.angle;
|
||||||
|
float height = params.height;
|
||||||
|
ObjectType type = params.type;
|
||||||
|
|
||||||
|
CObjectUPtr obj(new CObject(params.id));
|
||||||
|
|
||||||
obj->SetType(type);
|
obj->SetType(type);
|
||||||
|
|
||||||
|
@ -2812,7 +2861,7 @@ CObject* CObjectFactory::CreateHome(Math::Vector pos, float angle, float height,
|
||||||
obj->SetPosition(0, pos); // to display the shadows immediately
|
obj->SetPosition(0, pos); // to display the shadows immediately
|
||||||
|
|
||||||
obj->SetFloorHeight(0.0f);
|
obj->SetFloorHeight(0.0f);
|
||||||
AddObjectAuto(obj);
|
AddObjectAuto(obj.get());
|
||||||
|
|
||||||
pos = obj->GetPosition(0);
|
pos = obj->GetPosition(0);
|
||||||
pos.y += height;
|
pos.y += height;
|
||||||
|
@ -2822,10 +2871,14 @@ CObject* CObjectFactory::CreateHome(Math::Vector pos, float angle, float height,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates ruin placed on the ground.
|
// Creates ruin placed on the ground.
|
||||||
|
CObjectUPtr CObjectFactory::CreateRuin(const ObjectCreateParams& params)
|
||||||
CObject* CObjectFactory::CreateRuin(Math::Vector pos, float angle, float height, ObjectType type)
|
|
||||||
{
|
{
|
||||||
CObject* obj = new CObject();
|
Math::Vector pos = params.pos;
|
||||||
|
float angle = params.angle;
|
||||||
|
float height = params.height;
|
||||||
|
ObjectType type = params.type;
|
||||||
|
|
||||||
|
CObjectUPtr obj(new CObject(params.id));
|
||||||
|
|
||||||
obj->SetType(type);
|
obj->SetType(type);
|
||||||
|
|
||||||
|
@ -3078,7 +3131,7 @@ CObject* CObjectFactory::CreateRuin(Math::Vector pos, float angle, float height,
|
||||||
obj->SetPosition(0, pos); //to display the shadows immediately
|
obj->SetPosition(0, pos); //to display the shadows immediately
|
||||||
|
|
||||||
obj->SetFloorHeight(0.0f);
|
obj->SetFloorHeight(0.0f);
|
||||||
AddObjectAuto(obj);
|
AddObjectAuto(obj.get());
|
||||||
|
|
||||||
if ( type != OBJECT_RUINfactory &&
|
if ( type != OBJECT_RUINfactory &&
|
||||||
type != OBJECT_RUINconvert &&
|
type != OBJECT_RUINconvert &&
|
||||||
|
@ -3234,9 +3287,13 @@ CObject* CObjectFactory::CreateRuin(Math::Vector pos, float angle, float height,
|
||||||
|
|
||||||
// Creates a gadget apollo.
|
// Creates a gadget apollo.
|
||||||
|
|
||||||
CObject* CObjectFactory::CreateApollo(Math::Vector pos, float angle, ObjectType type)
|
CObjectUPtr CObjectFactory::CreateApollo(const ObjectCreateParams& params)
|
||||||
{
|
{
|
||||||
CObject* obj = new CObject();
|
Math::Vector pos = params.pos;
|
||||||
|
float angle = params.angle;
|
||||||
|
ObjectType type = params.type;
|
||||||
|
|
||||||
|
CObjectUPtr obj(new CObject(params.id));
|
||||||
|
|
||||||
obj->SetType(type);
|
obj->SetType(type);
|
||||||
|
|
||||||
|
@ -3399,7 +3456,7 @@ CObject* CObjectFactory::CreateApollo(Math::Vector pos, float angle, ObjectType
|
||||||
obj->CreateShadowCircle(3.0f, 0.7f);
|
obj->CreateShadowCircle(3.0f, 0.7f);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddObjectAuto(obj);
|
AddObjectAuto(obj.get());
|
||||||
|
|
||||||
pos = obj->GetPosition(0);
|
pos = obj->GetPosition(0);
|
||||||
obj->SetPosition(0, pos); // to display the shadows immediately
|
obj->SetPosition(0, pos); // to display the shadows immediately
|
||||||
|
@ -3409,16 +3466,24 @@ CObject* CObjectFactory::CreateApollo(Math::Vector pos, float angle, ObjectType
|
||||||
|
|
||||||
// Creates a vehicle traveling any pose on the floor.
|
// Creates a vehicle traveling any pose on the floor.
|
||||||
|
|
||||||
CObject* CObjectFactory::CreateVehicle(Math::Vector pos, float angle, ObjectType type, float power, bool trainer, bool toy, int option)
|
CObjectUPtr CObjectFactory::CreateVehicle(const ObjectCreateParams& params)
|
||||||
{
|
{
|
||||||
CObject* obj = new CObject();
|
Math::Vector pos = params.pos;
|
||||||
|
float angle = params.angle;
|
||||||
|
ObjectType type = params.type;
|
||||||
|
float power = params.power;
|
||||||
|
bool trainer = params.trainer;
|
||||||
|
bool toy = params.toy;
|
||||||
|
int option = params.option;
|
||||||
|
|
||||||
|
CObjectUPtr obj(new CObject(params.id));
|
||||||
|
|
||||||
obj->SetType(type);
|
obj->SetType(type);
|
||||||
obj->SetOption(option);
|
obj->SetOption(option);
|
||||||
|
|
||||||
if ( type == OBJECT_TOTO )
|
if ( type == OBJECT_TOTO )
|
||||||
{
|
{
|
||||||
CMotion* motion = new CMotionToto(obj);
|
CMotion* motion = new CMotionToto(obj.get());
|
||||||
motion->Create(pos, angle, type, 1.0f, m_modelManager);
|
motion->Create(pos, angle, type, 1.0f, m_modelManager);
|
||||||
obj->SetMotion(motion);
|
obj->SetMotion(motion);
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -3436,8 +3501,8 @@ CObject* CObjectFactory::CreateVehicle(Math::Vector pos, float angle, ObjectType
|
||||||
|
|
||||||
obj->SetToy(toy);
|
obj->SetToy(toy);
|
||||||
|
|
||||||
CPhysics* physics = new CPhysics(obj);
|
CPhysics* physics = new CPhysics(obj.get());
|
||||||
CBrain* brain = new CBrain(obj);
|
CBrain* brain = new CBrain(obj.get());
|
||||||
|
|
||||||
physics->SetBrain(brain);
|
physics->SetBrain(brain);
|
||||||
brain->SetPhysics(physics);
|
brain->SetPhysics(physics);
|
||||||
|
@ -3481,15 +3546,15 @@ CObject* CObjectFactory::CreateVehicle(Math::Vector pos, float angle, ObjectType
|
||||||
if ( type == OBJECT_HUMAN ||
|
if ( type == OBJECT_HUMAN ||
|
||||||
type == OBJECT_TECH )
|
type == OBJECT_TECH )
|
||||||
{
|
{
|
||||||
motion = new CMotionHuman(obj);
|
motion = new CMotionHuman(obj.get());
|
||||||
}
|
}
|
||||||
else if ( type == OBJECT_CONTROLLER )
|
else if ( type == OBJECT_CONTROLLER )
|
||||||
{
|
{
|
||||||
motion = new CMotionDummy(obj); //dummy object
|
motion = new CMotionDummy(obj.get()); //dummy object
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
motion = new CMotionVehicle(obj);
|
motion = new CMotionVehicle(obj.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
physics->SetMotion(motion);
|
physics->SetMotion(motion);
|
||||||
|
@ -3505,14 +3570,18 @@ CObject* CObjectFactory::CreateVehicle(Math::Vector pos, float angle, ObjectType
|
||||||
|
|
||||||
// Creates an insect lands on any ground.
|
// Creates an insect lands on any ground.
|
||||||
|
|
||||||
CObject* CObjectFactory::CreateInsect(Math::Vector pos, float angle, ObjectType type)
|
CObjectUPtr CObjectFactory::CreateInsect(const ObjectCreateParams& params)
|
||||||
{
|
{
|
||||||
CObject* obj = new CObject();
|
Math::Vector pos = params.pos;
|
||||||
|
float angle = params.angle;
|
||||||
|
ObjectType type = params.type;
|
||||||
|
|
||||||
|
CObjectUPtr obj(new CObject(params.id));
|
||||||
|
|
||||||
obj->SetType(type);
|
obj->SetType(type);
|
||||||
|
|
||||||
CPhysics* physics = new CPhysics(obj);
|
CPhysics* physics = new CPhysics(obj.get());
|
||||||
CBrain* brain = new CBrain(obj);
|
CBrain* brain = new CBrain(obj.get());
|
||||||
|
|
||||||
physics->SetBrain(brain);
|
physics->SetBrain(brain);
|
||||||
brain->SetPhysics(physics);
|
brain->SetPhysics(physics);
|
||||||
|
@ -3523,23 +3592,23 @@ CObject* CObjectFactory::CreateInsect(Math::Vector pos, float angle, ObjectType
|
||||||
CMotion* motion = nullptr;
|
CMotion* motion = nullptr;
|
||||||
if ( type == OBJECT_MOTHER )
|
if ( type == OBJECT_MOTHER )
|
||||||
{
|
{
|
||||||
motion = new CMotionMother(obj);
|
motion = new CMotionMother(obj.get());
|
||||||
}
|
}
|
||||||
if ( type == OBJECT_ANT )
|
if ( type == OBJECT_ANT )
|
||||||
{
|
{
|
||||||
motion = new CMotionAnt(obj);
|
motion = new CMotionAnt(obj.get());
|
||||||
}
|
}
|
||||||
if ( type == OBJECT_SPIDER )
|
if ( type == OBJECT_SPIDER )
|
||||||
{
|
{
|
||||||
motion = new CMotionSpider(obj);
|
motion = new CMotionSpider(obj.get());
|
||||||
}
|
}
|
||||||
if ( type == OBJECT_BEE )
|
if ( type == OBJECT_BEE )
|
||||||
{
|
{
|
||||||
motion = new CMotionBee(obj);
|
motion = new CMotionBee(obj.get());
|
||||||
}
|
}
|
||||||
if ( type == OBJECT_WORM )
|
if ( type == OBJECT_WORM )
|
||||||
{
|
{
|
||||||
motion = new CMotionWorm(obj);
|
motion = new CMotionWorm(obj.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
physics->SetMotion(motion);
|
physics->SetMotion(motion);
|
||||||
|
|
|
@ -40,6 +40,22 @@ class CTerrain;
|
||||||
class CObject;
|
class CObject;
|
||||||
class CRobotMain;
|
class CRobotMain;
|
||||||
|
|
||||||
|
using CObjectUPtr = std::unique_ptr<CObject>;
|
||||||
|
|
||||||
|
struct ObjectCreateParams
|
||||||
|
{
|
||||||
|
Math::Vector pos;
|
||||||
|
float angle;
|
||||||
|
ObjectType type;
|
||||||
|
float power;
|
||||||
|
float zoom;
|
||||||
|
float height;
|
||||||
|
bool trainer;
|
||||||
|
bool toy;
|
||||||
|
int option;
|
||||||
|
int id;
|
||||||
|
};
|
||||||
|
|
||||||
class CObjectFactory
|
class CObjectFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -49,26 +65,23 @@ public:
|
||||||
Gfx::CParticle* particle,
|
Gfx::CParticle* particle,
|
||||||
CRobotMain* main);
|
CRobotMain* main);
|
||||||
|
|
||||||
CObject* CreateObject(Math::Vector pos, float angle, ObjectType type,
|
CObjectUPtr CreateObject(const ObjectCreateParams& params);
|
||||||
float power, float zoom, float height,
|
|
||||||
bool trainer, bool toy, int option);
|
|
||||||
|
|
||||||
CObject* CreateBuilding(Math::Vector pos, float angle, float height, ObjectType type, float power=1.0f);
|
|
||||||
CObject* CreateResource(Math::Vector pos, float angle, ObjectType type, float power=1.0f);
|
|
||||||
CObject* CreateVehicle(Math::Vector pos, float angle, ObjectType type, float power, bool trainer, bool toy, int option);
|
|
||||||
CObject* CreateInsect(Math::Vector pos, float angle, ObjectType type);
|
|
||||||
CObject* CreateFlag(Math::Vector pos, float angle, ObjectType type);
|
|
||||||
CObject* CreateBarrier(Math::Vector pos, float angle, float height, ObjectType type);
|
|
||||||
CObject* CreatePlant(Math::Vector pos, float angle, float height, ObjectType type);
|
|
||||||
CObject* CreateMushroom(Math::Vector pos, float angle, float height, ObjectType type);
|
|
||||||
CObject* CreateTeen(Math::Vector pos, float angle, float zoom, float height, ObjectType type, int option);
|
|
||||||
CObject* CreateQuartz(Math::Vector pos, float angle, float height, ObjectType type);
|
|
||||||
CObject* CreateRoot(Math::Vector pos, float angle, float height, ObjectType type);
|
|
||||||
CObject* CreateHome(Math::Vector pos, float angle, float height, ObjectType type);
|
|
||||||
CObject* CreateRuin(Math::Vector pos, float angle, float height, ObjectType type);
|
|
||||||
CObject* CreateApollo(Math::Vector pos, float angle, ObjectType type);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
CObjectUPtr CreateBuilding(const ObjectCreateParams& params);
|
||||||
|
CObjectUPtr CreateResource(const ObjectCreateParams& params);
|
||||||
|
CObjectUPtr CreateVehicle(const ObjectCreateParams& params);
|
||||||
|
CObjectUPtr CreateInsect(const ObjectCreateParams& params);
|
||||||
|
CObjectUPtr CreateFlag(const ObjectCreateParams& params);
|
||||||
|
CObjectUPtr CreateBarrier(const ObjectCreateParams& params);
|
||||||
|
CObjectUPtr CreatePlant(const ObjectCreateParams& params);
|
||||||
|
CObjectUPtr CreateMushroom(const ObjectCreateParams& params);
|
||||||
|
CObjectUPtr CreateTeen(const ObjectCreateParams& params);
|
||||||
|
CObjectUPtr CreateQuartz(const ObjectCreateParams& params);
|
||||||
|
CObjectUPtr CreateRoot(const ObjectCreateParams& params);
|
||||||
|
CObjectUPtr CreateHome(const ObjectCreateParams& params);
|
||||||
|
CObjectUPtr CreateRuin(const ObjectCreateParams& params);
|
||||||
|
CObjectUPtr CreateApollo(const ObjectCreateParams& params);
|
||||||
void AddObjectAuto(CObject* obj);
|
void AddObjectAuto(CObject* obj);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -40,6 +40,7 @@ CObjectManager::CObjectManager(Gfx::CEngine* engine,
|
||||||
Gfx::CParticle* particle,
|
Gfx::CParticle* particle,
|
||||||
CRobotMain* main)
|
CRobotMain* main)
|
||||||
: m_objectFactory(new CObjectFactory(engine, terrain, modelManager, particle, main))
|
: m_objectFactory(new CObjectFactory(engine, terrain, modelManager, particle, main))
|
||||||
|
, m_nextId(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,33 +48,39 @@ CObjectManager::~CObjectManager()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CObjectManager::AddObject(CObject* instance)
|
|
||||||
{
|
|
||||||
assert(instance != nullptr);
|
|
||||||
assert(m_table[instance->GetID()] == nullptr);
|
|
||||||
m_table[instance->GetID()] = instance;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CObjectManager::DeleteObject(CObject* instance)
|
bool CObjectManager::DeleteObject(CObject* instance)
|
||||||
{
|
{
|
||||||
assert(instance != nullptr);
|
assert(instance != nullptr);
|
||||||
for(auto it = m_table.begin(); it != m_table.end(); ++it)
|
|
||||||
|
instance->DeleteObject();
|
||||||
|
|
||||||
|
auto it = m_table.find(instance->GetID());
|
||||||
|
if (it != m_table.end())
|
||||||
{
|
{
|
||||||
if(it->second == instance)
|
m_table.erase(it);
|
||||||
{
|
return true;
|
||||||
m_table.erase(it);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CObjectManager::DeleteAllObjects()
|
||||||
|
{
|
||||||
|
for (auto& it : m_table)
|
||||||
|
{
|
||||||
|
bool all = true;
|
||||||
|
it.second->DeleteObject(all);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_table.clear();
|
||||||
|
|
||||||
|
m_nextId = 0;
|
||||||
|
}
|
||||||
|
|
||||||
CObject* CObjectManager::GetObjectById(unsigned int id)
|
CObject* CObjectManager::GetObjectById(unsigned int id)
|
||||||
{
|
{
|
||||||
if(m_table.count(id) == 0) return nullptr;
|
if(m_table.count(id) == 0) return nullptr;
|
||||||
return m_table[id];
|
return m_table[id].get();
|
||||||
}
|
}
|
||||||
|
|
||||||
CObject* CObjectManager::GetObjectByRank(unsigned int id)
|
CObject* CObjectManager::GetObjectByRank(unsigned int id)
|
||||||
|
@ -81,32 +88,46 @@ CObject* CObjectManager::GetObjectByRank(unsigned int id)
|
||||||
if(id >= m_table.size()) return nullptr;
|
if(id >= m_table.size()) return nullptr;
|
||||||
auto it = m_table.begin();
|
auto it = m_table.begin();
|
||||||
for(unsigned int i = 0; i < id; i++, ++it);
|
for(unsigned int i = 0; i < id; i++, ++it);
|
||||||
return it->second;
|
return it->second.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::map<unsigned int, CObject*>& CObjectManager::GetAllObjects()
|
CObject* CObjectManager::CreateObject(Math::Vector pos,
|
||||||
|
float angle,
|
||||||
|
ObjectType type,
|
||||||
|
float power,
|
||||||
|
float zoom,
|
||||||
|
float height,
|
||||||
|
bool trainer,
|
||||||
|
bool toy,
|
||||||
|
int option,
|
||||||
|
int id)
|
||||||
{
|
{
|
||||||
return m_table;
|
if (id < 0)
|
||||||
}
|
{
|
||||||
|
id = m_nextId;
|
||||||
|
m_nextId++;
|
||||||
|
}
|
||||||
|
|
||||||
void CObjectManager::Flush()
|
assert(m_table.find(id) == m_table.end());
|
||||||
{
|
|
||||||
m_table.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, ObjectType type,
|
ObjectCreateParams params;
|
||||||
float power, float zoom, float height,
|
params.pos = pos;
|
||||||
bool trainer, bool toy, int option)
|
params.angle = angle;
|
||||||
{
|
params.type = type;
|
||||||
return m_objectFactory->CreateObject(pos, angle, type, power, zoom, height, trainer, toy, option);
|
params.power = power;
|
||||||
}
|
params.zoom = zoom;
|
||||||
|
params.height = height;
|
||||||
|
params.trainer = trainer;
|
||||||
|
params.toy = toy;
|
||||||
|
params.option = option;
|
||||||
|
params.id = id;
|
||||||
|
|
||||||
bool CObjectManager::DestroyObject(int id)
|
auto objectUPtr = m_objectFactory->CreateObject(params);
|
||||||
{
|
CObject* objectPtr = objectUPtr.get();
|
||||||
CObject* obj = GetObjectById(id);
|
|
||||||
if(obj == nullptr) return false;
|
m_table[id] = std::move(objectUPtr);
|
||||||
delete obj; // Destructor calls CObjectManager::DeleteObject
|
|
||||||
return true;
|
return objectPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
@ -161,7 +182,7 @@ CObject* CObjectManager::Radar(CObject* pThis, Math::Vector thisPosition, float
|
||||||
pBest = nullptr;
|
pBest = nullptr;
|
||||||
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.get();
|
||||||
if ( pObj == pThis ) continue; // pThis may be nullptr but it doesn't matter
|
if ( pObj == pThis ) continue; // pThis may be nullptr but it doesn't matter
|
||||||
|
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
||||||
|
@ -248,4 +269,4 @@ CObject* CObjectManager::FindNearest(CObject* pThis, Math::Vector thisPosition,
|
||||||
CObject* CObjectManager::FindNearest(CObject* pThis, Math::Vector thisPosition, std::vector<ObjectType> type, float maxDist, bool 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);
|
return Radar(pThis, thisPosition, 0.0f, type, 0.0f, Math::PI*2.0f, 0.0f, maxDist, false, FILTER_NONE, cbotTypes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ enum RadarFilter
|
||||||
FILTER_ONLYFLYING = 2,
|
FILTER_ONLYFLYING = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using CObjectMap = std::map<int, std::unique_ptr<CObject>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class ObjectManager
|
* \class ObjectManager
|
||||||
|
@ -68,40 +69,102 @@ public:
|
||||||
CRobotMain* main);
|
CRobotMain* main);
|
||||||
virtual ~CObjectManager();
|
virtual ~CObjectManager();
|
||||||
|
|
||||||
//! Registers new object
|
//! Creates an object
|
||||||
bool AddObject(CObject* instance);
|
CObject* CreateObject(Math::Vector pos,
|
||||||
//! Unregisters the object
|
float angle,
|
||||||
|
ObjectType type,
|
||||||
|
float power = -1.f,
|
||||||
|
float zoom = 1.f,
|
||||||
|
float height = 0.f,
|
||||||
|
bool trainer = false,
|
||||||
|
bool toy = false,
|
||||||
|
int option = 0,
|
||||||
|
int id = -1);
|
||||||
|
|
||||||
|
//! Deletes the object
|
||||||
bool DeleteObject(CObject* instance);
|
bool DeleteObject(CObject* instance);
|
||||||
|
//! Deletes all objects
|
||||||
|
void DeleteAllObjects();
|
||||||
|
|
||||||
//! Finds object by id (CObject::GetID())
|
//! Finds object by id (CObject::GetID())
|
||||||
CObject* GetObjectById(unsigned 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
|
|
||||||
const std::map<unsigned int, CObject*>& GetAllObjects();
|
|
||||||
//! Removes all objects
|
|
||||||
void Flush();
|
|
||||||
|
|
||||||
//! Creates an object
|
//! Gets object by id in range <0; number of objects - 1)
|
||||||
CObject* CreateObject(Math::Vector pos, float angle, ObjectType type, float power = -1.f, float zoom = 1.f, float height = 0.f, bool trainer = false, bool toy = false, int option = 0);
|
CObject* GetObjectByRank(unsigned int id);
|
||||||
//! Destroys an object
|
|
||||||
bool DestroyObject(int id);
|
//! Returns all objects
|
||||||
|
inline const CObjectMap& GetAllObjects()
|
||||||
|
{
|
||||||
|
return m_table;
|
||||||
|
}
|
||||||
|
|
||||||
//! Finds an object, like radar() in CBot
|
//! Finds an object, like radar() in CBot
|
||||||
//@{
|
//@{
|
||||||
CObject* Radar(CObject* pThis, 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,
|
||||||
CObject* Radar(CObject* pThis, std::vector<ObjectType> type = std::vector<ObjectType>(), 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);
|
ObjectType type = OBJECT_NULL,
|
||||||
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);
|
float angle = 0.0f,
|
||||||
CObject* Radar(CObject* pThis, Math::Vector thisPosition, float thisAngle, std::vector<ObjectType> type = std::vector<ObjectType>(), 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);
|
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,
|
||||||
|
std::vector<ObjectType> type = std::vector<ObjectType>(),
|
||||||
|
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 = std::vector<ObjectType>(),
|
||||||
|
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
|
//! 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,
|
||||||
CObject* FindNearest(CObject* pThis, std::vector<ObjectType> type = std::vector<ObjectType>(), float maxDist = 1000.0f, bool cbotTypes = false);
|
ObjectType type = OBJECT_NULL,
|
||||||
CObject* FindNearest(CObject* pThis, Math::Vector thisPosition, ObjectType type = OBJECT_NULL, float maxDist = 1000.0f, bool cbotTypes = false);
|
float maxDist = 1000.0f,
|
||||||
CObject* FindNearest(CObject* pThis, Math::Vector thisPosition, std::vector<ObjectType> type = std::vector<ObjectType>(), float maxDist = 1000.0f, bool cbotTypes = false);
|
bool cbotTypes = false);
|
||||||
|
CObject* FindNearest(CObject* pThis,
|
||||||
|
std::vector<ObjectType> type = std::vector<ObjectType>(),
|
||||||
|
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 = std::vector<ObjectType>(),
|
||||||
|
float maxDist = 1000.0f,
|
||||||
|
bool cbotTypes = false);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::map<unsigned int, CObject*> m_table;
|
CObjectMap m_table;
|
||||||
std::unique_ptr<CObjectFactory> m_objectFactory;
|
std::unique_ptr<CObjectFactory> m_objectFactory;
|
||||||
|
int m_nextId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,6 @@ const float UNIT = 4.0f;
|
||||||
|
|
||||||
// Global variables.
|
// Global variables.
|
||||||
|
|
||||||
long g_id; // unique identifier
|
|
||||||
int g_build; // constructible buildings
|
int g_build; // constructible buildings
|
||||||
int g_researchDone; // research done
|
int g_researchDone; // research done
|
||||||
long g_researchEnable; // research available
|
long g_researchEnable; // research available
|
||||||
|
@ -224,7 +223,6 @@ CRobotMain::CRobotMain(CController* controller)
|
||||||
m_cameraPan = 0.0f;
|
m_cameraPan = 0.0f;
|
||||||
m_cameraZoom = 0.0f;
|
m_cameraZoom = 0.0f;
|
||||||
|
|
||||||
g_id = 0;
|
|
||||||
g_build = 0;
|
g_build = 0;
|
||||||
g_researchDone = 0; // no research done
|
g_researchDone = 0; // no research done
|
||||||
g_researchEnable = 0;
|
g_researchEnable = 0;
|
||||||
|
@ -503,8 +501,6 @@ void CRobotMain::ChangePhase(Phase phase)
|
||||||
iMan->Flush(CLASS_BRAIN);
|
iMan->Flush(CLASS_BRAIN);
|
||||||
iMan->Flush(CLASS_PYRO);
|
iMan->Flush(CLASS_PYRO);
|
||||||
|
|
||||||
m_objMan->Flush();
|
|
||||||
|
|
||||||
Math::Point dim, pos;
|
Math::Point dim, pos;
|
||||||
|
|
||||||
// Creates and hide the command console.
|
// Creates and hide the command console.
|
||||||
|
@ -1710,9 +1706,8 @@ void CRobotMain::StartDisplayVisit(EventType event)
|
||||||
// Creates the arrow to show the place.
|
// Creates the arrow to show the place.
|
||||||
if (m_visitArrow != 0)
|
if (m_visitArrow != 0)
|
||||||
{
|
{
|
||||||
m_visitArrow->DeleteObject();
|
CObjectManager::GetInstancePointer()->DeleteObject(m_visitArrow);
|
||||||
delete m_visitArrow;
|
m_visitArrow = nullptr;
|
||||||
m_visitArrow = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Math::Vector goal = m_displayText->GetVisitGoal(event);
|
Math::Vector goal = m_displayText->GetVisitGoal(event);
|
||||||
|
@ -1775,8 +1770,7 @@ void CRobotMain::StopDisplayVisit()
|
||||||
// Removes the arrow.
|
// Removes the arrow.
|
||||||
if (m_visitArrow != nullptr)
|
if (m_visitArrow != nullptr)
|
||||||
{
|
{
|
||||||
m_visitArrow->DeleteObject();
|
CObjectManager::GetInstancePointer()->DeleteObject(m_visitArrow);
|
||||||
delete m_visitArrow;
|
|
||||||
m_visitArrow = nullptr;
|
m_visitArrow = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1812,10 +1806,9 @@ CObject* CRobotMain::GetSelectObject()
|
||||||
CObject* CRobotMain::DeselectAll()
|
CObject* CRobotMain::DeselectAll()
|
||||||
{
|
{
|
||||||
CObject* prev = nullptr;
|
CObject* prev = nullptr;
|
||||||
for(auto it : m_objMan->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
if (obj->GetSelect()) prev = obj;
|
if (obj->GetSelect()) prev = obj;
|
||||||
obj->SetSelect(false);
|
obj->SetSelect(false);
|
||||||
}
|
}
|
||||||
|
@ -1936,21 +1929,14 @@ void CRobotMain::DeleteAllObjects()
|
||||||
// Removes the arrow.
|
// Removes the arrow.
|
||||||
if (m_visitArrow != nullptr)
|
if (m_visitArrow != nullptr)
|
||||||
{
|
{
|
||||||
m_visitArrow->DeleteObject();
|
CObjectManager::GetInstancePointer()->DeleteObject(m_visitArrow);
|
||||||
delete m_visitArrow;
|
|
||||||
m_visitArrow = nullptr;
|
m_visitArrow = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < MAXSHOWLIMIT; i++)
|
for (int i = 0; i < MAXSHOWLIMIT; i++)
|
||||||
FlushShowLimit(i);
|
FlushShowLimit(i);
|
||||||
|
|
||||||
while(m_objMan->GetAllObjects().size() > 0)
|
|
||||||
{
|
|
||||||
CObject* obj = m_objMan->GetAllObjects().begin()->second;
|
|
||||||
|
|
||||||
obj->DeleteObject(true); // destroys rapidly
|
m_objMan->DeleteAllObjects();
|
||||||
delete obj;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Selects the human
|
//! Selects the human
|
||||||
|
@ -1976,10 +1962,9 @@ CObject* CRobotMain::SearchNearest(Math::Vector pos, CObject* exclu)
|
||||||
{
|
{
|
||||||
float min = 100000.0f;
|
float min = 100000.0f;
|
||||||
CObject* best = 0;
|
CObject* best = 0;
|
||||||
for(auto it : m_objMan->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
if (obj == exclu) continue;
|
if (obj == exclu) continue;
|
||||||
if (!IsSelectable(obj)) continue;
|
if (!IsSelectable(obj)) continue;
|
||||||
|
|
||||||
|
@ -2000,10 +1985,9 @@ CObject* CRobotMain::SearchNearest(Math::Vector pos, CObject* exclu)
|
||||||
//! Returns the selected object
|
//! Returns the selected object
|
||||||
CObject* CRobotMain::GetSelect()
|
CObject* CRobotMain::GetSelect()
|
||||||
{
|
{
|
||||||
for(auto it : m_objMan->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
if (obj->GetSelect())
|
if (obj->GetSelect())
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -2020,9 +2004,9 @@ CObject* CRobotMain::DetectObject(Math::Point pos)
|
||||||
{
|
{
|
||||||
int objRank = m_engine->DetectObject(pos);
|
int objRank = m_engine->DetectObject(pos);
|
||||||
|
|
||||||
for(auto it : m_objMan->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
if (!obj->GetActif()) continue;
|
if (!obj->GetActif()) continue;
|
||||||
CObject* truck = obj->GetTruck();
|
CObject* truck = obj->GetTruck();
|
||||||
|
@ -2260,9 +2244,9 @@ void CRobotMain::HiliteClear()
|
||||||
int rank = -1;
|
int rank = -1;
|
||||||
m_engine->SetHighlightRank(&rank); // nothing more selected
|
m_engine->SetHighlightRank(&rank); // nothing more selected
|
||||||
|
|
||||||
for(auto it : m_objMan->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
obj->SetHilite(false);
|
obj->SetHilite(false);
|
||||||
m_map->SetHighlight(0);
|
m_map->SetHighlight(0);
|
||||||
|
@ -2420,10 +2404,9 @@ void CRobotMain::HelpObject()
|
||||||
//! Change the mode of the camera
|
//! Change the mode of the camera
|
||||||
void CRobotMain::ChangeCamera()
|
void CRobotMain::ChangeCamera()
|
||||||
{
|
{
|
||||||
for(auto it : m_objMan->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
if (obj->GetSelect())
|
if (obj->GetSelect())
|
||||||
{
|
{
|
||||||
if (obj->GetCameraLock()) return;
|
if (obj->GetCameraLock()) return;
|
||||||
|
@ -2565,10 +2548,9 @@ void CRobotMain::RemoteCamera(float pan, float zoom, float rTime)
|
||||||
//! Cancels the current movie
|
//! Cancels the current movie
|
||||||
void CRobotMain::AbortMovie()
|
void CRobotMain::AbortMovie()
|
||||||
{
|
{
|
||||||
for(auto it : m_objMan->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
CAuto* automat = obj->GetAuto();
|
CAuto* automat = obj->GetAuto();
|
||||||
if (automat != 0)
|
if (automat != 0)
|
||||||
automat->Abort();
|
automat->Abort();
|
||||||
|
@ -2645,17 +2627,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(auto it : objman->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
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();
|
||||||
|
@ -2665,9 +2647,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(auto it : objman->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
if (obj->GetTruck() == nullptr) continue;
|
if (obj->GetTruck() == nullptr) continue;
|
||||||
obj->EventProcess(event);
|
obj->EventProcess(event);
|
||||||
}
|
}
|
||||||
|
@ -2825,9 +2807,9 @@ bool CRobotMain::EventObject(const Event &event)
|
||||||
|
|
||||||
m_resetCreate = false;
|
m_resetCreate = false;
|
||||||
|
|
||||||
for(auto it : m_objMan->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
obj->EventProcess(event);
|
obj->EventProcess(event);
|
||||||
}
|
}
|
||||||
|
@ -2866,8 +2848,6 @@ void CRobotMain::ScenePerso()
|
||||||
iMan->Flush(CLASS_PHYSICS);
|
iMan->Flush(CLASS_PHYSICS);
|
||||||
iMan->Flush(CLASS_BRAIN);
|
iMan->Flush(CLASS_BRAIN);
|
||||||
iMan->Flush(CLASS_PYRO);
|
iMan->Flush(CLASS_PYRO);
|
||||||
|
|
||||||
m_objMan->Flush();
|
|
||||||
|
|
||||||
|
|
||||||
ChangeColor();
|
ChangeColor();
|
||||||
|
@ -2907,7 +2887,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
|
|
||||||
m_fixScene = fixScene;
|
m_fixScene = fixScene;
|
||||||
|
|
||||||
g_id = 0;
|
|
||||||
m_base = nullptr;
|
m_base = nullptr;
|
||||||
|
|
||||||
if (!resetObject)
|
if (!resetObject)
|
||||||
|
@ -4224,10 +4203,9 @@ bool CRobotMain::TestGadgetQuantity(int rank)
|
||||||
float CRobotMain::SearchNearestObject(Math::Vector center, CObject *exclu)
|
float CRobotMain::SearchNearestObject(Math::Vector center, CObject *exclu)
|
||||||
{
|
{
|
||||||
float min = 100000.0f;
|
float min = 100000.0f;
|
||||||
for(auto it : m_objMan->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
if (!obj->GetActif()) continue; // inactive?
|
if (!obj->GetActif()) continue; // inactive?
|
||||||
if (obj->GetTruck() != nullptr) continue; // object carries?
|
if (obj->GetTruck() != nullptr) continue; // object carries?
|
||||||
if (obj == exclu) continue;
|
if (obj == exclu) continue;
|
||||||
|
@ -4374,10 +4352,9 @@ void CRobotMain::ShowDropZone(CObject* metal, CObject* truck)
|
||||||
// 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(auto it : m_objMan->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
if (!obj->GetActif()) continue; // inactive?
|
if (!obj->GetActif()) continue; // inactive?
|
||||||
if (obj->GetTruck() != nullptr) continue; // object carried?
|
if (obj->GetTruck() != nullptr) continue; // object carried?
|
||||||
if (obj == metal) continue;
|
if (obj == metal) continue;
|
||||||
|
@ -4575,16 +4552,14 @@ void CRobotMain::CompileScript(bool soluce)
|
||||||
{
|
{
|
||||||
int nbError = 0;
|
int nbError = 0;
|
||||||
int lastError = 0;
|
int lastError = 0;
|
||||||
|
|
||||||
CObjectManager* objman = CObjectManager::GetInstancePointer();
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
lastError = nbError;
|
lastError = nbError;
|
||||||
nbError = 0;
|
nbError = 0;
|
||||||
for(auto it : objman->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
if (obj->GetTruck() != nullptr) continue;
|
if (obj->GetTruck() != nullptr) continue;
|
||||||
|
|
||||||
CBrain* brain = obj->GetBrain();
|
CBrain* brain = obj->GetBrain();
|
||||||
|
@ -4610,9 +4585,9 @@ void CRobotMain::CompileScript(bool soluce)
|
||||||
// Load all solutions.
|
// Load all solutions.
|
||||||
if (soluce)
|
if (soluce)
|
||||||
{
|
{
|
||||||
for(auto it : objman->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
if (obj->GetTruck() != 0) continue;
|
if (obj->GetTruck() != 0) continue;
|
||||||
|
|
||||||
CBrain* brain = obj->GetBrain();
|
CBrain* brain = obj->GetBrain();
|
||||||
|
@ -4627,9 +4602,9 @@ void CRobotMain::CompileScript(bool soluce)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start all programs according to the command "run".
|
// Start all programs according to the command "run".
|
||||||
for(auto it : objman->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
if (obj->GetTruck() != nullptr) continue;
|
if (obj->GetTruck() != nullptr) continue;
|
||||||
|
|
||||||
CBrain* brain = obj->GetBrain();
|
CBrain* brain = obj->GetBrain();
|
||||||
|
@ -4708,10 +4683,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()
|
||||||
{
|
{
|
||||||
for(auto it : m_objMan->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
SaveOneScript(obj);
|
SaveOneScript(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4861,9 +4835,9 @@ bool CRobotMain::IsBusy()
|
||||||
{
|
{
|
||||||
if (CScriptFunctions::m_CompteurFileOpen > 0) return true;
|
if (CScriptFunctions::m_CompteurFileOpen > 0) return true;
|
||||||
|
|
||||||
for(auto it : m_objMan->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
CBrain* brain = obj->GetBrain();
|
CBrain* brain = obj->GetBrain();
|
||||||
if (brain != nullptr)
|
if (brain != nullptr)
|
||||||
|
@ -4952,12 +4926,14 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
|
||||||
line->AddParam("text", new CLevelParserParam(std::string(info)));
|
line->AddParam("text", new CLevelParserParam(std::string(info)));
|
||||||
level->AddLine(line);
|
level->AddLine(line);
|
||||||
|
|
||||||
|
|
||||||
//TODO: Do we need that? It's not used anyway
|
//TODO: Do we need that? It's not used anyway
|
||||||
line = new CLevelParserLine("Version");
|
line = new CLevelParserLine("Version");
|
||||||
line->AddParam("maj", new CLevelParserParam(0));
|
line->AddParam("maj", new CLevelParserParam(0));
|
||||||
line->AddParam("min", new CLevelParserParam(1));
|
line->AddParam("min", new CLevelParserParam(1));
|
||||||
level->AddLine(line);
|
level->AddLine(line);
|
||||||
|
|
||||||
|
|
||||||
line = new CLevelParserLine("Created");
|
line = new CLevelParserLine("Created");
|
||||||
line->AddParam("date", new CLevelParserParam(GetCurrentTimestamp()));
|
line->AddParam("date", new CLevelParserParam(GetCurrentTimestamp()));
|
||||||
level->AddLine(line);
|
level->AddLine(line);
|
||||||
|
@ -4990,12 +4966,12 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int objRank = 0;
|
int objRank = 0;
|
||||||
for(auto it : m_objMan->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
if (obj->GetType() == OBJECT_TOTO) continue;
|
if (obj->GetType() == OBJECT_TOTO) continue;
|
||||||
if (obj->GetType() == OBJECT_FIX) continue;
|
if (obj->GetType() == OBJECT_FIX) continue;
|
||||||
if (obj->GetTruck() != nullptr) continue;
|
if (obj->GetTruck() != nullptr) continue;
|
||||||
|
@ -5017,6 +4993,7 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
|
||||||
IOWriteObject(line, power);
|
IOWriteObject(line, power);
|
||||||
level->AddLine(line);
|
level->AddLine(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
line = new CLevelParserLine("CreateObject");
|
line = new CLevelParserLine("CreateObject");
|
||||||
IOWriteObject(line, obj);
|
IOWriteObject(line, obj);
|
||||||
|
@ -5043,10 +5020,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(auto it : m_objMan->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
if (obj->GetType() == OBJECT_TOTO) continue;
|
if (obj->GetType() == OBJECT_TOTO) continue;
|
||||||
if (obj->GetType() == OBJECT_FIX) continue;
|
if (obj->GetType() == OBJECT_FIX) continue;
|
||||||
if (obj->GetTruck() != nullptr) continue;
|
if (obj->GetTruck() != nullptr) continue;
|
||||||
|
@ -5076,13 +5052,11 @@ CObject* CRobotMain::IOReadObject(CLevelParserLine *line, const char* filename,
|
||||||
bool toy = line->GetParam("toy")->AsBool(false);
|
bool toy = line->GetParam("toy")->AsBool(false);
|
||||||
int option = line->GetParam("option")->AsInt(0);
|
int option = line->GetParam("option")->AsInt(0);
|
||||||
|
|
||||||
CObject* obj = m_objMan->CreateObject(pos, dir.y, type, 0.0f, 1.0f, 0.0f, trainer, toy, option);
|
CObject* obj = m_objMan->CreateObject(pos, dir.y, type, 0.0f, 1.0f, 0.0f, trainer, toy, option, id);
|
||||||
obj->SetDefRank(objRank);
|
obj->SetDefRank(objRank);
|
||||||
obj->SetPosition(0, pos);
|
obj->SetPosition(0, pos);
|
||||||
obj->SetAngle(0, dir);
|
obj->SetAngle(0, dir);
|
||||||
obj->SetIgnoreBuildCheck(line->GetParam("ignoreBuildCheck")->AsBool(false));
|
obj->SetIgnoreBuildCheck(line->GetParam("ignoreBuildCheck")->AsBool(false));
|
||||||
obj->SetID(id);
|
|
||||||
if (g_id < id) g_id = id;
|
|
||||||
|
|
||||||
if (zoom.x != 0.0f || zoom.y != 0.0f || zoom.z != 0.0f)
|
if (zoom.x != 0.0f || zoom.y != 0.0f || zoom.z != 0.0f)
|
||||||
obj->SetZoom(0, zoom);
|
obj->SetZoom(0, zoom);
|
||||||
|
@ -5205,8 +5179,6 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
|
||||||
}
|
}
|
||||||
delete level;
|
delete level;
|
||||||
|
|
||||||
CObjectManager* objman = CObjectManager::GetInstancePointer();
|
|
||||||
|
|
||||||
// Compiles scripts.
|
// Compiles scripts.
|
||||||
int nbError = 0;
|
int nbError = 0;
|
||||||
int lastError = 0;
|
int lastError = 0;
|
||||||
|
@ -5214,9 +5186,9 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
|
||||||
{
|
{
|
||||||
lastError = nbError;
|
lastError = nbError;
|
||||||
nbError = 0;
|
nbError = 0;
|
||||||
for(auto it : objman->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
if (obj->GetTruck() != nullptr) continue;
|
if (obj->GetTruck() != nullptr) continue;
|
||||||
|
|
||||||
objRank = obj->GetDefRank();
|
objRank = obj->GetDefRank();
|
||||||
|
@ -5228,9 +5200,9 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
|
||||||
while (nbError > 0 && nbError != lastError);
|
while (nbError > 0 && nbError != lastError);
|
||||||
|
|
||||||
// Starts scripts
|
// Starts scripts
|
||||||
for(auto it : objman->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
if (obj->GetTruck() != nullptr) continue;
|
if (obj->GetTruck() != nullptr) continue;
|
||||||
if (obj->GetDefRank() == -1) continue;
|
if (obj->GetDefRank() == -1) continue;
|
||||||
|
|
||||||
|
@ -5256,10 +5228,9 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
|
||||||
if (version == CBotProgram::GetVersion())
|
if (version == CBotProgram::GetVersion())
|
||||||
{
|
{
|
||||||
objRank = 0;
|
objRank = 0;
|
||||||
for(auto it : objman->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
if (obj->GetType() == OBJECT_TOTO) continue;
|
if (obj->GetType() == OBJECT_TOTO) continue;
|
||||||
if (obj->GetType() == OBJECT_FIX) continue;
|
if (obj->GetType() == OBJECT_FIX) continue;
|
||||||
if (obj->GetTruck() != nullptr) continue;
|
if (obj->GetTruck() != nullptr) continue;
|
||||||
|
@ -5445,8 +5416,6 @@ void CRobotMain::ResetCreate()
|
||||||
iMan->Flush(CLASS_PHYSICS);
|
iMan->Flush(CLASS_PHYSICS);
|
||||||
iMan->Flush(CLASS_BRAIN);
|
iMan->Flush(CLASS_BRAIN);
|
||||||
iMan->Flush(CLASS_PYRO);
|
iMan->Flush(CLASS_PYRO);
|
||||||
|
|
||||||
m_objMan->Flush();
|
|
||||||
|
|
||||||
m_camera->SetType(Gfx::CAM_TYPE_DIALOG);
|
m_camera->SetType(Gfx::CAM_TYPE_DIALOG);
|
||||||
|
|
||||||
|
@ -5455,9 +5424,9 @@ void CRobotMain::ResetCreate()
|
||||||
|
|
||||||
if (!GetNiceReset()) return;
|
if (!GetNiceReset()) return;
|
||||||
|
|
||||||
for(auto it : m_objMan->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
ResetCap cap = obj->GetResetCap();
|
ResetCap cap = obj->GetResetCap();
|
||||||
if (cap == RESET_NONE) continue;
|
if (cap == RESET_NONE) continue;
|
||||||
|
@ -5487,10 +5456,9 @@ void CRobotMain::UpdateAudio(bool frame)
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
|
|
||||||
int nb = 0;
|
int nb = 0;
|
||||||
for(auto it : m_objMan->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
// 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!
|
||||||
if (obj->GetLock()) continue;
|
if (obj->GetLock()) continue;
|
||||||
|
@ -5612,10 +5580,9 @@ Error CRobotMain::CheckEndMission(bool frame)
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
|
|
||||||
int nb = 0;
|
int nb = 0;
|
||||||
for(auto it : m_objMan->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
// 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!
|
||||||
if (obj->GetLock()) continue;
|
if (obj->GetLock()) continue;
|
||||||
|
@ -5892,9 +5859,9 @@ bool CRobotMain::GetRadar()
|
||||||
if (m_cheatRadar)
|
if (m_cheatRadar)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for(auto it : m_objMan->GetAllObjects())
|
for(auto& it : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second;
|
CObject* obj = it.second.get();
|
||||||
|
|
||||||
ObjectType type = obj->GetType();
|
ObjectType type = obj->GetType();
|
||||||
if (type == OBJECT_RADAR && !obj->GetLock())
|
if (type == OBJECT_RADAR && !obj->GetLock())
|
||||||
|
|
|
@ -474,9 +474,8 @@ Error CTaskBuild::IsEnded()
|
||||||
|
|
||||||
DeleteMark(m_metal->GetPosition(0), 20.0f);
|
DeleteMark(m_metal->GetPosition(0), 20.0f);
|
||||||
|
|
||||||
m_metal->DeleteObject(); // removes the metal
|
CObjectManager::GetInstancePointer()->DeleteObject(m_metal);
|
||||||
delete m_metal;
|
m_metal = nullptr;
|
||||||
m_metal = 0;
|
|
||||||
|
|
||||||
m_building->SetZoom(0, 1.0f);
|
m_building->SetZoom(0, 1.0f);
|
||||||
m_building->SetCirVibration(Math::Vector(0.0f, 0.0f, 0.0f));
|
m_building->SetCirVibration(Math::Vector(0.0f, 0.0f, 0.0f));
|
||||||
|
@ -590,10 +589,9 @@ Error CTaskBuild::FlatFloor()
|
||||||
|
|
||||||
max = 100000.0f;
|
max = 100000.0f;
|
||||||
bBase = false;
|
bBase = false;
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( !pObj->GetActif() ) continue; // inactive?
|
if ( !pObj->GetActif() ) continue; // inactive?
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
||||||
if ( pObj == m_metal ) continue;
|
if ( pObj == m_metal ) continue;
|
||||||
|
@ -637,10 +635,9 @@ Error CTaskBuild::FlatFloor()
|
||||||
}
|
}
|
||||||
|
|
||||||
max = 100000.0f;
|
max = 100000.0f;
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( !pObj->GetActif() ) continue; // inactive?
|
if ( !pObj->GetActif() ) continue; // inactive?
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
||||||
if ( pObj == m_metal ) continue;
|
if ( pObj == m_metal ) continue;
|
||||||
|
@ -707,10 +704,9 @@ CObject* CTaskBuild::SearchMetalObject(float &angle, float dMin, float dMax,
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
pBest = 0;
|
pBest = 0;
|
||||||
bMetal = false;
|
bMetal = false;
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
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?
|
||||||
|
|
||||||
|
@ -761,16 +757,12 @@ CObject* CTaskBuild::SearchMetalObject(float &angle, float dMin, float dMax,
|
||||||
|
|
||||||
void CTaskBuild::DeleteMark(Math::Vector pos, float radius)
|
void CTaskBuild::DeleteMark(Math::Vector pos, float radius)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
std::vector<CObject*> objectsToDelete;
|
||||||
Math::Vector oPos;
|
|
||||||
ObjectType type;
|
|
||||||
float distance;
|
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
|
||||||
pObj = it.second;
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
{
|
||||||
|
CObject* obj = it.second.get();
|
||||||
|
ObjectType type = obj->GetType();
|
||||||
if ( type != OBJECT_MARKSTONE &&
|
if ( type != OBJECT_MARKSTONE &&
|
||||||
type != OBJECT_MARKURANIUM &&
|
type != OBJECT_MARKURANIUM &&
|
||||||
type != OBJECT_MARKKEYa &&
|
type != OBJECT_MARKKEYa &&
|
||||||
|
@ -779,13 +771,17 @@ void CTaskBuild::DeleteMark(Math::Vector pos, float radius)
|
||||||
type != OBJECT_MARKKEYd &&
|
type != OBJECT_MARKKEYd &&
|
||||||
type != OBJECT_MARKPOWER ) continue;
|
type != OBJECT_MARKPOWER ) continue;
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
distance = Math::Distance(oPos, pos);
|
float distance = Math::Distance(oPos, pos);
|
||||||
if ( distance <= radius )
|
if ( distance <= radius )
|
||||||
{
|
{
|
||||||
pObj->DeleteObject(); // removes the mark
|
objectsToDelete.push_back(obj);
|
||||||
delete pObj;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (CObject* obj : objectsToDelete)
|
||||||
|
{
|
||||||
|
CObjectManager::GetInstancePointer()->DeleteObject(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ bool CTaskDeleteMark::Abort()
|
||||||
|
|
||||||
void CTaskDeleteMark::DeleteMark()
|
void CTaskDeleteMark::DeleteMark()
|
||||||
{
|
{
|
||||||
CObject* pObj = CObjectManager::GetInstancePointer()->FindNearest(m_object, {
|
CObject* obj = CObjectManager::GetInstancePointer()->FindNearest(m_object, {
|
||||||
OBJECT_MARKPOWER,
|
OBJECT_MARKPOWER,
|
||||||
OBJECT_MARKSTONE,
|
OBJECT_MARKSTONE,
|
||||||
OBJECT_MARKURANIUM,
|
OBJECT_MARKURANIUM,
|
||||||
|
@ -83,9 +83,8 @@ void CTaskDeleteMark::DeleteMark()
|
||||||
OBJECT_MARKKEYd
|
OBJECT_MARKKEYd
|
||||||
}, 8.0f/g_unit);
|
}, 8.0f/g_unit);
|
||||||
|
|
||||||
if(pObj != nullptr)
|
if (obj != nullptr)
|
||||||
{
|
{
|
||||||
pObj->DeleteObject(); // removes the mark
|
CObjectManager::GetInstancePointer()->DeleteObject(obj);
|
||||||
delete pObj;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -156,10 +156,9 @@ int CTaskFlag::CountObject(ObjectType type)
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for (auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( !pObj->GetEnable() ) continue;
|
if ( !pObj->GetEnable() ) continue;
|
||||||
|
|
||||||
oType = pObj->GetType();
|
oType = pObj->GetType();
|
||||||
|
|
|
@ -508,9 +508,9 @@ CObject* CTaskGoto::WormSearch(Math::Vector &impact)
|
||||||
iPos = m_object->GetPosition(0);
|
iPos = m_object->GetPosition(0);
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
oType = pObj->GetType();
|
oType = pObj->GetType();
|
||||||
if ( oType != OBJECT_MOBILEfa &&
|
if ( oType != OBJECT_MOBILEfa &&
|
||||||
|
@ -1154,9 +1154,9 @@ bool CTaskGoto::AdjustBuilding(Math::Vector &pos, float margin, float &distance)
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
float dist, suppl;
|
float dist, suppl;
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( !pObj->GetActif() ) continue;
|
if ( !pObj->GetActif() ) continue;
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
||||||
|
@ -1314,10 +1314,9 @@ bool CTaskGoto::LeakSearch(Math::Vector &pos, float &delay)
|
||||||
|
|
||||||
min = 100000.0f;
|
min = 100000.0f;
|
||||||
bRadius = 0.0f;
|
bRadius = 0.0f;
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( pObj == m_object ) continue;
|
if ( pObj == m_object ) continue;
|
||||||
if ( !pObj->GetActif() ) continue;
|
if ( !pObj->GetActif() ) continue;
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
||||||
|
@ -1494,9 +1493,9 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir)
|
||||||
bAlien = true;
|
bAlien = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( pObj == m_object ) continue;
|
if ( pObj == m_object ) continue;
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( pObj->GetTruck() != 0 ) continue;
|
||||||
|
@ -1585,9 +1584,9 @@ void CTaskGoto::ComputeFlyingRepulse(float &dir)
|
||||||
fac = 1.5f;
|
fac = 1.5f;
|
||||||
dir = 0.0f;
|
dir = 0.0f;
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( pObj == m_object ) continue;
|
if ( pObj == m_object ) continue;
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( pObj->GetTruck() != 0 ) continue;
|
||||||
|
@ -1898,9 +1897,9 @@ void CTaskGoto::BitmapObject()
|
||||||
|
|
||||||
m_object->GetCrashSphere(0, iPos, iRadius);
|
m_object->GetCrashSphere(0, iPos, iRadius);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
|
|
||||||
|
|
|
@ -733,10 +733,9 @@ CObject* CTaskManip::SearchTakeUnderObject(Math::Vector &pos, float dLimit)
|
||||||
|
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
pBest = 0;
|
pBest = 0;
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
|
|
||||||
if ( type != OBJECT_FRET &&
|
if ( type != OBJECT_FRET &&
|
||||||
|
@ -802,10 +801,9 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos,
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
pBest = 0;
|
pBest = 0;
|
||||||
bAngle = 0.0f;
|
bAngle = 0.0f;
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
|
|
||||||
if ( type != OBJECT_FRET &&
|
if ( type != OBJECT_FRET &&
|
||||||
|
@ -891,10 +889,9 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos,
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
pBest = 0;
|
pBest = 0;
|
||||||
bAngle = 0.0f;
|
bAngle = 0.0f;
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
|
|
||||||
if ( type != OBJECT_FRET &&
|
if ( type != OBJECT_FRET &&
|
||||||
|
@ -986,9 +983,9 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos,
|
||||||
dLimit = MARGIN_FRIEND;
|
dLimit = MARGIN_FRIEND;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( pObj == m_object ) continue; // yourself?
|
if ( pObj == m_object ) continue; // yourself?
|
||||||
|
|
||||||
|
@ -1341,9 +1338,9 @@ bool CTaskManip::IsFreeDeposeObject(Math::Vector pos)
|
||||||
mat = m_object->GetWorldMatrix(0);
|
mat = m_object->GetWorldMatrix(0);
|
||||||
iPos = Transform(*mat, pos);
|
iPos = Transform(*mat, pos);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( pObj == m_object ) continue;
|
if ( pObj == m_object ) continue;
|
||||||
if ( !pObj->GetActif() ) continue; // inactive?
|
if ( !pObj->GetActif() ) continue; // inactive?
|
||||||
|
|
|
@ -328,9 +328,8 @@ Error CTaskRecover::IsEnded()
|
||||||
{
|
{
|
||||||
m_metal->SetZoom(0, 1.0f);
|
m_metal->SetZoom(0, 1.0f);
|
||||||
|
|
||||||
m_ruin->DeleteObject(); // destroys the ruin
|
CObjectManager::GetInstancePointer()->DeleteObject(m_ruin);
|
||||||
delete m_ruin;
|
m_ruin = nullptr;
|
||||||
m_ruin = 0;
|
|
||||||
|
|
||||||
m_soundChannel = -1;
|
m_soundChannel = -1;
|
||||||
|
|
||||||
|
|
|
@ -283,9 +283,9 @@ bool CTaskReset::SearchVehicle()
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float oRadius, dist;
|
float oRadius, dist;
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for (auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( pObj == m_object ) continue;
|
if ( pObj == m_object ) continue;
|
||||||
|
|
||||||
|
|
|
@ -294,9 +294,10 @@ bool CTaskSearch::CreateMark()
|
||||||
|
|
||||||
void CTaskSearch::DeleteMark(ObjectType type)
|
void CTaskSearch::DeleteMark(ObjectType type)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
CObject* obj = CObjectManager::GetInstancePointer()->FindNearest(nullptr, type);
|
||||||
pObj = CObjectManager::GetInstancePointer()->FindNearest(nullptr, type);
|
if (obj != nullptr)
|
||||||
pObj->DeleteObject();
|
{
|
||||||
delete pObj;
|
CObjectManager::GetInstancePointer()->DeleteObject(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -556,9 +556,9 @@ void CTaskShield::IncreaseShield()
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
float dist, shield;
|
float dist, shield;
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type == OBJECT_MOTHER ||
|
if ( type == OBJECT_MOTHER ||
|
||||||
|
|
|
@ -311,10 +311,9 @@ CObject* CTaskTake::SearchTakeObject(float &angle,
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
pBest = 0;
|
pBest = 0;
|
||||||
bAngle = 0.0f;
|
bAngle = 0.0f;
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
|
|
||||||
if ( type != OBJECT_FRET &&
|
if ( type != OBJECT_FRET &&
|
||||||
|
@ -375,9 +374,9 @@ CObject* CTaskTake::SearchFriendObject(float &angle,
|
||||||
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
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( pObj == m_object ) continue; // yourself?
|
if ( pObj == m_object ) continue; // yourself?
|
||||||
|
|
||||||
|
@ -569,9 +568,9 @@ bool CTaskTake::IsFreeDeposeObject(Math::Vector pos)
|
||||||
mat = m_object->GetWorldMatrix(0);
|
mat = m_object->GetWorldMatrix(0);
|
||||||
iPos = Transform(*mat, pos);
|
iPos = Transform(*mat, pos);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( pObj == m_object ) continue;
|
if ( pObj == m_object ) continue;
|
||||||
if ( !pObj->GetActif() ) continue; // inactive?
|
if ( !pObj->GetActif() ) continue; // inactive?
|
||||||
|
|
|
@ -350,9 +350,9 @@ bool CTaskTerraform::Terraform()
|
||||||
|
|
||||||
m_sound->Play(SOUND_THUMP, m_terraPos);
|
m_sound->Play(SOUND_THUMP, m_terraPos);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type == OBJECT_NULL ) continue;
|
if ( type == OBJECT_NULL ) continue;
|
||||||
|
|
|
@ -2527,10 +2527,9 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
|
||||||
iType = m_object->GetType();
|
iType = m_object->GetType();
|
||||||
|
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto &it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
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?
|
||||||
if ( !pObj->GetEnable() ) continue; // inactive?
|
if ( !pObj->GetEnable() ) continue; // inactive?
|
||||||
|
|
|
@ -1041,12 +1041,10 @@ CBotTypResult CScriptFunctions::cDelete(CBotVar* &var, void* user)
|
||||||
|
|
||||||
bool CScriptFunctions::rDelete(CBotVar* var, CBotVar* result, int& exception, void* user)
|
bool CScriptFunctions::rDelete(CBotVar* var, CBotVar* result, int& exception, void* user)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
|
||||||
int rank;
|
|
||||||
int exploType = 0;
|
int exploType = 0;
|
||||||
float force = 1.0f;
|
float force = 1.0f;
|
||||||
|
|
||||||
rank = var->GetValInt();
|
int rank = var->GetValInt();
|
||||||
var->GetNext();
|
var->GetNext();
|
||||||
if ( var != 0 )
|
if ( var != 0 )
|
||||||
{
|
{
|
||||||
|
@ -1057,9 +1055,9 @@ bool CScriptFunctions::rDelete(CBotVar* var, CBotVar* result, int& exception, vo
|
||||||
force = var->GetValFloat();
|
force = var->GetValFloat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pObj = static_cast<CObject*>(CObjectManager::GetInstancePointer()->GetObjectById(rank));
|
CObject* obj = CObjectManager::GetInstancePointer()->GetObjectById(rank);
|
||||||
if ( pObj == 0 )
|
if ( obj == nullptr )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1067,11 +1065,11 @@ bool CScriptFunctions::rDelete(CBotVar* var, CBotVar* result, int& exception, vo
|
||||||
{
|
{
|
||||||
if ( exploType )
|
if ( exploType )
|
||||||
{
|
{
|
||||||
pObj->ExploObject(static_cast<ExploType>(exploType), force);
|
obj->ExploObject(static_cast<ExploType>(exploType), force);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pObj->DeleteObject(false);
|
CObjectManager::GetInstancePointer()->DeleteObject(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -138,9 +138,9 @@ bool CMainShort::CreateShortcuts()
|
||||||
m_shortcuts[rank] = 0;
|
m_shortcuts[rank] = 0;
|
||||||
rank ++;
|
rank ++;
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( !pObj->GetActif() ) continue;
|
if ( !pObj->GetActif() ) continue;
|
||||||
if ( !pObj->GetSelectable() ) continue;
|
if ( !pObj->GetSelectable() ) continue;
|
||||||
|
|
|
@ -191,9 +191,9 @@ CObject* CTarget::DetectFriendObject(Math::Point pos)
|
||||||
|
|
||||||
objRank = m_engine->DetectObject(pos);
|
objRank = m_engine->DetectObject(pos);
|
||||||
|
|
||||||
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second;
|
pObj = it.second.get();
|
||||||
|
|
||||||
if ( !pObj->GetActif() ) continue;
|
if ( !pObj->GetActif() ) continue;
|
||||||
if ( pObj->GetProxyActivate() ) continue;
|
if ( pObj->GetProxyActivate() ) continue;
|
||||||
|
@ -268,6 +268,7 @@ CObject* CTarget::DetectFriendObject(Math::Point pos)
|
||||||
return pTarget;
|
return pTarget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue