]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIManager.cxx
Make the scenerio's work again (now for real) and a small number of updates.
[flightgear.git] / src / AIModel / AIManager.cxx
index d6839cf854112fde3dd2392e534d5521b4a9828d..e066b5a09135417219599e94b6550238c14cf843 100644 (file)
@@ -47,6 +47,7 @@ FGAIManager::FGAIManager() {
 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;
     }
@@ -97,6 +98,7 @@ void FGAIManager::update(double dt) {
                 if ((*ai_list_itr)->getDie()) {      
                    --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);
@@ -250,6 +252,7 @@ void FGAIManager::destroyObject( void* ID ) {
             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);
 
@@ -285,26 +288,25 @@ void FGAIManager::processThermal( FGAIThermal* thermal ) {
 }
 
 
-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) {
-      if (en->m_type == "aircraft") {
+      if ( !strcmp(en->m_type, "aircraft")) {
          createAircraft( en );
 
-      } else if (en->m_type == "ship") {
+      } else if ( !strcmp(en->m_type, "ship")) {
            createShip( en );
 
-      } else if (en->m_type == "storm") {
+      } else if ( !strcmp(en->m_type, "thunderstorm")) {
         createStorm( en );
 
-      } else if (en->m_type == "thermal") {
+      } else if ( !strcmp(en->m_type, "thermal")) {
         createThermal( en );
 
-      } else if (en->m_type == "ballistic") {
+      } else if ( !strcmp(en->m_type, "ballistic")) {
         createBallistic( en );
       }      
     }