]> git.mxchange.org Git - flightgear.git/commitdiff
AIFlightPlan: Initialize the same member variables in all constructors.
authorThorstenB <brehmt@gmail.com>
Sun, 25 Mar 2012 12:03:53 +0000 (14:03 +0200)
committerThorstenB <brehmt@gmail.com>
Mon, 26 Mar 2012 19:11:03 +0000 (21:11 +0200)
distance_to_go / lead_distance were not initialized in all constructors.
Fixes 'condition on uninitialized data' reported by valgrind.
Also comment-out unused vars.

src/AIModel/AIFlightPlan.cxx

index 21ad6f9ab119ecc78fdaba8611efb709be0d6da8..e552f05e071347430a58c0b5e97dfe36e957289b 100644 (file)
@@ -71,32 +71,36 @@ bool FGAIWaypoint::contains(string target) {
 
 FGAIFlightPlan::FGAIFlightPlan() 
 {
-    sid = 0;
-    repeat = false;
-    distance_to_go = 0;
-    lead_distance = 0;
-    start_time = 0;
-    arrivalTime = 0;
-    leg = 10;
-    gateId = 0;
+    sid             = 0;
+    repeat          = false;
+    distance_to_go  = 0;
+    lead_distance   = 0;
+    start_time      = 0;
+    arrivalTime     = 0;
+    leg             = 10;
+    gateId          = 0;
     lastNodeVisited = 0;
-    taxiRoute = 0;
-    wpt_iterator = waypoints.begin();
-    isValid = true;
+    taxiRoute       = 0;
+    wpt_iterator    = waypoints.begin();
+    isValid         = true;
 }
 
 FGAIFlightPlan::FGAIFlightPlan(const string& filename)
 {
-  int i;
-  sid = 0;
-  start_time = 0;
-  leg = 10;
-  gateId = 0;
-  taxiRoute = 0;
+  sid               = 0;
+  repeat            = false;
+  distance_to_go    = 0;
+  lead_distance     = 0;
+  start_time        = 0;
+  arrivalTime       = 0;
+  leg               = 10;
+  gateId            = 0;
+  lastNodeVisited   = 0;
+  taxiRoute         = 0;
+
   SGPath path( globals->get_fg_root() );
   path.append( ("/AI/FlightPlans/" + filename).c_str() );
   SGPropertyNode root;
-  repeat = false;
 
   try {
       readProperties(path.str(), &root);
@@ -108,7 +112,7 @@ FGAIFlightPlan::FGAIFlightPlan(const string& filename)
   }
 
   SGPropertyNode * node = root.getNode("flightplan");
-  for (i = 0; i < node->nChildren(); i++) { 
+  for (int i = 0; i < node->nChildren(); i++) {
      //cout << "Reading waypoint " << i << endl;        
      FGAIWaypoint* wpt = new FGAIWaypoint;
      SGPropertyNode * wpt_node = node->getChild(i);
@@ -144,45 +148,51 @@ FGAIFlightPlan::FGAIFlightPlan(const string& filename)
 // traffic manager. 
 FGAIFlightPlan::FGAIFlightPlan(FGAIAircraft *ac,
                                const std::string& p,
-                              double course,
-                              time_t start,
-                              FGAirport *dep,
-                              FGAirport *arr,
-                              bool firstLeg,
-                              double radius,
+                               double course,
+                               time_t start,
+                               FGAirport *dep,
+                               FGAirport *arr,
+                               bool firstLeg,
+                               double radius,
                                double alt,
                                double lat,
                                double lon,
                                double speed,
-                              const string& fltType,
-                              const string& acType,
-                              const string& airline)
+                               const string& fltType,
+                               const string& acType,
+                               const string& airline)
 {
-  sid = 0;
-  repeat = false;
-  leg = 10;
-  gateId=0;
-  taxiRoute = 0;
-  start_time = start;
-  bool useInitialWayPoint = true;
-  bool useCurrentWayPoint = false;
+  sid               = 0;
+  repeat            = false;
+  distance_to_go    = 0;
+  lead_distance     = 0;
+  start_time        = start;
+  arrivalTime       = 0;
+  leg               = 10;
+  gateId            = 0;
+  lastNodeVisited   = 0;
+  taxiRoute         = 0;
+
   SGPath path( globals->get_fg_root() );
   path.append( "/AI/FlightPlans" );
   path.append( p );
   
   SGPropertyNode root;
   isValid = true;
+
   // This is a bit of a hack:
   // Normally the value of course will be used to evaluate whether
   // or not a waypoint will be used for midair initialization of 
   // an AI aircraft. However, if a course value of 999 will be passed
   // when an update request is received, which will by definition always be
   // on the ground and should include all waypoints.
-  if (course == 999) 
-    {
-      useInitialWayPoint = false;
-      useCurrentWayPoint = true;
-    }
+//  bool useInitialWayPoint = true;
+//  bool useCurrentWayPoint = false;
+//  if (course == 999)
+//    {
+//      useInitialWayPoint = false;
+//      useCurrentWayPoint = true;
+//    }
 
   if (path.exists()) 
     {