+ // we specify tgt extent (ft) according to the AIObject type
+ double tgt_ht[] = {0, 50 ,100, 250, 0, 100, 0, 0, 50, 50};
+ double tgt_length[] = {0, 100, 200, 750, 0, 50, 0, 0, 200, 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;
+ }
+
+ double tgt_lat = (*ai_list_itr)->_getLatitude();
+ double tgt_lon = (*ai_list_itr)->_getLongitude();
+ int id = (*ai_list_itr)->getID();
+
+ double range = calcRange(lat, lon, tgt_lat, tgt_lon);
+
+ SG_LOG(SG_GENERAL, SG_DEBUG, "AIManager: AI list size "
+ << ai_list.size()
+ << " type " << type
+ << " ID " << id
+ << " range " << range
+ //<< " bearing " << bearing
+ << " alt " << tgt_alt
+ );
+
+ tgt_length[type] += fuse_range;
+
+ if (range < tgt_length[type]){
+ SG_LOG(SG_GENERAL, SG_DEBUG, "AIManager: HIT! "
+ << " type " << type
+ << " ID " << id
+ << " range " << range
+ << " alt " << tgt_alt
+ );
+ return (*ai_list_itr).get();
+ }
+ ++ai_list_itr;
+ }
+ return 0;