]> git.mxchange.org Git - flightgear.git/commitdiff
AIFlihtPlan: Proper member initialization
authorThorstenB <brehmt@gmail.com>
Sat, 24 Nov 2012 12:04:59 +0000 (13:04 +0100)
committerThorstenB <brehmt@gmail.com>
Sat, 24 Nov 2012 12:30:00 +0000 (13:30 +0100)
(i.e. "isValid" needs to be initialized unconditionally)

src/AIModel/AIFlightPlan.cxx
src/Traffic/Schedule.cxx
src/Traffic/TrafficMgr.cxx

index 23401fe111591c216dfe286b589aefe0183cf653..5e17a3d9aff7b11c8c764d85828477edb9ba0623 100644 (file)
@@ -96,35 +96,33 @@ void FGAIWaypoint::setAltitude(double alt)
   pos.setElevationFt(alt);
 }
 
-FGAIFlightPlan::FGAIFlightPlan()
+FGAIFlightPlan::FGAIFlightPlan() :
+    sid(NULL),
+    repeat(false),
+    distance_to_go(0),
+    lead_distance(0),
+    leadInAngle(0),
+    start_time(0),
+    arrivalTime(0),
+    leg(0),
+    lastNodeVisited(0),
+    isValid(true)
 {
-    sid             = 0;
-    repeat          = false;
-    distance_to_go  = 0;
-    lead_distance   = 0;
-    start_time      = 0;
-    arrivalTime     = 0;
-    leg             = 10;
-    lastNodeVisited = 0;
-  //  taxiRoute       = 0;
     wpt_iterator    = waypoints.begin();
-    isValid         = true;
 }
 
-FGAIFlightPlan::FGAIFlightPlan(const string& filename)
+FGAIFlightPlan::FGAIFlightPlan(const string& filename) :
+    sid(NULL),
+    repeat(false),
+    distance_to_go(0),
+    lead_distance(0),
+    leadInAngle(0),
+    start_time(0),
+    arrivalTime(0),
+    leg(10),
+    lastNodeVisited(0),
+    isValid(parseProperties(filename))
 {
-  sid               = 0;
-  repeat            = false;
-  distance_to_go    = 0;
-  lead_distance     = 0;
-  start_time        = 0;
-  arrivalTime       = 0;
-  leg               = 10;
-  lastNodeVisited   = 0;
-//  taxiRoute         = 0;
-
-
-  isValid = parseProperties(filename);
 }
 
 
@@ -149,19 +147,19 @@ FGAIFlightPlan::FGAIFlightPlan(FGAIAircraft *ac,
                                const string& fltType,
                                const string& acType,
                                const string& airline) :
-  departure(dep),
-  arrival(arr)
+    sid(NULL),
+    repeat(false),
+    distance_to_go(0),
+    lead_distance(0),
+    leadInAngle(0),
+    start_time(start),
+    arrivalTime(0),
+    leg(10),
+    lastNodeVisited(0),
+    isValid(false),
+    departure(dep),
+    arrival(arr)
 {
-  sid               = 0;
-  repeat            = false;
-  distance_to_go    = 0;
-  lead_distance     = 0;
-  start_time        = start;
-  arrivalTime       = 0;
-  leg               = 10;
-  lastNodeVisited   = 0;
- // taxiRoute         = 0;
-
   if (parseProperties(p)) {
     isValid = true;
   } else {
index 4421762444f9315af1933fe42c3dde7a6a997941..5884118ba21a2703177c212fc682e550fc6fd295 100644 (file)
  * schedule of Flights for an artificially controlled aircraft.
  *****************************************************************************/
 FGAISchedule::FGAISchedule()
+  : heavy(false),
+    radius(0),
+    groundOffset(0),
+    distanceToUser(0),
+    score(0),
+    runCount(0),
+    hits(0),
+    lastRun(0),
+    firstRun(false),
+    courseToDest(0),
+    initialized(false),
+    valid(false)
 {
-  firstRun     = true;
-
-  heavy = false;
-  radius = 0;
-  groundOffset = 0;
-  distanceToUser = 0;
-  valid = true;
-  lastRun = 0;
-  //score = 0;
 }
 
 
@@ -84,6 +87,18 @@ FGAISchedule::FGAISchedule(const string& model,
                            const string& fltpe,
                            double rad, 
                            double grnd)
+    : heavy(hvy),
+      radius(rad),
+      groundOffset(grnd),
+      distanceToUser(0),
+      score(0),
+      runCount(0),
+      hits(0),
+      lastRun(0),
+      firstRun(true),
+      courseToDest(0),
+      initialized(false),
+      valid(true)
 {
   modelPath        = model; 
   livery           = lvry; 
@@ -94,21 +109,10 @@ FGAISchedule::FGAISchedule(const string& model,
   airline          = arln;
   m_class          = mclass;
   flightType       = fltpe;
-  radius           = rad;
-  groundOffset     = grnd;
-  distanceToUser   = 0;
-  heavy            = hvy;
   /*for (FGScheduledFlightVecIterator i = flt.begin();
        i != flt.end();
        i++)
     flights.push_back(new FGScheduledFlight((*(*i))));*/
-  score    =         0;
-  firstRun         = true;
-  runCount         = 0;
-  hits             = 0;
-  lastRun          = 0;
-  initialized      = false;
-  valid            = true;
 }
 
 FGAISchedule::FGAISchedule(const FGAISchedule &other)
index 989e3eb7ddd42e6443dcbb93405a4876e14118e6..8aec72aed33d67e5ffaac17221ed75dc4bcbbc96 100644 (file)
@@ -151,14 +151,18 @@ FGTrafficManager::FGTrafficManager() :
   inited(false),
   doingInit(false),
   waitingMetarTime(0.0),
+  cruiseAlt(0),
+  score(0),
+  runCount(0),
+  acCounter(0),
+  radius(0),
+  offset(0),
+  heavy(false),
   enabled("/sim/traffic-manager/enabled"),
   aiEnabled("/sim/ai/enabled"),
   realWxEnabled("/environment/realwx/enabled"),
   metarValid("/environment/metar/valid")
 {
-    //score = 0;
-    //runCount = 0;
-    acCounter = 0;
 }
 
 FGTrafficManager::~FGTrafficManager()