]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/ATCDialog.cxx
Mathias Fröhlich:
[flightgear.git] / src / ATC / ATCDialog.cxx
index 8d390f1b874d476dc613ab9fab0224ecc85e29a3..42d8bf7be7f5b873d618145900c0569d2afaad84 100644 (file)
@@ -254,41 +254,33 @@ void FGATCDialog::add_entry(string station, string transmission, string menutext
   a.menuentry = menutext;
   a.callback_code = code;
 
-  //atcmentrylist_station[station.c_str()].push_back(a);
   (available_dialog[type])[station.c_str()].push_back(a);
 
 }
 
 void FGATCDialog::remove_entry( const string &station, const string &trans, atc_type type ) {
-  atcmentry_vec_type     atcmlist = (available_dialog[type])[station];
-  atcmentry_vec_iterator current  = atcmlist.begin();
-  atcmentry_vec_iterator last     = atcmlist.end();
-  
-  while(current != last) {
-    if(current->transmission == trans) current = atcmlist.erase(current);
+  atcmentry_vec_type* p = &((available_dialog[type])[station]);
+  atcmentry_vec_iterator current = p->begin();  
+  while(current != p->end()) {
+    if(current->transmission == trans) current = p->erase(current);
        else ++current;
   }
 }
 
 void FGATCDialog::remove_entry( const string &station, int code, atc_type type ) {
-  atcmentry_vec_type     atcmlist = (available_dialog[type])[station];
-  atcmentry_vec_iterator current  = atcmlist.begin();
-  atcmentry_vec_iterator last     = atcmlist.end();
-  
-  while(current != last) {
-    if(current->callback_code == code) current = atcmlist.erase(current);
+  atcmentry_vec_type* p = &((available_dialog[type])[station]);
+  atcmentry_vec_iterator current = p->begin();
+  while(current != p->end()) {
+    if(current->callback_code == code) current = p->erase(current);
        else ++current;
   }
 }
 
 // query the database whether the transmission is already registered; 
 bool FGATCDialog::trans_reg( const string &station, const string &trans, atc_type type ) {
-  //atcmentry_list_type     atcmlist = atcmentrylist_station[station];
-  atcmentry_vec_type     atcmlist = (available_dialog[type])[station];
-  atcmentry_vec_iterator current  = atcmlist.begin();
-  atcmentry_vec_iterator last     = atcmlist.end();
-  
-  for ( ; current != last ; ++current ) {
+  atcmentry_vec_type* p = &((available_dialog[type])[station]);
+  atcmentry_vec_iterator current = p->begin();
+  for ( ; current != p->end() ; ++current ) {
     if ( current->transmission == trans ) return true;
   }
   return false;
@@ -296,12 +288,9 @@ bool FGATCDialog::trans_reg( const string &station, const string &trans, atc_typ
 
 // query the database whether the transmission is already registered; 
 bool FGATCDialog::trans_reg( const string &station, int code, atc_type type ) {
-  //atcmentry_list_type     atcmlist = atcmentrylist_station[station];
-  atcmentry_vec_type     atcmlist = (available_dialog[type])[station];
-  atcmentry_vec_iterator current  = atcmlist.begin();
-  atcmentry_vec_iterator last     = atcmlist.end();
-  
-  for ( ; current != last ; ++current ) {
+  atcmentry_vec_type* p = &((available_dialog[type])[station]);
+  atcmentry_vec_iterator current = p->begin();
+  for ( ; current != p->end() ; ++current ) {
     if ( current->callback_code == code ) return true;
   }
   return false;
@@ -366,7 +355,7 @@ void FGATCDialog::PopupDialog() {
                                } 
                                optList[k] = NULL;
                                atcDialogCommunicationOptions->newList(optList);
-                               atcDialogCommunicationOptions->setSize(w-100, h-100);
+                               atcDialogCommunicationOptions->setSize(w-100, h-90);
                                atcDialogCommunicationOptions->reveal();
                                atcDialogMessage -> setLabel( "ATC Menu" );
                                atcDialogMessage -> setPosition(w / 2, h - 30);
@@ -408,14 +397,24 @@ void FGATCDialog::PopupCallback() {
                                break;
                        }
                } else if(atcptr->GetType() == TOWER) {
-                       ATCMenuEntry a = ((available_dialog[TOWER])[(string)atcptr->get_ident()])[atcDialogCommunicationOptions->getValue()];
-                       atcptr->SetFreqInUse();
-                       globals->get_ATC_display()->RegisterSingleMessage(atcptr->GenText(a.transmission, a.callback_code));
-                       _callbackPending = true;
-                       _callbackTimer = 0.0;
-                       _callbackWait = 5.0;
-                       _callbackPtr = atcptr;
-                       _callbackCode = a.callback_code;
+                       //cout << "TOWER " << endl;
+                       //cout << "ident is " << atcptr->get_ident() << endl;
+                       atcmentry_vec_type atcmlist = (available_dialog[TOWER])[atcptr->get_ident()];
+                       if(atcmlist.size()) {
+                               //cout << "Doing callback...\n";
+                               ATCMenuEntry a = atcmlist[atcDialogCommunicationOptions->getValue()];
+                               atcptr->SetFreqInUse();
+                               // This is the user's speech getting displayed.
+                               globals->get_ATC_display()->RegisterSingleMessage(atcptr->GenText(a.transmission, a.callback_code));
+                               _callbackPending = true;
+                               _callbackTimer = 0.0;
+                               _callbackWait = 5.0;
+                               _callbackPtr = atcptr;
+                               _callbackCode = a.callback_code;
+                       } else {
+                               //cout << "No options available...\n";
+                       }
+                       //cout << "Donded" << endl;
                }
        }
 }
@@ -461,7 +460,7 @@ void FGATCDialog::FreqDisplay(string ident) {
     FGAirport a;
     if ( dclFindAirportID( ident, &a ) ) {
                comm_list_type stations;
-               int found = current_commlist->FindByPos(a.longitude, a.latitude, a.elevation, 20.0, &stations);
+               int found = current_commlist->FindByPos(a.getLongitude(), a.getLatitude(), a.getElevation(), 20.0, &stations);
                if(found) {
                        ostringstream ostr;
                        comm_list_iterator itr = stations.begin();