1
0
Fork 0

Fix a nasty problem in the FGAIMgr search code that could cause a stackdump with AI traffic enabled

This commit is contained in:
daveluff 2003-03-14 12:27:24 +00:00
parent c32c8aca51
commit b9985548d4

View file

@ -195,7 +195,7 @@ void FGAIMgr::ActivateAirport(string ident) {
// Search for valid airports in the vicinity of the user and activate them if necessary // Search for valid airports in the vicinity of the user and activate them if necessary
void FGAIMgr::SearchByPos(double range) void FGAIMgr::SearchByPos(double range)
{ {
//cout << "In SearchByPos(...)\n"; //cout << "In SearchByPos(...)" << endl;
// get bucket number for plane position // get bucket number for plane position
lon = lon_node->getDoubleValue(); lon = lon_node->getDoubleValue();
@ -204,9 +204,9 @@ void FGAIMgr::SearchByPos(double range)
// get neigboring buckets // get neigboring buckets
int bx = (int)( range*SG_NM_TO_METER / buck.get_width_m() / 2); int bx = (int)( range*SG_NM_TO_METER / buck.get_width_m() / 2);
//cout << "bx = " << bx << '\n'; //cout << "bx = " << bx << endl;
int by = (int)( range*SG_NM_TO_METER / buck.get_height_m() / 2 ); int by = (int)( range*SG_NM_TO_METER / buck.get_height_m() / 2 );
//cout << "by = " << by << '\n'; //cout << "by = " << by << endl;
// loop over bucket range // loop over bucket range
for ( int i=-bx; i<=bx; i++) { for ( int i=-bx; i<=bx; i++) {
@ -215,28 +215,31 @@ void FGAIMgr::SearchByPos(double range)
//cout << "j loop\n"; //cout << "j loop\n";
buck = sgBucketOffset(lon, lat, i, j); buck = sgBucketOffset(lon, lat, i, j);
long int bucket = buck.gen_index(); long int bucket = buck.gen_index();
//cout << "bucket is " << bucket << '\n'; //cout << "bucket is " << bucket << endl;
aptID_list_type* apts = airports[bucket]; if(airports.find(bucket) != airports.end()) {
aptID_list_iterator current = apts->begin(); aptID_list_type* apts = airports[bucket];
aptID_list_iterator last = apts->end(); aptID_list_iterator current = apts->begin();
aptID_list_iterator last = apts->end();
//cout << "Size of apts is " << apts->size() << '\n'; //cout << "Size of apts is " << apts->size() << endl;
//double rlon = lon * SGD_DEGREES_TO_RADIANS; //double rlon = lon * SGD_DEGREES_TO_RADIANS;
//double rlat = lat * SGD_DEGREES_TO_RADIANS; //double rlat = lat * SGD_DEGREES_TO_RADIANS;
//Point3D aircraft = sgGeodToCart( Point3D(rlon, rlat, elev) ); //Point3D aircraft = sgGeodToCart( Point3D(rlon, rlat, elev) );
//Point3D airport; //Point3D airport;
for(; current != last; ++current) { for(; current != last; ++current) {
//cout << "Found " << *current << '\n'; //cout << "Found " << *current << endl;;
if(activated.find(*current) == activated.end()) { if(activated.find(*current) == activated.end()) {
//cout << "Activating " << *current << '\n'; //cout << "Activating " << *current << endl;
//FGAirport a; //FGAirport a;
//if(dclFindAirportID(*current, &a)) { //if(dclFindAirportID(*current, &a)) {
// // We can do something here based on distance from the user if we wish. // // We can do something here based on distance from the user if we wish.
//} //}
ActivateAirport(*current); ActivateAirport(*current);
} else { //cout << "Activation done" << endl;
//cout << *current << " already activated\n"; } else {
//cout << *current << " already activated" << endl;
}
} }
} }
} }