Removed old Scrap objects; cleaned up some more if()'s

master
krzys-h 2015-08-13 19:41:21 +02:00
parent 28d88347eb
commit 275e792a81
9 changed files with 132 additions and 338 deletions

View File

@ -363,11 +363,6 @@ ObjectType CLevelParserParam::ToObjectType(std::string value)
if (value == "KeyC" ) return OBJECT_KEYc; if (value == "KeyC" ) return OBJECT_KEYc;
if (value == "KeyD" ) return OBJECT_KEYd; if (value == "KeyD" ) return OBJECT_KEYd;
if (value == "TNT" ) return OBJECT_TNT; if (value == "TNT" ) return OBJECT_TNT;
if (value == "Scrap1" ) return OBJECT_SCRAP1;
if (value == "Scrap2" ) return OBJECT_SCRAP2;
if (value == "Scrap3" ) return OBJECT_SCRAP3;
if (value == "Scrap4" ) return OBJECT_SCRAP4;
if (value == "Scrap5" ) return OBJECT_SCRAP5;
if (value == "Mine" ) return OBJECT_BOMB; if (value == "Mine" ) return OBJECT_BOMB;
if (value == "Firework" ) return OBJECT_WINFIRE; if (value == "Firework" ) return OBJECT_WINFIRE;
if (value == "Bag" ) return OBJECT_BAG; if (value == "Bag" ) return OBJECT_BAG;
@ -518,11 +513,6 @@ const std::string CLevelParserParam::FromObjectType(ObjectType value)
if (value == OBJECT_KEYc ) return "KeyC"; if (value == OBJECT_KEYc ) return "KeyC";
if (value == OBJECT_KEYd ) return "KeyD"; if (value == OBJECT_KEYd ) return "KeyD";
if (value == OBJECT_TNT ) return "TNT"; if (value == OBJECT_TNT ) return "TNT";
if (value == OBJECT_SCRAP1 ) return "Scrap1";
if (value == OBJECT_SCRAP2 ) return "Scrap2";
if (value == OBJECT_SCRAP3 ) return "Scrap3";
if (value == OBJECT_SCRAP4 ) return "Scrap4";
if (value == OBJECT_SCRAP5 ) return "Scrap5";
if (value == OBJECT_BOMB ) return "Mine"; if (value == OBJECT_BOMB ) return "Mine";
if (value == OBJECT_WINFIRE ) return "Firework"; if (value == OBJECT_WINFIRE ) return "Firework";
if (value == OBJECT_BAG ) return "Bag"; if (value == OBJECT_BAG ) return "Bag";

View File

@ -1921,121 +1921,12 @@ CObject* CRobotMain::DetectObject(Math::Point pos)
if (transporter != nullptr && !transporter->GetActive()) continue; if (transporter != nullptr && !transporter->GetActive()) continue;
if (obj->GetProxyActivate()) continue; if (obj->GetProxyActivate()) continue;
CObject* target = nullptr; CObject* target = obj;
ObjectType type = obj->GetType(); if (obj->GetType() == OBJECT_POWER || obj->GetType() == OBJECT_ATOMIC)
if ( type == OBJECT_PORTICO ||
type == OBJECT_BASE ||
type == OBJECT_DERRICK ||
type == OBJECT_FACTORY ||
type == OBJECT_REPAIR ||
type == OBJECT_DESTROYER ||
type == OBJECT_STATION ||
type == OBJECT_CONVERT ||
type == OBJECT_TOWER ||
type == OBJECT_RESEARCH ||
type == OBJECT_RADAR ||
type == OBJECT_INFO ||
type == OBJECT_ENERGY ||
type == OBJECT_LABO ||
type == OBJECT_NUCLEAR ||
type == OBJECT_PARA ||
type == OBJECT_SAFE ||
type == OBJECT_HUSTON ||
type == OBJECT_TARGET1 ||
type == OBJECT_TARGET2 ||
type == OBJECT_START ||
type == OBJECT_END ||
type == OBJECT_STONE ||
type == OBJECT_URANIUM ||
type == OBJECT_BULLET ||
type == OBJECT_METAL ||
type == OBJECT_BBOX ||
type == OBJECT_KEYa ||
type == OBJECT_KEYb ||
type == OBJECT_KEYc ||
type == OBJECT_KEYd ||
type == OBJECT_TNT ||
type == OBJECT_SCRAP1 ||
type == OBJECT_SCRAP2 ||
type == OBJECT_SCRAP3 ||
type == OBJECT_SCRAP4 ||
type == OBJECT_SCRAP5 ||
type == OBJECT_BOMB ||
type == OBJECT_BAG ||
type == OBJECT_WAYPOINT ||
type == OBJECT_FLAGb ||
type == OBJECT_FLAGr ||
type == OBJECT_FLAGg ||
type == OBJECT_FLAGy ||
type == OBJECT_FLAGv ||
type == OBJECT_MARKPOWER ||
type == OBJECT_MARKSTONE ||
type == OBJECT_MARKURANIUM ||
type == OBJECT_MARKKEYa ||
type == OBJECT_MARKKEYb ||
type == OBJECT_MARKKEYc ||
type == OBJECT_MARKKEYd ||
type == OBJECT_HUMAN ||
type == OBJECT_TECH ||
type == OBJECT_TOTO ||
type == OBJECT_MOBILEfa ||
type == OBJECT_MOBILEta ||
type == OBJECT_MOBILEwa ||
type == OBJECT_MOBILEia ||
type == OBJECT_MOBILEfc ||
type == OBJECT_MOBILEtc ||
type == OBJECT_MOBILEwc ||
type == OBJECT_MOBILEic ||
type == OBJECT_MOBILEfi ||
type == OBJECT_MOBILEti ||
type == OBJECT_MOBILEwi ||
type == OBJECT_MOBILEii ||
type == OBJECT_MOBILEfs ||
type == OBJECT_MOBILEts ||
type == OBJECT_MOBILEws ||
type == OBJECT_MOBILEis ||
type == OBJECT_MOBILErt ||
type == OBJECT_MOBILErc ||
type == OBJECT_MOBILErr ||
type == OBJECT_MOBILErs ||
type == OBJECT_MOBILEsa ||
type == OBJECT_MOBILEtg ||
type == OBJECT_MOBILEft ||
type == OBJECT_MOBILEtt ||
type == OBJECT_MOBILEwt ||
type == OBJECT_MOBILEit ||
type == OBJECT_MOBILEdr ||
type == OBJECT_MOTHER ||
type == OBJECT_ANT ||
type == OBJECT_SPIDER ||
type == OBJECT_BEE ||
type == OBJECT_WORM ||
type == OBJECT_EGG ||
type == OBJECT_RUINmobilew1 ||
type == OBJECT_RUINmobilew2 ||
type == OBJECT_RUINmobilet1 ||
type == OBJECT_RUINmobilet2 ||
type == OBJECT_RUINmobiler1 ||
type == OBJECT_RUINmobiler2 ||
type == OBJECT_RUINfactory ||
type == OBJECT_RUINdoor ||
type == OBJECT_RUINsupport ||
type == OBJECT_RUINradar ||
type == OBJECT_RUINconvert ||
type == OBJECT_RUINbase ||
type == OBJECT_RUINhead ||
type == OBJECT_APOLLO1 ||
type == OBJECT_APOLLO2 ||
type == OBJECT_APOLLO3 ||
type == OBJECT_APOLLO4 ||
type == OBJECT_APOLLO5 )
{
target = obj;
}
else if (type == OBJECT_POWER || type == OBJECT_ATOMIC)
{ {
assert(obj->Implements(ObjectInterfaceType::Transportable));
target = dynamic_cast<CTransportableObject*>(obj)->GetTransporter(); // battery connected target = dynamic_cast<CTransportableObject*>(obj)->GetTransporter(); // battery connected
if (!target) target = obj; // standalone battery if (target == nullptr) target = obj; // standalone battery
} }
for (int j = 0; j < OBJECTMAXPART; j++) for (int j = 0; j < OBJECTMAXPART; j++)
@ -2052,75 +1943,25 @@ CObject* CRobotMain::DetectObject(Math::Point pos)
//! Indicates whether an object is selectable //! Indicates whether an object is selectable
bool CRobotMain::IsSelectable(CObject* obj) bool CRobotMain::IsSelectable(CObject* obj)
{ {
if (obj->GetType() == OBJECT_TOTO) return true;
if (!obj->Implements(ObjectInterfaceType::Controllable)) return false; if (!obj->Implements(ObjectInterfaceType::Controllable)) return false;
if (!dynamic_cast<CControllableObject*>(obj)->GetSelectable()) return false;
ObjectType type = obj->GetType(); if (!m_selectInsect)
if ( type == OBJECT_HUMAN ||
type == OBJECT_TOTO ||
type == OBJECT_MOBILEfa ||
type == OBJECT_MOBILEta ||
type == OBJECT_MOBILEwa ||
type == OBJECT_MOBILEia ||
type == OBJECT_MOBILEfc ||
type == OBJECT_MOBILEtc ||
type == OBJECT_MOBILEwc ||
type == OBJECT_MOBILEic ||
type == OBJECT_MOBILEfi ||
type == OBJECT_MOBILEti ||
type == OBJECT_MOBILEwi ||
type == OBJECT_MOBILEii ||
type == OBJECT_MOBILEfs ||
type == OBJECT_MOBILEts ||
type == OBJECT_MOBILEws ||
type == OBJECT_MOBILEis ||
type == OBJECT_MOBILErt ||
type == OBJECT_MOBILErc ||
type == OBJECT_MOBILErr ||
type == OBJECT_MOBILErs ||
type == OBJECT_MOBILEsa ||
type == OBJECT_MOBILEft ||
type == OBJECT_MOBILEtt ||
type == OBJECT_MOBILEwt ||
type == OBJECT_MOBILEit ||
type == OBJECT_MOBILEdr ||
type == OBJECT_APOLLO2 ||
type == OBJECT_BASE ||
type == OBJECT_DERRICK ||
type == OBJECT_FACTORY ||
type == OBJECT_REPAIR ||
type == OBJECT_DESTROYER||
type == OBJECT_STATION ||
type == OBJECT_CONVERT ||
type == OBJECT_TOWER ||
type == OBJECT_RESEARCH ||
type == OBJECT_RADAR ||
type == OBJECT_INFO ||
type == OBJECT_ENERGY ||
type == OBJECT_LABO ||
type == OBJECT_NUCLEAR ||
type == OBJECT_PARA ||
type == OBJECT_SAFE ||
type == OBJECT_HUSTON )
{ {
return true; // TODO: Some function in CControllableObject
} if ( obj->GetType() == OBJECT_MOTHER ||
obj->GetType() == OBJECT_ANT ||
if (m_selectInsect) obj->GetType() == OBJECT_SPIDER ||
obj->GetType() == OBJECT_BEE ||
obj->GetType() == OBJECT_WORM ||
obj->GetType() == OBJECT_MOBILEtg )
{ {
if ( type == OBJECT_MOTHER ||
type == OBJECT_ANT ||
type == OBJECT_SPIDER ||
type == OBJECT_BEE ||
type == OBJECT_WORM ||
type == OBJECT_MOBILEtg )
{
return true;
}
}
return false; return false;
} }
}
return dynamic_cast<CControllableObject*>(obj)->GetSelectable();
}
//! Deletes the selected object //! Deletes the selected object

View File

@ -66,15 +66,7 @@ int CSceneCondition::CountObjects()
if (IsObjectBeingTransported(obj)) continue; if (IsObjectBeingTransported(obj)) continue;
} }
// TODO: I really hate those fragments that hardcode subcategories into one in random places in code, we should refactor that at some point
ObjectType type = obj->GetType(); ObjectType type = obj->GetType();
if (type == OBJECT_SCRAP2 ||
type == OBJECT_SCRAP3 ||
type == OBJECT_SCRAP4 ||
type == OBJECT_SCRAP5) // wastes?
{
type = OBJECT_SCRAP1;
}
ToolType tool = GetToolFromObject(type); ToolType tool = GetToolFromObject(type);
DriveType drive = GetDriveFromObject(type); DriveType drive = GetDriveFromObject(type);

View File

@ -389,10 +389,7 @@ CObject* CAutoPowerPlant::SearchMetal()
if ( obj == nullptr ) return nullptr; if ( obj == nullptr ) return nullptr;
ObjectType type = obj->GetType(); ObjectType type = obj->GetType();
if ( type == OBJECT_METAL || if ( type == OBJECT_METAL ) return obj;
type == OBJECT_SCRAP1 ||
type == OBJECT_SCRAP2 ||
type == OBJECT_SCRAP3 ) return obj;
return nullptr; return nullptr;
} }
@ -511,10 +508,7 @@ Error CAutoPowerPlant::GetError()
if (obj == nullptr) return ERR_ENERGY_EMPTY; if (obj == nullptr) return ERR_ENERGY_EMPTY;
ObjectType type = obj->GetType(); ObjectType type = obj->GetType();
if ( type == OBJECT_POWER ) return ERR_OK; if ( type == OBJECT_POWER ) return ERR_OK;
if ( type != OBJECT_METAL && if ( type != OBJECT_METAL ) return ERR_ENERGY_BAD;
type != OBJECT_SCRAP1 &&
type != OBJECT_SCRAP2 &&
type != OBJECT_SCRAP3 ) return ERR_ENERGY_BAD;
return ERR_OK; return ERR_OK;
} }

View File

@ -147,11 +147,6 @@ CObjectUPtr CObjectFactory::CreateObject(const ObjectCreateParams& params)
case OBJECT_KEYc: case OBJECT_KEYc:
case OBJECT_KEYd: case OBJECT_KEYd:
case OBJECT_TNT: case OBJECT_TNT:
case OBJECT_SCRAP1:
case OBJECT_SCRAP2:
case OBJECT_SCRAP3:
case OBJECT_SCRAP4:
case OBJECT_SCRAP5:
case OBJECT_BOMB: case OBJECT_BOMB:
case OBJECT_WAYPOINT: case OBJECT_WAYPOINT:
case OBJECT_SHOW: case OBJECT_SHOW:
@ -1088,11 +1083,6 @@ CObjectUPtr CObjectFactory::CreateResource(const ObjectCreateParams& params)
if ( type == OBJECT_KEYc ) name = "keyc.mod"; if ( type == OBJECT_KEYc ) name = "keyc.mod";
if ( type == OBJECT_KEYd ) name = "keyd.mod"; if ( type == OBJECT_KEYd ) name = "keyd.mod";
if ( type == OBJECT_TNT ) name = "tnt.mod"; if ( type == OBJECT_TNT ) name = "tnt.mod";
if ( type == OBJECT_SCRAP1 ) name = "scrap1.mod";
if ( type == OBJECT_SCRAP2 ) name = "scrap2.mod";
if ( type == OBJECT_SCRAP3 ) name = "scrap3.mod";
if ( type == OBJECT_SCRAP4 ) name = "scrap4.mod";
if ( type == OBJECT_SCRAP5 ) name = "scrap5.mod";
if ( type == OBJECT_BOMB ) name = "bomb.mod"; if ( type == OBJECT_BOMB ) name = "bomb.mod";
if ( type == OBJECT_WAYPOINT ) name = "waypoint.mod"; if ( type == OBJECT_WAYPOINT ) name = "waypoint.mod";
if ( type == OBJECT_SHOW ) name = "show.mod"; if ( type == OBJECT_SHOW ) name = "show.mod";

View File

@ -305,14 +305,6 @@ CObject* CObjectManager::Radar(CObject* pThis, Math::Vector thisPosition, float
oType = OBJECT_RUINmobilew1; // any ruin oType = OBJECT_RUINmobilew1; // any ruin
} }
if ( oType == OBJECT_SCRAP2 ||
oType == OBJECT_SCRAP3 ||
oType == OBJECT_SCRAP4 ||
oType == OBJECT_SCRAP5 ) // wastes?
{
oType = OBJECT_SCRAP1; // any waste
}
if ( oType == OBJECT_BARRIER2 || if ( oType == OBJECT_BARRIER2 ||
oType == OBJECT_BARRIER3 ) // barriers? oType == OBJECT_BARRIER3 ) // barriers?
{ {

View File

@ -556,12 +556,7 @@ void COldObject::DestroyObject(DestructionType type)
m_type == OBJECT_ATOMIC || m_type == OBJECT_ATOMIC ||
m_type == OBJECT_BULLET || m_type == OBJECT_BULLET ||
m_type == OBJECT_BBOX || m_type == OBJECT_BBOX ||
m_type == OBJECT_TNT || m_type == OBJECT_TNT ) // (*)
m_type == OBJECT_SCRAP1 ||
m_type == OBJECT_SCRAP2 ||
m_type == OBJECT_SCRAP3 ||
m_type == OBJECT_SCRAP4 ||
m_type == OBJECT_SCRAP5 ) // (*)
{ {
CScriptFunctions::DestroyObjectVar(m_botVar, false); CScriptFunctions::DestroyObjectVar(m_botVar, false);
} }
@ -696,22 +691,43 @@ void COldObject::SetType(ObjectType type)
} }
// TODO: Another temporary hack // TODO: Another temporary hack
if ( m_type == OBJECT_MOTHER || if (m_type == OBJECT_MOBILEfa ||
m_type == OBJECT_ANT || m_type == OBJECT_MOBILEta ||
m_type == OBJECT_SPIDER || m_type == OBJECT_MOBILEwa ||
m_type == OBJECT_BEE || m_type == OBJECT_MOBILEia ||
m_type == OBJECT_WORM || m_type == OBJECT_MOBILEfc ||
m_type == OBJECT_APOLLO2 || m_type == OBJECT_MOBILEtc ||
m_type == OBJECT_MOBILEdr || m_type == OBJECT_MOBILEwc ||
m_type == OBJECT_CONTROLLER || m_type == OBJECT_MOBILEic ||
m_type == OBJECT_HUMAN || m_type == OBJECT_MOBILEfi ||
m_type == OBJECT_TECH ) m_type == OBJECT_MOBILEti ||
m_type == OBJECT_MOBILEwi ||
m_type == OBJECT_MOBILEii ||
m_type == OBJECT_MOBILEfs ||
m_type == OBJECT_MOBILEts ||
m_type == OBJECT_MOBILEws ||
m_type == OBJECT_MOBILEis ||
m_type == OBJECT_MOBILErt ||
m_type == OBJECT_MOBILErc ||
m_type == OBJECT_MOBILErr ||
m_type == OBJECT_MOBILErs ||
m_type == OBJECT_MOBILEsa ||
m_type == OBJECT_MOBILEtg ||
m_type == OBJECT_MOBILEft ||
m_type == OBJECT_MOBILEtt ||
m_type == OBJECT_MOBILEwt ||
m_type == OBJECT_MOBILEit ||
m_type == OBJECT_TOWER ||
m_type == OBJECT_RESEARCH ||
m_type == OBJECT_ENERGY ||
m_type == OBJECT_LABO ||
m_type == OBJECT_NUCLEAR )
{ {
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Powered)] = false; m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Powered)] = true;
} }
else else
{ {
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Powered)] = true; m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Powered)] = false;
} }
// TODO: Hacking some more // TODO: Hacking some more
@ -720,11 +736,6 @@ void COldObject::SetType(ObjectType type)
m_type == OBJECT_POWER || m_type == OBJECT_POWER ||
m_type == OBJECT_ATOMIC || m_type == OBJECT_ATOMIC ||
m_type == OBJECT_TNT || m_type == OBJECT_TNT ||
m_type == OBJECT_SCRAP1 ||
m_type == OBJECT_SCRAP2 ||
m_type == OBJECT_SCRAP3 ||
m_type == OBJECT_SCRAP4 ||
m_type == OBJECT_SCRAP5 ||
m_type == OBJECT_BULLET || m_type == OBJECT_BULLET ||
m_type == OBJECT_EGG || m_type == OBJECT_EGG ||
m_type == OBJECT_BOMB || m_type == OBJECT_BOMB ||
@ -803,6 +814,83 @@ void COldObject::SetType(ObjectType type)
// TODO: #TooMuchHacking // TODO: #TooMuchHacking
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::ShieldedAutoRegen)] = (m_type == OBJECT_HUMAN); m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::ShieldedAutoRegen)] = (m_type == OBJECT_HUMAN);
// TODO: Hacking in progress...
if ( m_type == OBJECT_FRET ||
m_type == OBJECT_STONE ||
m_type == OBJECT_URANIUM ||
m_type == OBJECT_BULLET ||
m_type == OBJECT_METAL ||
m_type == OBJECT_POWER ||
m_type == OBJECT_ATOMIC ||
m_type == OBJECT_BBOX ||
m_type == OBJECT_KEYa ||
m_type == OBJECT_KEYb ||
m_type == OBJECT_KEYc ||
m_type == OBJECT_KEYd ||
m_type == OBJECT_TNT )
{
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Transportable)] = true;
}
else
{
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Transportable)] = false;
}
// TODO: You have been hacked!
if (m_type == OBJECT_HUMAN ||
m_type == OBJECT_TOTO ||
m_type == OBJECT_MOBILEfa ||
m_type == OBJECT_MOBILEta ||
m_type == OBJECT_MOBILEwa ||
m_type == OBJECT_MOBILEia ||
m_type == OBJECT_MOBILEfc ||
m_type == OBJECT_MOBILEtc ||
m_type == OBJECT_MOBILEwc ||
m_type == OBJECT_MOBILEic ||
m_type == OBJECT_MOBILEfi ||
m_type == OBJECT_MOBILEti ||
m_type == OBJECT_MOBILEwi ||
m_type == OBJECT_MOBILEii ||
m_type == OBJECT_MOBILEfs ||
m_type == OBJECT_MOBILEts ||
m_type == OBJECT_MOBILEws ||
m_type == OBJECT_MOBILEis ||
m_type == OBJECT_MOBILErt ||
m_type == OBJECT_MOBILErc ||
m_type == OBJECT_MOBILErr ||
m_type == OBJECT_MOBILErs ||
m_type == OBJECT_MOBILEsa ||
m_type == OBJECT_MOBILEft ||
m_type == OBJECT_MOBILEtt ||
m_type == OBJECT_MOBILEwt ||
m_type == OBJECT_MOBILEit ||
m_type == OBJECT_MOBILEdr ||
m_type == OBJECT_APOLLO2 ||
m_type == OBJECT_BASE ||
m_type == OBJECT_DERRICK ||
m_type == OBJECT_FACTORY ||
m_type == OBJECT_REPAIR ||
m_type == OBJECT_DESTROYER||
m_type == OBJECT_STATION ||
m_type == OBJECT_CONVERT ||
m_type == OBJECT_TOWER ||
m_type == OBJECT_RESEARCH ||
m_type == OBJECT_RADAR ||
m_type == OBJECT_INFO ||
m_type == OBJECT_ENERGY ||
m_type == OBJECT_LABO ||
m_type == OBJECT_NUCLEAR ||
m_type == OBJECT_PARA ||
m_type == OBJECT_SAFE ||
m_type == OBJECT_HUSTON )
{
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Controllable)] = true;
}
else
{
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Controllable)] = false;
}
if ( m_type == OBJECT_MOBILEwc || if ( m_type == OBJECT_MOBILEwc ||
m_type == OBJECT_MOBILEtc || m_type == OBJECT_MOBILEtc ||
@ -2312,11 +2400,6 @@ float COldObject::GetShield()
m_type == OBJECT_KEYc || m_type == OBJECT_KEYc ||
m_type == OBJECT_KEYd || m_type == OBJECT_KEYd ||
m_type == OBJECT_TNT || m_type == OBJECT_TNT ||
m_type == OBJECT_SCRAP1 ||
m_type == OBJECT_SCRAP2 ||
m_type == OBJECT_SCRAP3 ||
m_type == OBJECT_SCRAP4 ||
m_type == OBJECT_SCRAP5 ||
m_type == OBJECT_BOMB || m_type == OBJECT_BOMB ||
m_type == OBJECT_WAYPOINT || m_type == OBJECT_WAYPOINT ||
m_type == OBJECT_FLAGb || m_type == OBJECT_FLAGb ||

View File

@ -725,7 +725,6 @@ CObject* CTaskManip::SearchTakeUnderObject(Math::Vector &pos, float dLimit)
{ {
CObject *pBest; CObject *pBest;
Math::Vector iPos, oPos; Math::Vector iPos, oPos;
ObjectType type;
float min, distance; float min, distance;
iPos = m_object->GetPosition(); iPos = m_object->GetPosition();
@ -734,21 +733,7 @@ CObject* CTaskManip::SearchTakeUnderObject(Math::Vector &pos, float dLimit)
pBest = 0; pBest = 0;
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects()) for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
{ {
type = pObj->GetType(); if ( !pObj->Implements(ObjectInterfaceType::Transportable) ) continue;
if ( type != OBJECT_FRET &&
type != OBJECT_STONE &&
type != OBJECT_URANIUM &&
type != OBJECT_BULLET &&
type != OBJECT_METAL &&
type != OBJECT_POWER &&
type != OBJECT_ATOMIC &&
type != OBJECT_BBOX &&
type != OBJECT_KEYa &&
type != OBJECT_KEYb &&
type != OBJECT_KEYc &&
type != OBJECT_KEYd &&
type != OBJECT_TNT ) continue;
if (IsObjectBeingTransported(pObj)) continue; if (IsObjectBeingTransported(pObj)) continue;
if ( pObj->GetLock() ) continue; if ( pObj->GetLock() ) continue;
@ -777,7 +762,6 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos,
{ {
CObject *pBest; CObject *pBest;
Math::Vector iPos, oPos; Math::Vector iPos, oPos;
ObjectType type;
float min, iAngle, bAngle, aLimit, dLimit, f; float min, iAngle, bAngle, aLimit, dLimit, f;
iPos = m_object->GetPosition(); iPos = m_object->GetPosition();
@ -801,26 +785,7 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos,
bAngle = 0.0f; bAngle = 0.0f;
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects()) for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
{ {
type = pObj->GetType(); if ( !pObj->Implements(ObjectInterfaceType::Transportable) ) continue;
if ( type != OBJECT_FRET &&
type != OBJECT_STONE &&
type != OBJECT_URANIUM &&
type != OBJECT_BULLET &&
type != OBJECT_METAL &&
type != OBJECT_POWER &&
type != OBJECT_ATOMIC &&
type != OBJECT_BBOX &&
type != OBJECT_KEYa &&
type != OBJECT_KEYb &&
type != OBJECT_KEYc &&
type != OBJECT_KEYd &&
type != OBJECT_TNT &&
type != OBJECT_SCRAP1 &&
type != OBJECT_SCRAP2 &&
type != OBJECT_SCRAP3 &&
type != OBJECT_SCRAP4 &&
type != OBJECT_SCRAP5 ) continue;
if (IsObjectBeingTransported(pObj)) continue; if (IsObjectBeingTransported(pObj)) continue;
if ( pObj->GetLock() ) continue; if ( pObj->GetLock() ) continue;
@ -865,7 +830,6 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos,
{ {
CObject *pBest; CObject *pBest;
Math::Vector iPos, oPos; Math::Vector iPos, oPos;
ObjectType type;
float min, iAngle, bAngle, aLimit, dLimit, f; float min, iAngle, bAngle, aLimit, dLimit, f;
iPos = m_object->GetPosition(); iPos = m_object->GetPosition();
@ -888,26 +852,7 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos,
bAngle = 0.0f; bAngle = 0.0f;
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects()) for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
{ {
type = pObj->GetType(); if ( !pObj->Implements(ObjectInterfaceType::Transportable) ) continue;
if ( type != OBJECT_FRET &&
type != OBJECT_STONE &&
type != OBJECT_URANIUM &&
type != OBJECT_BULLET &&
type != OBJECT_METAL &&
type != OBJECT_POWER &&
type != OBJECT_ATOMIC &&
type != OBJECT_BBOX &&
type != OBJECT_KEYa &&
type != OBJECT_KEYb &&
type != OBJECT_KEYc &&
type != OBJECT_KEYd &&
type != OBJECT_TNT &&
type != OBJECT_SCRAP1 &&
type != OBJECT_SCRAP2 &&
type != OBJECT_SCRAP3 &&
type != OBJECT_SCRAP4 &&
type != OBJECT_SCRAP5 ) continue;
if (IsObjectBeingTransported(pObj)) continue; if (IsObjectBeingTransported(pObj)) continue;
if ( pObj->GetLock() ) continue; if ( pObj->GetLock() ) continue;
@ -983,39 +928,8 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos,
if ( pObj == m_object ) continue; // yourself? if ( pObj == m_object ) continue; // yourself?
ObjectType type = pObj->GetType(); ObjectType type = pObj->GetType();
if ( type != OBJECT_MOBILEfa && if ( !pObj->Implements(ObjectInterfaceType::Powered) ) continue;
type != OBJECT_MOBILEta &&
type != OBJECT_MOBILEwa &&
type != OBJECT_MOBILEia &&
type != OBJECT_MOBILEfc &&
type != OBJECT_MOBILEtc &&
type != OBJECT_MOBILEwc &&
type != OBJECT_MOBILEic &&
type != OBJECT_MOBILEfi &&
type != OBJECT_MOBILEti &&
type != OBJECT_MOBILEwi &&
type != OBJECT_MOBILEii &&
type != OBJECT_MOBILEfs &&
type != OBJECT_MOBILEts &&
type != OBJECT_MOBILEws &&
type != OBJECT_MOBILEis &&
type != OBJECT_MOBILErt &&
type != OBJECT_MOBILErc &&
type != OBJECT_MOBILErr &&
type != OBJECT_MOBILErs &&
type != OBJECT_MOBILEsa &&
type != OBJECT_MOBILEtg &&
type != OBJECT_MOBILEft &&
type != OBJECT_MOBILEtt &&
type != OBJECT_MOBILEwt &&
type != OBJECT_MOBILEit &&
type != OBJECT_TOWER &&
type != OBJECT_RESEARCH &&
type != OBJECT_ENERGY &&
type != OBJECT_LABO &&
type != OBJECT_NUCLEAR ) continue;
assert(pObj->Implements(ObjectInterfaceType::Powered));
CObject* power = dynamic_cast<CPoweredObject*>(pObj)->GetPower(); CObject* power = dynamic_cast<CPoweredObject*>(pObj)->GetPower();
if (power != nullptr) if (power != nullptr)
{ {

View File

@ -66,7 +66,6 @@ const char* GetObjectName(ObjectType type)
if ( type == OBJECT_KEYc ) return "KeyC"; if ( type == OBJECT_KEYc ) return "KeyC";
if ( type == OBJECT_KEYd ) return "KeyD"; if ( type == OBJECT_KEYd ) return "KeyD";
if ( type == OBJECT_TNT ) return "TNT"; if ( type == OBJECT_TNT ) return "TNT";
if ( type == OBJECT_SCRAP1 ) return "Scrap";
if ( type == OBJECT_BOMB ) return "Mine"; if ( type == OBJECT_BOMB ) return "Mine";
if ( type == OBJECT_BARRIER1 ) return "Barrier"; if ( type == OBJECT_BARRIER1 ) return "Barrier";
if ( type == OBJECT_WAYPOINT ) return "WayPoint"; if ( type == OBJECT_WAYPOINT ) return "WayPoint";
@ -169,7 +168,6 @@ std::string GetHelpFilename(ObjectType type)
if ( type == OBJECT_KEYc ) helpfile = "object/key"; if ( type == OBJECT_KEYc ) helpfile = "object/key";
if ( type == OBJECT_KEYd ) helpfile = "object/key"; if ( type == OBJECT_KEYd ) helpfile = "object/key";
if ( type == OBJECT_TNT ) helpfile = "object/tnt"; if ( type == OBJECT_TNT ) helpfile = "object/tnt";
if ( type == OBJECT_SCRAP1 ) helpfile = "object/scrap";
if ( type == OBJECT_BOMB ) helpfile = "object/mine"; if ( type == OBJECT_BOMB ) helpfile = "object/mine";
if ( type == OBJECT_BARRIER1 ) helpfile = "object/barrier"; if ( type == OBJECT_BARRIER1 ) helpfile = "object/barrier";
if ( type == OBJECT_WAYPOINT ) helpfile = "object/waypoint"; if ( type == OBJECT_WAYPOINT ) helpfile = "object/waypoint";