From 1ebab94710faaa5295470ad77cc44be5e8104473 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sun, 26 Jun 2011 16:08:19 +0200 Subject: [PATCH] #358: Missing option to disable AI scenarios --ai-scenario=... can only add/enable another scenario. Introduce --disable-ai-scenarios option to disable all scenarios (can be used by external launchers, GUIs etc) Also provide error instead of debug message when a scenario cannot be loaded. --- src/AIModel/AIManager.cxx | 6 +++--- src/Main/options.cxx | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx index 419098112..91ef65271 100644 --- a/src/AIModel/AIManager.cxx +++ b/src/AIModel/AIManager.cxx @@ -358,9 +358,9 @@ FGAIManager::loadScenarioFile(const std::string& filename) SGPropertyNode_ptr root = new SGPropertyNode; readProperties(path.str(), root); return root; - } catch (const sg_exception &) { - SG_LOG(SG_GENERAL, SG_DEBUG, "Incorrect path specified for AI " - "scenario: \"" << path.str() << "\""); + } catch (const sg_exception &t) { + SG_LOG(SG_GENERAL, SG_ALERT, "Failed to load scenario '" + << path.str() << "': " << t.getFormattedMessage()); return 0; } } diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 453e68e48..ff306e6d9 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -1167,6 +1167,15 @@ fgOptScenario( const char *arg ) return FG_OPTIONS_OK; } +static int +fgOptNoScenarios( const char *arg ) +{ + SGPropertyNode_ptr ai_node = fgGetNode( "/sim/ai", true ); + ai_node->removeChildren("scenario",false); + ai_node->setBoolValue( "enabled", false ); + return FG_OPTIONS_OK; +} + static int fgOptRunway( const char *arg ) { @@ -1465,6 +1474,7 @@ struct OptionDesc { {"min-status", true, OPTION_STRING, "/sim/aircraft-min-status", false, "all", 0 }, {"livery", true, OPTION_FUNC, "", false, "", fgOptLivery }, {"ai-scenario", true, OPTION_FUNC, "", false, "", fgOptScenario }, + {"disable-ai-scenarios", false, OPTION_FUNC, "", false, "", fgOptNoScenarios}, {"parking-id", true, OPTION_FUNC, "", false, "", fgOptParking }, {"version", false, OPTION_FUNC, "", false, "", fgOptVersion }, {"enable-fpe", false, OPTION_FUNC, "", false, "", fgOptFpe}, -- 2.39.5