1
0
Fork 0

AIFlihtPlan: Proper member initialization

(i.e. "isValid" needs to be initialized unconditionally)
This commit is contained in:
ThorstenB 2012-11-24 13:04:59 +01:00
parent ec2975bac3
commit ff49cd7acf
3 changed files with 65 additions and 59 deletions

View file

@ -96,35 +96,33 @@ void FGAIWaypoint::setAltitude(double alt)
pos.setElevationFt(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(); 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& fltType,
const string& acType, const string& acType,
const string& airline) : const string& airline) :
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), departure(dep),
arrival(arr) 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)) { if (parseProperties(p)) {
isValid = true; isValid = true;
} else { } else {

View file

@ -59,16 +59,19 @@
* schedule of Flights for an artificially controlled aircraft. * schedule of Flights for an artificially controlled aircraft.
*****************************************************************************/ *****************************************************************************/
FGAISchedule::FGAISchedule() 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, const string& fltpe,
double rad, double rad,
double grnd) 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; modelPath = model;
livery = lvry; livery = lvry;
@ -94,21 +109,10 @@ FGAISchedule::FGAISchedule(const string& model,
airline = arln; airline = arln;
m_class = mclass; m_class = mclass;
flightType = fltpe; flightType = fltpe;
radius = rad;
groundOffset = grnd;
distanceToUser = 0;
heavy = hvy;
/*for (FGScheduledFlightVecIterator i = flt.begin(); /*for (FGScheduledFlightVecIterator i = flt.begin();
i != flt.end(); i != flt.end();
i++) i++)
flights.push_back(new FGScheduledFlight((*(*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) FGAISchedule::FGAISchedule(const FGAISchedule &other)

View file

@ -151,14 +151,18 @@ FGTrafficManager::FGTrafficManager() :
inited(false), inited(false),
doingInit(false), doingInit(false),
waitingMetarTime(0.0), waitingMetarTime(0.0),
cruiseAlt(0),
score(0),
runCount(0),
acCounter(0),
radius(0),
offset(0),
heavy(false),
enabled("/sim/traffic-manager/enabled"), enabled("/sim/traffic-manager/enabled"),
aiEnabled("/sim/ai/enabled"), aiEnabled("/sim/ai/enabled"),
realWxEnabled("/environment/realwx/enabled"), realWxEnabled("/environment/realwx/enabled"),
metarValid("/environment/metar/valid") metarValid("/environment/metar/valid")
{ {
//score = 0;
//runCount = 0;
acCounter = 0;
} }
FGTrafficManager::~FGTrafficManager() FGTrafficManager::~FGTrafficManager()