]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/ATCDialog.cxx
If it's a struct, it's not a class
[flightgear.git] / src / ATC / ATCDialog.cxx
index 0f1bc8e652c4bba38acbee0ec0c83cbc2af2f225..8fc3e0f1efbb3c83a2cb53ab8d70c003733f16b4 100644 (file)
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
 
 #include <simgear/compiler.h>
 
 #include <Airports/simple.hxx>
 
 #include <sstream>
-#include <map>
 
 SG_USING_STD(ostringstream);
-SG_USING_STD(map);
 
 FGATCDialog *current_atcdialog;
 
@@ -264,12 +266,15 @@ void FGATCDialog::PopupCallback(int num) {
                //cout << "TOWER " << endl;
                //cout << "ident is " << atcptr->get_ident() << endl;
                atcmentry_vec_type atcmlist = (available_dialog[TOWER])[atcptr->get_ident()];
-               if(atcmlist.size()) {
+               unsigned int size = atcmlist.size();
+               if(size && num < size) {
                        //cout << "Doing callback...\n";
                        ATCMenuEntry a = atcmlist[num];
                        atcptr->SetFreqInUse();
+                       string pilot = atcptr->GenText(a.transmission, a.callback_code);
+                       fgSetString("/sim/messages/pilot", pilot.c_str());
                        // This is the user's speech getting displayed.
-                       globals->get_ATC_display()->RegisterSingleMessage(atcptr->GenText(a.transmission, a.callback_code));
+                       globals->get_ATC_display()->RegisterSingleMessage(pilot);
                        _callbackPending = true;
                        _callbackTimer = 0.0;
                        _callbackWait = 5.0;
@@ -365,8 +370,8 @@ void FGATCDialog::FreqDisplay(string& ident) {
        atcUppercase(ident);
        string label;
 
-       FGAirport a;
-       if (!dclFindAirportID(ident, &a)) {
+       const FGAirport *a = fgFindAirportID(ident);
+       if (!a) {
                label = "Airport " + ident + " not found in database.";
                mkDialog(label.c_str());
                return;
@@ -379,7 +384,7 @@ void FGATCDialog::FreqDisplay(string& ident) {
        int n = 0;      // Number of ATC frequencies at this airport
 
        comm_list_type stations;
-       int found = current_commlist->FindByPos(a.getLongitude(), a.getLatitude(), a.getElevation(), 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();