]> git.mxchange.org Git - flightgear.git/commitdiff
#358: Missing option to disable AI scenarios
authorThorstenB <brehmt@gmail.com>
Sun, 26 Jun 2011 14:08:19 +0000 (16:08 +0200)
committerThorstenB <brehmt@gmail.com>
Sun, 26 Jun 2011 14:08:19 +0000 (16:08 +0200)
--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
src/Main/options.cxx

index 4190981124242bea13257c082babf70a59c18b60..91ef652717e9cba4c7bdcb0f88fdcc3e322abc2c 100644 (file)
@@ -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;
     }
 }
index 453e68e486c6066cc534043951faf707ff315969..ff306e6d9fe63018b11c7a56e04078947f3362bf 100644 (file)
@@ -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},