summaryrefslogtreecommitdiffstats
path: root/src/script
diff options
context:
space:
mode:
authorkrzys-h <krzys_h@interia.pl>2013-04-12 23:28:44 +0200
committerkrzys-h <krzys_h@interia.pl>2013-04-12 23:28:44 +0200
commit69e52e5f24d3e02dde20bda5ee322697bafc92c8 (patch)
tree19f8a0076d84f2830811f5bdec8a8ec33c1e9284 /src/script
parent7b2e0e6519525f872fb58df7f287eaefd3c15782 (diff)
downloadcolobot-69e52e5f24d3e02dde20bda5ee322697bafc92c8.tar.gz
colobot-69e52e5f24d3e02dde20bda5ee322697bafc92c8.tar.bz2
colobot-69e52e5f24d3e02dde20bda5ee322697bafc92c8.zip
Removed find() & repeat() functions
Issue #168
Diffstat (limited to 'src/script')
-rw-r--r--src/script/cbottoken.cpp5
-rw-r--r--src/script/script.cpp142
2 files changed, 0 insertions, 147 deletions
diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp
index 95b259b..19b0f78 100644
--- a/src/script/cbottoken.cpp
+++ b/src/script/cbottoken.cpp
@@ -220,7 +220,6 @@ std::string GetHelpFilename(const char *token)
{
if ( strcmp(token, "if" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/if.txt");
if ( strcmp(token, "else" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/if.txt");
- if ( strcmp(token, "repeat" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/repeat.txt");
if ( strcmp(token, "for" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/for.txt");
if ( strcmp(token, "while" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/while.txt");
if ( strcmp(token, "do" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/do.txt");
@@ -262,7 +261,6 @@ std::string GetHelpFilename(const char *token)
if ( strcmp(token, "move" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/move.txt");
if ( strcmp(token, "turn" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/turn.txt");
if ( strcmp(token, "goto" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/goto.txt");
- if ( strcmp(token, "find" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/find.txt");
if ( strcmp(token, "grab" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/grab.txt");
if ( strcmp(token, "drop" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/drop.txt");
if ( strcmp(token, "sniff" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/sniff.txt");
@@ -380,7 +378,6 @@ bool IsFunction(const char *token)
if ( strcmp(token, "move" ) == 0 ) return true;
if ( strcmp(token, "turn" ) == 0 ) return true;
if ( strcmp(token, "goto" ) == 0 ) return true;
- if ( strcmp(token, "find" ) == 0 ) return true;
if ( strcmp(token, "grab" ) == 0 ) return true;
if ( strcmp(token, "drop" ) == 0 ) return true;
if ( strcmp(token, "sniff" ) == 0 ) return true;
@@ -432,7 +429,6 @@ const char* GetHelpText(const char *token)
{
if ( strcmp(token, "if" ) == 0 ) return "if ( condition ) { bloc }";
if ( strcmp(token, "else" ) == 0 ) return "else { bloc }";
- if ( strcmp(token, "repeat" ) == 0 ) return "repeat ( number )";
if ( strcmp(token, "for" ) == 0 ) return "for ( before ; condition ; end )";
if ( strcmp(token, "while" ) == 0 ) return "while ( condition ) { bloc }";
if ( strcmp(token, "do" ) == 0 ) return "do { bloc } while ( condition );";
@@ -464,7 +460,6 @@ const char* GetHelpText(const char *token)
if ( strcmp(token, "move" ) == 0 ) return "move ( distance );";
if ( strcmp(token, "turn" ) == 0 ) return "turn ( angle );";
if ( strcmp(token, "goto" ) == 0 ) return "goto ( position, altitude );";
- if ( strcmp(token, "find" ) == 0 ) return "find ( cat );";
if ( strcmp(token, "grab" ) == 0 ) return "grab ( order );";
if ( strcmp(token, "drop" ) == 0 ) return "drop ( order );";
if ( strcmp(token, "sniff" ) == 0 ) return "sniff ( );";
diff --git a/src/script/script.cpp b/src/script/script.cpp
index 6095e05..b3fd6ce 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -1632,147 +1632,6 @@ bool CScript::rGoto(CBotVar* var, CBotVar* result, int& exception, void* user)
return Process(script, result, exception);
}
-// Instruction "find(type)".
-
-bool CScript::rFind(CBotVar* var, CBotVar* result, int& exception, void* user)
-{
- CScript* script = (static_cast<CObject *>(user))->GetRunScript();
- Math::Vector pos;
- TaskGotoGoal goal;
- TaskGotoCrash crash;
- float altitude;
- Error err;
- CObject* pThis = static_cast<CObject *>(user);
- CObject *pObj, *pBest;
- CBotVar* array;
- Math::Vector iPos, oPos;
- float best, minDist, maxDist, iAngle, focus, d, a;
- int type, oType, i;
- bool bArray;
-
- exception = 0;
-
- if ( script->m_primaryTask == 0 ) // no task in progress?
- {
- type = OBJECT_NULL;
- focus = Math::PI*2.0f;
- minDist = 0.0f*g_unit;
- maxDist = 1000.0f*g_unit;
-
- if ( var->GetType() == CBotTypArrayPointer )
- {
- array = var->GetItemList();
- bArray = true;
- }
- else
- {
- type = var->GetValInt();
- bArray = false;
- }
-
- CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
-
- best = 100000.0f;
- pBest = 0;
- for ( i=0 ; i<1000000 ; i++ )
- {
- pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
- if ( pObj == 0 ) break;
- if ( pObj == pThis ) continue;
-
- if ( pObj->GetTruck() != 0 ) continue; // object transported?
- if ( !pObj->GetActif() ) continue;
- if ( pObj->GetProxyActivate() ) continue;
-
- oType = pObj->GetType();
- if ( oType == OBJECT_TOTO ) continue;
-
- if ( oType == OBJECT_RUINmobilew2 ||
- oType == OBJECT_RUINmobilet1 ||
- oType == OBJECT_RUINmobilet2 ||
- oType == OBJECT_RUINmobiler1 ||
- oType == OBJECT_RUINmobiler2 )
- {
- 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 ||
- oType == OBJECT_BARRIER3 ) // barriers?
- {
- oType = OBJECT_BARRIER1; // any barrier
- }
-
- if ( bArray )
- {
- if ( !FindList(array, oType) ) continue;
- }
- else
- {
- if ( type != oType && type != OBJECT_NULL ) continue;
- }
-
- oPos = pObj->GetPosition(0);
- d = Math::DistanceProjected(iPos, oPos);
- if ( d < minDist || d > maxDist ) continue; // too close or too far?
-
- if ( focus >= Math::PI*2.0f )
- {
- if ( d < best )
- {
- best = d;
- pBest = pObj;
- }
- continue;
- }
-
- a = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
- if ( Math::TestAngle(a, iAngle-focus/2.0f, iAngle+focus/2.0f) )
- {
- if ( d < best )
- {
- best = d;
- pBest = pObj;
- }
- }
- }
-
- if ( pBest == 0 )
- {
- exception = ERR_FIND_IMPOSSIBLE;
- return false;
- }
-
- pos = pBest->GetPosition(0);
- goal = TGG_DEFAULT;
- crash = TGC_DEFAULT;
- altitude = 0.0f*g_unit;
-
- script->m_primaryTask = new CTaskManager(script->m_object);
- err = script->m_primaryTask->StartTaskGoto(pos, altitude, goal, crash);
- if ( err != ERR_OK )
- {
- delete script->m_primaryTask;
- script->m_primaryTask = 0;
- result->SetValInt(err); // shows the error
- if ( script->m_errMode == ERM_STOP )
- {
- exception = err;
- return false;
- }
- return true;
- }
- }
- return Process(script, result, exception);
-}
-
// Compilation "grab/drop(oper)".
CBotTypResult CScript::cGrabDrop(CBotVar* &var, void* user)
@@ -2968,7 +2827,6 @@ void CScript::InitFonctions()
CBotProgram::AddFunction("move", rMove, CScript::cOneFloat);
CBotProgram::AddFunction("turn", rTurn, CScript::cOneFloat);
CBotProgram::AddFunction("goto", rGoto, CScript::cGoto);
- CBotProgram::AddFunction("find", rFind, CScript::cOneFloat);
CBotProgram::AddFunction("grab", rGrab, CScript::cGrabDrop);
CBotProgram::AddFunction("drop", rDrop, CScript::cGrabDrop);
CBotProgram::AddFunction("sniff", rSniff, CScript::cNull);