From fad737b41ef9029a64b6556d50ec915e5c6fafcb Mon Sep 17 00:00:00 2001 From: mfranz Date: Fri, 3 Aug 2007 18:02:33 +0000 Subject: [PATCH] prevent multiple loading of one and the same scenario --- src/AIModel/AIManager.cxx | 23 +++++++++++++++++------ src/AIModel/AIManager.hxx | 2 -- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx index 19a6c76b1..cec1980ac 100644 --- a/src/AIModel/AIManager.cxx +++ b/src/AIModel/AIManager.cxx @@ -79,13 +79,24 @@ FGAIManager::init() { void FGAIManager::postinit() { // postinit, so that it can access the Nasal subsystem - for(int i = 0 ; i < root->nChildren() ; i++) { - SGPropertyNode *aiEntry = root->getChild( i ); - if( !strcmp( aiEntry->getName(), "scenario" ) ) { - scenario_filename = aiEntry->getStringValue(); - if (!scenario_filename.empty()) - processScenario( scenario_filename ); + map scenarios; + for (int i = 0 ; i < root->nChildren() ; i++) { + SGPropertyNode *n = root->getChild(i); + if (strcmp(n->getName(), "scenario")) + continue; + + string name = n->getStringValue(); + if (name.empty()) + continue; + + if (scenarios.find(name) != scenarios.end()) { + SG_LOG(SG_GENERAL, SG_WARN, "won't load scenario '" << name << "' twice"); + continue; } + + SG_LOG(SG_GENERAL, SG_INFO, "loading scenario '" << name << '\''); + processScenario(name); + scenarios[name] = true; } } diff --git a/src/AIModel/AIManager.hxx b/src/AIModel/AIManager.hxx index a327421ef..2bcd4a541 100644 --- a/src/AIModel/AIManager.hxx +++ b/src/AIModel/AIManager.hxx @@ -110,8 +110,6 @@ private: SGPropertyNode_ptr wind_from_east_node; SGPropertyNode_ptr wind_from_north_node; - string scenario_filename; - double user_latitude; double user_longitude; double user_altitude; -- 2.39.5