From 4d3e523f90df176f21d9a817d6874277186af55f Mon Sep 17 00:00:00 2001 From: ehofman Date: Wed, 19 May 2004 13:55:49 +0000 Subject: [PATCH] Add AI models enableing/disableing command line option and support code. --- src/AIModel/AIAircraft.cxx | 3 +-- src/AIModel/AIManager.cxx | 9 +++++++++ src/AIModel/AIManager.hxx | 1 + src/Main/options.cxx | 2 ++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/AIModel/AIAircraft.cxx b/src/AIModel/AIAircraft.cxx index 61045327f..bb5107d6b 100644 --- a/src/AIModel/AIAircraft.cxx +++ b/src/AIModel/AIAircraft.cxx @@ -379,8 +379,7 @@ void FGAIAircraft::ProcessFlightPlan( double dt ) { if (dt_count < 0.1) { return; } else { - while (dt_count > 0.1) - dt_count -= dt; + dt_count = 0; // check to see if we've reached the lead point for our next turn double dist_to_go = fp->getDistanceToGo(pos.lat(), pos.lon(), curr); diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx index e450f47a2..466f5332a 100644 --- a/src/AIModel/AIManager.cxx +++ b/src/AIModel/AIManager.cxx @@ -56,6 +56,12 @@ FGAIManager::~FGAIManager() { void FGAIManager::init() { int rval; root = fgGetNode("sim/ai", true); + + enabled = root->getNode("enabled", true)->getStringValue(); + if (!enabled) + return; + + wind_from_down = fgGetNode("/environment/wind-from-down-fps", true); for (int i = 0; i < root->nChildren(); i++) { @@ -140,6 +146,9 @@ void FGAIManager::update(double dt) { range_nearest = 10000.0; strength = 0.0; + if (!enabled) + return; + _dt = dt; ai_list_itr = ai_list.begin(); diff --git a/src/AIModel/AIManager.hxx b/src/AIModel/AIManager.hxx index b6cdd8a9c..449b03b40 100644 --- a/src/AIModel/AIManager.hxx +++ b/src/AIModel/AIManager.hxx @@ -125,6 +125,7 @@ public: private: bool initDone; + bool enabled; int numObjects; SGPropertyNode* root; SGPropertyNode* wind_from_down; diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 8a85e80dd..e7bf6d0c7 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -1186,6 +1186,8 @@ struct OptionDesc { {"enable-mouse-pointer", false, OPTION_STRING, "/sim/startup/mouse-pointer", false, "enabled", 0 }, {"disable-random-objects", false, OPTION_BOOL, "/sim/rendering/random-objects", false, "", 0 }, {"enable-random-objects", false, OPTION_BOOL, "/sim/rendering/random-objects", true, "", 0 }, + {"disable-ai-models", false, OPTION_BOOL, "/sim/ai/enabled", false, "", 0 }, + {"enable-ai-models", false, OPTION_BOOL, "/sim/ai/enabled", true, "", 0 }, {"disable-freeze", false, OPTION_BOOL, "/sim/freeze/master", false, "", 0 }, {"enable-freeze", false, OPTION_BOOL, "/sim/freeze/master", true, "", 0 }, {"disable-fuel-freeze", false, OPTION_BOOL, "/sim/freeze/fuel", false, "", 0 },