Fixed #424, #423 and probably #421

master
krzys-h 2015-01-08 18:56:26 +01:00
parent 986cf98aaf
commit 61b186343f
5 changed files with 47 additions and 7 deletions

View File

@ -552,7 +552,26 @@ bool CAutoFactory::Read(CLevelParserLine* line)
CObject* CAutoFactory::SearchFret()
{
return CObjectManager::GetInstancePointer()->FindNearest(nullptr, m_fretPos, OBJECT_METAL, 8.0f/g_unit);
CObject* pObj;
Math::Vector oPos;
ObjectType type;
float dist;
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
{
pObj = it.second;
type = pObj->GetType();
if ( type != OBJECT_METAL ) continue;
if ( pObj->GetTruck() != 0 ) continue;
oPos = pObj->GetPosition(0);
dist = Math::Distance(oPos, m_fretPos);
if ( dist < 8.0f ) return pObj;
}
return 0;
}
// Search if a vehicle is too close.
@ -674,7 +693,28 @@ bool CAutoFactory::CreateVehicle()
CObject* CAutoFactory::SearchVehicle()
{
return CObjectManager::GetInstancePointer()->FindNearest(nullptr, m_fretPos, m_type, 8.0f/g_unit);
CObject* pObj;
Math::Vector oPos;
ObjectType type;
float dist;
for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects())
{
pObj = it.second;
if ( !pObj->GetLock() ) continue;
type = pObj->GetType();
if ( type != m_type ) continue;
if ( pObj->GetTruck() != 0 ) continue;
oPos = pObj->GetPosition(0);
dist = Math::Distance(oPos, m_fretPos);
if ( dist < 8.0f ) return pObj;
}
return 0;
}
// Creates all the interface when the object is selected.

View File

@ -28,7 +28,7 @@
#include "common/singleton.h"
#include <unordered_map>
#include <map>
/**
* \class ObjectManager

View File

@ -1031,7 +1031,7 @@ Error CTaskGoto::IsEnded()
CObject* CTaskGoto::SearchTarget(Math::Vector pos, float margin)
{
return CObjectManager::GetInstancePointer()->FindNearest(nullptr, pos, OBJECT_NULL, margin);;
return CObjectManager::GetInstancePointer()->FindNearest(nullptr, pos, OBJECT_NULL, margin/g_unit);
}
// Adjusts the target as a function of the object.

View File

@ -384,6 +384,6 @@ bool CTaskRecover::Abort()
CObject* CTaskRecover::SearchRuin()
{
return CObjectManager::GetInstancePointer()->FindNearest(nullptr, m_recoverPos, {OBJECT_RUINmobilew1, OBJECT_RUINmobilew2, OBJECT_RUINmobilet1, OBJECT_RUINmobilet2, OBJECT_RUINmobiler1, OBJECT_RUINmobiler2}, 10.0f);
return CObjectManager::GetInstancePointer()->FindNearest(nullptr, m_recoverPos, {OBJECT_RUINmobilew1, OBJECT_RUINmobilew2, OBJECT_RUINmobilet1, OBJECT_RUINmobilet2, OBJECT_RUINmobiler1, OBJECT_RUINmobiler2}, 40.0f/g_unit);
}

View File

@ -1186,12 +1186,12 @@ bool CScriptFunctions::rRadar(CBotVar* var, CBotVar* result, int& exception, voi
var = var->GetNext();
if ( var != 0 )
{
minDist = var->GetValFloat()*g_unit;
minDist = var->GetValFloat();
var = var->GetNext();
if ( var != 0 )
{
maxDist = var->GetValFloat()*g_unit;
maxDist = var->GetValFloat();
var = var->GetNext();
if ( var != 0 )