- SGPropertyNode* root = fgGetNode("sim/ai", true);
- if (!root->getNode("enabled", true)->getBoolValue())
- return 0;
-
- bool found = false;
- for(int i = 0 ; (!found) && i < root->nChildren() ; i++) {
- SGPropertyNode *aiEntry = root->getChild( i );
- if( !strcmp( aiEntry->getName(), "scenario" ) ) {
- string filename = aiEntry->getStringValue();
- FGAIScenario* s = new FGAIScenario( filename );
- for (int i=0; i<s->nEntries(); i++) {
- FGAIModelEntity* en = s->getNextEntry();
- if (en && en->m_type == "carrier" &&
- (en->pennant_number == id || en->name == id)) {
- FGAICarrier* ai_carrier = new FGAICarrier(0);
- ai_carrier->setHeading(en->heading);
- ai_carrier->setSpeed(en->speed);
- ai_carrier->setAltitude(en->altitude);
- ai_carrier->setLongitude(en->longitude);
- ai_carrier->setLatitude(en->latitude);
- ai_carrier->setBank(en->rudder);
- ai_carrier->setParkingPositions(en->ppositions);
-
- if (ai_carrier->getParkPosition(pid, geodPos, heading, uvw)) {
- delete ai_carrier;
- found = true;
- break;
- }
+ // we specify tgt extent (ft) according to the AIObject type
+ double tgt_ht[] = {0, 50 ,100, 250, 0, 100, 0, 0, 50, 50, 50};
+ double tgt_length[] = {0, 100, 200, 750, 0, 50, 0, 0, 200, 100, 100};
+ ai_list_iterator ai_list_itr = ai_list.begin();
+ ai_list_iterator end = ai_list.end();
+
+ while (ai_list_itr != end) {
+ double tgt_alt = (*ai_list_itr)->_getAltitude();
+ int type = (*ai_list_itr)->getType();
+ tgt_ht[type] += fuse_range;
+
+ if (fabs(tgt_alt - alt) > tgt_ht[type] || type == FGAIBase::otBallistic
+ || type == FGAIBase::otStorm || type == FGAIBase::otThermal ) {
+ SG_LOG(SG_GENERAL, SG_DEBUG, "AIManager: skipping "
+ << fabs(tgt_alt - alt)
+ << " "
+ << type
+ );
+ ++ai_list_itr;
+ continue;
+ }