1
0
Fork 0

Maintenance: namespace

Clean up namespaces.
Don't use broad 'using namespace' context in header files.
Header Guards.
SPDX tags.
This commit is contained in:
scttgs0 2023-05-20 17:10:29 -05:00
parent cd35776536
commit 89043efdaa
19 changed files with 688 additions and 885 deletions

View file

@ -1,22 +1,9 @@
// FGAIAircraft - FGAIBase-derived class creates an AI airplane /*
// * SPDX-FileName: AIAircraft.cxx
// Written by David Culp, started October 2003. * SPDX-FileComment: AIBase derived class creates an AI aircraft
// * SPDX-FileCopyrightText: Copyright (C) 2003 David P. Culp - davidculp2@comcast.net
// Copyright (C) 2003 David P. Culp - davidculp2@comcast.net * SPDX-License-Identifier: GPL-2.0-or-later
// */
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#include <Main/globals.hxx> #include <Main/globals.hxx>
@ -1485,7 +1472,7 @@ void FGAIAircraft::updateUserFlightPlan(double dt)
<< "\t" << current->getPos().getLatitudeDeg() << "\t" << current->getPos().getLatitudeDeg()
<< "\t" << current->getPos().getLongitudeDeg()); << "\t" << current->getPos().getLongitudeDeg());
if ( currDist>legDistance ) { if ( currDist>legDistance ) {
// We are definetly beyond the airport // We are definitely beyond the airport
fp->incrementLeg(); fp->incrementLeg();
} }
} }
@ -1758,7 +1745,7 @@ void FGAIAircraft::dumpCSV(std::unique_ptr<sg_ofstream> &o, int lineIndex) {
const double headingDiff = SGMiscd::normalizePeriodic(-180, 180, hdg-tgt_heading); const double headingDiff = SGMiscd::normalizePeriodic(-180, 180, hdg-tgt_heading);
(*o) << lineIndex << "\t"; (*o) << lineIndex << "\t";
(*o) << setprecision(12); (*o) << std::setprecision(12);
(*o) << this->getGeodPos().getLatitudeDeg() << "\t"; (*o) << this->getGeodPos().getLatitudeDeg() << "\t";
(*o) << this->getGeodPos().getLongitudeDeg() << "\t"; (*o) << this->getGeodPos().getLongitudeDeg() << "\t";
(*o) << this->getGeodPos().getElevationFt() << "\t"; (*o) << this->getGeodPos().getElevationFt() << "\t";

View file

@ -1,31 +1,19 @@
// FGAIAircraft - AIBase derived class creates an AI aircraft /*
// * SPDX-FileName: AIAircraft.hxx
// Written by David Culp, started October 2003. * SPDX-FileComment: AIBase derived class creates an AI aircraft
// * SPDX-FileCopyrightText: Copyright (C) 2003 David P. Culp - davidculp2@comcast.net
// Copyright (C) 2003 David P. Culp - davidculp2@comcast.net * SPDX-License-Identifier: GPL-2.0-or-later
// */
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#pragma once #pragma once
#include <iostream>
#include <string> #include <string>
#include <string_view> #include <string_view>
#include <iostream>
#include "AIBaseAircraft.hxx" #include "AIBaseAircraft.hxx"
class PerformanceData; class PerformanceData;
class FGAISchedule; class FGAISchedule;
class FGAIFlightPlan; class FGAIFlightPlan;
@ -34,41 +22,37 @@ class FGATCInstruction;
class FGAIWaypoint; class FGAIWaypoint;
class sg_ofstream; class sg_ofstream;
namespace AILeg namespace AILeg {
{ enum Type {
enum Type STARTUP_PUSHBACK = 1,
{ TAXI = 2,
STARTUP_PUSHBACK = 1, TAKEOFF = 3,
TAXI = 2, CLIMB = 4,
TAKEOFF = 3, CRUISE = 5,
CLIMB = 4, APPROACH = 6,
CRUISE = 5, HOLD = 7,
APPROACH = 6, LANDING = 8,
HOLD = 7, PARKING_TAXI = 9,
LANDING = 8, PARKING = 10
PARKING_TAXI = 9, };
PARKING = 10
};
} }
// 1 = joined departure queue; 2 = Passed DepartureHold waypoint; handover control to tower; 0 = any other state. // 1 = joined departure queue; 2 = Passed DepartureHold waypoint; handover control to tower; 0 = any other state.
namespace AITakeOffStatus namespace AITakeOffStatus {
{ enum Type {
enum Type NONE = 0,
{ QUEUED = 1, // joined departure queue
NONE = 0, CLEARED_FOR_TAKEOFF = 2 // Passed DepartureHold waypoint; handover control to tower;
QUEUED = 1, // joined departure queue };
CLEARED_FOR_TAKEOFF = 2 // Passed DepartureHold waypoint; handover control to tower;
};
} }
class FGAIAircraft : public FGAIBaseAircraft { class FGAIAircraft : public FGAIBaseAircraft
{
public: public:
FGAIAircraft(FGAISchedule *ref=0); FGAIAircraft(FGAISchedule* ref = 0);
virtual ~FGAIAircraft(); virtual ~FGAIAircraft();
string_view getTypeString(void) const override { return "aircraft"; } std::string_view getTypeString(void) const override { return "aircraft"; }
void readFromScenario(SGPropertyNode* scFileNode) override; void readFromScenario(SGPropertyNode* scFileNode) override;
void bind() override; void bind() override;
@ -83,8 +67,11 @@ public:
void initializeFlightPlan(); void initializeFlightPlan();
#endif #endif
FGAIFlightPlan* GetFlightPlan() const { return fp.get(); }; FGAIFlightPlan* GetFlightPlan() const
void ProcessFlightPlan( double dt, time_t now ); {
return fp.get();
};
void ProcessFlightPlan(double dt, time_t now);
time_t checkForArrivalTime(const std::string& wptName); time_t checkForArrivalTime(const std::string& wptName);
time_t calcDeparture(); time_t calcDeparture();
@ -101,7 +88,7 @@ public:
void getGroundElev(double dt); //TODO these 3 really need to be public? void getGroundElev(double dt); //TODO these 3 really need to be public?
void doGroundAltitude(); void doGroundAltitude();
bool loadNextLeg (double dist=0); bool loadNextLeg(double dist = 0);
void resetPositionFromFlightPlan(); void resetPositionFromFlightPlan();
double getBearing(double crse); double getBearing(double crse);
@ -109,24 +96,24 @@ public:
const std::string& getAcType() const { return acType; } const std::string& getAcType() const { return acType; }
const std::string& getCompany() const { return company; } const std::string& getCompany() const { return company; }
void setCompany(const std::string& comp) { company = comp;}; void setCompany(const std::string& comp) { company = comp; };
//ATC //ATC
void announcePositionToController(); //TODO have to be public? void announcePositionToController(); //TODO have to be public?
void processATC(const FGATCInstruction& instruction); void processATC(const FGATCInstruction& instruction);
void setTaxiClearanceRequest(bool arg) { needsTaxiClearance = arg; }; void setTaxiClearanceRequest(bool arg) { needsTaxiClearance = arg; };
bool getTaxiClearanceRequest() { return needsTaxiClearance; }; bool getTaxiClearanceRequest() { return needsTaxiClearance; };
FGAISchedule * getTrafficRef() { return trafficRef; }; FGAISchedule* getTrafficRef() { return trafficRef; };
void setTrafficRef(FGAISchedule *ref) { trafficRef = ref; }; void setTrafficRef(FGAISchedule* ref) { trafficRef = ref; };
void resetTakeOffStatus() { takeOffStatus = AITakeOffStatus::NONE;}; void resetTakeOffStatus() { takeOffStatus = AITakeOffStatus::NONE; };
void setTakeOffStatus(int status) { takeOffStatus = status; }; void setTakeOffStatus(int status) { takeOffStatus = status; };
int getTakeOffStatus() { return takeOffStatus; }; int getTakeOffStatus() { return takeOffStatus; };
void setTakeOffSlot(time_t timeSlot) { takeOffTimeSlot = timeSlot;}; void setTakeOffSlot(time_t timeSlot) { takeOffTimeSlot = timeSlot; };
time_t getTakeOffSlot(){return takeOffTimeSlot;}; time_t getTakeOffSlot() { return takeOffTimeSlot; };
void scheduleForATCTowerDepartureControl(); void scheduleForATCTowerDepartureControl();
const std::string& GetTransponderCode() { return transponderCode; }; const std::string& GetTransponderCode() { return transponderCode; };
void SetTransponderCode(const std::string& tc) { transponderCode = tc;}; void SetTransponderCode(const std::string& tc) { transponderCode = tc; };
// included as performance data needs them, who else? // included as performance data needs them, who else?
inline PerformanceData* getPerformance() { return _performance; }; inline PerformanceData* getPerformance() { return _performance; };
@ -136,25 +123,26 @@ public:
inline double getPitch() const { return pitch; }; inline double getPitch() const { return pitch; };
inline double getAltitude() const { return altitude_ft; }; inline double getAltitude() const { return altitude_ft; };
inline double getVerticalSpeedFPM() const { return vs_fps * 60; }; inline double getVerticalSpeedFPM() const { return vs_fps * 60; };
inline double altitudeAGL() const { return props->getFloatValue("position/altitude-agl-ft");}; inline double altitudeAGL() const { return props->getFloatValue("position/altitude-agl-ft"); };
inline double airspeed() const { return props->getFloatValue("velocities/airspeed-kt");}; inline double airspeed() const { return props->getFloatValue("velocities/airspeed-kt"); };
const std::string& atGate(); const std::string& atGate();
std::string acwakecategory; std::string acwakecategory;
void checkTcas(); void checkTcas();
double calcVerticalSpeed(double vert_ft, double dist_m, double speed, double error); double calcVerticalSpeed(double vert_ft, double dist_m, double speed, double error);
FGATCController * getATCController() { return controller; }; FGATCController* getATCController() { return controller; };
void clearATCController(); void clearATCController();
bool isBlockedBy(FGAIAircraft* other); bool isBlockedBy(FGAIAircraft* other);
void dumpCSVHeader(std::unique_ptr<sg_ofstream> &o); void dumpCSVHeader(std::unique_ptr<sg_ofstream>& o);
void dumpCSV(std::unique_ptr<sg_ofstream> &o, int lineIndex); void dumpCSV(std::unique_ptr<sg_ofstream>& o, int lineIndex);
protected: protected:
void Run(double dt); void Run(double dt);
private: private:
FGAISchedule *trafficRef; FGAISchedule* trafficRef;
FGATCController *controller, FGATCController *controller,
*prevController, *prevController,
*towerController; // Only needed to make a pre-announcement *towerController; // Only needed to make a pre-announcement
@ -205,11 +193,13 @@ private:
int determineNextLeg(int leg); int determineNextLeg(int leg);
void handleATCRequests(double dt); void handleATCRequests(double dt);
inline bool isStationary() { inline bool isStationary()
{
return ((fabs(speed) <= 0.0001) && (fabs(tgt_speed) <= 0.0001)); return ((fabs(speed) <= 0.0001) && (fabs(tgt_speed) <= 0.0001));
} }
inline bool needGroundElevation() { inline bool needGroundElevation()
{
if (!isStationary()) if (!isStationary())
_needsGroundElevation = true; _needsGroundElevation = true;
return _needsGroundElevation; return _needsGroundElevation;
@ -243,11 +233,11 @@ private:
bool holdPos = false; bool holdPos = false;
const char * _getTransponderCode() const; const char* _getTransponderCode() const;
bool needsTaxiClearance = false; bool needsTaxiClearance = false;
bool _needsGroundElevation = true; bool _needsGroundElevation = true;
int takeOffStatus; // 1 = joined departure queue; 2 = Passed DepartureHold waypoint; handover control to tower; 0 = any other state. int takeOffStatus; // 1 = joined departure queue; 2 = Passed DepartureHold waypoint; handover control to tower; 0 = any other state.
time_t takeOffTimeSlot; time_t takeOffTimeSlot;
time_t timeElapsed; time_t timeElapsed;
@ -259,9 +249,9 @@ private:
struct struct
{ {
double remainingLength; double remainingLength;
std::string startWptName; std::string startWptName;
std::string finalWptName; std::string finalWptName;
} trackCache; } trackCache;
// these are init-ed on first use by lazyInitControlsNodes() // these are init-ed on first use by lazyInitControlsNodes()
@ -275,4 +265,4 @@ private:
std::unique_ptr<sg_ofstream> csvFile; std::unique_ptr<sg_ofstream> csvFile;
long csvIndex; long csvIndex;
}; };

View file

@ -1,23 +1,10 @@
// FGAIBallistic.hxx - AIBase derived class creates an AI ballistic object /*
// * SPDX-FileName: AIBallistic.hxx
// Written by David Culp, started November 2003. * SPDX-FileComment: AIBase derived class creates an AI ballistic object
// - davidculp2@comcast.net * SPDX-FileCopyrightText: Copyright (C) 2003 David P. Culp - davidculp2@comcast.net
// * SPDX-FileContributor: With major additions by Vivian Meazza, Feb 2008
// With major additions by Vivian Meazza, Feb 2008 * SPDX-License-Identifier: GPL-2.0-or-later
// */
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#pragma once #pragma once
@ -25,20 +12,20 @@
#include <string_view> #include <string_view>
#include <vector> #include <vector>
#include <simgear/structure/SGSharedPtr.hxx>
#include <simgear/scene/material/mat.hxx> #include <simgear/scene/material/mat.hxx>
#include <simgear/structure/SGSharedPtr.hxx>
#include "AIManager.hxx"
#include "AIBase.hxx" #include "AIBase.hxx"
#include "AIManager.hxx"
class FGAIBallistic : public FGAIBase {
class FGAIBallistic : public FGAIBase
{
public: public:
FGAIBallistic(object_type ot = object_type::otBallistic); FGAIBallistic(object_type ot = object_type::otBallistic);
virtual ~FGAIBallistic() = default; virtual ~FGAIBallistic() = default;
string_view getTypeString(void) const override { return "ballistic"; } std::string_view getTypeString(void) const override { return "ballistic"; }
void readFromScenario(SGPropertyNode* scFileNode) override; void readFromScenario(SGPropertyNode* scFileNode) override;
bool init(ModelSearchOrder searchOrder) override; bool init(ModelSearchOrder searchOrder) override;
@ -48,24 +35,24 @@ public:
void Run(double dt); void Run(double dt);
void setAzimuth( double az ); void setAzimuth(double az);
void setElevation( double el ); void setElevation(double el);
void setAzimuthRandomError(double error); void setAzimuthRandomError(double error);
void setElevationRandomError(double error); void setElevationRandomError(double error);
void setRoll( double rl ); void setRoll(double rl);
void setStabilisation( bool val ); void setStabilisation(bool val);
void setDragArea( double a ); void setDragArea(double a);
void setLife( double seconds ); void setLife(double seconds);
void setBuoyancy( double fpss ); void setBuoyancy(double fpss);
void setWind_from_east( double fps ); void setWind_from_east(double fps);
void setWind_from_north( double fps ); void setWind_from_north(double fps);
void setWind( bool val ); void setWind(bool val);
void setCd(double cd); void setCd(double cd);
void setCdRandomness(double randomness); void setCdRandomness(double randomness);
void setMass( double m ); void setMass(double m);
void setWeight( double w ); void setWeight(double w);
void setNoRoll( bool nr ); void setNoRoll(bool nr);
void setRandom( bool r ); void setRandom(bool r);
void setLifeRandomness(double randomness); void setLifeRandomness(double randomness);
void setCollision(bool c); void setCollision(bool c);
void setExpiry(bool e); void setExpiry(bool e);
@ -76,16 +63,16 @@ public:
void setSMPath(const std::string&); void setSMPath(const std::string&);
void setSubID(int i); void setSubID(int i);
void setSubmodel(const std::string&); void setSubmodel(const std::string&);
void setExternalForce( bool f ); void setExternalForce(bool f);
void setForcePath(const std::string&); void setForcePath(const std::string&);
void setContentsPath(const std::string&); void setContentsPath(const std::string&);
void setForceStabilisation( bool val ); void setForceStabilisation(bool val);
void setGroundOffset(double g); void setGroundOffset(double g);
void setLoadOffset(double l); void setLoadOffset(double l);
void setSlaved(bool s); void setSlaved(bool s);
void setSlavedLoad(bool s); void setSlavedLoad(bool s);
void setPch (double e, double dt, double c); void setPch(double e, double dt, double c);
int setHdg (double az, double dt, double c); int setHdg(double az, double dt, double c);
void setBnk(double r, double dt, double c); void setBnk(double r, double dt, double c);
void setHt(double h, double dt, double c); void setHt(double h, double dt, double c);
void setSpd(double s, double dt, double c); void setSpd(double s, double dt, double c);
@ -95,7 +82,7 @@ public:
void setOffsetVelocity(double dt, SGGeod pos); void setOffsetVelocity(double dt, SGGeod pos);
void setTime(double sec); void setTime(double sec);
double _getTime()const; double _getTime() const;
double getRelBrgHitchToUser() const; double getRelBrgHitchToUser() const;
double getElevHitchToUser() const; double getElevHitchToUser() const;
double getLoadOffset() const; double getLoadOffset() const;
@ -110,7 +97,7 @@ public:
bool getSlaved() const; bool getSlaved() const;
bool getSlavedLoad() const; bool getSlavedLoad() const;
FGAIBallistic *ballistic = nullptr; FGAIBallistic* ballistic = nullptr;
static const double slugs_to_kgs; //conversion factor static const double slugs_to_kgs; //conversion factor
static const double slugs_to_lbs; //conversion factor static const double slugs_to_lbs; //conversion factor
@ -137,10 +124,10 @@ public:
double _height; double _height;
double _speed; double _speed;
double _ht_agl_ft; // height above ground level double _ht_agl_ft; // height above ground level
double _azimuth; // degrees true double _azimuth; // degrees true
double _elevation; // degrees double _elevation; // degrees
double _rotation; // degrees double _rotation; // degrees
double _speed_north_fps = 0.0; double _speed_north_fps = 0.0;
double _speed_east_fps = 0.0; double _speed_east_fps = 0.0;
double _wind_from_east = 0.0; // fps double _wind_from_east = 0.0; // fps
@ -148,7 +135,6 @@ public:
double hs; double hs;
void setTgtXOffset(double x); void setTgtXOffset(double x);
void setTgtYOffset(double y); void setTgtYOffset(double y);
void setTgtZOffset(double z); void setTgtZOffset(double z);
@ -169,38 +155,37 @@ public:
SGGeod _oldoffsetpos; SGGeod _oldoffsetpos;
private: private:
double _az_random_error; // maximum azimuth error in degrees
double _az_random_error; // maximum azimuth error in degrees double _el_random_error; // maximum elevation error in degrees
double _el_random_error; // maximum elevation error in degrees bool _aero_stabilised; // if true, object will align with trajectory
bool _aero_stabilised; // if true, object will align with trajectory double _drag_area; // equivalent drag area in ft2
double _drag_area; // equivalent drag area in ft2 double _cd; // current drag coefficient
double _cd; // current drag coefficient double _init_cd; // initial drag coefficient
double _init_cd; // initial drag coefficient double _cd_randomness; // randomness of Cd. 1.0 means +- 100%, 0.0 means no randomness
double _cd_randomness; // randomness of Cd. 1.0 means +- 100%, 0.0 means no randomness double _buoyancy; // fps^2
double _buoyancy; // fps^2 double _life_timer; // seconds
double _life_timer; // seconds bool _wind; // if true, local wind will be applied to object
bool _wind; // if true, local wind will be applied to object double _mass; // slugs
double _mass; // slugs bool _random; // modifier for Cd, life, az
bool _random; // modifier for Cd, life, az double _life_randomness; // dimension for _random, only applies to life at present
double _life_randomness; // dimension for _random, only applies to life at present double _load_resistance; // ground load resistance N/m^2
double _load_resistance; // ground load resistanc N/m^2 double _frictionFactor = 0.0; // dimensionless modifier for Coefficient of Friction
double _frictionFactor = 0.0; // dimensionless modifier for Coefficient of Friction bool _solid; // if true ground is solid for FDMs
bool _solid; // if true ground is solid for FDMs // double _elevation_m = 0.0; // ground elevation in meters
// double _elevation_m = 0.0; // ground elevation in meters bool _force_stabilised; // if true, object will align to external force
bool _force_stabilised;// if true, object will align to external force bool _slave_to_ac; // if true, object will be slaved to the parent ac pos and orientation
bool _slave_to_ac; // if true, object will be slaved to the parent ac pos and orientation bool _slave_load_to_ac; // if true, object will be slaved to the parent ac pos
bool _slave_load_to_ac;// if true, object will be slaved to the parent ac pos double _contents_lb; // contents of the object
double _contents_lb; // contents of the object double _weight_lb = 0.0; // weight of the object (no contents if appropriate) (lbs)
double _weight_lb = 0.0; // weight of the object (no contents if appropriate) (lbs)
std::string _mat_name; std::string _mat_name;
bool _report_collision; // if true a collision point with AI Objects is calculated bool _report_collision; // if true a collision point with AI Objects is calculated
bool _report_impact; // if true an impact point on the terrain is calculated bool _report_impact; // if true an impact point on the terrain is calculated
bool _external_force; // if true then apply external force bool _external_force; // if true then apply external force
bool _report_expiry; bool _report_expiry;
SGPropertyNode_ptr _impact_report_node; // report node for impact and collision SGPropertyNode_ptr _impact_report_node; // report node for impact and collision
SGPropertyNode_ptr _contents_node; // node for droptank etc. contents SGPropertyNode_ptr _contents_node; // node for droptank etc. contents
double _fuse_range = 0.0; double _fuse_range = 0.0;
@ -211,7 +196,7 @@ private:
void handle_collision(); void handle_collision();
void handle_expiry(); void handle_expiry();
void handle_impact(); void handle_impact();
void report_impact(double elevation, const FGAIBase *target = 0); void report_impact(double elevation, const FGAIBase* target = 0);
void slaveToAC(double dt); void slaveToAC(double dt);
void setContents(double c); void setContents(double c);
void calcVSHS(); void calcVSHS();

View file

@ -1,24 +1,10 @@
// FGAIBase - abstract base class for AI objects /*
// Written by David Culp, started Nov 2003, based on * SPDX-FileName: AIBase.cxx
// David Luff's FGAIEntity class. * SPDX-FileComment: abstract base class for AI objects, based on David Luff's FGAIEntity class.
// - davidculp2@comcast.net * SPDX-FileCopyrightText: Written by David Culp, started Nov 2003 - davidculp2@comcast.net
// * SPDX-FileContributor: With additions by Mathias Froehlich & Vivian Meazza 2004-2007
// With additions by Mathias Froehlich & Vivian Meazza 2004 -2007 * SPDX-License-Identifier: GPL-2.0-or-later
// */
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <config.h> #include <config.h>
@ -470,11 +456,11 @@ void FGAIBase::updateLOD()
_model->setRange(modelLowDetailIndex , maxRangeBare, maxRangeDetail); // least detailed _model->setRange(modelLowDetailIndex , maxRangeBare, maxRangeDetail); // least detailed
} else if (_low_res.valid() && !_high_res.valid()) { } else if (_low_res.valid() && !_high_res.valid()) {
// we have only low_res_model model it obviously will have to be displayed from the smallest value // we have only low_res_model model it obviously will have to be displayed from the smallest value
_model->setRange(modelLowDetailIndex, min(maxRangeBare, maxRangeDetail), FLT_MAX ); _model->setRange(modelLowDetailIndex, std::min(maxRangeBare, maxRangeDetail), FLT_MAX );
_model->setRange(modelHighDetailIndex, 0,0); _model->setRange(modelHighDetailIndex, 0,0);
} else if (!_low_res.valid() && _high_res.valid()) { } else if (!_low_res.valid() && _high_res.valid()) {
// we have only high_res model it obviously will have to be displayed from the smallest value // we have only high_res model it obviously will have to be displayed from the smallest value
_model->setRange(modelHighDetailIndex, min(maxRangeBare, maxRangeDetail), FLT_MAX ); _model->setRange(modelHighDetailIndex, std::min(maxRangeBare, maxRangeDetail), FLT_MAX );
_model->setRange(modelLowDetailIndex, 0,0); _model->setRange(modelLowDetailIndex, 0,0);
} }
} else { } else {
@ -654,7 +640,7 @@ bool FGAIBase::init(ModelSearchOrder searchOrder)
// Load models // Load models
_model = new osg::LOD(); _model = new osg::LOD();
vector<string> model_list = resolveModelPath(searchOrder); std::vector<string> model_list = resolveModelPath(searchOrder);
if(model_list.size() == 1 && _modeldata && _modeldata->hasInteriorPath()) { if(model_list.size() == 1 && _modeldata && _modeldata->hasInteriorPath()) {
// Only one model and interior available (expecting this to be a high_res model) // Only one model and interior available (expecting this to be a high_res model)
_low_res = new osg::PagedLOD(); // Dummy node to keep LOD node happy _low_res = new osg::PagedLOD(); // Dummy node to keep LOD node happy

View file

@ -1,21 +1,9 @@
// FGAIBase.hxx - abstract base class for AI objects /*
// Written by David Culp, started Nov 2003, based on * SPDX-FileName: AIBase.hxx
// David Luff's FGAIEntity class. * SPDX-FileComment: abstract base class for AI objects, based on David Luff's FGAIEntity class.
// - davidculp2@comcast.net * SPDX-FileCopyrightText: Written by David Culp, started Nov 2003 - davidculp2@comcast.net
// * SPDX-License-Identifier: GPL-2.0-or-later
// This program is free software; you can redistribute it and/or */
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#pragma once #pragma once
@ -33,13 +21,18 @@
#include <simgear/structure/SGReferenced.hxx> #include <simgear/structure/SGReferenced.hxx>
#include <simgear/structure/SGSharedPtr.hxx> #include <simgear/structure/SGSharedPtr.hxx>
namespace osg { class PagedLOD; }
namespace simgear { class BVHMaterial; } namespace osg {
class PagedLOD;
}
namespace simgear {
class BVHMaterial;
}
class FGAIManager; class FGAIManager;
class FGAIFlightPlan; class FGAIFlightPlan;
class FGFX; class FGFX;
class FGAIModelData; // defined below class FGAIModelData; // defined below
class FGAIBase : public SGReferenced class FGAIBase : public SGReferenced
@ -59,13 +52,13 @@ public:
otGroundVehicle, otGroundVehicle,
otEscort, otEscort,
otMultiplayer, otMultiplayer,
MAX_OBJECTS // Needs to be last!!! MAX_OBJECTS // Needs to be last!!!
}; };
FGAIBase(object_type ot, bool enableHot); FGAIBase(object_type ot, bool enableHot);
virtual ~FGAIBase(); virtual ~FGAIBase();
// these depend on the order in which the models are loaded. OSG is a little vague about this, but // these depend on the order in which the models are loaded. OSG is a little vague about this, but
// from experimentation it seems to work best if the LODs are in the range list in terms of detail // from experimentation it seems to work best if the LODs are in the range list in terms of detail
// from lowest to highest // from lowest to highest
const int modelLowDetailIndex = 0; const int modelLowDetailIndex = 0;
@ -86,7 +79,7 @@ public:
virtual void unbind(); virtual void unbind();
virtual void reinit() {} virtual void reinit() {}
// default model radius for LOD. // default model radius for LOD.
virtual double getDefaultModelRadius() { return 20.0; } virtual double getDefaultModelRadius() { return 20.0; }
void updateLOD(); void updateLOD();
@ -94,45 +87,45 @@ public:
void setManager(FGAIManager* mgr, SGPropertyNode* p); void setManager(FGAIManager* mgr, SGPropertyNode* p);
void setPath( const char* model ); void setPath(const char* model);
void setPathLowres( std::string model ); void setPathLowres(std::string model);
void setFallbackModelIndex(const int i ); void setFallbackModelIndex(const int i);
void setSMPath( const std::string& p ); void setSMPath(const std::string& p);
void setCallSign(const std::string& ); void setCallSign(const std::string&);
void setSpeed( double speed_KTAS ); void setSpeed(double speed_KTAS);
void setMaxSpeed(double kts); void setMaxSpeed(double kts);
void setAltitude( double altitude_ft ); void setAltitude(double altitude_ft);
void setAltitudeAGL( double altitude_agl_ft ); void setAltitudeAGL(double altitude_agl_ft);
void setHeading( double heading ); void setHeading(double heading);
void setLatitude( double latitude ); void setLatitude(double latitude);
void setLongitude( double longitude ); void setLongitude(double longitude);
void setBank( double bank ); void setBank(double bank);
void setPitch( double newpitch ); void setPitch(double newpitch);
void setRadius ( double radius ); void setRadius(double radius);
void setXoffset( double x_offset ); void setXoffset(double x_offset);
void setYoffset( double y_offset ); void setYoffset(double y_offset);
void setZoffset( double z_offset ); void setZoffset(double z_offset);
void setPitchoffset( double x_offset ); void setPitchoffset(double x_offset);
void setRolloffset( double y_offset ); void setRolloffset(double y_offset);
void setYawoffset( double z_offset ); void setYawoffset(double z_offset);
void setServiceable ( bool serviceable ); void setServiceable(bool serviceable);
bool getDie(); bool getDie();
void setDie( bool die ); void setDie(bool die);
bool isValid() const; bool isValid() const;
void setCollisionData( bool i, double lat, double lon, double elev ); void setCollisionData(bool i, double lat, double lon, double elev);
void setImpactData( bool d ); void setImpactData(bool d);
void setImpactLat( double lat ); void setImpactLat(double lat);
void setImpactLon( double lon ); void setImpactLon(double lon);
void setImpactElev( double e ); void setImpactElev(double e);
void setName(const std::string& n); void setName(const std::string& n);
bool setParentNode(); bool setParentNode();
@ -142,7 +135,7 @@ public:
void setCollisionHeight(int height); void setCollisionHeight(int height);
void calcRangeBearing(double lat, double lon, double lat2, double lon2, void calcRangeBearing(double lat, double lon, double lat2, double lon2,
double &range, double &bearing) const; double& range, double& bearing) const;
double calcRelBearingDeg(double bearing, double heading); double calcRelBearingDeg(double bearing, double heading);
double calcTrueBearingDeg(double bearing, double heading); double calcTrueBearingDeg(double bearing, double heading);
double calcRecipBearingDeg(double bearing); double calcRecipBearingDeg(double bearing);
@ -224,14 +217,14 @@ protected:
FGAIManager* manager = nullptr; FGAIManager* manager = nullptr;
// these describe the model's actual state // these describe the model's actual state
SGGeod pos; // WGS84 lat & lon in degrees, elev above sea-level in meters SGGeod pos; // WGS84 lat & lon in degrees, elev above sea-level in meters
double hdg; // True heading in degrees double hdg; // True heading in degrees
double roll; // degrees, left is negative double roll; // degrees, left is negative
double pitch; // degrees, nose-down is negative double pitch; // degrees, nose-down is negative
double speed; // knots true airspeed double speed; // knots true airspeed
double speed_fps = 0.0; // fps true airspeed double speed_fps = 0.0; // fps true airspeed
double altitude_ft; // feet above sea level double altitude_ft; // feet above sea level
double vs_fps; // vertical speed double vs_fps; // vertical speed
double speed_north_deg_sec; double speed_north_deg_sec;
double speed_east_deg_sec; double speed_east_deg_sec;
double turn_radius_ft; // turn radius ft at 15 kts rudder angle 15 degrees double turn_radius_ft; // turn radius ft at 15 kts rudder angle 15 degrees
@ -250,17 +243,17 @@ protected:
double tgt_vs; double tgt_vs;
// these describe radar information for the user // these describe radar information for the user
bool in_range; // true if in range of the radar, otherwise false bool in_range; // true if in range of the radar, otherwise false
double bearing; // true bearing from user to this model double bearing; // true bearing from user to this model
double elevation; // elevation in degrees from user to this model double elevation; // elevation in degrees from user to this model
double range; // range from user to this model, nm double range; // range from user to this model, nm
double rdot; // range rate, in knots double rdot; // range rate, in knots
double horiz_offset; // look left/right from user to me, deg double horiz_offset; // look left/right from user to me, deg
double vert_offset; // look up/down from user to me, deg double vert_offset; // look up/down from user to me, deg
double x_shift; // value used by radar display instrument double x_shift; // value used by radar display instrument
double y_shift; // value used by radar display instrument double y_shift; // value used by radar display instrument
double rotation; // value used by radar display instrument double rotation; // value used by radar display instrument
double ht_diff; // value used by radar display instrument double ht_diff; // value used by radar display instrument
std::string model_path; // Path to the 3D model std::string model_path; // Path to the 3D model
std::string model_path_lowres; // Path to optional low res 3D model std::string model_path_lowres; // Path to optional low res 3D model
@ -308,25 +301,24 @@ private:
osg::ref_ptr<osg::PagedLOD> _high_res; osg::ref_ptr<osg::PagedLOD> _high_res;
osg::ref_ptr<osg::Group> _group; osg::ref_ptr<osg::Group> _group;
osg::ref_ptr<osg::PagedLOD> _interior; osg::ref_ptr<osg::PagedLOD> _interior;
osg::ref_ptr<FGAIModelData> _modeldata; osg::ref_ptr<FGAIModelData> _modeldata;
SGSharedPtr<FGFX> _fx; SGSharedPtr<FGFX> _fx;
std::vector<std::string> resolveModelPath(ModelSearchOrder searchOrder); std::vector<std::string> resolveModelPath(ModelSearchOrder searchOrder);
public: public:
object_type getType(); object_type getType();
virtual string_view getTypeString(void) const { return "null"; } virtual std::string_view getTypeString(void) const { return "null"; }
bool isa( object_type otype ); bool isa(object_type otype);
void _setVS_fps( double _vs ); void _setVS_fps(double _vs);
void _setAltitude( double _alt ); void _setAltitude(double _alt);
void _setLongitude( double longitude ); void _setLongitude(double longitude);
void _setLatitude ( double latitude ); void _setLatitude(double latitude);
void _setSubID( int s ); void _setSubID(int s);
double _getAltitudeAGL(SGGeod inpos, double start); double _getAltitudeAGL(SGGeod inpos, double start);
@ -359,12 +351,12 @@ public:
double _getYOffset() const; double _getYOffset() const;
double _getZOffset() const; double _getZOffset() const;
bool _getServiceable() const; bool _getServiceable() const;
bool _getFirstTime() const; bool _getFirstTime() const;
bool _getImpact(); bool _getImpact();
bool _getImpactData(); bool _getImpactData();
bool _getCollisionData(); bool _getCollisionData();
bool _getExpiryData(); bool _getExpiryData();
SGPropertyNode* _getProps() const; SGPropertyNode* _getProps() const;
@ -385,126 +377,152 @@ public:
static bool _isNight(); static bool _isNight();
const std::string& getCallSign() const { return _callsign; } const std::string& getCallSign() const { return _callsign; }
ModelSearchOrder getSearchOrder() const {return _searchOrder;} ModelSearchOrder getSearchOrder() const { return _searchOrder; }
}; };
typedef SGSharedPtr<FGAIBase> FGAIBasePtr; typedef SGSharedPtr<FGAIBase> FGAIBasePtr;
inline void FGAIBase::setManager(FGAIManager* mgr, SGPropertyNode* p) { inline void FGAIBase::setManager(FGAIManager* mgr, SGPropertyNode* p)
{
manager = mgr; manager = mgr;
props = p; props = p;
} }
inline void FGAIBase::setPath(const char* model ) { inline void FGAIBase::setPath(const char* model)
{
model_path.append(model); model_path.append(model);
} }
inline void FGAIBase::setPathLowres(std::string model ) { inline void FGAIBase::setPathLowres(std::string model)
{
model_path_lowres.append(model); model_path_lowres.append(model);
} }
inline void FGAIBase::setFallbackModelIndex(const int i ) { inline void FGAIBase::setFallbackModelIndex(const int i)
{
_fallback_model_index = i; _fallback_model_index = i;
} }
inline void FGAIBase::setSMPath(const std::string& p) { inline void FGAIBase::setSMPath(const std::string& p)
{
_path = p; _path = p;
} }
inline void FGAIBase::setServiceable(bool s) { inline void FGAIBase::setServiceable(bool s)
{
serviceable = s; serviceable = s;
} }
inline void FGAIBase::setSpeed( double speed_KTAS ) { inline void FGAIBase::setSpeed(double speed_KTAS)
{
speed = tgt_speed = speed_KTAS; speed = tgt_speed = speed_KTAS;
} }
inline void FGAIBase::setRadius( double radius ) { inline void FGAIBase::setRadius(double radius)
{
turn_radius_ft = radius; turn_radius_ft = radius;
} }
inline void FGAIBase::setHeading( double heading ) { inline void FGAIBase::setHeading(double heading)
{
hdg = tgt_heading = heading; hdg = tgt_heading = heading;
} }
inline void FGAIBase::setAltitude( double alt_ft ) { inline void FGAIBase::setAltitude(double alt_ft)
{
altitude_ft = tgt_altitude_ft = alt_ft; altitude_ft = tgt_altitude_ft = alt_ft;
pos.setElevationFt(altitude_ft); pos.setElevationFt(altitude_ft);
} }
inline void FGAIBase::setAltitudeAGL( double alt_ft ) { inline void FGAIBase::setAltitudeAGL(double alt_ft)
{
altitude_agl_ft = alt_ft; altitude_agl_ft = alt_ft;
} }
inline void FGAIBase::setBank( double bank ) { inline void FGAIBase::setBank(double bank)
{
roll = tgt_roll = bank; roll = tgt_roll = bank;
no_roll = false; no_roll = false;
} }
inline void FGAIBase::setPitch( double newpitch ) { inline void FGAIBase::setPitch(double newpitch)
{
pitch = tgt_pitch = newpitch; pitch = tgt_pitch = newpitch;
} }
inline void FGAIBase::setLongitude( double longitude ) { inline void FGAIBase::setLongitude(double longitude)
pos.setLongitudeDeg( longitude ); {
pos.setLongitudeDeg(longitude);
} }
inline void FGAIBase::setLatitude ( double latitude ) { inline void FGAIBase::setLatitude(double latitude)
pos.setLatitudeDeg( latitude ); {
pos.setLatitudeDeg(latitude);
} }
inline void FGAIBase::setCallSign(const std::string& s) { inline void FGAIBase::setCallSign(const std::string& s)
{
_callsign = s; _callsign = s;
} }
inline void FGAIBase::setXoffset(double x) { inline void FGAIBase::setXoffset(double x)
{
_x_offset = x; _x_offset = x;
} }
inline void FGAIBase::setYoffset(double y) { inline void FGAIBase::setYoffset(double y)
{
_y_offset = y; _y_offset = y;
} }
inline void FGAIBase::setZoffset(double z) { inline void FGAIBase::setZoffset(double z)
{
_z_offset = z; _z_offset = z;
} }
inline void FGAIBase::setPitchoffset(double p) { inline void FGAIBase::setPitchoffset(double p)
{
_pitch_offset = p; _pitch_offset = p;
} }
inline void FGAIBase::setRolloffset(double r) { inline void FGAIBase::setRolloffset(double r)
{
_roll_offset = r; _roll_offset = r;
} }
inline void FGAIBase::setYawoffset(double y) { inline void FGAIBase::setYawoffset(double y)
{
_yaw_offset = y; _yaw_offset = y;
} }
inline void FGAIBase::setParentName(const std::string& p) { inline void FGAIBase::setParentName(const std::string& p)
{
_parent = p; _parent = p;
} }
inline void FGAIBase::setName(const std::string& n) { inline void FGAIBase::setName(const std::string& n)
{
_name = n; _name = n;
} }
inline void FGAIBase::setCollisionLength(int length){ inline void FGAIBase::setCollisionLength(int length)
{
collisionLength = length; collisionLength = length;
} }
inline void FGAIBase::setCollisionHeight(int height){ inline void FGAIBase::setCollisionHeight(int height)
{
collisionHeight = height; collisionHeight = height;
} }
inline void FGAIBase::setDie( bool die ) { delete_me = die; } inline void FGAIBase::setDie(bool die) { delete_me = die; }
inline bool FGAIBase::getDie() { return delete_me; } inline bool FGAIBase::getDie() { return delete_me; }
inline FGAIBase::object_type FGAIBase::getType() { return _otype; } inline FGAIBase::object_type FGAIBase::getType() { return _otype; }
inline void FGAIBase::calcRangeBearing(double lat, double lon, double lat2, double lon2, inline void FGAIBase::calcRangeBearing(double lat, double lon, double lat2, double lon2,
double &range, double &bearing) const double& range, double& bearing) const
{ {
// calculate the bearing and range of the second pos from the first // calculate the bearing and range of the second pos from the first
double az2, distance; double az2, distance;
@ -512,25 +530,29 @@ inline void FGAIBase::calcRangeBearing(double lat, double lon, double lat2, doub
range = distance * SG_METER_TO_NM; range = distance * SG_METER_TO_NM;
} }
inline double FGAIBase::calcRelBearingDeg(double bearing, double heading){ inline double FGAIBase::calcRelBearingDeg(double bearing, double heading)
{
double angle = bearing - heading; double angle = bearing - heading;
SG_NORMALIZE_RANGE(angle, -180.0, 180.0); SG_NORMALIZE_RANGE(angle, -180.0, 180.0);
return angle; return angle;
} }
inline double FGAIBase::calcTrueBearingDeg(double bearing, double heading){ inline double FGAIBase::calcTrueBearingDeg(double bearing, double heading)
{
double angle = bearing + heading; double angle = bearing + heading;
SG_NORMALIZE_RANGE(angle, 0.0, 360.0); SG_NORMALIZE_RANGE(angle, 0.0, 360.0);
return angle; return angle;
} }
inline double FGAIBase::calcRecipBearingDeg(double bearing){ inline double FGAIBase::calcRecipBearingDeg(double bearing)
{
double angle = bearing - 180; double angle = bearing - 180;
SG_NORMALIZE_RANGE(angle, 0.0, 360.0); SG_NORMALIZE_RANGE(angle, 0.0, 360.0);
return angle; return angle;
} }
inline void FGAIBase::setMaxSpeed(double m) { inline void FGAIBase::setMaxSpeed(double m)
{
_max_speed = m; _max_speed = m;
} }
@ -539,7 +561,7 @@ inline void FGAIBase::setMaxSpeed(double m) {
* The difference in height is used first and then the range must be within * The difference in height is used first and then the range must be within
* the value specifed in the length field. This effective chops the top and * the value specifed in the length field. This effective chops the top and
* bottom off the circle - but does not take into account the orientation of the * bottom off the circle - but does not take into account the orientation of the
* AI model; so this algorithm is fast but fairly innaccurate. * AI model; so this algorithm is fast but fairly inaccurate.
* *
* Default values: * Default values:
* +---------------+-------------+------------+ * +---------------+-------------+------------+
@ -561,7 +583,7 @@ inline void FGAIBase::setMaxSpeed(double m) {
* +---------------+-------------+------------+ * +---------------+-------------+------------+
*/ */
const static double tgt_ht[] = {0, 50, 100, 250, 0, 100, 0, 0, 50, 50, 20, 100, 50}; const static double tgt_ht[] = {0, 50, 100, 250, 0, 100, 0, 0, 50, 50, 20, 100, 50};
const static double tgt_length[] = {0, 100, 200, 750, 0, 50, 0, 0, 200, 100, 40, 200, 100}; const static double tgt_length[] = {0, 100, 200, 750, 0, 50, 0, 0, 200, 100, 40, 200, 100};
inline int FGAIBase::getCollisionHeight() const inline int FGAIBase::getCollisionHeight() const
{ {
@ -577,4 +599,3 @@ inline int FGAIBase::getCollisionLength() const
return collisionLength; return collisionLength;
} }

View file

@ -1,21 +1,9 @@
// FGAICarrier - FGAIShip-derived class creates an AI aircraft carrier /*
// * SPDX-FileName: AICarrier.cxx
// Written by David Culp, started October 2004. * SPDX-FileComment: AIShip-derived class creates an AI aircraft carrier
// - davidculp2@comcast.net * SPDX-FileCopyrightText: Written by David Culp, started October 2004 - davidculp2@comcast.net
// * SPDX-License-Identifier: GPL-2.0-or-later
// This program is free software; you can redistribute it and/or */
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <config.h> #include <config.h>
@ -99,7 +87,7 @@ void FGAICarrier::readFromScenario(SGPropertyNode* scFileNode) {
std::vector<SGPropertyNode_ptr> props = scFileNode->getChildren("parking-pos"); std::vector<SGPropertyNode_ptr> props = scFileNode->getChildren("parking-pos");
std::vector<SGPropertyNode_ptr>::const_iterator it; std::vector<SGPropertyNode_ptr>::const_iterator it;
for (it = props.begin(); it != props.end(); ++it) { for (it = props.begin(); it != props.end(); ++it) {
const string name = (*it)->getStringValue("name", "unnamed"); const std::string name = (*it)->getStringValue("name", "unnamed");
// Transform to the right coordinate frame, configuration is done in // Transform to the right coordinate frame, configuration is done in
// the usual x-back, y-right, z-up coordinates, computations // the usual x-back, y-right, z-up coordinates, computations
// in the simulation usual body x-forward, y-right, z-down coordinates // in the simulation usual body x-forward, y-right, z-down coordinates
@ -141,11 +129,11 @@ void FGAICarrier::setDeckAltitudeFt(const double altitude_feet) {
_deck_altitude_ft = altitude_feet; _deck_altitude_ft = altitude_feet;
} }
void FGAICarrier::setSign(const string& s) { void FGAICarrier::setSign(const std::string& s) {
_sign = s; _sign = s;
} }
void FGAICarrier::setTACANChannelID(const string& id) { void FGAICarrier::setTACANChannelID(const std::string& id) {
_TACAN_channel_id = id; _TACAN_channel_id = id;
} }
@ -474,7 +462,7 @@ void FGAICarrier::bind(){
} }
} }
bool FGAICarrier::getParkPosition(const string& id, SGGeod& geodPos, bool FGAICarrier::getParkPosition(const std::string& id, SGGeod& geodPos,
double& hdng, SGVec3d& uvw) double& hdng, SGVec3d& uvw)
{ {
@ -724,7 +712,7 @@ void FGAICarrier::UpdateElevator(double dt) {
void FGAICarrier::UpdateJBD(double dt) { void FGAICarrier::UpdateJBD(double dt) {
const string launchbar_state = _launchbar_state_node->getStringValue(); const std::string launchbar_state = _launchbar_state_node->getStringValue();
double step = 0; double step = 0;
if (launchbar_state == "Engaged"){ if (launchbar_state == "Engaged"){

View file

@ -1,22 +1,9 @@
// FGAICarrier - AIShip-derived class creates an AI aircraft carrier /*
// * SPDX-FileName: AICarrier.hxx
// Written by David Culp, started October 2004. * SPDX-FileComment: AIShip-derived class creates an AI aircraft carrier
// * SPDX-FileCopyrightText: Copyright (C) 2004 David P. Culp - davidculp2@comcast.net
// Copyright (C) 2004 David P. Culp - davidculp2@comcast.net * SPDX-License-Identifier: GPL-2.0-or-later
// */
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#pragma once #pragma once
@ -28,10 +15,10 @@
#include <simgear/emesary/Emesary.hxx> #include <simgear/emesary/Emesary.hxx>
#include "AIShip.hxx" #include "AIShip.hxx"
#include "AIBase.hxx" #include "AIBase.hxx"
#include "AIManager.hxx" #include "AIManager.hxx"
class FGAIManager; class FGAIManager;
class FGAICarrier; class FGAICarrier;
@ -41,7 +28,7 @@ public:
FGAICarrier(); FGAICarrier();
virtual ~FGAICarrier(); virtual ~FGAICarrier();
string_view getTypeString(void) const override { return "carrier"; } std::string_view getTypeString(void) const override { return "carrier"; }
void readFromScenario(SGPropertyNode* scFileNode) override; void readFromScenario(SGPropertyNode* scFileNode) override;
void setSign(const std::string&); void setSign(const std::string&);

View file

@ -1,22 +1,8 @@
// FGAIGroundVehicle - FGAIShip-derived class creates an AI Ground Vehicle /*
// by adding a ground following utility * SPDX-FileName: AIEscort.hxx
// * SPDX-FileCopyrightText: Written by Vivian Meazza, started August 2009 - vivian.meazza at lineone.net
// Written by Vivian Meazza, started August 2009. * SPDX-License-Identifier: GPL-2.0-or-later
// - vivian.meazza at lineone.net */
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#pragma once #pragma once
@ -33,13 +19,14 @@
#include "AIBase.hxx" #include "AIBase.hxx"
#include "AIManager.hxx" #include "AIManager.hxx"
class FGAIEscort : public FGAIShip class FGAIEscort : public FGAIShip
{ {
public: public:
FGAIEscort(); FGAIEscort();
virtual ~FGAIEscort() = default; virtual ~FGAIEscort() = default;
string_view getTypeString(void) const override { return "escort"; } std::string_view getTypeString(void) const override { return "escort"; }
void readFromScenario(SGPropertyNode* scFileNode) override; void readFromScenario(SGPropertyNode* scFileNode) override;
bool init(ModelSearchOrder searchOrder) override; bool init(ModelSearchOrder searchOrder) override;
@ -69,7 +56,7 @@ private:
SGVec3d getCartHitchPosAt(const SGVec3d& off) const; SGVec3d getCartHitchPosAt(const SGVec3d& off) const;
void calcRangeBearing(double lat, double lon, double lat2, double lon2, void calcRangeBearing(double lat, double lon, double lat2, double lon2,
double &range, double &bearing) const; double& range, double& bearing) const;
double calcTrueBearingDeg(double bearing, double heading); double calcTrueBearingDeg(double bearing, double heading);
SGGeod _selectedpos; SGGeod _selectedpos;

View file

@ -1,20 +1,9 @@
// // FGAIFlightPlan - class for loading and storing AI flight plans /*
// Written by David Culp, started May 2004 * SPDX-FileName: AIFlightPlan.cxx
// - davidculp2@comcast.net * SPDX-FileComment: class for loading and storing AI flight plans
// * SPDX-FileCopyrightText: Written by David Culp, started May 2004 - davidculp2@comcast.net
// This program is free software; you can redistribute it and/or * SPDX-License-Identifier: GPL-2.0-or-later
// modify it under the terms of the GNU General Public License as */
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include <config.h> # include <config.h>
@ -575,11 +564,11 @@ void FGAIFlightPlan::pushBackWaypoint(FGAIWaypoint *wpt)
SG_LOG(SG_AI, SG_DEBUG, "Double WP : \t" << wpt->getName() << " not added "); SG_LOG(SG_AI, SG_DEBUG, "Double WP : \t" << wpt->getName() << " not added ");
} else { } else {
waypoints.push_back(wpt); waypoints.push_back(wpt);
SG_LOG(SG_AI, SG_BULK, "Added WP : \t" << setprecision(12) << wpt->getName() << "\t" << wpt->getPos() << "\t" << wpt->getSpeed()); SG_LOG(SG_AI, SG_BULK, "Added WP : \t" << std::setprecision(12) << wpt->getName() << "\t" << wpt->getPos() << "\t" << wpt->getSpeed());
} }
} else { } else {
waypoints.push_back(wpt); waypoints.push_back(wpt);
SG_LOG(SG_AI, SG_BULK, "Added WP : \t" << setprecision(12) << wpt->getName() << "\t" << wpt->getPos() << "\t" << wpt->getSpeed()); SG_LOG(SG_AI, SG_BULK, "Added WP : \t" << std::setprecision(12) << wpt->getName() << "\t" << wpt->getPos() << "\t" << wpt->getSpeed());
} }
// std::vector::push_back invalidates waypoints // std::vector::push_back invalidates waypoints
// so we should restore wpt_iterator after push_back // so we should restore wpt_iterator after push_back

View file

@ -1,22 +1,9 @@
// FGAIGroundVehicle - FGAIShip-derived class creates an AI Ground Vehicle /*
// by adding a ground following utility * SPDX-FileName: AIGroundVehicle.hxx
// * SPDX-FileComment: AIShip-derived class creates an AI Ground Vehicle by adding a ground following utility
// Written by Vivian Meazza, started August 2009. * SPDX-FileCopyrightText: Written by Vivian Meazza, started August 2009 - vivian.meazza at lineone.net
// - vivian.meazza at lineone.net * SPDX-License-Identifier: GPL-2.0-or-later
// */
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#pragma once #pragma once
@ -24,20 +11,22 @@
#include <string_view> #include <string_view>
#include <vector> #include <vector>
#include <simgear/structure/SGSharedPtr.hxx>
#include <simgear/scene/material/mat.hxx> #include <simgear/scene/material/mat.hxx>
#include <simgear/structure/SGSharedPtr.hxx>
#include "AIShip.hxx" #include "AIShip.hxx"
#include "AIManager.hxx"
#include "AIBase.hxx" #include "AIBase.hxx"
#include "AIManager.hxx"
class FGAIGroundVehicle : public FGAIShip {
class FGAIGroundVehicle : public FGAIShip
{
public: public:
FGAIGroundVehicle(); FGAIGroundVehicle();
virtual ~FGAIGroundVehicle() = default; virtual ~FGAIGroundVehicle() = default;
string_view getTypeString(void) const override { return "groundvehicle"; } std::string_view getTypeString(void) const override { return "groundvehicle"; }
void readFromScenario(SGPropertyNode* scFileNode) override; void readFromScenario(SGPropertyNode* scFileNode) override;
bool init(ModelSearchOrder searchOrder) override; bool init(ModelSearchOrder searchOrder) override;
@ -72,13 +61,13 @@ private:
SGVec3d getCartHitchPosAt(const SGVec3d& off) const; SGVec3d getCartHitchPosAt(const SGVec3d& off) const;
void calcRangeBearing(double lat, double lon, double lat2, double lon2, void calcRangeBearing(double lat, double lon, double lat2, double lon2,
double &range, double &bearing) const; double& range, double& bearing) const;
SGGeod _selectedpos; SGGeod _selectedpos;
bool _solid = true; // if true ground is solid for FDMs bool _solid = true; // if true ground is solid for FDMs
double _load_resistance = 0.0; // ground load resistanc N/m^2 double _load_resistance = 0.0; // ground load resistance N/m^2
double _frictionFactor = 0.0; // dimensionless modifier for Coefficient of Friction double _frictionFactor = 0.0; // dimensionless modifier for Coefficient of Friction
double _elevation = 0.0; double _elevation = 0.0;
double _elevation_coeff = 0.0; double _elevation_coeff = 0.0;

View file

@ -1,22 +1,9 @@
// AIManager.cxx Based on David Luff's AIMgr: /*
// - a global management type for AI objects * SPDX-FileName: AIManager.cxx
// * SPDX-FileComment: a global management type for AI objects, based on David Luff's AIMgr
// Written by David Culp, started October 2003. * SPDX-FileCopyrightText: Written by David Culp, started October 2003 - davidculp2@comcast.net
// - davidculp2@comcast.net * SPDX-License-Identifier: GPL-2.0-or-later
// */
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
@ -263,7 +250,7 @@ SGPropertyNode_ptr FGAIManager::registerScenarioFile(SGPropertyNode_ptr root, co
} catch (sg_exception& e) { } catch (sg_exception& e) {
SG_LOG(SG_AI, SG_WARN, "Skipping malformed scenario file:" << xmlPath); SG_LOG(SG_AI, SG_WARN, "Skipping malformed scenario file:" << xmlPath);
simgear::reportFailure(simgear::LoadFailure::BadData, simgear::ErrorCode::ScenarioLoad, simgear::reportFailure(simgear::LoadFailure::BadData, simgear::ErrorCode::ScenarioLoad,
string{"The scenario couldn't be loaded:"} + e.getFormattedMessage(), std::string{"The scenario couldn't be loaded:"} + e.getFormattedMessage(),
e.getLocation()); e.getLocation());
sNode.reset(); sNode.reset();
} }
@ -282,7 +269,7 @@ FGAIManager::postinit()
// process all scenarios // process all scenarios
for (auto n : root->getChildren("scenario")) { for (auto n : root->getChildren("scenario")) {
const string& name = n->getStringValue(); const std::string& name = n->getStringValue();
if (name.empty()) if (name.empty())
continue; continue;
@ -425,7 +412,7 @@ FGAIManager::updateLOD(SGPropertyNode* node)
void void
FGAIManager::attach(const SGSharedPtr<FGAIBase> &model) FGAIManager::attach(const SGSharedPtr<FGAIBase> &model)
{ {
string_view typeString = model->getTypeString(); std::string_view typeString = model->getTypeString();
SGPropertyNode* root = globals->get_props()->getNode("ai/models", true); SGPropertyNode* root = globals->get_props()->getNode("ai/models", true);
SGPropertyNode* p; SGPropertyNode* p;
int i; int i;
@ -619,7 +606,7 @@ FGAIBasePtr FGAIManager::getObjectFromProperty(const SGPropertyNode* aProp) cons
} }
bool bool
FGAIManager::loadScenario( const string &id ) FGAIManager::loadScenario( const std::string &id )
{ {
SGPath path; SGPath path;
SGPropertyNode_ptr file = loadScenarioFile(id, path); SGPropertyNode_ptr file = loadScenarioFile(id, path);
@ -643,7 +630,7 @@ FGAIManager::loadScenario( const string &id )
bool bool
FGAIManager::unloadScenario( const string &filename) FGAIManager::unloadScenario( const std::string &filename)
{ {
auto it = _scenarios.find(filename); auto it = _scenarios.find(filename);
if (it == _scenarios.end()) { if (it == _scenarios.end()) {

View file

@ -1,22 +1,9 @@
// FGAIMultiplayer - AIBase derived class creates an AI multiplayer aircraft /*
// * SPDX-FileName: AIMultiplayer.hxx
// Written by David Culp, started October 2003. * SPDX-FileComment: AIBase derived class creates an AI multiplayer aircraft
// * SPDX-FileCopyrightText: Copyright (C) 2003 David P. Culp - davidculp2@comcast.net
// Copyright (C) 2003 David P. Culp - davidculp2@comcast.net * SPDX-License-Identifier: GPL-2.0-or-later
// */
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#pragma once #pragma once
@ -28,183 +15,181 @@
#include "AIBase.hxx" #include "AIBase.hxx"
class FGAIMultiplayer : public FGAIBase {
class FGAIMultiplayer : public FGAIBase
{
public: public:
FGAIMultiplayer(); FGAIMultiplayer();
virtual ~FGAIMultiplayer() = default; virtual ~FGAIMultiplayer() = default;
string_view getTypeString(void) const override { return "multiplayer"; } std::string_view getTypeString(void) const override { return "multiplayer"; }
bool init(ModelSearchOrder searchOrder) override; bool init(ModelSearchOrder searchOrder) override;
void bind() override; void bind() override;
void update(double dt) override; void update(double dt) override;
void addMotionInfo(FGExternalMotionData& motionInfo, long stamp); void addMotionInfo(FGExternalMotionData& motionInfo, long stamp);
#if 0 #if 0
void setDoubleProperty(const std::string& prop, double val); void setDoubleProperty(const std::string& prop, double val);
#endif #endif
long getLastTimestamp(void) const long getLastTimestamp(void) const
{ {
return mLastTimestamp; return mLastTimestamp;
} }
void setAllowExtrapolation(bool allowExtrapolation) void setAllowExtrapolation(bool allowExtrapolation)
{ {
mAllowExtrapolation = allowExtrapolation; mAllowExtrapolation = allowExtrapolation;
}
} bool getAllowExtrapolation(void) const
bool getAllowExtrapolation(void) const {
{ return mAllowExtrapolation;
return mAllowExtrapolation; }
}
void setLagAdjustSystemSpeed(double lagAdjustSystemSpeed)
{
if (lagAdjustSystemSpeed < 0)
lagAdjustSystemSpeed = 0;
mLagAdjustSystemSpeed = lagAdjustSystemSpeed;
}
double getLagAdjustSystemSpeed(void) const
{
return mLagAdjustSystemSpeed;
}
void addPropertyId(unsigned id, const char* name) void setLagAdjustSystemSpeed(double lagAdjustSystemSpeed)
{ {
mPropertyMap[id] = props->getNode(name, true); if (lagAdjustSystemSpeed < 0)
} lagAdjustSystemSpeed = 0;
mLagAdjustSystemSpeed = lagAdjustSystemSpeed;
}
double getplayerLag(void) const double getLagAdjustSystemSpeed(void) const
{ {
return playerLag; return mLagAdjustSystemSpeed;
} }
void setplayerLag(double mplayerLag) void addPropertyId(unsigned id, const char* name)
{ {
playerLag = mplayerLag; mPropertyMap[id] = props->getNode(name, true);
} }
int getcompensateLag(void) const double getplayerLag(void) const
{ {
return compensateLag; return playerLag;
} }
void setcompensateLag(int mcompensateLag) void setplayerLag(double mplayerLag)
{ {
compensateLag = mcompensateLag; playerLag = mplayerLag;
} }
SGPropertyNode* getPropertyRoot() int getcompensateLag(void) const
{ {
return props; return compensateLag;
} }
void clearMotionInfo(); void setcompensateLag(int mcompensateLag)
{
compensateLag = mcompensateLag;
}
SGPropertyNode* getPropertyRoot()
{
return props;
}
void clearMotionInfo();
private: private:
// Automatic sorting of motion data according to its timestamp
typedef std::map<double, FGExternalMotionData> MotionInfo;
MotionInfo mMotionInfo;
// Automatic sorting of motion data according to its timestamp // Map between the property id's from the multiplayer network packets
typedef std::map<double,FGExternalMotionData> MotionInfo; // and the property nodes
MotionInfo mMotionInfo; typedef std::map<unsigned, SGSharedPtr<SGPropertyNode>> PropertyMap;
PropertyMap mPropertyMap;
// Map between the property id's from the multiplayers network packets // Calculates position, orientation and velocity using interpolation between
// and the property nodes // *prevIt and *nextIt, specifically (1-tau)*(*prevIt) + tau*(*nextIt).
typedef std::map<unsigned, SGSharedPtr<SGPropertyNode> > PropertyMap; //
PropertyMap mPropertyMap; // Cannot call this method 'interpolate' because that would hide the name in
// OSG.
// Calculates position, orientation and velocity using interpolation between //
// *prevIt and *nextIt, specifically (1-tau)*(*prevIt) + tau*(*nextIt). void FGAIMultiplayerInterpolate(
//
// Cannot call this method 'interpolate' because that would hide the name in
// OSG.
//
void FGAIMultiplayerInterpolate(
MotionInfo::iterator prevIt, MotionInfo::iterator prevIt,
MotionInfo::iterator nextIt, MotionInfo::iterator nextIt,
double tau, double tau,
SGVec3d& ecPos, SGVec3d& ecPos,
SGQuatf& ecOrient, SGQuatf& ecOrient,
SGVec3f& ecLinearVel SGVec3f& ecLinearVel);
);
// Calculates position, orientation and velocity using extrapolation from // Calculates position, orientation and velocity using extrapolation from
// *nextIt. // *nextIt.
// //
void FGAIMultiplayerExtrapolate( void FGAIMultiplayerExtrapolate(
MotionInfo::iterator nextIt, MotionInfo::iterator nextIt,
double tInterp, double tInterp,
bool motion_logging, bool motion_logging,
SGVec3d& ecPos, SGVec3d& ecPos,
SGQuatf& ecOrient, SGQuatf& ecOrient,
SGVec3f& ecLinearVel SGVec3f& ecLinearVel);
);
bool mTimeOffsetSet = false; bool mTimeOffsetSet = false;
bool realTime = false; bool realTime = false;
int compensateLag = 1; int compensateLag = 1;
double playerLag = 0.03; double playerLag = 0.03;
double mTimeOffset = 0.0; double mTimeOffset = 0.0;
double lastUpdateTime = 0.0; double lastUpdateTime = 0.0;
double lastTime = 0.0; double lastTime = 0.0;
double lagPpsAveraged = 1.0; double lagPpsAveraged = 1.0;
double rawLag = 0.0; double rawLag = 0.0;
double rawLagMod = 0.0; double rawLagMod = 0.0;
double lagModAveraged = 0.0; double lagModAveraged = 0.0;
/// Properties which are for now exposed for testing /// Properties which are for now exposed for testing
bool mAllowExtrapolation = true; bool mAllowExtrapolation = true;
double mLagAdjustSystemSpeed = 10.0; double mLagAdjustSystemSpeed = 10.0;
long mLastTimestamp = 0; long mLastTimestamp = 0;
// Properties for tankers // Properties for tankers
SGPropertyNode_ptr refuel_node; SGPropertyNode_ptr refuel_node;
bool isTanker = false; bool isTanker = false;
bool contact = false; // set if this tanker is within fuelling range bool contact = false; // set if this tanker is within fuelling range
// velocities/u,v,wbody-fps
SGPropertyNode_ptr _uBodyNode;
SGPropertyNode_ptr _vBodyNode;
SGPropertyNode_ptr _wBodyNode;
// Things for simple-time.
//
SGPropertyNode_ptr m_simple_time_enabled;
SGPropertyNode_ptr m_sim_replay_replay_state;
SGPropertyNode_ptr m_sim_replay_time;
bool m_simple_time_first_time = true;
double m_simple_time_offset = 0.0;
double m_simple_time_offset_smoothed = 0.0;
double m_simple_time_compensation = 0.0;
double m_simple_time_recent_packet_time = 0.0;
SGPropertyNode_ptr m_lagPPSAveragedNode;
SGPropertyNode_ptr m_lagModAveragedNode;
SGPropertyNode_ptr m_node_simple_time_latest; // velocities/u,v,wbody-fps
SGPropertyNode_ptr m_node_simple_time_offset; SGPropertyNode_ptr _uBodyNode;
SGPropertyNode_ptr m_node_simple_time_offset_smoothed; SGPropertyNode_ptr _vBodyNode;
SGPropertyNode_ptr m_node_simple_time_compensation; SGPropertyNode_ptr _wBodyNode;
// For use with scripts/python/recordreplay.py --test-motion-mp. // Things for simple-time.
SGPropertyNode_ptr mLogRawSpeedMultiplayer; //
SGPropertyNode_ptr m_simple_time_enabled;
SGPropertyNode_ptr m_node_ai_latch;
std::string m_ai_latch; SGPropertyNode_ptr m_sim_replay_replay_state;
SGPropertyNode_ptr m_node_ai_latch_latitude; SGPropertyNode_ptr m_sim_replay_time;
SGPropertyNode_ptr m_node_ai_latch_longitude;
SGPropertyNode_ptr m_node_ai_latch_altitude; bool m_simple_time_first_time = true;
SGPropertyNode_ptr m_node_ai_latch_heading; double m_simple_time_offset = 0.0;
SGPropertyNode_ptr m_node_ai_latch_pitch; double m_simple_time_offset_smoothed = 0.0;
SGPropertyNode_ptr m_node_ai_latch_roll; double m_simple_time_compensation = 0.0;
SGPropertyNode_ptr m_node_ai_latch_ubody_fps; double m_simple_time_recent_packet_time = 0.0;
SGPropertyNode_ptr m_node_ai_latch_vbody_fps;
SGPropertyNode_ptr m_node_ai_latch_wbody_fps; SGPropertyNode_ptr m_lagPPSAveragedNode;
SGPropertyNode_ptr m_node_ai_latch_speed_kts; SGPropertyNode_ptr m_lagModAveragedNode;
SGPropertyNode_ptr m_node_log_multiplayer; SGPropertyNode_ptr m_node_simple_time_latest;
SGPropertyNode_ptr m_node_simple_time_offset;
SGPropertyNode_ptr m_node_simple_time_offset_smoothed;
SGPropertyNode_ptr m_node_simple_time_compensation;
// For use with scripts/python/recordreplay.py --test-motion-mp.
SGPropertyNode_ptr mLogRawSpeedMultiplayer;
SGPropertyNode_ptr m_node_ai_latch;
std::string m_ai_latch;
SGPropertyNode_ptr m_node_ai_latch_latitude;
SGPropertyNode_ptr m_node_ai_latch_longitude;
SGPropertyNode_ptr m_node_ai_latch_altitude;
SGPropertyNode_ptr m_node_ai_latch_heading;
SGPropertyNode_ptr m_node_ai_latch_pitch;
SGPropertyNode_ptr m_node_ai_latch_roll;
SGPropertyNode_ptr m_node_ai_latch_ubody_fps;
SGPropertyNode_ptr m_node_ai_latch_vbody_fps;
SGPropertyNode_ptr m_node_ai_latch_wbody_fps;
SGPropertyNode_ptr m_node_ai_latch_speed_kts;
SGPropertyNode_ptr m_node_log_multiplayer;
}; };

View file

@ -1,23 +1,10 @@
// FGAIShip - AIBase derived class creates an AI ship /*
// * SPDX-FileName: AIShip.hxx
// Written by David Culp, started November 2003. * SPDX-FileComment: AIBase derived class creates an AI ship
// with major amendments and additions by Vivian Meazza, 2004 - 2007 * SPDX-FileCopyrightText: Copyright (C) 2003 David P. Culp - davidculp2@comcast.net
// * SPDX-FileContributor: with major amendments and additions by Vivian Meazza, 2004 - 2007
// Copyright (C) 2003 David P. Culp - davidculp2@comcast.net * SPDX-License-Identifier: GPL-2.0-or-later
// */
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#pragma once #pragma once
@ -28,15 +15,16 @@
#include "AIBase.hxx" #include "AIBase.hxx"
#include "AIFlightPlan.hxx" #include "AIFlightPlan.hxx"
class FGAIManager; class FGAIManager;
class FGAIShip : public FGAIBase { class FGAIShip : public FGAIBase
{
public: public:
FGAIShip(object_type ot = object_type::otShip); FGAIShip(object_type ot = object_type::otShip);
virtual ~FGAIShip() = default; virtual ~FGAIShip() = default;
string_view getTypeString(void) const override { return "ship"; } std::string_view getTypeString(void) const override { return "ship"; }
void readFromScenario(SGPropertyNode* scFileNode) override; void readFromScenario(SGPropertyNode* scFileNode) override;
bool init(ModelSearchOrder searchOrder) override; bool init(ModelSearchOrder searchOrder) override;
@ -47,7 +35,7 @@ public:
void setRudder(float r); void setRudder(float r);
void setRoll(double rl); void setRoll(double rl);
void ProcessFlightPlan( double dt); void ProcessFlightPlan(double dt);
void AccelTo(double speed); void AccelTo(double speed);
void PitchTo(double angle); void PitchTo(double angle);
void RollTo(double angle); void RollTo(double angle);
@ -91,7 +79,7 @@ public:
double _missed_range = 0.0; double _missed_range = 0.0;
double _tow_angle; double _tow_angle;
double _wait_count = 0.0; double _wait_count = 0.0;
double _missed_count,_wp_range; double _missed_count, _wp_range;
double _dt_count, _next_run; double _dt_count, _next_run;
FGAIWaypoint* prev = nullptr; // the one behind you FGAIWaypoint* prev = nullptr; // the one behind you
@ -121,7 +109,7 @@ private:
double processTimeString(const std::string& time); double processTimeString(const std::string& time);
bool initFlightPlan(); bool initFlightPlan();
bool advanceFlightPlan (double elapsed_sec, double day_sec); bool advanceFlightPlan(double elapsed_sec, double day_sec);
float _rudder = 0.0f; float _rudder = 0.0f;
float _tgt_rudder = 0.0f; float _tgt_rudder = 0.0f;
@ -149,4 +137,3 @@ private:
bool _fp_init; bool _fp_init;
bool _missed; bool _missed;
}; };

View file

@ -1,38 +1,24 @@
// FGAIStatic - AIBase derived class creates AI static object /*
// * SPDX-FileName: AIStatic.hxx
// Written by David Culp, started Jun 2005. * SPDX-FileComment: AIBase derived class creates AI static object
// * SPDX-FileCopyrightText: Copyright (C) 2005 David P. Culp - davidculp2@comcast.net
// Copyright (C) 2005 David P. Culp - davidculp2@comcast.net * SPDX-License-Identifier: GPL-2.0-or-later
// */
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#pragma once #pragma once
#include <string_view> #include <string_view>
#include "AIManager.hxx"
#include "AIBase.hxx" #include "AIBase.hxx"
#include "AIManager.hxx"
class FGAIStatic : public FGAIBase { class FGAIStatic : public FGAIBase
{
public: public:
FGAIStatic(); FGAIStatic();
virtual ~FGAIStatic() = default; virtual ~FGAIStatic() = default;
string_view getTypeString(void) const override { return "static"; } std::string_view getTypeString(void) const override { return "static"; }
void update(double dt) override; void update(double dt) override;
}; };

View file

@ -1,68 +1,55 @@
// FGAIStorm - AIBase derived class creates an AI thunderstorm /*
// * SPDX-FileName: AIStorm.hxx
// Written by David Culp, started Feb 2004. * SPDX-FileComment: AIBase derived class creates an AI thunderstorm
// * SPDX-FileCopyrightText: Copyright (C) 2004 David P. Culp - davidculp2@comcast.net
// Copyright (C) 2004 David P. Culp - davidculp2@comcast.net * SPDX-License-Identifier: GPL-2.0-or-later
// */
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#pragma once #pragma once
#include <string> #include <string>
#include <string_view> #include <string_view>
#include "AIManager.hxx"
#include "AIBase.hxx" #include "AIBase.hxx"
#include "AIManager.hxx"
class FGAIStorm : public FGAIBase { class FGAIStorm : public FGAIBase
{
public: public:
FGAIStorm(); FGAIStorm();
virtual ~FGAIStorm() = default; virtual ~FGAIStorm() = default;
string_view getTypeString(void) const override { return "thunderstorm"; } std::string_view getTypeString(void) const override { return "thunderstorm"; }
void readFromScenario(SGPropertyNode* scFileNode) override; void readFromScenario(SGPropertyNode* scFileNode) override;
void update(double dt) override; void update(double dt) override;
inline void setStrengthNorm( double s ) { strength_norm = s; }; inline void setStrengthNorm(double s) { strength_norm = s; };
inline void setDiameter( double d ) { diameter = d; }; inline void setDiameter(double d) { diameter = d; };
inline void setHeight( double h ) { height = h; }; inline void setHeight(double h) { height = h; };
inline double getStrengthNorm() const { return strength_norm; }; inline double getStrengthNorm() const { return strength_norm; };
inline double getDiameter() const { return diameter; }; inline double getDiameter() const { return diameter; };
inline double getHeight() const { return height; }; inline double getHeight() const { return height; };
private: private:
double diameter = 0.0; // diameter of turbulence zone, in nm double diameter = 0.0; // diameter of turbulence zone, in nm
double height = 0.0; // top of turbulence zone, in feet MSL double height = 0.0; // top of turbulence zone, in feet MSL
double strength_norm = 0.0; // strength of turbulence double strength_norm = 0.0; // strength of turbulence
void Run(double dt); void Run(double dt);
// lightning stuff // lightning stuff
double delay; // average time (sec) between lightning flashes double delay; // average time (sec) between lightning flashes
int subflashes; // number of subflashes per flash int subflashes; // number of subflashes per flash
double random_delay; // delay +/- random number double random_delay; // delay +/- random number
double timer; double timer;
SGPropertyNode_ptr flash_node; SGPropertyNode_ptr flash_node;
int flashed; // number of subflashes already done this flash int flashed; // number of subflashes already done this flash
bool flashing; // true if currently flashing; bool flashing; // true if currently flashing;
int subflash_array[8]; int subflash_array[8];
int subflash_index; int subflash_index;
// turbulence stuff // turbulence stuff
SGPropertyNode_ptr turb_mag_node; SGPropertyNode_ptr turb_mag_node;
SGPropertyNode_ptr turb_rate_node; SGPropertyNode_ptr turb_rate_node;
}; };

View file

@ -1,21 +1,10 @@
// AISwiftAircraft.h - Derived AIBase class for swift aircraft /*
// * SPDX-FileName: AISwiftAircraft.h
// Copyright (C) 2020 - swift Project Community / Contributors (http://swift-project.org/) * SPDX-FileComment: Derived AIBase class for swift aircraft
// Written by Lars Toenning <dev@ltoenning.de> started on April 2020. * SPDX-FileCopyrightText: Written by Lars Toenning <dev@ltoenning.de> started on April 2020
// * SPDX-FileContributor: Copyright (C) 2020 - swift Project Community / Contributors (http://swift-project.org/)
// This program is free software; you can redistribute it and/or * SPDX-License-Identifier: GPL-2.0-or-later
// modify it under the terms of the GNU General Public License as */
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#pragma once #pragma once
@ -25,11 +14,12 @@
#include "AIBaseAircraft.hxx" #include "AIBaseAircraft.hxx"
struct AircraftTransponder
{ struct AircraftTransponder {
AircraftTransponder(std::string callsign, int code, bool modeC, bool ident) AircraftTransponder(std::string callsign, int code, bool modeC, bool ident)
: callsign(std::move(callsign)), code(code), modeC(modeC), ident(ident) : callsign(std::move(callsign)), code(code), modeC(modeC), ident(ident)
{} {
}
std::string callsign; std::string callsign;
int code; int code;
@ -37,14 +27,13 @@ struct AircraftTransponder
bool ident; bool ident;
}; };
struct AircraftSurfaces struct AircraftSurfaces {
{
AircraftSurfaces(std::string callsign, double gear, double flaps, double spoilers, double speedBrake, double slats, double wingSweeps, AircraftSurfaces(std::string callsign, double gear, double flaps, double spoilers, double speedBrake, double slats, double wingSweeps,
double thrust, double elevator, double rudder, double aileron, bool landingLight, bool taxiLight, bool beaconLight, double thrust, double elevator, double rudder, double aileron, bool landingLight, bool taxiLight, bool beaconLight,
bool strobeLight, bool navLight, int lightPattern) bool strobeLight, bool navLight, int lightPattern)
: callsign(std::move(callsign)), gear(gear), flaps(flaps), spoilers(spoilers), speedBrake(speedBrake), slats(slats), wingSweeps(wingSweeps), : callsign(std::move(callsign)), gear(gear), flaps(flaps), spoilers(spoilers), speedBrake(speedBrake), slats(slats), wingSweeps(wingSweeps),
thrust(thrust), elevator(elevator), rudder(rudder), aileron(aileron), landingLight(landingLight), taxiLight(taxiLight), beaconLight(beaconLight), thrust(thrust), elevator(elevator), rudder(rudder), aileron(aileron), landingLight(landingLight), taxiLight(taxiLight), beaconLight(beaconLight),
strobeLight(strobeLight), navLight(navLight), lightPattern(lightPattern){} strobeLight(strobeLight), navLight(navLight), lightPattern(lightPattern) {}
std::string callsign; std::string callsign;
double gear; double gear;
@ -71,10 +60,10 @@ public:
FGAISwiftAircraft(const std::string& callsign, const std::string& modelString); FGAISwiftAircraft(const std::string& callsign, const std::string& modelString);
virtual ~FGAISwiftAircraft() = default; virtual ~FGAISwiftAircraft() = default;
string_view getTypeString() const override { return "swift"; } std::string_view getTypeString() const override { return "swift"; }
void update(double dt) override; void update(double dt) override;
void updatePosition(const SGGeod &position, const SGVec3d &orientation, double groundspeed, bool initPos); void updatePosition(const SGGeod& position, const SGVec3d& orientation, double groundspeed, bool initPos);
double getGroundElevation(const SGGeod& pos) const; double getGroundElevation(const SGGeod& pos) const;
void initProps(); void initProps();
void setPlaneSurface(const AircraftSurfaces& surfaces); void setPlaneSurface(const AircraftSurfaces& surfaces);

View file

@ -1,23 +1,10 @@
// AITanker.hxx Based on David Culp's AIModel code /*
// - Tanker specific code isolated from AI Aircraft code * SPDX-FileName: AITanker.hxx
// by Thomas Foerster, started June 2007 * SPDX-FileComment: Tanker specific code isolated from AI Aircraft code, based on David Culp's AIModel code
// * SPDX-FileCopyrightText: by Thomas Foerster, started June 2007
// * SPDX-FileContributor: Original code written by David Culp, started October 2003 - davidculp2@comcast.net
// Original code written by David Culp, started October 2003. * SPDX-License-Identifier: GPL-2.0-or-later
// - davidculp2@comcast.net/ */
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#pragma once #pragma once
@ -25,6 +12,7 @@
#include "AIAircraft.hxx" #include "AIAircraft.hxx"
/** /**
* An AI tanker for air-air refueling. * An AI tanker for air-air refueling.
* *
@ -35,20 +23,21 @@
* @author Thomas F<EFBFBD>ster <t.foerster@biologie.hu-berlin.de> * @author Thomas F<EFBFBD>ster <t.foerster@biologie.hu-berlin.de>
*/ */
class FGAITanker : public FGAIAircraft { class FGAITanker : public FGAIAircraft
{
public: public:
FGAITanker(FGAISchedule* ref = 0); FGAITanker(FGAISchedule* ref = 0);
virtual ~FGAITanker() = default; virtual ~FGAITanker() = default;
string_view getTypeString(void) const override { return "tanker"; } std::string_view getTypeString(void) const override { return "tanker"; }
void readFromScenario(SGPropertyNode* scFileNode) override; void readFromScenario(SGPropertyNode* scFileNode) override;
void bind() override; void bind() override;
void setTACANChannelID(const std::string& id); void setTACANChannelID(const std::string& id);
private: private:
std::string TACAN_channel_id; // The TACAN channel of this tanker std::string TACAN_channel_id; // The TACAN channel of this tanker
bool contact = false; // set if this tanker is within fuelling range bool contact = false; // set if this tanker is within fuelling range
virtual void Run(double dt); virtual void Run(double dt);
void update(double dt) override; void update(double dt) override;

View file

@ -1,24 +1,9 @@
// FGAIThermal - FGAIBase-derived class creates an AI thermal /*
// * SPDX-FileName: AIThermal.hxx
// Original by Written by David Culp * SPDX-FileComment: AIBase-derived class creates an AI thermal. An attempt to refine the thermal shape and behaviour by WooT 2009
// * SPDX-FileCopyrightText: Copyright (C) 2009 Patrice Poly ( WooT )
// An attempt to refine the thermal shape and behaviour by WooT 2009 * SPDX-License-Identifier: GPL-2.0-or-later
// */
// Copyright (C) 2009 Patrice Poly ( WooT )
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#pragma once #pragma once
@ -30,63 +15,63 @@
#include <string> #include <string>
class FGAIThermal : public FGAIBase { class FGAIThermal : public FGAIBase
{
public: public:
FGAIThermal(); FGAIThermal();
virtual ~FGAIThermal() = default; virtual ~FGAIThermal() = default;
string_view getTypeString(void) const override { return "thermal"; } std::string_view getTypeString(void) const override { return "thermal"; }
void readFromScenario(SGPropertyNode* scFileNode) override; void readFromScenario(SGPropertyNode* scFileNode) override;
bool init(ModelSearchOrder searchOrder) override; bool init(ModelSearchOrder searchOrder) override;
void bind() override; void bind() override;
void update(double dt) override; void update(double dt) override;
inline void setMaxStrength( double s ) { max_strength = s; }; inline void setMaxStrength(double s) { max_strength = s; };
inline void setDiameter( double d ) { diameter = d; }; inline void setDiameter(double d) { diameter = d; };
inline void setHeight( double h ) { height = h; }; inline void setHeight(double h) { height = h; };
inline void setMaxUpdraft( double lift ) { v_up_max = lift; }; inline void setMaxUpdraft(double lift) { v_up_max = lift; };
inline void setMinUpdraft( double sink ) { v_up_min = sink; }; inline void setMinUpdraft(double sink) { v_up_min = sink; };
inline void setR_up_frac( double r ) { r_up_frac = r; }; inline void setR_up_frac(double r) { r_up_frac = r; };
inline double getStrength() const { return strength; }; inline double getStrength() const { return strength; };
inline double getDiameter() const { return diameter; }; inline double getDiameter() const { return diameter; };
inline double getHeight() const { return height; }; inline double getHeight() const { return height; };
inline double getV_up_max() const { return v_up_max; }; inline double getV_up_max() const { return v_up_max; };
inline double getV_up_min() const { return v_up_min; }; inline double getV_up_min() const { return v_up_min; };
inline double getR_up_frac() const { return r_up_frac; }; inline double getR_up_frac() const { return r_up_frac; };
void getGroundElev(double dt); void getGroundElev(double dt);
private: private:
void Run(double dt); void Run(double dt);
double get_strength_fac(double alt_frac); double get_strength_fac(double alt_frac);
double max_strength; double max_strength;
double strength; double strength;
double diameter; double diameter;
double height = 0.0; double height = 0.0;
double factor; double factor;
double alt_rel = 0.0; double alt_rel = 0.0;
double alt; double alt;
double v_up_max = 0.0; double v_up_max = 0.0;
double v_up_min = 0.0; double v_up_min = 0.0;
double r_up_frac = 0.0; double r_up_frac = 0.0;
double cycle_timer; double cycle_timer;
double dt_count; double dt_count;
double time = 0.0; double time = 0.0;
double xx = 0.0; double xx = 0.0;
double ground_elev_ft; // ground level in ft double ground_elev_ft; // ground level in ft
bool do_agl_calc = false; bool do_agl_calc = false;
bool is_forming = false; bool is_forming = false;
bool is_formed = false; bool is_formed = false;
bool is_dying = false; bool is_dying = false;
bool is_dead = false; bool is_dead = false;
SGPropertyNode_ptr _surface_wind_from_deg_node; SGPropertyNode_ptr _surface_wind_from_deg_node;
SGPropertyNode_ptr _surface_wind_speed_node; SGPropertyNode_ptr _surface_wind_speed_node;
SGPropertyNode_ptr _aloft_wind_from_deg_node; SGPropertyNode_ptr _aloft_wind_from_deg_node;
SGPropertyNode_ptr _aloft_wind_speed_node; SGPropertyNode_ptr _aloft_wind_speed_node;
}; };

View file

@ -1,21 +1,9 @@
// FGAIWingman - FGAIBllistic-derived class creates an AI Wingman /*
// * SPDX-FileName: AIWingman.hxx
// Written by Vivian Meazza, started February 2008. * SPDX-FileComment: AIBllistic-derived class creates an AI Wingman
// - vivian.meazza at lineone.net * SPDX-FileCopyrightText: Written by Vivian Meazza, started February 2008 - vivian.meazza at lineone.net
// * SPDX-License-Identifier: GPL-2.0-or-later
// This program is free software; you can redistribute it and/or */
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#pragma once #pragma once
@ -28,12 +16,13 @@
#include "AIManager.hxx" #include "AIManager.hxx"
class FGAIWingman : public FGAIBallistic { class FGAIWingman : public FGAIBallistic
{
public: public:
FGAIWingman(); FGAIWingman();
virtual ~FGAIWingman() = default; virtual ~FGAIWingman() = default;
string_view getTypeString(void) const override { return "wingman"; } std::string_view getTypeString(void) const override { return "wingman"; }
void readFromScenario(SGPropertyNode* scFileNode) override; void readFromScenario(SGPropertyNode* scFileNode) override;
bool init(ModelSearchOrder searchOrder) override; bool init(ModelSearchOrder searchOrder) override;
@ -53,15 +42,15 @@ private:
double calcAngle(double rangeM, SGGeod pos1, SGGeod pos2); double calcAngle(double rangeM, SGGeod pos1, SGGeod pos2);
double calcDistanceM(SGGeod pos1, SGGeod pos2) const; double calcDistanceM(SGGeod pos1, SGGeod pos2) const;
bool _formate_to_ac; bool _formate_to_ac;
bool _break; bool _break;
bool _join; bool _join;
double _break_angle; //degrees relative double _break_angle; //degrees relative
double _coeff_hdg; //dimensionless coefficient double _coeff_hdg; //dimensionless coefficient
double _coeff_pch; //dimensionless coefficient double _coeff_pch; //dimensionless coefficient
double _coeff_bnk; //dimensionless coefficient double _coeff_bnk; //dimensionless coefficient
double _coeff_spd; //dimensionless coefficient double _coeff_spd; //dimensionless coefficient
SGPropertyNode_ptr user_WoW_node; SGPropertyNode_ptr user_WoW_node;
@ -75,50 +64,59 @@ private:
inline void setCoeffBnk(double r); inline void setCoeffBnk(double r);
inline void setCoeffSpd(double s); inline void setCoeffSpd(double s);
inline bool getFormate() const { return _formate_to_ac;} inline bool getFormate() const { return _formate_to_ac; }
inline double getTgtHdg() const { return tgt_heading;} inline double getTgtHdg() const { return tgt_heading; }
inline double getTgtSpd() const { return tgt_speed;} inline double getTgtSpd() const { return tgt_speed; }
inline double getBrkAng() const { return _break_angle;} inline double getBrkAng() const { return _break_angle; }
inline SGVec3d getCartInPos(SGGeod in_pos) const; inline SGVec3d getCartInPos(SGGeod in_pos) const;
}; };
void FGAIWingman::setFormate(bool f) { void FGAIWingman::setFormate(bool f)
{
_formate_to_ac = f; _formate_to_ac = f;
} }
void FGAIWingman::setTgtHdg(double h) { void FGAIWingman::setTgtHdg(double h)
{
tgt_heading = h; tgt_heading = h;
} }
void FGAIWingman::setTgtSpd(double s) { void FGAIWingman::setTgtSpd(double s)
{
tgt_speed = s; tgt_speed = s;
} }
void FGAIWingman::setBrkHdg(double a){ void FGAIWingman::setBrkHdg(double a)
tgt_heading = hdg + a ; {
tgt_heading = hdg + a;
SG_NORMALIZE_RANGE(tgt_heading, 0.0, 360.0); SG_NORMALIZE_RANGE(tgt_heading, 0.0, 360.0);
} }
void FGAIWingman::setBrkAng(double a){ void FGAIWingman::setBrkAng(double a)
_break_angle = a ; {
_break_angle = a;
SG_NORMALIZE_RANGE(_break_angle, -180.0, 180.0); SG_NORMALIZE_RANGE(_break_angle, -180.0, 180.0);
} }
void FGAIWingman::setCoeffHdg(double h){ void FGAIWingman::setCoeffHdg(double h)
{
_coeff_hdg = h; _coeff_hdg = h;
} }
void FGAIWingman::setCoeffPch(double p){ void FGAIWingman::setCoeffPch(double p)
{
_coeff_pch = p; _coeff_pch = p;
} }
void FGAIWingman::setCoeffBnk(double b){ void FGAIWingman::setCoeffBnk(double b)
{
_coeff_bnk = b; _coeff_bnk = b;
} }
void FGAIWingman::setCoeffSpd(double s){ void FGAIWingman::setCoeffSpd(double s)
{
_coeff_spd = s; _coeff_spd = s;
} }
@ -138,7 +136,8 @@ void FGAIWingman::setCoeffSpd(double s){
// return _break_angle; // return _break_angle;
//} //}
SGVec3d FGAIWingman::getCartInPos(SGGeod in_pos) const { SGVec3d FGAIWingman::getCartInPos(SGGeod in_pos) const
{
SGVec3d cartPos = SGVec3d::fromGeod(in_pos); SGVec3d cartPos = SGVec3d::fromGeod(in_pos);
return cartPos; return cartPos;
} }