53
54
#include <simgear/structure/subsystem_mgr.hxx>
54
55
#include <simgear/xml/easyxml.hxx>
57
#include <AIModel/AIAircraft.hxx>
56
58
#include <AIModel/AIFlightPlan.hxx>
57
59
#include <AIModel/AIBase.hxx>
58
60
#include <Airports/simple.hxx>
74
77
void FGTrafficManager::init()
76
currAircraft = scheduledAircraft.begin();
79
//cerr << "Initializing Schedules" << endl;
80
time_t now = time(NULL) + fgGetLong("/sim/time/warp");
81
currAircraft = scheduledAircraft.begin();
82
while (currAircraft != scheduledAircraft.end())
84
if (!(currAircraft->init()))
86
currAircraft=scheduledAircraft.erase(currAircraft);
87
//cerr << "Erasing " << currAircraft->getRegistration() << endl;
95
//cerr << "Sorting by distance " << endl;
96
sort(scheduledAircraft.begin(), scheduledAircraft.end());
97
currAircraft = scheduledAircraft.begin();
98
currAircraftClosest = scheduledAircraft.begin();
99
//cerr << "Done initializing schedules" << endl;
79
102
void FGTrafficManager::update(double something)
82
//static const SGPropertyNode *warp = globals->get_props()->getNode("/sim/time/warp");
84
//time_t now = time(NULL) + globals->get_warp();
85
104
time_t now = time(NULL) + fgGetLong("/sim/time/warp");
86
// cerr << "TrafficManager update" << globals->get_warp() << endl;
87
if(currAircraft == scheduledAircraft.end())
105
if(currAircraft == scheduledAircraft.end())
107
//cerr << "resetting schedule " << endl;
88
108
currAircraft = scheduledAircraft.begin();
89
currAircraft->update(now);
110
if (!(currAircraft->update(now)))
112
// after proper initialization, we shouldnt get here.
113
// But let's make sure
114
cerr << "Failed to update aircraft schedule in traffic manager" << endl;
93
void FGTrafficManager::release(void *id)
119
void FGTrafficManager::release(int id)
95
121
releaseList.push_back(id);
98
bool FGTrafficManager::isReleased(void *id)
124
bool FGTrafficManager::isReleased(int id)
100
126
IdListIterator i = releaseList.begin();
101
127
while (i != releaseList.end())
147
173
else if (element == string("registration"))
148
174
registration = value;
175
else if (element == string("airline"))
177
else if (element == string("actype"))
179
else if (element == string("flighttype"))
181
else if (element == string("radius"))
182
radius = atoi(value.c_str());
183
else if (element == string("offset"))
184
offset = atoi(value.c_str());
185
else if (element == string("performance-class"))
149
187
else if (element == string("heavy"))
151
189
if(value == string("true"))