1
0
Fork 0

Support disabling AI traffic at run-time.

This commit is contained in:
ThorstenB 2012-05-01 10:32:30 +02:00
parent 746b0d60cc
commit 229fe3bff9
3 changed files with 28 additions and 1 deletions

View file

@ -158,6 +158,15 @@ FGAISchedule::FGAISchedule(const FGAISchedule &other)
FGAISchedule::~FGAISchedule()
{
// remove related object from AI manager
if (AIManagerRef)
{
FGAIManager* aimgr = (FGAIManager *) globals-> get_subsystem("ai-model");
if (aimgr)
aimgr->destroyObject(AIManagerRef);
AIManagerRef = 0;
}
/* for (FGScheduledFlightVecIterator flt = flights.begin(); flt != flights.end(); flt++)
{
delete (*flt);

View file

@ -90,6 +90,11 @@ FGTrafficManager::FGTrafficManager() :
}
FGTrafficManager::~FGTrafficManager()
{
shutdown();
}
void FGTrafficManager::shutdown()
{
// Save the heuristics data
bool saveData = false;
@ -129,6 +134,11 @@ FGTrafficManager::~FGTrafficManager()
}
scheduledAircraft.clear();
flights.clear();
releaseList.clear();
currAircraft = scheduledAircraft.begin();
doingInit = false;
inited = false;
}
@ -261,7 +271,14 @@ void FGTrafficManager::loadHeuristics()
void FGTrafficManager::update(double /*dt */ )
{
if (!enabled || (realWxEnabled && !metarValid)) {
if (!enabled)
{
if (inited || doingInit)
shutdown();
return;
}
if ((realWxEnabled && !metarValid)) {
return;
}

View file

@ -108,6 +108,7 @@ private:
void initStep();
void finishInit();
void shutdown();
// during incremental init, contains the XML files still be read in
simgear::PathList schedulesToRead;