]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/ATCDialog.cxx
try to fix yet another crash bug (don't worry, there's one for anybody!)
[flightgear.git] / src / ATC / ATCDialog.cxx
index b54679d5cdb1a6ea3755b0c3c6582bcc5466986d..2946478da79633c790f46e5801005ff4526be488 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 "ATCDialog.hxx"
 #include "ATC.hxx"
 #include "ATCmgr.hxx"
-#include "ATCdisplay.hxx"
 #include "commlist.hxx"
 #include "ATCutils.hxx"
 #include <Airports/simple.hxx>
 
 #include <sstream>
-#include <map>
 
 SG_USING_STD(ostringstream);
-SG_USING_STD(map);
 
 FGATCDialog *current_atcdialog;
 
@@ -189,7 +190,7 @@ bool FGATCDialog::trans_reg( const string &station, int code, atc_type type ) {
 // Display the ATC popup dialog box with options relevant to the users current situation.
 void FGATCDialog::PopupDialog() {
        const char *dialog_name = "atc-dialog";
-       SGPropertyNode_ptr dlg = _gui->getDialog(dialog_name);
+       SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name);
        if (!dlg)
                return;
 
@@ -264,12 +265,14 @@ 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));
                        _callbackPending = true;
                        _callbackTimer = 0.0;
                        _callbackWait = 5.0;
@@ -301,7 +304,7 @@ struct atcdata {
 
 void FGATCDialog::FreqDialog() {
        const char *dialog_name = "atc-freq-search";
-       SGPropertyNode_ptr dlg = _gui->getDialog(dialog_name);
+       SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name);
        if (!dlg)
                return;
 
@@ -311,7 +314,7 @@ void FGATCDialog::FreqDialog() {
        // remove all dynamic airport/ATC buttons
        button_group->removeChildren("button", false);
 
-       // Find the ATC stations within a reasonable range (about 40 miles?)
+       // Find the ATC stations within a reasonable range
        comm_list_type atc_stations;
        comm_list_iterator atc_stat_itr;
        
@@ -322,7 +325,7 @@ void FGATCDialog::FreqDialog() {
                lat * SGD_DEGREES_TO_RADIANS, elev));
 
        // search stations in range
-       int num_stat = current_commlist->FindByPos(lon, lat, elev, 40.0, &atc_stations);
+       int num_stat = current_commlist->FindByPos(lon, lat, elev, 50.0, &atc_stations);
        if (num_stat != 0) {
                map<atcdata, bool> uniq;
                // fill map (sorts by distance and removes duplicates)
@@ -352,7 +355,7 @@ void FGATCDialog::FreqDialog() {
 
 void FGATCDialog::FreqDisplay(string& ident) {
        const char *dialog_name = "atc-freq-display";
-       SGPropertyNode_ptr dlg = _gui->getDialog(dialog_name);
+       SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name);
        if (!dlg)
                return;