]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/tower.cxx
Modified Files:
[flightgear.git] / src / ATC / tower.cxx
index d3a1113b85b36aca49c3b88d7ee1bf2a1e606403..cdeb185482f1b02d0610ae906cf23e2454bac0bf 100644 (file)
@@ -16,7 +16,7 @@
 //
 // 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>
@@ -204,13 +204,11 @@ FGTower::FGTower() {
        update_count_max = 15;
        
        holdListItr = holdList.begin();
-       appList.clear();
        appListItr = appList.begin();
        depListItr = depList.begin();
        rwyListItr = rwyList.begin();
        circuitListItr = circuitList.begin();
        trafficListItr = trafficList.begin();
-       vacatedList.clear();
        vacatedListItr = vacatedList.begin();
        
        freqClear = true;
@@ -319,7 +317,7 @@ void FGTower::Init() {
                // TODO FIXME - this will break when user starts on apron, at hold short, etc.
                if(!OnAnyRunway(Point3D(user_lon_node->getDoubleValue(), user_lat_node->getDoubleValue(), 0.0))) {
                        //cout << ident << "  ADD 0\n";
-                       current_atcdialog->add_entry(ident, "@AP Tower @CS @MI miles @CD of the airport for full stop with ATIS", "Contact tower for VFR arrival (full stop)", TOWER, (int)USER_REQUEST_VFR_ARRIVAL_FULL_STOP);
+                       current_atcdialog->add_entry(ident, "@AP Tower, @CS @MI miles @CD of the airport for full stop with ATIS", "Contact tower for VFR arrival (full stop)", TOWER, (int)USER_REQUEST_VFR_ARRIVAL_FULL_STOP);
                }
        }
 }
@@ -478,7 +476,7 @@ void FGTower::Respond() {
                        string trns = t->plane.callsign;
                        trns += " ";
                        trns += name;
-                       trns += " Tower";
+                       trns += " Tower,";
                        // Should we clear staight in or for downwind entry?
                        // For now we'll clear straight in if greater than 1km from a line drawn through the threshold perpendicular to the rwy.
                        // Later on we might check the actual heading and direct some of those to enter on downwind or base.
@@ -487,7 +485,7 @@ void FGTower::Respond() {
                                trns += " Report three mile straight-in runway ";
                                t->opType = STRAIGHT_IN;
                                if(t->isUser) {
-                                       current_atcdialog->add_entry(ident, "@AP Tower @CS @MI mile final Runway @RW", "Report Final", TOWER, (int)USER_REPORT_3_MILE_FINAL);
+                                       current_atcdialog->add_entry(ident, "@AP Tower, @CS @MI mile final Runway @RW", "Report Final", TOWER, (int)USER_REPORT_3_MILE_FINAL);
                                } else {
                                        t->planePtr->RegisterTransmission(14);
                                }
@@ -502,7 +500,7 @@ void FGTower::Respond() {
                                t->opType = CIRCUIT;
                                // leave it in the app list until it gets into pattern though.
                                if(t->isUser) {
-                                       current_atcdialog->add_entry(ident, "@AP Tower @CS Downwind @RW", "Report Downwind", TOWER, (int)USER_REPORT_DOWNWIND);
+                                       current_atcdialog->add_entry(ident, "@AP Tower, @CS Downwind @RW", "Report Downwind", TOWER, (int)USER_REPORT_DOWNWIND);
                                } else {
                                        t->planePtr->RegisterTransmission(15);
                                }
@@ -658,7 +656,7 @@ void FGTower::ProcessDownwindReport(TowerPlaneRec* t) {
                trns += s;
                if((tt->opType) == CIRCUIT) {
                        PatternLeg leg;
-                       if(t->isUser) {
+                       if(tt->isUser) {
                                leg = tt->leg;
                        } else {
                                leg = tt->planePtr->GetLeg();
@@ -1325,7 +1323,7 @@ void FGTower::CheckDepartureList(double dt) {
                                // Change the communication options
                                RemoveAllUserDialogOptions();
                                //cout << "ADD A\n";
-                               current_atcdialog->add_entry(ident, "@AP Tower @CS @MI miles @CD of the airport for full stop with ATIS", "Contact tower for VFR arrival (full stop)", TOWER, (int)USER_REQUEST_VFR_ARRIVAL_FULL_STOP);
+                               current_atcdialog->add_entry(ident, "@AP Tower, @CS @MI miles @CD of the airport for full stop with ATIS", "Contact tower for VFR arrival (full stop)", TOWER, (int)USER_REQUEST_VFR_ARRIVAL_FULL_STOP);
                        } else {
                                // Send a clear-of-airspace signal
                                // TODO - implement this once we actually have departing AI traffic (currently all circuits or arrivals).
@@ -2168,61 +2166,64 @@ void FGTower::RemovePlane(const string& ID) {
        // but we can only delete it once, AT THE END.
        TowerPlaneRec* t = NULL;
        tower_plane_rec_list_iterator twrItr;
-       for(twrItr = appList.begin(); twrItr != appList.end(); twrItr++) {
+       for(twrItr = appList.begin(); twrItr != appList.end();) {
                if((*twrItr)->plane.callsign == ID) {
                        t = *twrItr;
                        twrItr = appList.erase(twrItr);
                        appListItr = appList.begin();
-                       break;
-               }
+                       // HACK: aircraft are sometimes more than once in a list, so we need to
+                       // remove them all before we can delete the TowerPlaneRec class
+                       //break;
+               } else
+                        ++twrItr;
        }
-       for(twrItr = depList.begin(); twrItr != depList.end(); twrItr++) {
+       for(twrItr = depList.begin(); twrItr != depList.end();) {
                if((*twrItr)->plane.callsign == ID) {
                        t = *twrItr;
                        twrItr = depList.erase(twrItr);
                        depListItr = depList.begin();
-                       break;
-               }
+               } else
+                        ++twrItr;
        }
-       for(twrItr = circuitList.begin(); twrItr != circuitList.end(); twrItr++) {
+       for(twrItr = circuitList.begin(); twrItr != circuitList.end();) {
                if((*twrItr)->plane.callsign == ID) {
                        t = *twrItr;
                        twrItr = circuitList.erase(twrItr);
                        circuitListItr = circuitList.begin();
-                       break;
-               }
+                } else
+                        ++twrItr;
        }
-       for(twrItr = holdList.begin(); twrItr != holdList.end(); twrItr++) {
+       for(twrItr = holdList.begin(); twrItr != holdList.end();) {
                if((*twrItr)->plane.callsign == ID) {
                        t = *twrItr;
                        twrItr = holdList.erase(twrItr);
                        holdListItr = holdList.begin();
-                       break;
-               }
+                } else
+                        ++twrItr;
        }
-       for(twrItr = rwyList.begin(); twrItr != rwyList.end(); twrItr++) {
+       for(twrItr = rwyList.begin(); twrItr != rwyList.end();) {
                if((*twrItr)->plane.callsign == ID) {
                        t = *twrItr;
                        twrItr = rwyList.erase(twrItr);
                        rwyListItr = rwyList.begin();
-                       break;
-               }
+                } else
+                        ++twrItr;
        }
-       for(twrItr = vacatedList.begin(); twrItr != vacatedList.end(); twrItr++) {
+       for(twrItr = vacatedList.begin(); twrItr != vacatedList.end();) {
                if((*twrItr)->plane.callsign == ID) {
                        t = *twrItr;
                        twrItr = vacatedList.erase(twrItr);
                        vacatedListItr = vacatedList.begin();
-                       break;
-               }
+                } else
+                        ++twrItr;
        }
-       for(twrItr = trafficList.begin(); twrItr != trafficList.end(); twrItr++) {
+       for(twrItr = trafficList.begin(); twrItr != trafficList.end();) {
                if((*twrItr)->plane.callsign == ID) {
                        t = *twrItr;
                        twrItr = trafficList.erase(twrItr);
                        trafficListItr = trafficList.begin();
-                       break;
-               }
+                } else
+                        ++twrItr;
        }
        // And finally, delete the record.
        delete t;
@@ -2264,7 +2265,7 @@ void FGTower::ReportGoingAround(const string& ID) {
        if(ID == "USER") {
                uid = fgGetString("/sim/user/callsign");
                RemoveAllUserDialogOptions();   // TODO - it would be much more efficient if ATCDialog simply had a clear() function!!!
-               current_atcdialog->add_entry(ident, "@AP Tower @CS Downwind @RW", "Report Downwind", TOWER, (int)USER_REPORT_DOWNWIND);
+               current_atcdialog->add_entry(ident, "@AP Tower, @CS Downwind @RW", "Report Downwind", TOWER, (int)USER_REPORT_DOWNWIND);
        }
        TowerPlaneRec* t = FindPlane(uid);
        if(t) {