X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAIModel%2FAIThermal.cxx;h=e9ad927a137e24fc4aedb4fda5364d63e9200dc1;hb=7e73a8788223c9c2af3c26435162e0667b412279;hp=c3d2def1c32375ba74eda9039913e95d158dae02;hpb=85df309a3beed294b98aa86e9241d166a2a4fddb;p=flightgear.git diff --git a/src/AIModel/AIThermal.cxx b/src/AIModel/AIThermal.cxx index c3d2def1c..e9ad927a1 100644 --- a/src/AIModel/AIThermal.cxx +++ b/src/AIModel/AIThermal.cxx @@ -16,41 +16,47 @@ // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifdef HAVE_CONFIG_H # include #endif -#include #include
#include
#include #include #include -SG_USING_STD(string); +using std::string; #include "AIThermal.hxx" -FGAIThermal::FGAIThermal(FGAIManager* mgr) { - manager = mgr; - _type_str = "thermal"; - _otype = otThermal; +FGAIThermal::FGAIThermal() : FGAIBase(otThermal) { max_strength = 6.0; diameter = 0.5; strength = factor = 0.0; } - FGAIThermal::~FGAIThermal() { } +void FGAIThermal::readFromScenario(SGPropertyNode* scFileNode) { + if (!scFileNode) + return; + + FGAIBase::readFromScenario(scFileNode); + + setMaxStrength(scFileNode->getDoubleValue("strength-fps", 8.0)); + setDiameter(scFileNode->getDoubleValue("diameter-ft", 0.0)/6076.11549); + setHeight(scFileNode->getDoubleValue("height-msl", 5000.0)); +} -bool FGAIThermal::init() { +bool FGAIThermal::init(bool search_in_AI_path) { factor = 8.0 * max_strength / (diameter * diameter * diameter); - return FGAIBase::init(); + setAltitude( height ); + return FGAIBase::init(search_in_AI_path); } void FGAIThermal::bind() { @@ -71,8 +77,6 @@ void FGAIThermal::update(double dt) { void FGAIThermal::Run(double dt) { - FGAIThermal::dt = dt; - //###########################// // do calculations for range // //###########################// @@ -83,8 +87,8 @@ void FGAIThermal::Run(double dt) { double user_altitude = manager->get_user_altitude(); // calculate range to target in feet and nautical miles - double lat_range = fabs(pos.lat() - user_latitude) * ft_per_deg_lat; - double lon_range = fabs(pos.lon() - user_longitude) * ft_per_deg_lon; + double lat_range = fabs(pos.getLatitudeDeg() - user_latitude) * ft_per_deg_lat; + double lon_range = fabs(pos.getLongitudeDeg() - user_longitude) * ft_per_deg_lon; double range_ft = sqrt(lat_range*lat_range + lon_range*lon_range); range = range_ft / 6076.11549;