FGAIManager::~FGAIManager() {
ai_list_itr = ai_list.begin();
while(ai_list_itr != ai_list.end()) {
+ (*ai_list_itr)->unbind();
delete (*ai_list_itr);
++ai_list_itr;
}
wind_from_down_node = fgGetNode("/environment/wind-from-down-fps", true);
scenario_filename = root->getNode("scenario", true)->getStringValue();
-
if (scenario_filename != "") processScenario( scenario_filename );
+
initDone = true;
}
if (!enabled)
return;
- _dt = dt;
+ _dt = dt;
ai_list_itr = ai_list.begin();
while(ai_list_itr != ai_list.end()) {
if ((*ai_list_itr)->getDie()) {
- delete (*ai_list_itr);
--numObjects[(*ai_list_itr)->getType()];
--numObjects[0];
+ (*ai_list_itr)->unbind();
+ delete (*ai_list_itr);
if ( ai_list_itr == ai_list.begin() ) {
ai_list.erase(ai_list_itr);
ai_list_itr = ai_list.begin();
ai_ballistic->setDragArea(entity->eda);
ai_ballistic->setLife(entity->life);
ai_ballistic->setBuoyancy(entity->buoyancy);
- ai_ballistic->setWind_from_east(entity->wind_from_east);
- ai_ballistic->setWind_from_north(entity->wind_from_north);
- ai_ballistic->setWind(entity->wind);
+ ai_ballistic->setWind_from_east(entity->wind_from_east);
+ ai_ballistic->setWind_from_north(entity->wind_from_north);
+ ai_ballistic->setWind(entity->wind);
+ ai_ballistic->setRoll(entity->roll);
+ ai_ballistic->setCd(entity->cd);
+ ai_ballistic->setWeight(entity->weight);
ai_ballistic->init();
ai_ballistic->bind();
return ai_ballistic;
FGAIManager::createStorm( FGAIModelEntity *entity ) {
FGAIStorm* ai_storm = new FGAIStorm(this);
- ai_list.push_back(ai_storm);
++numObjects[0];
++numObjects[FGAIBase::otStorm];
ai_storm->setHeading(entity->heading);
ai_storm->setLatitude(entity->latitude);
ai_storm->init();
ai_storm->bind();
+ ai_list.push_back(ai_storm);
return ai_storm;
}
FGAIManager::createThermal( FGAIModelEntity *entity ) {
FGAIThermal* ai_thermal = new FGAIThermal(this);
- ai_list.push_back(ai_thermal);
++numObjects[0];
++numObjects[FGAIBase::otThermal];
ai_thermal->setLongitude(entity->longitude);
ai_thermal->setDiameter(entity->diameter / 6076.11549);
ai_thermal->init();
ai_thermal->bind();
+ ai_list.push_back(ai_thermal);
return ai_thermal;
}
if ((*ai_list_itr)->getID() == ID) {
--numObjects[0];
--numObjects[(*ai_list_itr)->getType()];
+ (*ai_list_itr)->unbind();
delete (*ai_list_itr);
ai_list.erase(ai_list_itr);
}
-void FGAIManager::processScenario( string filename ) {
+void FGAIManager::processScenario( string &filename ) {
FGAIScenario* s = new FGAIScenario( filename );
-
for (int i=0;i<s->nEntries();i++) {
FGAIModelEntity* en = s->getNextEntry();
if (en) {
- en->fp = NULL;
- if (en->flightplan != ""){
- en->fp = new FGAIFlightPlan( en->flightplan );
- }
-
- if (en->m_class == "aircraft") {
+ if ( !strcmp(en->m_type, "aircraft")) {
createAircraft( en );
- } else if (en->m_class == "ship") {
+ } else if ( !strcmp(en->m_type, "ship")) {
createShip( en );
- } else if (en->m_class == "storm") {
+ } else if ( !strcmp(en->m_type, "thunderstorm")) {
createStorm( en );
- } else if (en->m_class == "thermal") {
+ } else if ( !strcmp(en->m_type, "thermal")) {
createThermal( en );
- } else if (en->m_class == "ballistic") {
+ } else if ( !strcmp(en->m_type, "ballistic")) {
createBallistic( en );
}
}
delete s;
}
+//end AIManager.cxx