MCPcopy Create free account
hub / github.com/MergHQ/CRYENGINE / CreateQueryFromTacticalSpec

Method CreateQueryFromTacticalSpec

Code/CryEngine/CryAISystem/ScriptBind_AI.cpp:10390–10538  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10388}
10389
10390int CScriptBind_AI::CreateQueryFromTacticalSpec(SmartScriptTable specTable)
10391{
10392 ITacticalPointSystem* pTPS = gAIEnv.pTacticalPointSystem;
10393 int option = 0;
10394 bool bOk = true, bAllTables = true, bAtLeastOneGenerationProvided = false, bAtLeastOneWeightProvided = false;
10395
10396 // Myriad checking to add here :/
10397
10398 char* queryName;
10399 if (!specTable->GetValue("Name", queryName))
10400 {
10401 AIErrorID("<CScriptBind_AI> ", "CreateQueryFromTacticalSpec() Query specification missing name");
10402 return 0;
10403 }
10404
10405 int queryID = pTPS->CreateQueryID(queryName);
10406
10407 IScriptTable::Iterator itO;
10408 for (itO = specTable->BeginIteration(); specTable->MoveNext(itO); option++)
10409 {
10410 if (itO.value.type == ANY_TSTRING) continue; // Skip the name field
10411
10412 SmartScriptTable optionTable;
10413 if (!itO.value.CopyTo(optionTable)) return false; // Scream and shout!
10414 SmartScriptTable subTable;
10415 IScriptTable::Iterator itS;
10416
10417 // parameter table is optional
10418 if (optionTable->GetValue("Parameters", subTable))
10419 {
10420 for (itS = subTable->BeginIteration(); subTable->MoveNext(itS); )
10421 {
10422 const char* querySpec = itS.sKey;
10423 if (itS.value.type == ANY_TNUMBER)
10424 {
10425 float fVal = itS.value.number;
10426 bOk &= pTPS->AddToParameters(queryID, querySpec, fVal, option);
10427 }
10428 else if (itS.value.type == ANY_TSTRING)
10429 {
10430 const char* sVal = itS.value.str;
10431 bOk &= pTPS->AddToParameters(queryID, querySpec, sVal, option);
10432 }
10433 else
10434 {
10435 bOk = false;
10436 AIErrorID("<ScriptBind_AI> ", "CreateQueryFromTacticalSpec(): \"%s\": Parameters criteria only take numbers (at this point)", queryName);
10437 }
10438 }
10439
10440 specTable->EndIteration(itS);
10441 }
10442
10443 if (!optionTable->GetValue("Generation", subTable))
10444 bAllTables = false;
10445 else
10446 for (itS = subTable->BeginIteration(); subTable->MoveNext(itS); )
10447 {

Callers

nothing calls this directly

Calls 11

CreateQueryIDMethod · 0.80
BeginIterationMethod · 0.80
EndIterationMethod · 0.80
DestroyQueryIDMethod · 0.80
GetValueMethod · 0.45
MoveNextMethod · 0.45
CopyToMethod · 0.45
AddToParametersMethod · 0.45
AddToGenerationMethod · 0.45
AddToConditionsMethod · 0.45
AddToWeightsMethod · 0.45

Tested by

no test coverage detected