numObjects = 0;
_dt = 0.0;
dt_count = 9;
+ scenario_filename = "";
}
FGAIManager::~FGAIManager() {
for (int i = 0; i < root->nChildren(); i++) {
const SGPropertyNode * entry = root->getChild(i);
+ if (!strcmp(entry->getName(), "scenario")){
+ scenario_filename = entry->getStringValue();
+ }
+
if (!strcmp(entry->getName(), "entry")) {
if (!strcmp(entry->getStringValue("type", ""), "aircraft")) {
}
}
- //********** Flight Plan test code !!!! ****************
- processScenario( "default_scenario" );
- //*******************************************************
-
+ if (scenario_filename != "") processScenario( scenario_filename );
initDone = true;
}
void FGAIManager::processScenario( string filename ) {
//cout << "AIManager: creating a scenario." << endl;
FGAIScenario* s = new FGAIScenario( filename );
- FGAIScenario::entry* en = s->getNextEntry();
- if (en) {
- FGAIFlightPlan* f = new FGAIFlightPlan( en->flightplan );
- createAircraft("jet_transport", "Aircraft/737/Models/boeing733.xml", f);
+ for (int i=0;i<s->nEntries();i++) {
+ FGAIScenario::entry* en = s->getNextEntry();
+ if (en) {
+ FGAIFlightPlan* f = new FGAIFlightPlan( en->flightplan );
+ createAircraft("jet_transport", "Aircraft/737/Models/boeing733.xml", f);
+ }
}
delete s;
}
entries.push_back( en );
SGPropertyNode * entry_node = node->getChild(i);
en->callsign = entry_node->getStringValue("callsign", "none");
+ en->aitype = entry_node->getStringValue("type", "aircraft");
en->aircraft_class = entry_node->getStringValue("class", "jet_transport");
en->model_path = entry_node->getStringValue("model", "Models/Geometry/glider.ac");
en->flightplan = entry_node->getStringValue("flightplan", "");
+ en->repeat = entry_node->getDoubleValue("repeat", 0.0);
}
entry_iterator = entries.begin();
FGAIScenario::entry*
FGAIScenario::getNextEntry( void )
{
- return *entry_iterator;
+ if (entries.size() == 0) return 0;
+ if (entry_iterator != entries.end()) {
+ return *entry_iterator++;
+ } else {
+ return 0;
+ }
}
int FGAIScenario::nEntries( void )