From: fredb Date: Sat, 20 May 2006 12:19:33 +0000 (+0000) Subject: Add an option to enable ai scenarii from the command line instead of editing preferen... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b55833dffb43c0236c74dc8d9366c162e304eee8;p=flightgear.git Add an option to enable ai scenarii from the command line instead of editing preferences.xml --- diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 6c9a8b43b..fb396de3c 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -1165,6 +1165,24 @@ fgOptLivery( const char *arg ) return FG_OPTIONS_OK; } +static int +fgOptScenario( const char *arg ) +{ + SGPropertyNode_ptr ai_node = fgGetNode( "/sim/ai", false ); + vector scenarii = ai_node->getChildren( "scenario" ); + int index = -1; + for ( size_t i = 0; i < scenarii.size(); ++i ) { + int ind = scenarii[i]->getIndex(); + if ( index < ind ) { + index = ind; + } + } + SGPropertyNode_ptr scenario = ai_node->getNode( "scenario", index + 1, true ); + scenario->setStringValue( arg ); + ai_node->setBoolValue( "enabled", true ); + return FG_OPTIONS_OK; +} + static map fgOptionMap; /* @@ -1367,6 +1385,7 @@ struct OptionDesc { {"dme", true, OPTION_FUNC, "", false, "", fgOptDME }, {"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 }, {0} };