diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx index 9e5e7fb3c..b4019554b 100644 --- a/src/AIModel/AIManager.cxx +++ b/src/AIModel/AIManager.cxx @@ -39,6 +39,7 @@ FGAIManager::FGAIManager() { numObjects = 0; _dt = 0.0; dt_count = 9; + scenario_filename = ""; } FGAIManager::~FGAIManager() { @@ -60,6 +61,10 @@ void FGAIManager::init() { 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")) { @@ -113,10 +118,7 @@ void FGAIManager::init() { } } - //********** Flight Plan test code !!!! **************** - processScenario( "default_scenario" ); - //******************************************************* - + if (scenario_filename != "") processScenario( scenario_filename ); initDone = true; } @@ -373,10 +375,12 @@ void FGAIManager::processThermal( FGAIThermal* thermal ) { 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;inEntries();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; } diff --git a/src/AIModel/AIManager.hxx b/src/AIModel/AIManager.hxx index 106d0abb3..b6cdd8a9c 100644 --- a/src/AIModel/AIManager.hxx +++ b/src/AIModel/AIManager.hxx @@ -128,6 +128,7 @@ private: int numObjects; SGPropertyNode* root; SGPropertyNode* wind_from_down; + string scenario_filename; double user_latitude; double user_longitude; diff --git a/src/AIModel/AIScenario.cxx b/src/AIModel/AIScenario.cxx index 8cd66f316..07013c9af 100644 --- a/src/AIModel/AIScenario.cxx +++ b/src/AIModel/AIScenario.cxx @@ -53,9 +53,11 @@ FGAIScenario::FGAIScenario(string filename) 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(); @@ -72,7 +74,12 @@ FGAIScenario::~FGAIScenario() 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 ) diff --git a/src/AIModel/AIScenario.hxx b/src/AIModel/AIScenario.hxx index 2e35d91b7..949c72768 100644 --- a/src/AIModel/AIScenario.hxx +++ b/src/AIModel/AIScenario.hxx @@ -32,9 +32,11 @@ public: typedef struct { string callsign; + string aitype; // can be aircraft, ship, storm, thermal string aircraft_class; string model_path; string flightplan; + double repeat; // in seconds } entry; FGAIScenario(string filename);