diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx index 50553b9d5..3f5271e7e 100644 --- a/src/AIModel/AIManager.cxx +++ b/src/AIModel/AIManager.cxx @@ -18,8 +18,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -#include #include +#include #include #include @@ -197,9 +197,16 @@ void FGAIManager::registerScenarios(SGPropertyNode_ptr root) // add-on scenario directories const auto& addonsManager = flightgear::addons::AddonManager::instance(); if (addonsManager) { + auto coll = addonsManager->registeredAddons(); + std::transform(coll.begin(), coll.end(), std::back_inserter(scenarioSearchPaths), + [](flightgear::addons::AddonRef a) { + return a->getBasePath() / "Scenarios"; + }); +#if 0 for (auto a : addonsManager->registeredAddons()) { scenarioSearchPaths.push_back(a->getBasePath() / "Scenarios"); } +#endif } SGPropertyNode_ptr scenariosNode = root->getNode("/sim/ai/scenarios", true); @@ -583,12 +590,21 @@ bool FGAIManager::removeObjectCommand(const SGPropertyNode* arg, const SGPropert bool FGAIManager::removeObject(const SGPropertyNode* args) { int id = args->getIntValue("id"); + auto coll = get_ai_list(); + auto it_ai = std::find_if(coll.begin(), coll.end(), [id](FGAIBasePtr ai) { + return ai->getID() == id; + }); + if (it_ai != coll.end()) + (*it_ai)->setDie(true); + +#if 0 for (FGAIBase* ai : get_ai_list()) { if (ai->getID() == id) { ai->setDie(true); break; } } +#endif return false; } diff --git a/src/AIModel/AIManager.hxx b/src/AIModel/AIManager.hxx index 087f245db..d74160df0 100644 --- a/src/AIModel/AIManager.hxx +++ b/src/AIModel/AIManager.hxx @@ -20,8 +20,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -#ifndef _FG_AIMANAGER_HXX -#define _FG_AIMANAGER_HXX +#pragma once #include #include @@ -145,19 +144,19 @@ private: ai_list_type ai_list; - double user_altitude_agl; - double user_heading; - double user_pitch; - double user_roll; - double user_speed; - double wind_from_east; - double wind_from_north; + double user_altitude_agl = 0.0; + double user_heading = 0.0; + double user_pitch = 0.0; + double user_roll = 0.0; + double user_speed = 0.0; + double wind_from_east = 0.0; + double wind_from_north = 0.0; void fetchUserState( double dt ); // used by thermals - double range_nearest; - double strength; + double range_nearest = 0.0; + double strength = 0.0; void processThermal( double dt, FGAIThermal* thermal ); SGPropertyChangeCallback cb_ai_bare; @@ -176,5 +175,3 @@ private: _radarDebugMode = false; double _radarRangeM = 0.0; }; - -#endif // _FG_AIMANAGER_HXX