From 9d1b5164e2352c35915cc10a38188bc05d0389d4 Mon Sep 17 00:00:00 2001 From: ehofman Date: Wed, 22 Sep 2004 10:03:26 +0000 Subject: [PATCH] fix a segmentation fault situation that is exposed at least on IRIX (but not Linux). --- src/AIModel/AIManager.cxx | 6 +----- src/AIModel/AIScenario.cxx | 10 ++++++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx index b7927ef2c..734963a96 100644 --- a/src/AIModel/AIManager.cxx +++ b/src/AIModel/AIManager.cxx @@ -287,15 +287,11 @@ void FGAIManager::processThermal( FGAIThermal* thermal ) { void FGAIManager::processScenario( string filename ) { FGAIScenario* s = new FGAIScenario( filename ); - for (int i=0;inEntries();i++) { FGAIModelEntity* en = s->getNextEntry(); if (en) { - en->fp = NULL; - if (en->flightplan != ""){ - en->fp = new FGAIFlightPlan( en->flightplan ); - } + if (en->m_class == "aircraft") { createAircraft( en ); diff --git a/src/AIModel/AIScenario.cxx b/src/AIModel/AIScenario.cxx index 2802a8152..e92f04da3 100644 --- a/src/AIModel/AIScenario.cxx +++ b/src/AIModel/AIScenario.cxx @@ -30,6 +30,7 @@ #include
#include "AIScenario.hxx" +#include "AIFlightPlan.hxx" @@ -49,6 +50,7 @@ FGAIScenario::FGAIScenario(string filename) return; } + entries.clear(); SGPropertyNode * node = root.getNode("scenario"); for (i = 0; i < node->nChildren(); i++) { //cout << "Reading entry " << i << endl; @@ -78,9 +80,13 @@ FGAIScenario::FGAIScenario(string filename) en->wind_from_east = entry_node->getDoubleValue("wind_from_east", 0); en->wind_from_north = entry_node->getDoubleValue("wind_from_north", 0); en->wind = entry_node->getBoolValue("wind", false); - en->cd = entry_node->getDoubleValue ("cd", 0.029); - en->weight = entry_node->getDoubleValue ("weight", 0.030); + en->cd = entry_node->getDoubleValue ("cd", 0.029); + en->weight = entry_node->getDoubleValue ("weight", 0.030); + en->fp = NULL; + if (en->flightplan != ""){ + en->fp = new FGAIFlightPlan( en->flightplan ); + } } entry_iterator = entries.begin();