]> git.mxchange.org Git - flightgear.git/commitdiff
Code to stop loading of invalid flightplans
authorportree_kid <midnight.ploughboy@gmail.com>
Thu, 12 Feb 2015 21:09:45 +0000 (22:09 +0100)
committerportree_kid <midnight.ploughboy@gmail.com>
Thu, 12 Feb 2015 21:09:45 +0000 (22:09 +0100)
src/AIModel/AIBase.cxx
src/AIModel/AIBase.hxx
src/AIModel/AIFlightPlan.cxx
src/AIModel/AIFlightPlan.hxx
src/AIModel/AIManager.cxx

index 136c77270a12e76d268080b24e0c500a5176d465..d933e68af0380fba264d42a4c8ac1c26288d2119 100644 (file)
@@ -106,7 +106,6 @@ public:
     bool getInteriorLoaded(void) { return _interiorLoaded;}
     bool hasInteriorPath(void) { return _hasInteriorPath;}
     inline std::string& getInteriorPath() { return _interiorPath; }
-    
 private:
     std::auto_ptr<FGNasalModelDataProxy> _nasal;
     std::string _fxpath;
@@ -932,5 +931,7 @@ int FGAIBase::_newAIModelID() {
     return id;
 }
 
-
-
+bool FGAIBase::isValid() { 
+       //Either no flightplan or it is valid
+       return !fp || fp->isValidPlan(); 
+}
index 504419c7c8fc15262f1b857b04113fc88ca31f54..f2ba097e7ef4b087fd96b91795fcc11743eb7f45 100644 (file)
@@ -110,6 +110,7 @@ public:
     int _getSubID() const;
 
     bool getDie();
+       bool isValid();
 
     SGVec3d getCartPosAt(const SGVec3d& off) const;
     SGVec3d getCartPos() const;
index eb0e6cc1f4dc03cbd3149682b64c98469d708bd1..99f68eb96884db65a9f2ede87c6aea6552772c9e 100644 (file)
@@ -251,6 +251,11 @@ bool FGAIFlightPlan::parseProperties(const std::string& filename)
     wpt->setFinished   ((wpt->getName() == "END"));
     pushBackWaypoint( wpt );
   }
+  if( getLastWaypoint()->getName().compare("END") != 0  ) {
+       SG_LOG(SG_AI, SG_ALERT, "FGAIFlightPlan::Flightplan missing END node" );
+       return false;
+  }
+
   
   wpt_iterator = waypoints.begin();
   return true;
index ff3ff2ceffc2bac9cb581e446db3af527bbeadc9..31e4f8698cd69e35f5477469b1693c187e872734 100644 (file)
@@ -244,7 +244,7 @@ private:
  public:
   wpt_vector_iterator getFirstWayPoint() { return waypoints.begin(); };
   wpt_vector_iterator getLastWayPoint()  { return waypoints.end(); };
-    bool isValidPlan() { return isValid; };
+  bool isValidPlan() { return isValid; };
 };
 
 #endif  // _FG_AIFLIGHTPLAN_HXX
index 27582d9ca708a2fb52a236acce96d99989006886..2c6fc15f455da60077324fc6f535831a90cb2532 100644 (file)
@@ -408,7 +408,14 @@ FGAIBasePtr FGAIManager::addObject(const SGPropertyNode* definition)
     }
 
     ai->readFromScenario(const_cast<SGPropertyNode*>(definition));
-    attach(ai);
+       if((ai->isValid())){
+               attach(ai);
+        SG_LOG(SG_AI, SG_DEBUG, "attached scenario " << ai->_getName());
+       }
+       else{
+               ai->setDie(true);
+               SG_LOG(SG_AI, SG_ALERT, "killed invalid scenario "  << ai->_getName());
+       }
     return ai;
 }