]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/AIMgr.cxx
Recent SimGear changes seem to require more additions of config.h to FG in order...
[flightgear.git] / src / ATC / AIMgr.cxx
index 022e094879dadd55c49bac3e5579c002c3a88a3b..34527a79f016b2c216c6d8617c6f30cb57be8eca 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.
 
-#include <simgear/misc/sg_path.hxx>
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
 
 #include <Main/fg_props.hxx>
 #include <Main/globals.hxx>
+#include <simgear/misc/sg_path.hxx>
 #include <simgear/math/sg_random.h>
 #include <list>
 
@@ -48,7 +51,7 @@ SG_USING_STD(cout);
 FGAIMgr::FGAIMgr() {
        ATC = globals->get_ATC_mgr();
        initDone = false;
-       ai_callsigns_used["CFGFS"] = 1; // so we don't inadvertently use this
+       ai_callsigns_used["GFS"] = 1;   // so we don't inadvertently use this
        // TODO - use the proper user callsign when it becomes user settable.
        removalList.clear();
        activated.clear();
@@ -56,8 +59,6 @@ FGAIMgr::FGAIMgr() {
 }
 
 FGAIMgr::~FGAIMgr() {
-        ssgDeRefDelete(_defaultModel);
-       if(_havePiperModel) ssgDeRefDelete(_piperModel);
 }
 
 void FGAIMgr::init() {
@@ -105,10 +106,6 @@ void FGAIMgr::init() {
                _havePiperModel = false;
        }
 
-       // We need to keep one ref of the models open to stop ssg deleting them behind our back!
-       _defaultModel->ref();
-       if(_havePiperModel) _piperModel->ref();
-
        // go through the $FG_ROOT/ATC directory and find all *.taxi files
        SGPath path(globals->get_fg_root());
        path.append("ATC/");
@@ -213,16 +210,18 @@ void FGAIMgr::update(double dt) {
                                string s = (*apt_itr).first;
                                if(traffic.find(s) != traffic.end()) {
                                        //cout << "s = " << s << ", traffic[s].size() = " << traffic[s].size() << '\n';
-                                       if(traffic[s].size()) {
+                                       if(!traffic[s].empty()) {
                                                apt_itr++;
                                        } else {
                                                //cout << "Erasing " << (*apt_itr).first << " and traffic" << '\n';
-                                               activated.erase(apt_itr++);
+                                               activated.erase(apt_itr);
+                                               apt_itr = activated.upper_bound(s);
                                                traffic.erase(s);
                                        }
                                } else {
                                                //cout << "Erasing " << (*apt_itr).first << ' ' << (*apt_itr).second << '\n';
-                                               activated.erase(apt_itr++);
+                                               activated.erase(apt_itr);
+                                               apt_itr = activated.upper_bound(s);
                                }
                        } else {
                                apt_itr++;
@@ -379,7 +378,10 @@ void FGAIMgr::GenerateSimpleAirportTraffic(const string& ident, double min_dist)
        double d = dclGetHorizontalSeparation(userpos, aptpos); // in meters
        
        int lev = fgGetInt("/sim/ai-traffic/level");
-       if(lev < 1 || lev > 3) lev = 2;
+       if(lev < 1)
+               return;
+       if (lev > 3)
+               lev = 3;
        if(visibility < 6000) lev = 1;
        //cout << "level = " << lev << '\n';