* Use "const string&" rather than "string" in function calls when appropriate.
* Use "const Point3D&" instead of "Pint3D" in function calls when appropriate.
* Improved course calculation in calc_gc_course_dist()
* Safer thread handling code.
Vassilii Khachaturov:
Dont use "const Point3D&" for return types unless you're absolutely sure.
Erik Hofman:
* Use SGD_(2)PI(_[24]) as defined in simgear/constants.h rather than
calculating it by hand every time.
flols_off = off;
}
-void FGAICarrier::getVelocityWrtEarth(sgdVec3 v, sgdVec3 omega, sgdVec3 pivot) {
+void FGAICarrier::getVelocityWrtEarth(sgdVec3& v, sgdVec3& omega, sgdVec3& pivot) {
sgdCopyVec3(v, vel_wrt_earth );
sgdCopyVec3(omega, rot_wrt_earth );
sgdCopyVec3(pivot, rot_pivot_wrt_earth );
return found;
}
-void FGAICarrier::UpdateFlols(sgdMat3 trans) {
+void FGAICarrier::UpdateFlols(const sgdMat3& trans) {
float in[3];
float out[3];
void setFlolsOffset(const Point3D& off);
void setTACANChannelID(const string &);
- void getVelocityWrtEarth(sgdVec3 v, sgdVec3 omega, sgdVec3 pivot);
+ void getVelocityWrtEarth(sgdVec3& v, sgdVec3& omega, sgdVec3& pivot);
virtual void bind();
virtual void unbind();
- void UpdateFlols ( sgdMat3 trans );
+ void UpdateFlols ( const sgdMat3& trans );
void UpdateWind ( double dt );
void UpdateTACAN( double dt );
void setWind_from_east( double fps );
#include "AIFlightPlan.hxx"
-FGAIFlightPlan::FGAIFlightPlan(string filename)
+FGAIFlightPlan::FGAIFlightPlan(const string& filename)
{
int i;
start_time = 0;
FGAirport *arr,
bool firstLeg,
double radius,
- string fltType,
- string acType,
- string airline)
+ const string& fltType,
+ const string& acType,
+ const string& airline)
{
leg = 10;
gateId=0;
bool on_ground;
} waypoint;
- FGAIFlightPlan(string filename);
+ FGAIFlightPlan(const string& filename);
FGAIFlightPlan(FGAIModelEntity *entity,
double course,
time_t start,
FGAirport *arr,
bool firstLeg,
double radius,
- string fltType,
- string acType,
- string airline);
+ const string& fltType,
+ const string& acType,
+ const string& airline);
~FGAIFlightPlan();
waypoint* getPreviousWaypoint( void );
time_t getStartTime() { return start_time; };
void create(FGAirport *dep, FGAirport *arr, int leg, double alt, double speed, double lat, double lon,
- bool firstLeg, double radius, string fltType, string aircraftType, string airline);
+ bool firstLeg, double radius, const string& fltType, const string& aircraftType, const string& airline);
void setLeg(int val) { leg = val;};
void setTime(time_t st) { start_time = st; };
int getGate() { return gateId; };
double getLeadInAngle() { return leadInAngle; };
- string getRunway() { return rwy._rwy_no; };
- string getRunwayId() { return rwy._id; };
+ const string& getRunway() { return rwy._rwy_no; };
+ const string& getRunwayId() { return rwy._id; };
void setRepeat(bool r) { repeat = r; };
bool getRepeat(void) { return repeat; };
void restart(void);
int gateId;
string activeRunway;
- void createPushBack(bool, FGAirport*, double, double, double, string, string, string);
- void createTaxi(bool, int, FGAirport *, double, double, double, string, string, string);
+ void createPushBack(bool, FGAirport*, double, double, double, const string&, const string&, const string&);
+ void createTaxi(bool, int, FGAirport *, double, double, double, const string&, const string&, const string&);
void createTakeOff(bool, FGAirport *, double);
void createClimb(bool, FGAirport *, double, double);
void createCruise(bool, FGAirport*, FGAirport*, double, double, double, double);
// Check lat/lon values during initialization;
void FGAIFlightPlan::create(FGAirport *dep, FGAirport *arr, int legNr, double alt, double speed,
double latitude, double longitude, bool firstFlight,
- double radius, string fltType, string aircraftType, string airline)
+ double radius, const string& fltType, const string& aircraftType, const string& airline)
{
int currWpt = wpt_iterator - waypoints.begin();
switch(legNr)
double latitude,
double longitude,
double radius,
- string fltType,
- string aircraftType,
- string airline)
+ const string& fltType,
+ const string& aircraftType,
+ const string& airline)
{
double heading;
double lat;
* createCreate Taxi.
* initialize the Aircraft at the parking location
******************************************************************/
-void FGAIFlightPlan::createTaxi(bool firstFlight, int direction, FGAirport *apt, double latitude, double longitude, double radius, string fltType, string acType, string airline)
+void FGAIFlightPlan::createTaxi(bool firstFlight, int direction, FGAirport *apt, double latitude, double longitude, double radius, const string& fltType, const string& acType, const string& airline)
{
double wind_speed;
double wind_heading;
// "NOTE: this is currently fixed to "com" for commercial traffic
// Should be changed to be used dynamically to allow "gen" and "mil"
// as well
- apt->getActiveRunway("com", 1, &activeRunway);
+ apt->getActiveRunway("com", 1, activeRunway);
if (!(globals->get_runways()->search(apt->getId(),
activeRunway,
&rwy)))
exit(1);
}
//string test;
- //apt->getActiveRunway(string("com"), 1, &test);
+ //apt->getActiveRunway(string("com"), 1, test);
//exit(1);
heading = rwy._heading;
// "NOTE: this is currently fixed to "com" for commercial traffic
// Should be changed to be used dynamically to allow "gen" and "mil"
// as well
- //apt->getActiveRunway("com", 1, &name);
+ //apt->getActiveRunway("com", 1, name);
//if (!(globals->get_runways()->search(apt->getId(),
// name,
// &rwy)))
// exit(1);
// }
//string test;
- //apt->getActiveRunway(string("com"), 1, &test);
+ //apt->getActiveRunway(string("com"), 1, test);
//exit(1);
//heading = rwy._heading;
// "NOTE: this is currently fixed to "com" for commercial traffic
// Should be changed to be used dynamically to allow "gen" and "mil"
// as well
- apt->getActiveRunway("com", 1, &activeRunway);
+ apt->getActiveRunway("com", 1, activeRunway);
if (!(globals->get_runways()->search(apt->getId(),
activeRunway,
&rwy)))
exit(1);
}
//string test;
- //apt->getActiveRunway(string("com"), 1, &test);
+ //apt->getActiveRunway(string("com"), 1, test);
//exit(1);
}
// "NOTE: this is currently fixed to "com" for commercial traffic
// Should be changed to be used dynamically to allow "gen" and "mil"
// as well
- apt->getActiveRunway("com", 1, &activeRunway);
+ apt->getActiveRunway("com", 1, activeRunway);
if (!(globals->get_runways()->search(apt->getId(),
activeRunway,
&rwy)))
exit(1);
}
//string test;
- //apt->getActiveRunway(string("com"), 1, &test);
+ //apt->getActiveRunway(string("com"), 1, test);
//exit(1);
}
//string name;
// should be changed dynamically to allow "gen" and "mil"
- arr->getActiveRunway("com", 2, &activeRunway);
+ arr->getActiveRunway("com", 2, activeRunway);
if (!(globals->get_runways()->search(arr->getId(),
activeRunway,
&rwy)))
exit(1);
}
//string test;
- //arr->getActiveRunway(string("com"), 1, &test);
+ //arr->getActiveRunway(string("com"), 1, test);
//exit(1);
//cerr << "Altitude = " << alt << endl;
//Beginning of Decent
//string name;
// allow "mil" and "gen" as well
- apt->getActiveRunway("com", 2, &activeRunway);
+ apt->getActiveRunway("com", 2, activeRunway);
if (!(globals->get_runways()->search(apt->getId(),
activeRunway,
&rwy)))
exit(1);
}
//string test;
- //apt->getActiveRunway(string("com"), 1, &test);
+ //apt->getActiveRunway(string("com"), 1, test);
//exit(1);
//cerr << "Done" << endl;
void FGAIEntity::Update(double dt) {
}
-string FGAIEntity::GetCallsign() {
- return("");
+const string &FGAIEntity::GetCallsign() {
+ static string s = "";
+ return(s);
}
void FGAIEntity::RegisterTransmission(int code) {
void SetModel(ssgBranch* model);
// Run the internal calculations
- virtual void Update(double dt);
+ virtual void Update(double dt)=0;
// Send a transmission *TO* the AIEntity.
// FIXME int code is a hack - eventually this will receive Alexander's coded messages.
- virtual void RegisterTransmission(int code);
+ virtual void RegisterTransmission(int code)=0;
- inline Point3D GetPos() { return(_pos); }
+ inline const Point3D& GetPos() const { return(_pos); }
- virtual string GetCallsign();
+ virtual const string& GetCallsign()=0;
protected:
//_model->deRef();
}
-void FGAILocalTraffic::GetAirportDetails(string id) {
+void FGAILocalTraffic::GetAirportDetails(const string& id) {
AirportATC a;
if(ATC->GetAirportATCDetails(airportID, &a)) {
if(a.tower_freq) { // Has a tower - TODO - check the opening hours!!!
// Get details of the active runway
// It is assumed that by the time this is called the tower control and airport code will have been set up.
-void FGAILocalTraffic::GetRwyDetails(string id) {
+void FGAILocalTraffic::GetRwyDetails(const string& id) {
//cout << "GetRwyDetails called" << endl;
if(_controlled) {
sufficient initialisation functionality within the plane classes to allow the manager
to initially position them where and how required.
*/
-bool FGAILocalTraffic::Init(const string& callsign, string ICAO, OperatingState initialState, PatternLeg initialLeg) {
+bool FGAILocalTraffic::Init(const string& callsign, const string& ICAO, OperatingState initialState, PatternLeg initialLeg) {
//cout << "FGAILocalTraffic.Init(...) called" << endl;
airportID = ICAO;
}
}
-void FGAILocalTraffic::ExitRunway(Point3D orthopos) {
+void FGAILocalTraffic::ExitRunway(const Point3D& orthopos) {
//cout << "In ExitRunway" << endl;
//cout << "Runway ID is " << rwy.ID << endl;
~FGAILocalTraffic();
// Initialise
- bool Init(const string& callsign, string ICAO, OperatingState initialState = PARKED, PatternLeg initialLeg = DOWNWIND);
+ bool Init(const string& callsign, const string& ICAO, OperatingState initialState = PARKED, PatternLeg initialLeg = DOWNWIND);
// Run the internal calculations
void Update(double dt);
FGATCAlignedProjection ortho; // Orthogonal mapping of the local area with the threshold at the origin
// and the runway aligned with the y axis.
- void GetAirportDetails(string id);
+ void GetAirportDetails(const string& id);
- void GetRwyDetails(string id);
+ void GetRwyDetails(const string& id);
double responseCounter; // timer in seconds to allow response to requests to be a little while after them
// Will almost certainly get moved to FGAIPlane.
void CalculateSoD(double base_leg_pos, double downwind_leg_pos, bool pattern_direction);
- void ExitRunway(Point3D orthopos);
+ void ExitRunway(const Point3D& orthopos);
void StartTaxi();
//cout << "Size of AI list is " << ai_list.size() << '\n';
}
-void FGAIMgr::ScheduleRemoval(string s) {
+void FGAIMgr::ScheduleRemoval(const string& s) {
//cout << "Scheduling removal of plane " << s << " from AIMgr\n";
removalList.push_back(s);
}
// Activate AI traffic at an airport
-void FGAIMgr::ActivateAirport(string ident) {
+void FGAIMgr::ActivateAirport(const string& ident) {
ATC->AIRegisterAirport(ident);
// TODO - need to start the traffic more randomly
FGAILocalTraffic* local_traffic = new FGAILocalTraffic;
}
// Hack - Generate AI traffic at an airport with no facilities file
-void FGAIMgr::GenerateSimpleAirportTraffic(string ident, double min_dist) {
+void FGAIMgr::GenerateSimpleAirportTraffic(const string& ident, double min_dist) {
// Ugly hack - don't let VFR Cessnas operate at a hardwired list of major airports
// This will go eventually once airport .xml files specify the traffic profile
if(ident == "KSFO" || ident == "KDFW" || ident == "EGLL" || ident == "KORD" || ident == "KJFK"
/*
// Generate a VFR arrival at airport apt, at least distance d (meters) out.
-void FGAIMgr::GenerateVFRArrival(string apt, double d) {
+void FGAIMgr::GenerateVFRArrival(const string& apt, double d) {
}
*/
}
// This will be moved somewhere else eventually!!!!
-string FGAIMgr::GenerateShortForm(string callsign, string plane_str, bool local) {
+string FGAIMgr::GenerateShortForm(const string& callsign, const string& plane_str, bool local) {
//cout << callsign << '\n';
string s;
if(local) s = "Trainer-";
// Signal that it is OK to remove a plane of callsign s
// (To be called by the plane itself).
- void ScheduleRemoval(string s);
+ void ScheduleRemoval(const string& s);
private:
//void RemoveFromList(const char* id, atc_type tp);
// Activate AI traffic at an airport
- void ActivateAirport(string ident);
+ void ActivateAirport(const string& ident);
// Hack - Generate AI traffic at an airport with no facilities file, with the first plane being at least min_dist out.
- void GenerateSimpleAirportTraffic(string ident, double min_dist = 0.0);
+ void GenerateSimpleAirportTraffic(const string& ident, double min_dist = 0.0);
// Search for valid airports in the vicinity of the user and activate them if necessary
void SearchByPos(double range);
string GenerateUniqueCallsign();
- string GenerateShortForm(string callsign, string plane_str = "Cessna-", bool local = false);
+ string GenerateShortForm(const string& callsign, const string& plane_str = "Cessna-", bool local = false);
// TODO - implement a proper robust system for registering and loading AI GA aircraft models
bool _havePiperModel;
// Outputs the transmission either on screen or as audio depending on user preference
// The refname is a string to identify this sample to the sound manager
// The repeating flag indicates whether the message should be repeated continuously or played once.
-void FGAIPlane::Render(string refname, bool repeating) {
+void FGAIPlane::Render(const string& refname, bool repeating) {
#ifdef ENABLE_AUDIO_SUPPORT
voice = (voiceOK && fgGetBool("/sim/sound/voice"));
if(voice) {
// Cease rendering a transmission.
-void FGAIPlane::NoRender(string refname) {
+void FGAIPlane::NoRender(const string& refname) {
if(playing) {
if(voice) {
#ifdef ENABLE_AUDIO_SUPPORT
virtual LandingType GetLandingOption();
// Return the callsign
- inline string GetCallsign() {return plane.callsign;}
+ inline const string& GetCallsign() {return plane.callsign;}
protected:
PlaneRec plane;
// Outputs the transmission either on screen or as audio depending on user preference
// The refname is a string to identify this sample to the sound manager
// The repeating flag indicates whether the message should be repeated continuously or played once.
- void Render(string refname, bool repeating);
+ void Render(const string& refname, bool repeating);
// Cease rendering a transmission.
// Requires the sound manager refname if audio, else "".
- void NoRender(string refname);
+ void NoRender(const string& refname);
// Rendering related stuff
bool voice; // Flag - true if we are using voice
SG_LOG(SG_ATC, SG_WARN, "WARNING - whichever ATC class was intended to receive callback code " << code << " didn't get it!!!");
}
-void FGATC::SetResponseReqd(string rid) {
+void FGATC::SetResponseReqd(const string& rid) {
receiving = false;
responseReqd = true;
respond = false; // TODO - this ignores the fact that more than one plane could call this before response
responseTime = 1.8; // TODO - randomize this slightly.
}
-void FGATC::NotifyTransmissionFinished(string rid) {
+void FGATC::NotifyTransmissionFinished(const string& rid) {
//cout << "Transmission finished, callsign = " << rid << '\n';
receiving = false;
responseID = rid;
void FGATC::ProcessCallback(int code) {
}
-void FGATC::AddPlane(string pid) {
+void FGATC::AddPlane(const string& pid) {
}
int FGATC::RemovePlane() {
// Outputs the transmission either on screen or as audio depending on user preference
// The refname is a string to identify this sample to the sound manager
// The repeating flag indicates whether the message should be repeated continuously or played once.
-void FGATC::Render(string msg, string refname, bool repeating) {
+void FGATC::Render(string& msg, const string& refname, bool repeating) {
#ifdef ENABLE_AUDIO_SUPPORT
_voice = (_voiceOK && fgGetBool("/sim/sound/voice"));
if(_voice) {
// Cease rendering a transmission.
-void FGATC::NoRender(string refname) {
+void FGATC::NoRender(const string& refname) {
if(_playing) {
if(_voice) {
#ifdef ENABLE_AUDIO_SUPPORT
virtual void ReceiveUserCallback(int code);
// Add plane to a stack
- virtual void AddPlane(string pid);
+ virtual void AddPlane(const string& pid);
// Remove plane from stack
virtual int RemovePlane();
// Indicate that the frequency is in use
inline void SetFreqInUse() { freqClear = false; receiving = true; }
// Transmission to the ATC is finished and a response is required
- void SetResponseReqd(string rid);
+ void SetResponseReqd(const string& rid);
// Transmission finished - let ATC decide if a response is reqd and clear freq if necessary
- void NotifyTransmissionFinished(string rid);
+ void NotifyTransmissionFinished(const string& rid);
// Transmission finished and no response required
inline void ReleaseFreq() { freqClear = true; receiving = false; } // TODO - check that the plane releasing the freq is the right one etc.
// The above 3 funcs under development!!
inline void set_freq(const int fq) {freq = fq;}
inline int get_range() const { return range; }
inline void set_range(const int rg) {range = rg;}
- inline string get_ident() { return ident; }
- inline void set_ident(const string id) { ident = id; }
- inline string get_name() { return name; }
- inline void set_name(const string nm) { name = nm; }
+ inline const string& get_ident() { return ident; }
+ inline void set_ident(const string& id) { ident = id; }
+ inline const string& get_name() { return name; }
+ inline void set_name(const string& nm) { name = nm; }
protected:
// Outputs the transmission either on screen or as audio depending on user preference
// The refname is a string to identify this sample to the sound manager
// The repeating flag indicates whether the message should be repeated continuously or played once.
- void Render(string msg, string refname = "", bool repeating = false);
+ void Render(string& msg, const string& refname = "", bool repeating = false);
// Cease rendering all transmission from this station.
// Requires the sound manager refname if audio, else "".
- void NoRender(string refname);
+ void NoRender(const string& refname);
// Transmit a message when channel becomes free of other dialog
void Transmit(int callback_code = 0);
}
// Add an entry
-void FGATCDialog::add_entry(string station, string transmission, string menutext, atc_type type, int code) {
+void FGATCDialog::add_entry(const string& station, const string& transmission, const string& menutext, atc_type type, int code) {
ATCMenuEntry a;
FG_PUSH_PUI_DIALOG(atcFreqDialog);
}
-void FGATCDialog::FreqDisplay(string ident) {
+void FGATCDialog::FreqDisplay(string& ident) {
atcUppercase(ident);
void PopupCallback();
- void add_entry( string station, string transmission, string menutext, atc_type type, int code);
+ void add_entry( const string& station, const string& transmission, const string& menutext, atc_type type, int code);
void remove_entry( const string &station, const string &trans, atc_type type );
-
+
void remove_entry( const string &station, int code, atc_type type );
// query the database whether the transmission is already registered;
// Display the comm ATC frequencies for airport ident
// where ident is a valid ICAO code.
- void FreqDisplay(string ident);
+ void FreqDisplay(string& ident);
private:
correction_factor = cos(origin.lat() * DCL_DEGREES_TO_RADIANS);
}
-FGATCProjection::FGATCProjection(Point3D centre) {
+FGATCProjection::FGATCProjection(const Point3D& centre) {
origin = centre;
correction_factor = cos(origin.lat() * DCL_DEGREES_TO_RADIANS);
}
FGATCProjection::~FGATCProjection() {
}
-void FGATCProjection::Init(Point3D centre) {
+void FGATCProjection::Init(const Point3D& centre) {
origin = centre;
correction_factor = cos(origin.lat() * DCL_DEGREES_TO_RADIANS);
}
-Point3D FGATCProjection::ConvertToLocal(Point3D pt) {
+Point3D FGATCProjection::ConvertToLocal(const Point3D& pt) {
double delta_lat = pt.lat() - origin.lat();
double delta_lon = pt.lon() - origin.lon();
return(Point3D(x,y,0.0));
}
-Point3D FGATCProjection::ConvertFromLocal(Point3D pt) {
+Point3D FGATCProjection::ConvertFromLocal(const Point3D& pt) {
double delta_lat = asin(pt.y() / SG_EQUATORIAL_RADIUS_M) * DCL_RADIANS_TO_DEGREES;
double delta_lon = (asin(pt.x() / SG_EQUATORIAL_RADIUS_M) * DCL_RADIANS_TO_DEGREES) / correction_factor;
FGATCAlignedProjection::~FGATCAlignedProjection() {
}
-void FGATCAlignedProjection::Init(Point3D centre, double heading) {
+void FGATCAlignedProjection::Init(const Point3D& centre, double heading) {
origin = centre;
theta = heading * DCL_DEGREES_TO_RADIANS;
correction_factor = cos(origin.lat() * DCL_DEGREES_TO_RADIANS);
}
-Point3D FGATCAlignedProjection::ConvertToLocal(Point3D pt) {
+Point3D FGATCAlignedProjection::ConvertToLocal(const Point3D& pt) {
// convert from lat/lon to orthogonal
double delta_lat = pt.lat() - origin.lat();
double delta_lon = pt.lon() - origin.lon();
return(Point3D(x,y,pt.elev()));
}
-Point3D FGATCAlignedProjection::ConvertFromLocal(Point3D pt) {
+Point3D FGATCAlignedProjection::ConvertFromLocal(const Point3D& pt) {
//cout << "theta = " << theta << '\n';
//cout << "origin = " << origin << '\n';
// de-align
public:
FGATCProjection();
- FGATCProjection(Point3D centre);
+ FGATCProjection(const Point3D& centre);
~FGATCProjection();
- void Init(Point3D centre);
+ void Init(const Point3D& centre);
// Convert a lat/lon co-ordinate (degrees) to the local projection (meters)
- Point3D ConvertToLocal(Point3D pt);
+ Point3D ConvertToLocal(const Point3D& pt);
// Convert a local projection co-ordinate (meters) to lat/lon (degrees)
- Point3D ConvertFromLocal(Point3D pt);
+ Point3D ConvertFromLocal(const Point3D& pt);
private:
Point3D origin; // lat/lon of local area origin
FGATCAlignedProjection();
~FGATCAlignedProjection();
- void Init(Point3D centre, double heading);
+ void Init(const Point3D& centre, double heading);
// Convert a lat/lon co-ordinate (degrees) to the local projection (meters)
- Point3D ConvertToLocal(Point3D pt);
+ Point3D ConvertToLocal(const Point3D& pt);
// Convert a local projection co-ordinate (meters) to lat/lon (degrees)
- Point3D ConvertFromLocal(Point3D pt);
+ Point3D ConvertFromLocal(const Point3D& pt);
private:
Point3D origin; // lat/lon of local area origin (the threshold)
// Load the two voice files - one containing the raw sound data (.wav) and one containing the word positions (.vce).
// Return true if successful.
-bool FGATCVoice::LoadVoice(string voice) {
+bool FGATCVoice::LoadVoice(const string& voice) {
// FIXME CLO: disabled to try to see if this is causign problemcs
// return false;
// Load the two voice files - one containing the raw sound data (.wav) and one containing the word positions (.vce).
// Return true if successful.
- bool LoadVoice(string voice);
+ bool LoadVoice(const string& voice);
// Given a desired message, return a pointer to the data buffer and write the buffer length into len.
// Sets dataOK = true if the returned buffer is valid.
}
}
-void FGATCDisplay::RegisterSingleMessage(string msg, double delay) {
+void FGATCDisplay::RegisterSingleMessage(const string& msg, double delay) {
//cout << msg << '\n';
atcMessage m;
m.msg = msg;
//cout << "Single message registered\n";
}
-void FGATCDisplay::RegisterRepeatingMessage(string msg) {
+void FGATCDisplay::RegisterRepeatingMessage(const string& msg) {
rep_msg = true;
rep_msg_str = msg;
return;
}
-void FGATCDisplay::ChangeRepeatingMessage(string newmsg) {
+void FGATCDisplay::ChangeRepeatingMessage(const string& newmsg) {
rep_msg_str = newmsg;
change_msg_flag = true;
return;
// Register a single message for display after a delay of delay seconds
// Will automatically stop displaying after a suitable interval.
- void RegisterSingleMessage(string msg, double delay = 0.0); // OK - I know passing a string in and out is probably not good but it will have to do for now.
+ void RegisterSingleMessage(const string& msg, double delay = 0.0);
// For now we will assume only one repeating message at once
// This is not really robust
// Register a continuously repeating message
- void RegisterRepeatingMessage(string msg);
+ void RegisterRepeatingMessage(const string& msg);
// Change a repeating message - assume that the message changes after the string has finished for now
- void ChangeRepeatingMessage(string newmsg);
+ void ChangeRepeatingMessage(const string& newmsg);
// Cancel the current repeating message
void CancelRepeatingMessage();
// Returns frequency in KHz - should I alter this to return in MHz?
-unsigned short int FGATCMgr::GetFrequency(string ident, atc_type tp) {
+unsigned short int FGATCMgr::GetFrequency(const string& ident, const atc_type& tp) {
ATCData test;
bool ok = current_commlist->FindByCode(ident, test, tp);
return(ok ? test.freq : 0);
// Register the fact that the AI system wants to activate an airport
// Might need more sophistication in this in the future - eg registration by aircraft call-sign.
-bool FGATCMgr::AIRegisterAirport(string ident) {
+bool FGATCMgr::AIRegisterAirport(const string& ident) {
SG_LOG(SG_ATC, SG_BULK, "AI registered airport " << ident << " with the ATC system");
//cout << "AI registered airport " << ident << " with the ATC system" << '\n';
if(airport_atc_map.find(ident) != airport_atc_map.end()) {
// Register the fact that the comm radio is tuned to an airport
// Channel is zero based
-bool FGATCMgr::CommRegisterAirport(string ident, int chan, atc_type tp) {
+bool FGATCMgr::CommRegisterAirport(const string& ident, int chan, const atc_type& tp) {
SG_LOG(SG_ATC, SG_BULK, "Comm channel " << chan << " registered airport " << ident);
//cout << "Comm channel " << chan << " registered airport " << ident << ' ' << tp << '\n';
if(airport_atc_map.find(ident) != airport_atc_map.end()) {
// Remove from list only if not needed by the AI system or the other comm channel
// Note that chan is zero based.
-void FGATCMgr::CommRemoveFromList(string id, atc_type tp, int chan) {
+void FGATCMgr::CommRemoveFromList(const string& id, const atc_type& tp, int chan) {
SG_LOG(SG_ATC, SG_BULK, "CommRemoveFromList called for airport " << id << " " << tp << " by channel " << chan);
//cout << "CommRemoveFromList called for airport " << id << " " << tp << " by channel " << chan << '\n';
if(airport_atc_map.find(id) != airport_atc_map.end()) {
// Remove from list - should only be called from above or similar
// This function *will* remove it from the list regardless of who else might want it.
-void FGATCMgr::RemoveFromList(string id, atc_type tp) {
+void FGATCMgr::RemoveFromList(const string& id, const atc_type& tp) {
//cout << "FGATCMgr::RemoveFromList called..." << endl;
//cout << "Requested type = " << tp << endl;
//cout << "id = " << id << endl;
// Find in list - return a currently active ATC pointer given ICAO code and type
// Return NULL if the given service is not in the list
// - *** THE CALLING FUNCTION MUST CHECK FOR THIS ***
-FGATC* FGATCMgr::FindInList(string id, atc_type tp) {
+FGATC* FGATCMgr::FindInList(const string& id, const atc_type& tp) {
//cout << "Entering FindInList for " << id << ' ' << tp << endl;
atc_list_iterator it = atc_list.begin();
while(it != atc_list.end()) {
}
// Returns true if the airport is found in the map
-bool FGATCMgr::GetAirportATCDetails(string icao, AirportATC* a) {
+bool FGATCMgr::GetAirportATCDetails(const string& icao, AirportATC* a) {
if(airport_atc_map.find(icao) != airport_atc_map.end()) {
*a = *airport_atc_map[icao];
return(true);
// Returns NULL if service doesn't exist - calling function should check for this.
// We really ought to make this private and call it from the CommRegisterAirport / AIRegisterAirport functions
// - at the moment all these GetATC... functions exposed are just too complicated.
-FGATC* FGATCMgr::GetATCPointer(string icao, atc_type type) {
+FGATC* FGATCMgr::GetATCPointer(const string& icao, const atc_type& type) {
if(airport_atc_map.find(icao) == airport_atc_map.end()) {
//cout << "Unable to find " << icao << ' ' << type << " in the airport_atc_map" << endl;
return NULL;
// TODO - in the future this will get more complex and dole out country/airport
// specific voices, and possible make sure that the same voice doesn't get used
// at different airports in quick succession if a large enough selection are available.
-FGATCVoice* FGATCMgr::GetVoicePointer(atc_type type) {
+FGATCVoice* FGATCMgr::GetVoicePointer(const atc_type& type) {
// TODO - implement me better - maintain a list of loaded voices and other voices!!
if(voice) {
switch(type) {
void update(double dt);
// Returns true if the airport is found in the map
- bool GetAirportATCDetails(string icao, AirportATC* a);
+ bool GetAirportATCDetails(const string& icao, AirportATC* a);
// Return a pointer to a given sort of ATC at a given airport and activate if necessary
// Returns NULL if service doesn't exist - calling function should check for this.
- FGATC* GetATCPointer(string icao, atc_type type);
+ FGATC* GetATCPointer(const string& icao, const atc_type& type);
// Return a pointer to an appropriate voice for a given type of ATC
// creating the voice if necessary - ie. make sure exactly one copy
// TODO - in the future this will get more complex and dole out country/airport
// specific voices, and possible make sure that the same voice doesn't get used
// at different airports in quick succession if a large enough selection are available.
- FGATCVoice* GetVoicePointer(atc_type type);
+ FGATCVoice* GetVoicePointer(const atc_type& type);
atc_type GetComm1ATCType() { return(comm_type[0]); }
FGATC* GetComm1ATCPointer() { return(comm_atc_ptr[0]); }
// Get the frequency of a given service at a given airport
// Returns zero if not found
- unsigned short int GetFrequency(string ident, atc_type tp);
+ unsigned short int GetFrequency(const string& ident, const atc_type& tp);
// Register the fact that the AI system wants to activate an airport
- bool AIRegisterAirport(string ident);
+ bool AIRegisterAirport(const string& ident);
// Register the fact that the comm radio is tuned to an airport
- bool CommRegisterAirport(string ident, int chan, atc_type tp);
+ bool CommRegisterAirport(const string& ident, int chan, const atc_type& tp);
private:
// Remove a class from the atc_list and delete it from memory
// *if* no other comm channel or AI plane is using it.
- void CommRemoveFromList(string id, atc_type tp, int chan);
+ void CommRemoveFromList(const string& id, const atc_type& tp, int chan);
// Remove a class from the atc_list and delete it from memory
// Should be called from the above - not directly!!
- void RemoveFromList(string id, atc_type tp);
+ void RemoveFromList(const string& id, const atc_type& tp);
// Return a pointer to a class in the list given ICAO code and type
// (external interface to this is through GetATCPointer)
// Return NULL if the given service is not in the list
// - *** THE CALLING FUNCTION MUST CHECK FOR THIS ***
- FGATC* FindInList(string id, atc_type tp);
+ FGATC* FindInList(const string& id, const atc_type& tp);
// Search the specified channel for stations on the same frequency and in range.
void FreqSearch(int channel);
//================================================================================================================
// Given two positions (lat & lon in degrees), get the HORIZONTAL separation (in meters)
-double dclGetHorizontalSeparation(const Point3D pos1, const Point3D pos2) {
+double dclGetHorizontalSeparation(const Point3D& pos1, const Point3D& pos2) {
double x; //East-West separation
double y; //North-South separation
double z; //Horizontal separation - z = sqrt(x^2 + y^2)
// Given a position (lat/lon/elev), heading and vertical angle (degrees), and distance (meters), calculate the new position.
// This function assumes the world is spherical. If geodetic accuracy is required use the functions is sg_geodesy instead!
// Assumes that the ground is not hit!!! Expects heading and angle in degrees, distance in meters.
-Point3D dclUpdatePosition(const Point3D pos, double heading, double angle, double distance) {
+Point3D dclUpdatePosition(const Point3D& pos, double heading, double angle, double distance) {
//cout << setprecision(10) << pos.lon() << ' ' << pos.lat() << '\n';
heading *= DCL_DEGREES_TO_RADIANS;
angle *= DCL_DEGREES_TO_RADIANS;
// Get a heading in degrees from one lat/lon to another.
// This function assumes the world is spherical. If geodetic accuracy is required use the functions is sg_geodesy instead!
// Warning - at the moment we are not checking for identical points - currently it returns 0 in this instance.
-double GetHeadingFromTo(const Point3D A, const Point3D B) {
+double GetHeadingFromTo(const Point3D& A, const Point3D& B) {
double latA = A.lat() * DCL_DEGREES_TO_RADIANS;
double lonA = A.lon() * DCL_DEGREES_TO_RADIANS;
double latB = B.lat() * DCL_DEGREES_TO_RADIANS;
// Runway stuff
// Given a Point3D (lon/lat/elev) and an FGRunway struct, determine if the point lies on the runway
-bool OnRunway(const Point3D pt, const FGRunway& rwy) {
+bool OnRunway(const Point3D& pt, const FGRunway& rwy) {
FGATCAlignedProjection ortho;
Point3D centre(rwy._lon, rwy._lat, 0.0); // We don't need the elev
ortho.Init(centre, rwy._heading);
********************************/
// Given two positions (lat & lon in degrees), get the HORIZONTAL separation (in meters)
-double dclGetHorizontalSeparation(const Point3D pos1, const Point3D pos2);
+double dclGetHorizontalSeparation(const Point3D& pos1, const Point3D& pos2);
// Given a point and a line, get the HORIZONTAL shortest distance from the point to a point on the line.
// Expects to be fed orthogonal co-ordinates, NOT lat & lon !
// Given a position (lat/lon/elev), heading, vertical angle, and distance, calculate the new position.
// Assumes that the ground is not hit!!! Expects heading and angle in degrees, distance in meters.
-Point3D dclUpdatePosition(const Point3D pos, double heading, double angle, double distance);
+Point3D dclUpdatePosition(const Point3D& pos, double heading, double angle, double distance);
// Get a heading from one lat/lon to another (in degrees)
-double GetHeadingFromTo(const Point3D A, const Point3D B);
+double GetHeadingFromTo(const Point3D& A, const Point3D& B);
// Given a heading (in degrees), bound it from 0 -> 360
void dclBoundHeading(double &hdg);
****************/
// Given a Point3D (lon/lat/elev) and an FGRunway struct, determine if the point lies on the runway
-bool OnRunway(const Point3D pt, const FGRunway& rwy);
+bool OnRunway(const Point3D& pt, const FGRunway& rwy);
#include "ATCDialog.hxx"
#include <Airports/runways.hxx>
+#include <simgear/constants.h>
#include <simgear/math/polar3d.hxx>
#include <simgear/misc/sg_path.hxx>
// =======================================================================
// Add plane to Approach list
// =======================================================================
-void FGApproach::AddPlane(string pid) {
+void FGApproach::AddPlane(const string& pid) {
int i;
for ( i=0; i<num_planes; i++) {
x3 *= sqrt(val2);
y3 *= sqrt(val2);
double da = fabs(atan2(y3,x3) - atan2(y1-y2,x1-x2));
- if ( da > SGD_PI ) da -= 2*SGD_PI;
- if ( fabs(da) > SGD_PI/2.) {
+ if ( da > SGD_PI ) da -= SGD_2PI;
+ if ( fabs(da) > SGD_PI_2) {
//if ( x3*(x1-x2) < 0.0 && y3*(y1-y2) < 0.0) {
x3 *= -1.0;
y3 *= -1.0;
double dis2 = y1-y2-y3;
dis = sqrt(dis);
da = atan2(dis2,dis1);
- if ( da < 0.0 ) da += 2*SGD_PI;
+ if ( da < 0.0 ) da += SGD_2PI;
if ( da < a3 ) dis *= -1.0;
//cout << dis1 << " " << dis2 << " " << da*SGD_RADIANS_TO_DEGREES << " " << h3
// << " " << sqrt(dis1*dis1 + dis2*dis2) << " " << dis << endl;
// Add new plane to stack if not already registered
// Input: pid - id of plane (name)
// Output: "true" if added; "false" if already existend
- void AddPlane(string pid);
+ void AddPlane(const string& pid);
// Remove plane from stack if out of range
int RemovePlane();
inline double get_bucket() const { return bucket; }
inline int get_pnum() const { return num_planes; }
- inline string get_trans_ident() { return trans_ident; }
+ inline const string& get_trans_ident() { return trans_ident; }
private:
void Update(double dt);
//inline void set_type(const atc_type tp) {type = tp;}
- inline string get_trans_ident() { return trans_ident; }
- inline void set_refname(string r) { refname = r; }
+ inline const string& get_trans_ident() { return trans_ident; }
+ inline void set_refname(const string& r) { refname = r; }
private:
// load the navaids and build the map
-bool FGCommList::init( SGPath path ) {
+bool FGCommList::init( const SGPath& path ) {
SGPath temp = path;
commlist_freq.erase(commlist_freq.begin(), commlist_freq.end());
}
-bool FGCommList::LoadComms(SGPath path) {
+bool FGCommList::LoadComms(const SGPath& path) {
sg_gzifstream fin( path.str() );
if ( !fin.is_open() ) {
// Find by Airport code.
// This is basically a wrapper for a call to the airport database to get the airport
// position followed by a call to FindByPos(...)
-bool FGCommList::FindByCode( string ICAO, ATCData& ad, atc_type tp ) {
+bool FGCommList::FindByCode( const string& ICAO, ATCData& ad, atc_type tp ) {
FGAirport a;
if ( dclFindAirportID( ICAO, &a ) ) {
comm_list_type stations;
// TODO - this function should move somewhere else eventually!
// Return an appropriate call-sign for an ATIS transmission.
-int FGCommList::GetCallSign( string apt_id, int hours, int mins )
+int FGCommList::GetCallSign( const string& apt_id, int hours, int mins )
{
atis_transmission_type tran;
~FGCommList();
// load all comm frequencies and build the map
- bool init( SGPath path );
+ bool init( const SGPath& path );
// query the database for the specified frequency, lon and lat are
// in degrees, elev is in meters.
double FindClosest( double lon, double lat, double elev, ATCData& ad, atc_type tp = INVALID, double max_range = 100.0 );
// Find by Airport code.
- bool FindByCode( string ICAO, ATCData& ad, atc_type tp = INVALID );
+ bool FindByCode( const string& ICAO, ATCData& ad, atc_type tp = INVALID );
// Return the callsign for an ATIS transmission given transmission time and airport id
// This maybe should get moved somewhere else!!
- int GetCallSign( string apt_id, int hours, int mins );
+ int GetCallSign( const string& apt_id, int hours, int mins );
private:
comm_map_type commlist_bck;
// Load comms from a specified path (which must include the filename)
- bool LoadComms(SGPath path);
+ bool LoadComms(const SGPath& path);
//----------- This stuff is left over from atislist.[ch]xx and maybe should move somewhere else
// Add structure and map for storing a log of atis transmissions
aptElev = 0.0;
}
-FGGround::FGGround(string id) {
+FGGround::FGGround(const string& id) {
ATCmgr = globals->get_ATC_mgr();
networkLoadOK = false;
ground_traffic.erase(ground_traffic.begin(), ground_traffic.end());
}
-node* FGGround::GetHoldShortNode(string rwyID) {
+node* FGGround::GetHoldShortNode(const string& rwyID) {
return(NULL); // TODO - either implement me or remove me!!!
}
// WARNING - This is hardwired to my prototype logical network format
// and will almost certainly change when Bernie's stuff comes on-line.
// Returns NULL if it can't find a valid node.
-node* FGGround::GetThresholdNode(string rwyID) {
+node* FGGround::GetThresholdNode(const string& rwyID) {
// For now go through all the nodes and parse their names
// Maybe in the future we'll map threshold nodes by ID
//cout << "Size of network is " << network.size() << '\n';
};
// Get a path from a node to a runway threshold
-ground_network_path_type FGGround::GetPath(node* A, string rwyID) {
+ground_network_path_type FGGround::GetPath(node* A, const string& rwyID) {
node* b = GetThresholdNode(rwyID);
if(b == NULL) {
SG_LOG(SG_ATC, SG_ALERT, "ERROR - unable to find path to runway theshold in ground.cxx for airport " << ident << '\n');
// Get a path from a node to a runway hold short point
// Bit of a hack this at the moment!
-ground_network_path_type FGGround::GetPathToHoldShort(node* A, string rwyID) {
+ground_network_path_type FGGround::GetPathToHoldShort(node* A, const string& rwyID) {
ground_network_path_type path = GetPath(A, rwyID);
path.pop_back(); // That should be the threshold stripped of
path.pop_back(); // and that should be the arc from hold short to threshold
// Return a list of exits from a given runway
// It is up to the calling function to check for non-zero size of returned array before use
-node_array_type FGGround::GetExits(string rwyID) {
+node_array_type FGGround::GetExits(const string& rwyID) {
// FIXME - get a 07L or similar in here and we're stuffed!!!
return(runways[atoi(rwyID.c_str())].exits);
}
-void FGGround::RequestDeparture(PlaneRec plane, FGAIEntity* requestee) {
+void FGGround::RequestDeparture(const PlaneRec& plane, FGAIEntity* requestee) {
// For now we'll just automatically clear all planes to the runway hold.
// This communication needs to be delayed 20 sec or so from receiving the request.
// Even if display=false we still need to start the timer in case display=true when communication starts.
public:
FGGround();
- FGGround(string id);
+ FGGround(const string& id);
~FGGround();
void Init();
void Update(double dt);
- inline string get_trans_ident() { return trans_ident; }
+ inline const string& get_trans_ident() { return trans_ident; }
// Contact ground control on arrival, assumed to request any gate
//void NewArrival(plane_rec plane);
// Contact ground control on departure, assumed to request currently active runway.
- void RequestDeparture(PlaneRec plane, FGAIEntity* requestee);
+ void RequestDeparture(const PlaneRec& plane, FGAIEntity* requestee);
// Contact ground control when the calling routine doesn't know if arrival
// or departure is appropriate.
Gate* GetGateNode();
// Return a pointer to a hold short node
- node* GetHoldShortNode(string rwyID);
+ node* GetHoldShortNode(const string& rwyID);
// Runway stuff - this might change in the future.
// Get a list of exits from a given runway
// It is up to the calling function to check for non-zero size of returned array before use
- node_array_type GetExits(string rwyID);
+ node_array_type GetExits(const string& rwyID);
// Get a path from one node to another
ground_network_path_type GetPath(node* A, node* B);
// Get a path from a node to a runway threshold
- ground_network_path_type GetPath(node* A, string rwyID);
+ ground_network_path_type GetPath(node* A, const string& rwyID);
// Get a path from a node to a runway hold short point
// Bit of a hack this at the moment!
- ground_network_path_type GetPathToHoldShort(node* A, string rwyID);
+ ground_network_path_type GetPathToHoldShort(node* A, const string& rwyID);
private:
FGATCMgr* ATCmgr;
// Return a pointer to the node at a runway threshold
// Returns NULL if unsuccessful.
- node* GetThresholdNode(string rwyID);
+ node* GetThresholdNode(const string& rwyID);
// A shortest path algorithm from memory (I can't find the bl&*dy book again!)
ground_network_path_type GetShortestPath(node* A, node* B);
plane.callsign = "UNKNOWN";
}
-TowerPlaneRec::TowerPlaneRec(PlaneRec p) :
+TowerPlaneRec::TowerPlaneRec(const PlaneRec& p) :
planePtr(NULL),
clearedToLand(false),
clearedToLineUp(false),
plane = p;
}
-TowerPlaneRec::TowerPlaneRec(Point3D pt) :
+TowerPlaneRec::TowerPlaneRec(const Point3D& pt) :
planePtr(NULL),
clearedToLand(false),
clearedToLineUp(false),
pos = pt;
}
-TowerPlaneRec::TowerPlaneRec(PlaneRec p, Point3D pt) :
+TowerPlaneRec::TowerPlaneRec(const PlaneRec& p, const Point3D& pt) :
planePtr(NULL),
clearedToLand(false),
clearedToLineUp(false),
// Figure out if a given position lies on the active runway
// Might have to change when we consider more than one active rwy.
-bool FGTower::OnActiveRunway(Point3D pt) {
+bool FGTower::OnActiveRunway(const Point3D& pt) {
// TODO - check that the centre calculation below isn't confused by displaced thesholds etc.
Point3D xyc((rwy.end1ortho.x() + rwy.end2ortho.x())/2.0, (rwy.end1ortho.y() + rwy.end2ortho.y())/2.0, 0.0);
Point3D xyp = ortho.ConvertToLocal(pt);
// Figure out if a given position lies on any runway or not
// Only call this at startup - reading the runways database is expensive and needs to be fixed!
-bool FGTower::OnAnyRunway(Point3D pt) {
+bool FGTower::OnAnyRunway(const Point3D& pt) {
ATCData ad;
double dist = current_commlist->FindClosest(lon, lat, elev, ad, TOWER, 10.0);
if(dist < 0.0) {
// Returns true if successful
-bool FGTower::RemoveFromTrafficList(string id) {
+bool FGTower::RemoveFromTrafficList(const string& id) {
tower_plane_rec_list_iterator twrItr;
for(twrItr = trafficList.begin(); twrItr != trafficList.end(); twrItr++) {
TowerPlaneRec* tpr = *twrItr;
// Returns true if successful
-bool FGTower::RemoveFromAppList(string id) {
+bool FGTower::RemoveFromAppList(const string& id) {
tower_plane_rec_list_iterator twrItr;
for(twrItr = appList.begin(); twrItr != appList.end(); twrItr++) {
TowerPlaneRec* tpr = *twrItr;
}
// Returns true if successful
-bool FGTower::RemoveFromRwyList(string id) {
+bool FGTower::RemoveFromRwyList(const string& id) {
tower_plane_rec_list_iterator twrItr;
for(twrItr = rwyList.begin(); twrItr != rwyList.end(); twrItr++) {
TowerPlaneRec* tpr = *twrItr;
}
-void FGTower::ContactAtHoldShort(PlaneRec plane, FGAIPlane* requestee, tower_traffic_type operation) {
+void FGTower::ContactAtHoldShort(const PlaneRec& plane, FGAIPlane* requestee, tower_traffic_type operation) {
// HACK - assume that anything contacting at hold short is new for now - FIXME LATER
TowerPlaneRec* t = new TowerPlaneRec;
t->plane = plane;
// Register the presence of an AI plane at a point where contact would already have been made in real life
// CAUTION - currently it is assumed that this plane's callsign is unique - it is up to AIMgr to generate unique callsigns.
-void FGTower::RegisterAIPlane(PlaneRec plane, FGAIPlane* ai, tower_traffic_type op, PatternLeg lg) {
+void FGTower::RegisterAIPlane(const PlaneRec& plane, FGAIPlane* ai, const tower_traffic_type& op, const PatternLeg& lg) {
// At the moment this is only going to be tested with inserting an AI plane on downwind
TowerPlaneRec* t = new TowerPlaneRec;
t->plane = plane;
doThresholdUseOrder();
}
-void FGTower::DeregisterAIPlane(string id) {
+void FGTower::DeregisterAIPlane(const string& id) {
RemovePlane(id);
}
// eg "Cessna Charlie Foxtrot Golf Foxtrot Sierra eight miles South of the airport for full stop with Bravo"
// This function probably only called via user interaction - AI planes will have an overloaded function taking a planerec.
// opt defaults to AIP_LT_UNKNOWN
-void FGTower::VFRArrivalContact(string ID, LandingType opt) {
+void FGTower::VFRArrivalContact(const string& ID, const LandingType& opt) {
//cout << "USER Request Landing Clearance called for ID " << ID << '\n';
// For now we'll assume that the user is a light plane and can get him/her to join the circuit if necessary.
}
// landingType defaults to AIP_LT_UNKNOWN
-void FGTower::VFRArrivalContact(PlaneRec plane, FGAIPlane* requestee, LandingType lt) {
+void FGTower::VFRArrivalContact(const PlaneRec& plane, FGAIPlane* requestee, const LandingType& lt) {
//cout << "VFRArrivalContact called for plane " << plane.callsign << " at " << ident << '\n';
// Possible hack - assume this plane is new for now - TODO - should check really
TowerPlaneRec* t = new TowerPlaneRec;
AddToTrafficList(t);
}
-void FGTower::RequestDepartureClearance(string ID) {
+void FGTower::RequestDepartureClearance(const string& ID) {
//cout << "Request Departure Clearance called...\n";
}
-void FGTower::ReportFinal(string ID) {
+void FGTower::ReportFinal(const string& ID) {
//cout << "Report Final Called at tower " << ident << " by plane " << ID << '\n';
+ string uid=ID;
if(ID == "USER") {
- ID = fgGetString("/sim/user/callsign");
+ uid = fgGetString("/sim/user/callsign");
current_atcdialog->remove_entry(ident, USER_REPORT_3_MILE_FINAL, TOWER);
}
- TowerPlaneRec* t = FindPlane(ID);
+ TowerPlaneRec* t = FindPlane(uid);
if(t) {
t->finalReported = true;
t->finalAcknowledged = false;
}
}
-void FGTower::ReportLongFinal(string ID) {
+void FGTower::ReportLongFinal(const string& ID) {
+ string uid=ID;
if(ID == "USER") {
- ID = fgGetString("/sim/user/callsign");
+ uid = fgGetString("/sim/user/callsign");
current_atcdialog->remove_entry(ident, USER_REPORT_3_MILE_FINAL, TOWER);
}
- TowerPlaneRec* t = FindPlane(ID);
+ TowerPlaneRec* t = FindPlane(uid);
if(t) {
t->longFinalReported = true;
t->longFinalAcknowledged = false;
//void FGTower::ReportMiddleMarker(string ID);
//void FGTower::ReportInnerMarker(string ID);
-void FGTower::ReportRunwayVacated(string ID) {
+void FGTower::ReportRunwayVacated(const string& ID) {
//cout << "Report Runway Vacated Called at tower " << ident << " by plane " << ID << '\n';
+ string uid=ID;
if(ID == "USER") {
- ID = fgGetString("/sim/user/callsign");
+ uid = fgGetString("/sim/user/callsign");
current_atcdialog->remove_entry(ident, USER_REPORT_RWY_VACATED, TOWER);
}
- TowerPlaneRec* t = FindPlane(ID);
+ TowerPlaneRec* t = FindPlane(uid);
if(t) {
//cout << "Found it...\n";
t->rwyVacatedReported = true;
}
}
-TowerPlaneRec* FGTower::FindPlane(string ID) {
+TowerPlaneRec* FGTower::FindPlane(const string& ID) {
//cout << "FindPlane called for " << ID << "...\n";
tower_plane_rec_list_iterator twrItr;
// Do the approach list first
return(NULL);
}
-void FGTower::RemovePlane(string ID) {
+void FGTower::RemovePlane(const string& ID) {
//cout << ident << " RemovePlane called for " << ID << '\n';
// We have to be careful here - we want to erase the plane from all lists it is in,
// but we can only delete it once, AT THE END.
if(t) delete t;
}
-void FGTower::ReportDownwind(string ID) {
+void FGTower::ReportDownwind(const string& ID) {
//cout << "ReportDownwind(...) called\n";
+ string uid=ID;
if(ID == "USER") {
- ID = fgGetString("/sim/user/callsign");
+ uid = fgGetString("/sim/user/callsign");
current_atcdialog->remove_entry(ident, USER_REPORT_DOWNWIND, TOWER);
}
- TowerPlaneRec* t = FindPlane(ID);
+ TowerPlaneRec* t = FindPlane(uid);
if(t) {
t->downwindReported = true;
responseReqd = true;
}
}
-void FGTower::ReportGoingAround(string ID) {
+void FGTower::ReportGoingAround(const string& ID) {
+ string uid=ID;
if(ID == "USER") {
- ID = fgGetString("/sim/user/callsign");
+ uid = fgGetString("/sim/user/callsign");
RemoveAllUserDialogOptions(); // TODO - it would be much more efficient if ATCDialog simply had a clear() function!!!
current_atcdialog->add_entry(ident, "@AP Tower @CS Downwind @RW", "Report Downwind", TOWER, (int)USER_REPORT_DOWNWIND);
}
- TowerPlaneRec* t = FindPlane(ID);
+ TowerPlaneRec* t = FindPlane(uid);
if(t) {
//t->goAroundReported = true; // No need to set this until we start responding to it.
responseReqd = false; // might change in the future but for now we'll not distract them during the go-around.
public:
TowerPlaneRec();
- TowerPlaneRec(PlaneRec p);
- TowerPlaneRec(Point3D pt);
- TowerPlaneRec(PlaneRec p, Point3D pt);
+ TowerPlaneRec(const PlaneRec& p);
+ TowerPlaneRec(const Point3D& pt);
+ TowerPlaneRec(const PlaneRec& p, const Point3D& pt);
FGAIPlane* planePtr; // This might move to the planeRec eventually
PlaneRec plane;
PatternLeg leg;
LandingType landingType;
-
bool isUser; // true if this plane is the user
};
// Contact tower for VFR approach
// eg "Cessna Charlie Foxtrot Golf Foxtrot Sierra eight miles South of the airport for full stop with Bravo"
// This function probably only called via user interaction - AI planes will have an overloaded function taking a planerec.
- void VFRArrivalContact(string ID, LandingType opt = AIP_LT_UNKNOWN);
+ void VFRArrivalContact(const string& ID, const LandingType& opt = AIP_LT_UNKNOWN);
// For the AI planes...
- void VFRArrivalContact(PlaneRec plane, FGAIPlane* requestee, LandingType lt = AIP_LT_UNKNOWN);
-
- void RequestDepartureClearance(string ID);
- void ReportFinal(string ID);
- void ReportLongFinal(string ID);
- void ReportOuterMarker(string ID);
- void ReportMiddleMarker(string ID);
- void ReportInnerMarker(string ID);
- void ReportRunwayVacated(string ID);
- void ReportReadyForDeparture(string ID);
- void ReportDownwind(string ID);
- void ReportGoingAround(string ID);
+ void VFRArrivalContact(const PlaneRec& plane, FGAIPlane* requestee, const LandingType& lt = AIP_LT_UNKNOWN);
+
+ void RequestDepartureClearance(const string& ID);
+ void ReportFinal(const string& ID);
+ void ReportLongFinal(const string& ID);
+ void ReportOuterMarker(const string& ID);
+ void ReportMiddleMarker(const string& ID);
+ void ReportInnerMarker(const string& ID);
+ void ReportRunwayVacated(const string& ID);
+ void ReportReadyForDeparture(const string& ID);
+ void ReportDownwind(const string& ID);
+ void ReportGoingAround(const string& ID);
// Contact tower when at a hold short for departure - for now we'll assume plane - maybe vehicles might want to cross runway eventually?
- void ContactAtHoldShort(PlaneRec plane, FGAIPlane* requestee, tower_traffic_type operation);
+ void ContactAtHoldShort(const PlaneRec& plane, FGAIPlane* requestee, tower_traffic_type operation);
// Register the presence of an AI plane at a point where contact would already have been made in real life
// CAUTION - currently it is assumed that this plane's callsign is unique - it is up to AIMgr to generate unique callsigns.
- void RegisterAIPlane(PlaneRec plane, FGAIPlane* ai, tower_traffic_type op, PatternLeg lg = LEG_UNKNOWN);
+ void RegisterAIPlane(const PlaneRec& plane, FGAIPlane* ai, const tower_traffic_type& op, const PatternLeg& lg = LEG_UNKNOWN);
// Deregister and remove an AI plane.
- void DeregisterAIPlane(string id);
+ void DeregisterAIPlane(const string& id);
// Public interface to the active runway - this will get more complex
// in the future and consider multi-runway use, airplane weight etc.
- inline string GetActiveRunway() { return activeRwy; }
- inline RunwayDetails GetActiveRunwayDetails() { return rwy; }
+ inline const string& GetActiveRunway() { return activeRwy; }
+ inline const RunwayDetails& GetActiveRunwayDetails() { return rwy; }
// Get the pattern direction of the active rwy.
inline int GetPatternDirection() { return rwy.patternDirection; }
- inline string get_trans_ident() { return trans_ident; }
+ inline const string& get_trans_ident() { return trans_ident; }
inline FGGround* GetGroundPtr() { return ground; }
void ClearHoldingPlane(TowerPlaneRec* t);
// Find a pointer to plane of callsign ID within the internal data structures
- TowerPlaneRec* FindPlane(string ID);
+ TowerPlaneRec* FindPlane(const string& ID);
// Remove and delete all instances of a plane with a given ID
- void RemovePlane(string ID);
+ void RemovePlane(const string& ID);
// Figure out if a given position lies on the active runway
// Might have to change when we consider more than one active rwy.
- bool OnActiveRunway(Point3D pt);
+ bool OnActiveRunway(const Point3D& pt);
// Figure out if a given position lies on a runway or not
- bool OnAnyRunway(Point3D pt);
+ bool OnAnyRunway(const Point3D& pt);
// Calculate the eta of a plane to the threshold.
// For ground traffic this is the fastest they can get there.
tower_plane_rec_list_iterator vacatedListItr;
// Returns true if successful
- bool RemoveFromTrafficList(string id);
- bool RemoveFromAppList(string id);
- bool RemoveFromRwyList(string id);
+ bool RemoveFromTrafficList(const string& id);
+ bool RemoveFromAppList(const string& id);
+ bool RemoveFromRwyList(const string& id);
// Return the ETA of plane no. list_pos (1-based) in the traffic list.
// i.e. list_pos = 1 implies next to use runway.
void Init();
inline atc_type get_station() const { return StationType; }
- inline TransCode get_code() { return Code; }
- inline string get_transtext() { return TransText; }
- inline string get_menutext() { return MenuText; }
+ inline const TransCode& get_code() { return Code; }
+ inline const string& get_transtext() { return TransText; }
+ inline const string& get_menutext() { return MenuText; }
// Return the parsed logic of the transmission
TransPar Parse();
// load default.transmissions
-bool FGTransmissionList::init( SGPath path ) {
+bool FGTransmissionList::init( const SGPath& path ) {
FGTransmission a;
transmissionlist_station.erase( transmissionlist_station.begin(), transmissionlist_station.end() );
~FGTransmissionList();
// load the transmission data and build the map
- bool init( SGPath path );
+ bool init( const SGPath& path );
// query the database for the specified code,
bool query_station( const atc_type &station, FGTransmission *a, int max_trans, int &num_trans );
// add an entry to the list
-void FGRunwayList::add( const string id, const string rwy_no,
+void FGRunwayList::add( const string& id, const string& rwy_no,
const double longitude, const double latitude,
const double heading, const double length,
const double width,
const double displ_thresh1, const double displ_thresh2,
const double stopway1, const double stopway2,
- const string lighting_flags, const int surface_code,
- const string shoulder_code, const int marking_code,
+ const string& lighting_flags, const int surface_code,
+ const string& shoulder_code, const int marking_code,
const double smoothness, const bool dist_remaining )
{
FGRunway rwy;
// Return reverse rwy number
// eg 01 -> 19
// 03L -> 21R
-static string GetReverseRunwayNo(string rwyno) {
+static string GetReverseRunwayNo(string& rwyno) {
// cout << "Original rwyno = " << rwyNo << '\n';
// standardize input number
struct ltstr {
- bool operator()(const string s1, const string s2) const {
+ bool operator()(const string& s1, const string& s2) const {
return s1 < s2;
}
};
~FGRunwayList();
// add an entry to the list
- void add( const string id, const string rwy_no,
+ void add( const string& id, const string& rwy_no,
const double longitude, const double latitude,
const double heading, const double length, const double width,
const double displ_thresh1, const double displ_thresh2,
const double stopway1, const double stopway2,
- const string lighting_flags, const int surface_code,
- const string shoulder_code, const int marking_code,
+ const string& lighting_flags, const int surface_code,
+ const string& shoulder_code, const int marking_code,
const double smoothness, const bool dist_remaining );
// search for the specified apt id.
}
//couldn't find one so return 0;
//cerr << "Returning 0 " << endl;
- return string(0);
}
+ return string(0);
}
/******************************************************************************
* RunwayList
preferredRunways.push_back(*i);
return *this;
}
-void RunwayList::set(string tp, string lst)
+void RunwayList::set(const string &tp, const string &lst)
{
//weekday = atoi(timeCopy.substr(0,1).c_str());
// timeOffsetInDays = weekday - currTimeDate->getGmt()->tm_wday;
return *this;
}
-void RunwayGroup::setActive(string aptId,
+void RunwayGroup::setActive(const string &aptId,
double windSpeed,
double windHeading,
double maxTail,
}
-void RunwayGroup::getActive(int i, string *name, string *type)
+void RunwayGroup::getActive(int i, string &name, string &type)
{
if (i == -1)
{
}
if (nrActive == (int)rwyList.size())
{
- *name = rwyList[i].getRwyList(active);
- *type = rwyList[i].getType();
+ name = rwyList[i].getRwyList(active);
+ type = rwyList[i].getType();
}
else
{
- *name = rwyList[choice[i]].getRwyList(active);
- *type = rwyList[choice[i]].getType();
+ name = rwyList[choice[i]].getRwyList(active);
+ type = rwyList[choice[i]].getType();
}
}
/*****************************************************************************
return 0;
}
-RunwayGroup *FGRunwayPreference::getGroup(const string groupName)
+RunwayGroup *FGRunwayPreference::getGroup(const string &groupName)
{
PreferenceListIterator i = preferences.begin();
if (preferences.begin() == preferences.end())
}
//based on a string containing hour and minute, return nr seconds since day start.
-time_t FGRunwayPreference::processTime(string tme)
+time_t FGRunwayPreference::processTime(const string &tme)
{
string hour = tme.substr(0, tme.find(":",0));
string minute = tme.substr(tme.find(":",0)+1, tme.length());
/*****************************************************************************
* Helper function for parsing position string
****************************************************************************/
-double processPosition(string pos)
+double processPosition(const string &pos)
{
string prefix;
string subs;
double hdg,
double rad,
int idx,
- string name,
- string tpe,
- string codes)
+ const string &name,
+ const string &tpe,
+ const string &codes)
{
latitude = lat;
longitude = lon;
}
}
-FGAirport::FGAirport(string id, double lon, double lat, double elev, string name, bool has_metar)
+FGAirport::FGAirport(const string &id, double lon, double lat, double elev, const string &name, bool has_metar)
{
_id = id;
_longitude = lon;
groundNetwork.init();
}
-bool FGAirport::getAvailableParking(double *lat, double *lon, double *heading, int *gateId, double rad, string flType, string acType, string airline)
+bool FGAirport::getAvailableParking(double *lat, double *lon, double *heading, int *gateId, double rad, const string &flType, const string &acType, const string &airline)
{
bool found = false;
bool available = false;
<< endl;
}
-void FGAirport::setRwyUse(FGRunwayPreference& ref)
+void FGAirport::setRwyUse(const FGRunwayPreference& ref)
{
rwyPrefs = ref;
//cerr << "Exiting due to not implemented yet" << endl;
//exit(1);
}
-void FGAirport::getActiveRunway(string trafficType, int action, string *runway)
+void FGAirport::getActiveRunway(const string &trafficType, int action, string &runway)
{
double windSpeed;
double windHeading;
if (!(rwyPrefs.available()))
{
- chooseRunwayFallback(runway);
+ runway = chooseRunwayFallback();
return; // generic fall back goes here
}
else
for (int i = 0; i < nrActiveRunways; i++)
{
type = "unknown"; // initialize to something other than landing or takeoff
- currRunwayGroup->getActive(i, &name, &type);
+ currRunwayGroup->getActive(i, name, type);
if (type == "landing")
{
landing.push_back(name);
int nr = takeoff.size();
if (nr)
{
- *runway = takeoff[(rand() % nr)];
+ runway = takeoff[(rand() % nr)];
}
else
{ // Fallback
- chooseRunwayFallback(runway);
+ runway = chooseRunwayFallback();
}
}
if (action == 2) // landing
int nr = landing.size();
if (nr)
{
- *runway = landing[(rand() % nr)];
+ runway = landing[(rand() % nr)];
}
else
{ //fallback
- chooseRunwayFallback(runway);
+ runway = chooseRunwayFallback();
}
}
- //*runway = globals->get_runways()->search(_id, int(windHeading));
- //cerr << "Seleceted runway: " << *runway << endl;
+ //runway = globals->get_runways()->search(_id, int(windHeading));
+ //cerr << "Seleceted runway: " << runway << endl;
}
}
-void FGAirport::chooseRunwayFallback(string *runway)
+string FGAirport::chooseRunwayFallback()
{
FGEnvironment
stationweather = ((FGEnvironmentMgr *) globals->get_subsystem("environment"))
//which is consistent with Flightgear's initial setup.
}
- *runway = globals->get_runways()->search(_id, int(windHeading));
- return; // generic fall back goes here
+ return globals->get_runways()->search(_id, int(windHeading));
}
hasNetwork = false;
}
-void FGGroundNetwork::addSegment(FGTaxiSegment seg)
+void FGGroundNetwork::addSegment(const FGTaxiSegment &seg)
{
segments.push_back(seg);
}
-void FGGroundNetwork::addNode(FGTaxiNode node)
+void FGGroundNetwork::addNode(const FGTaxiNode &node)
{
nodes.push_back(node);
}
// add an entry to the list
-void FGAirportList::add( const string id, const double longitude,
+void FGAirportList::add( const string &id, const double longitude,
const double latitude, const double elevation,
- const string name, const bool has_metar )
+ const string &name, const bool has_metar )
{
FGRunwayPreference rwyPrefs;
FGAirport* a = new FGAirport(id, longitude, latitude, elevation, name, has_metar);
void clear();
void addStartTime(time_t time) { start.push_back(time); };
void addEndTime (time_t time) { end. push_back(time); };
- void addScheduleName(string sched) { scheduleNames.push_back(sched); };
+ void addScheduleName(const string& sched) { scheduleNames.push_back(sched); };
void setTailWind(double wnd) { tailWind = wnd; };
void setCrossWind(double wnd) { tailWind = wnd; };
RunwayList(const RunwayList &other);
RunwayList& operator= (const RunwayList &other);
- void set(string, string);
+ void set(const string&, const string&);
void clear();
string getType() { return type; };
void setName(string nm) { name = nm; };
void add(RunwayList list) { rwyList.push_back(list);};
- void setActive(string aptId, double windSpeed, double windHeading, double maxTail, double maxCross);
+ void setActive(const string& aptId, double windSpeed, double windHeading, double maxTail, double maxCross);
int getNrActiveRunways() { return nrActive;};
- void getActive(int i, string *name, string *type);
+ void getActive(int i, string& name, string& type);
string getName() { return name; };
void clear() { rwyList.clear(); };
RunwayGroup rwyGroup;
PreferenceList preferences;
- time_t processTime(string);
+ time_t processTime(const string&);
bool initialized;
public:
FGRunwayPreference & operator= (const FGRunwayPreference &other);
ScheduleTime *getSchedule(const char *trafficType);
- RunwayGroup *getGroup(const string groupName);
+ RunwayGroup *getGroup(const string& groupName);
bool available() { return initialized; };
// Some overloaded virtual XMLVisitor members
virtual void error (const char * message, int line, int column);
};
-double processPosition(string pos);
+double processPosition(const string& pos);
class FGParking {
private:
double hdg,
double rad,
int idx,
- string name,
- string tpe,
- string codes);
- void setLatitude (string lat) { latitude = processPosition(lat); };
- void setLongitude(string lon) { longitude = processPosition(lon); };
+ const string& name,
+ const string& tpe,
+ const string& codes);
+ void setLatitude (const string& lat) { latitude = processPosition(lat); };
+ void setLongitude(const string& lon) { longitude = processPosition(lon); };
void setHeading (double hdg) { heading = hdg; };
void setRadius (double rad) { radius = rad; };
void setIndex (int idx) { index = idx; };
- void setName (string name) { parkingName = name; };
- void setType (string tpe) { type = tpe; };
- void setCodes (string codes){ airlineCodes= codes;};
+ void setName (const string& name) { parkingName = name; };
+ void setType (const string& tpe) { type = tpe; };
+ void setCodes (const string& codes){ airlineCodes= codes;};
bool isAvailable () { return available;};
void setAvailable(bool val) { available = val; };
void setIndex(int idx) { index = idx;};
void setLatitude (double val) { lat = val;};
void setLongitude(double val) { lon = val;};
- void setLatitude (string val) { lat = processPosition(val); };
- void setLongitude(string val) { lon = processPosition(val); };
+ void setLatitude (const string& val) { lat = processPosition(val); };
+ void setLongitude(const string& val) { lon = processPosition(val); };
void addSegment(FGTaxiSegment *segment) { next.push_back(segment); };
double getLatitude() { return lat;};
public:
FGGroundNetwork();
- void addNode (FGTaxiNode node);
+ void addNode (const FGTaxiNode& node);
void addNodes (FGParkingVec *parkings);
- void addSegment(FGTaxiSegment seg);
+ void addSegment(const FGTaxiSegment& seg);
void init();
bool exists() { return hasNetwork; };
double avWindHeading [10];
double avWindSpeed [10];
+ string chooseRunwayFallback();
+
public:
FGAirport();
FGAirport(const FGAirport &other);
//operator= (FGAirport &other);
- FGAirport(string id, double lon, double lat, double elev, string name, bool has_metar);
+ FGAirport(const string& id, double lon, double lat, double elev, const string& name, bool has_metar);
void init();
- void getActiveRunway(string trafficType, int action, string *runway);
- void chooseRunwayFallback(string *runway);
- bool getAvailableParking(double *lat, double *lon, double *heading, int *gate, double rad, string fltype,
- string acType, string airline);
+ void getActiveRunway(const string& trafficType, int action, string& runway);
+ bool getAvailableParking(double *lat, double *lon, double *heading, int *gate, double rad, const string& fltype,
+ const string& acType, const string& airline);
void getParking (int id, double *lat, double* lon, double *heading);
FGParking *getParking(int i); // { if (i < parkings.size()) return parkings[i]; else return 0;};
void releaseParking(int id);
FGGroundNetwork* getGroundNetwork() { return &groundNetwork; };
- void setId(string id) { _id = id;};
+ void setId(const string& id) { _id = id;};
void setMetar(bool value) { _has_metar = value; };
- void setRwyUse(FGRunwayPreference& ref);
+ void setRwyUse(const FGRunwayPreference& ref);
// Some overloaded virtual XMLVisitor members
virtual void startXML ();
~FGAirportList();
// add an entry to the list
- void add( const string id, const double longitude, const double latitude,
- const double elevation, const string name, const bool has_metar );
+ void add( const string& id, const double longitude, const double latitude,
+ const double elevation, const string& name, const bool has_metar );
// search for the specified id.
// Returns NULL if unsucessfull.
/* add new waypoint (either from above popup window 'ok button or telnet session) */
-int NewWaypoint( string Tgt_Alt )
+int NewWaypoint( const string& Tgt_Alt )
{
string TgtAptId;
FGAirport a;
void NewHeadingInit();
void NewAltitudeInit();
-int NewWaypoint( string Tgt_Alt );
+int NewWaypoint( const string& Tgt_Alt );
#endif // _AUTO_GUI_HXX
bool build ();
- void add_waypoint( SGWayPoint wp ) {
+ void add_waypoint( const SGWayPoint& wp ) {
route->add_waypoint( wp );
}
virtual ~FGXMLAutoComponent() {}
- virtual void update (double dt) {}
+ virtual void update (double dt)=0;
- inline string get_name() { return name; }
+ inline const string& get_name() { return name; }
};
// Adjust to put the number in the centre
xoffset -= 0.25;
- FGCroppedTexture &t = getTexture();
+ FGCroppedTexture t = getTexture();
t.setCrop(xoffset, yoffset, xoffset + 0.5, yoffset + 0.25);
glPushAttrib(GL_DEPTH_BUFFER_BIT);
~fgLineSeg2D() {}
- void draw()
+ void draw() const
{
glVertex2f(x0, y0);
glVertex2f(x1, y1);
class DrawLineSeg2D {
public:
- void operator() (fgLineSeg2D elem) const {
+ void operator() (const fgLineSeg2D& elem) const {
elem.draw();
}
};
public:
fgLineList( void ) {}
~fgLineList( void ) {}
- void add( fgLineSeg2D seg ) { List.push_back(seg); }
+ void add( const fgLineSeg2D& seg ) { List.push_back(seg); }
void erase( void ) { List.erase( List.begin(), List.end() ); }
void draw( void ) {
glBegin(GL_LINES);
~fgTextList( void ) {}
void setFont( fntRenderer *Renderer ) { Font = Renderer; }
- void add( fgText String ) { List.push_back(String); }
+ void add( const fgText& String ) { List.push_back(String); }
void erase( void ) { List.erase( List.begin(), List.end() ); }
void draw( void ) {
List.add( fgText( x, y, s) );
}
-inline void Text( fgTextList &List, fgText &me)
+inline void Text( fgTextList &List, const fgText &me)
{
List.add(me);
}
class runway_instr : public instr_item
{
private:
- void boundPoint(sgdVec3 v, sgdVec3 m);
- bool boundOutsidePoints(sgdVec3 v, sgdVec3 m);
- bool drawLine(sgdVec3 a1, sgdVec3 a2, sgdVec3 p1, sgdVec3 p2);
+ void boundPoint(const sgdVec3& v, sgdVec3& m);
+ bool boundOutsidePoints(sgdVec3& v, sgdVec3& m);
+ bool drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3& p1, const sgdVec3& p2);
void drawArrow();
bool get_active_runway(FGRunway& rwy);
void get_rwy_points(sgdVec3 *points);
fgLineList StippleLineList;
public:
- HudLadder( string name,
+ HudLadder( const string& name,
int x,
int y,
UINT width,
+#include <simgear/constants.h>
+
#include "hud.hxx"
#include "panel.hxx"
#define DO_PANEL_HACK
//====================== Top of HudLadder Class =======================
-HudLadder :: HudLadder( string name,
+HudLadder :: HudLadder( const string& name,
int x,
int y,
UINT width,
// velocity vector
glBegin(GL_LINE_LOOP); // Use polygon to approximate a circle
for(count=0; count<50; count++) {
- cosine = 6 * cos(count * 2 * SGD_PI/50.0);
- sine = 6 * sin(count * 2 * SGD_PI/50.0);
+ cosine = 6 * cos(count * SGD_2PI/50.0);
+ sine = 6 * sin(count * SGD_2PI/50.0);
glVertex2f(cosine+vel_x, sine+vel_y);
}
glEnd();
center = currentCenter;
}
-bool runway_instr::drawLine(sgdVec3 a1, sgdVec3 a2, sgdVec3 point1, sgdVec3 point2) {
+bool runway_instr::drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3& point1, const sgdVec3& point2) {
sgdVec3 p1, p2;
sgdCopyVec3(p1, point1);
sgdCopyVec3(p2, point2);
return (p1Valid && p2Valid);
}
-void runway_instr::boundPoint(sgdVec3 v, sgdVec3 m) {
+void runway_instr::boundPoint(const sgdVec3& v, sgdVec3& m) {
double y = v[1];
if(m[1] < v[1]) {
y = location.bottom;
}
}
-bool runway_instr::boundOutsidePoints(sgdVec3 v, sgdVec3 m) {
+bool runway_instr::boundOutsidePoints(sgdVec3& v, sgdVec3& m) {
bool pointsInvalid = (v[1]>location.top && m[1]>location.top) ||
(v[1]<location.bottom && m[1]<location.bottom) ||
(v[0]>location.right && m[0]>location.right) ||
}
int
-FGLayeredInstrument::addLayer (FGCroppedTexture &texture,
+FGLayeredInstrument::addLayer (const FGCroppedTexture &texture,
int w, int h)
{
return addLayer(new FGTexturedLayer(texture, w, h));
// Transfer pointer ownership!!
virtual int addLayer (FGInstrumentLayer *layer);
- virtual int addLayer (FGCroppedTexture &texture, int w = -1, int h = -1);
+ virtual int addLayer (const FGCroppedTexture &texture, int w = -1, int h = -1);
// Transfer pointer ownership!!
virtual void addTransformation (FGPanelTransformation * transformation);
virtual void setTexture (const FGCroppedTexture &texture) {
_texture = texture;
}
- virtual FGCroppedTexture &getTexture () { return _texture; }
virtual const FGCroppedTexture &getTexture () const { return _texture; }
private:
- mutable FGCroppedTexture _texture;
+ FGCroppedTexture _texture;
};
double angle_rad;
if (wind_from_east_fps == 0) {
- angle_rad = (wind_from_north_fps >= 0 ? SGD_PI/2 : -SGD_PI/2);
+ angle_rad = (wind_from_north_fps >= 0 ? SGD_PI_2 : -SGD_PI_2);
} else {
angle_rad = atan(wind_from_north_fps/wind_from_east_fps);
}
void
-FGMetarEnvironmentCtrl::update_metar_properties( FGMetar *m )
+FGMetarEnvironmentCtrl::update_metar_properties( const FGMetar *m )
{
int i;
double d;
fgSetDouble("/environment/metar/max-visibility-m",
m->getMaxVisibility().getVisibility_m() );
- SGMetarVisibility *dirvis = m->getDirVisibility();
+ const SGMetarVisibility *dirvis = m->getDirVisibility();
for (i = 0; i < 8; i++, dirvis++) {
const char *min = "/environment/metar/visibility[%d]/min-m";
const char *max = "/environment/metar/visibility[%d]/max-m";
virtual void setEnvironment (FGEnvironment * environment);
- virtual FGEnvironment * getEnvironment () const { return _environment; }
+ virtual const FGEnvironment * getEnvironment () const { return _environment; }
virtual void setLongitudeDeg (double lon_deg);
virtual void setLatitudeDeg (double lat_deg);
SGPropertyNode *metar_max_age;
FGMetarResult fetch_data( const string &icao );
- virtual void update_metar_properties( FGMetar *m );
+ virtual void update_metar_properties( const FGMetar *m );
void update_env_config();
private:
}
}
-SGNewCloud *FGClouds::buildCloud(SGPropertyNode *cloud_def_root, string name) {
+SGNewCloud *FGClouds::buildCloud(SGPropertyNode *cloud_def_root, const string& name) {
SGPropertyNode *cld_def=NULL;
cld_def = cloud_def_root->getChild(name.c_str());
return cld;
}
-void FGClouds::buildLayer(SGCloudField *layer, string name, double alt, double coverage) {
+void FGClouds::buildLayer(SGCloudField *layer, const string& name, double alt, double coverage) {
struct {
string name;
double count;
fgSetDouble("/environment/metar/max-visibility-m",
m->getMaxVisibility().getVisibility_m() );
- SGMetarVisibility *dirvis = m->getDirVisibility();
+ const SGMetarVisibility *dirvis = m->getDirVisibility();
for (i = 0; i < 8; i++, dirvis++) {
const char *min = "/environment/metar/visibility[%d]/min-m";
const char *max = "/environment/metar/visibility[%d]/max-m";
}
-void FGClouds::setLayer( int iLayer, float alt_ft, string coverage, string layer_type ) {
+void FGClouds::setLayer( int iLayer, float alt_ft, const string& coverage, const string& layer_type ) {
double coverage_norm = 0.0;
if( coverage == "few" )
coverage_norm = 2.0/8.0; // <1-2
buildLayer(layer3D, layer_type, station_elevation_ft + alt_ft * SG_FEET_TO_METER, coverage_norm);
}
-void FGClouds::buildScenario( string scenario ) {
+void FGClouds::buildScenario( const string& scenario ) {
string fakeMetar="";
string station = fgGetString("/environment/metar/station-id", "XXXX");
class FGClouds {
private:
- SGNewCloud *buildCloud(SGPropertyNode *cloud_def_root, string name);
- void buildLayer(SGCloudField *layer, string name, double alt, double coverage);
+ SGNewCloud *buildCloud(SGPropertyNode *cloud_def_root, const string& name);
+ void buildLayer(SGCloudField *layer, const string& name, double alt, double coverage);
void buildMETAR(void);
- void buildScenario( string scenario );
+ void buildScenario( const string& scenario );
- void setLayer( int iLayer, float alt_m, string coverage, string layer_type );
+ void setLayer( int iLayer, float alt_m, const string& coverage, const string& layer_type );
void update_metar_properties( FGMetar *m );
void search ();
// internal values
- inline string get_ident() const { return ident; }
+ inline const string& get_ident() const { return ident; }
inline bool get_valid() const { return valid; }
inline bool get_inrange() const { return inrange; }
inline double get_stn_lon() const { return stn_lon; }
}
double
-TACAN::searchChannel (string _channel){
+TACAN::searchChannel (const string& _channel){
double frequency_khz = 0;
void search (double frequency, double longitude_rad,
double latitude_rad, double altitude_m);
- double searchChannel (string _channel);
+ double searchChannel (const string& _channel);
SGPropertyNode_ptr _longitude_node;
SGPropertyNode_ptr _latitude_node;
#include <simgear/debug/logstream.hxx>
#include <simgear/environment/metar.hxx>
#include <simgear/structure/exception.hxx>
+#include <simgear/scene/sky/sky.hxx>
using namespace std;
}
-ostream& operator<<(ostream& s, SGMetarVisibility& v)
+ostream& operator<<(ostream& s, const SGMetarVisibility& v)
{
ostringstream buf;
int m = v.getModifier();
// directed visibility
- SGMetarVisibility *dirvis = m->getDirVisibility();
+ const SGMetarVisibility *dirvis = m->getDirVisibility();
for (i = 0; i < 8; i++, dirvis++)
if (dirvis->getVisibility_m() != NaN)
cout << "\t\t\t" << *dirvis << endl;
);
}
+SGSky* thesky = new SGSky;
int main(int argc, char *argv[])
{
inline FGFix(void);
inline ~FGFix(void) {}
- inline string get_ident() const { return ident; }
+ inline const string& get_ident() const { return ident; }
inline double get_lon() const { return lon; }
inline double get_lat() const { return lat; }
inline FGNav();
inline FGNav( int _type, double _lat, double _lon, double _elev_ft,
int _freq, double _range, double _magvar,
- string _ident, string _name,
+ const string& _ident, const string& _name,
bool _serviceable );
inline ~FGNav() {}
inline double get_range() const { return range; }
// inline bool get_has_dme() const { return has_dme; }
inline const char *get_ident() { return ident.c_str(); }
- inline string get_trans_ident() { return trans_ident; }
+ inline const string& get_trans_ident() { return trans_ident; }
inline double get_magvar() const { return magvar; }
- inline string get_name() { return name; }
+ inline const string& get_name() { return name; }
};
inline
FGNav::FGNav( int _type, double _lat, double _lon, double _elev_ft,
int _freq, double _range, double _magvar,
- string _ident, string _name,
+ const string& _ident, const string& _name,
bool _serviceable ) :
type(0),
lon(0.0), lat(0.0),
}
// Given a TACAN Channel return the first matching frequency
-FGTACANRecord *FGTACANList::findByChannel( string channel )
+FGTACANRecord *FGTACANList::findByChannel( const string& channel )
{
tacan_list_type stations = ident_channels[channel];
SG_LOG( SG_INSTR, SG_DEBUG, "findByChannel " << channel<< " size " << stations.size() );
// given a frequency returns the first matching entry
FGNavRecord *findStationByFreq( double frequency );
- inline nav_map_type get_navaids() const { return navaids; }
+ inline const nav_map_type& get_navaids() const { return navaids; }
};
class FGTACANList {
bool add( FGTACANRecord *r );
// Given a TACAN Channel, return the appropriate frequency.
- FGTACANRecord *findByChannel( string channel );
+ FGTACANRecord *findByChannel( const string& channel );
};
/* Make sure the angles are reasonable onscale */
/* We use an asymmetric mapping so that the chair behaves
reasonably when upside down. Otherwise it oscillates. */
- while ( ang_pos < -2*SGD_PI/3 ) {
- ang_pos += 2 * SGD_PI;
+ while ( ang_pos < -SGD_2PI/3 ) {
+ ang_pos += SGD_2PI;
}
- while ( ang_pos > 4*SGD_PI/3 ) {
- ang_pos -= 2 * SGD_PI;
+ while ( ang_pos > 2*SGD_2PI/3 ) {
+ ang_pos -= SGD_2PI;
}
/* Tell interested parties what the situation is */
if ( fabs ( ang_pos - chair_heading ) > SGD_PI )
{ /* Need to swing chair by 360 degrees */
if ( ang_pos < chair_heading )
- chair_heading -= 2 * SGD_PI;
- else chair_heading += 2 * SGD_PI;
+ chair_heading -= SGD_2PI;
+ else chair_heading += SGD_2PI;
}
/* Remove the chair heading from the true heading */
ang_pos -= chair_heading;
can just about represent 30 degrees full scale. */
chair_heading += ang_pos * dt * 0.2;
/* If they turn fast, at 90 deg error subtract 30 deg */
- if ( fabs(ang_pos) > SGD_PI / 2 )
+ if ( fabs(ang_pos) > SGD_PI_2 )
chair_heading += ang_pos / 3;
} else
/* Scale to the hardware's full scale range */
propose /= fullscale [ subaxis ];
/* Use a sine shaped washout on all axes */
- if ( propose < -SGD_PI / 2 ) *dac = 0x0000; else
- if ( propose > SGD_PI / 2 ) *dac = 0xFFFF; else
+ if ( propose < -SGD_PI_2 ) *dac = 0x0000; else
+ if ( propose > SGD_PI_2 ) *dac = 0xFFFF; else
*dac = (unsigned short) ( 32767 *
( 1.0 + sin ( propose ) ) );
}
void FGScenery::unbind() {
}
-void FGScenery::set_center( Point3D p ) {
+void FGScenery::set_center( const Point3D& p ) {
center = p;
sgdVec3 c;
sgdSetVec3(c, p.x(), p.y(), p.z());
}
bool
-FGScenery::get_cart_elevation_m(const sgdVec3 pos, double max_altoff,
+FGScenery::get_cart_elevation_m(const sgdVec3& pos, double max_altoff,
double& alt, bool exact)
{
Point3D saved_center = center;
/// lat/lon pair. If there is no scenery for that point, the altitude
/// value is undefined.
/// All values are meant to be in meters.
- bool get_cart_elevation_m(const sgdVec3 pos, double max_altoff,
+ bool get_cart_elevation_m(const sgdVec3& pos, double max_altoff,
double& radius, bool exact = false);
- inline Point3D get_center() const { return center; }
- void set_center( Point3D p );
+ inline const Point3D& get_center() const { return center; }
+ void set_center( const Point3D& p );
- inline Point3D get_next_center() const { return next_center; }
- inline void set_next_center( Point3D p ) { next_center = p; }
+ inline const Point3D& get_next_center() const { return next_center; }
+ inline void set_next_center( const Point3D& p ) { next_center = p; }
inline ssgRoot *get_scene_graph () const { return scene_graph; }
inline void set_scene_graph (ssgRoot * s) { scene_graph = s; }
public:
inline FGDeferredModel() { }
- inline FGDeferredModel( const string mp, const string tp, SGBucket b,
+ inline FGDeferredModel( const string& mp, const string& tp, SGBucket b,
FGTileEntry *t, ssgTransform *ot )
{
model_path = mp;
obj_trans = ot;
}
inline ~FGDeferredModel() { }
- inline string get_model_path() const { return model_path; }
- inline string get_texture_path() const { return texture_path; }
- inline SGBucket get_bucket() const { return bucket; }
+ inline const string& get_model_path() const { return model_path; }
+ inline const string& get_texture_path() const { return texture_path; }
+ inline const SGBucket& get_bucket() const { return bucket; }
inline FGTileEntry *get_tile() const { return tile; }
inline ssgTransform *get_obj_trans() const { return obj_trans; }
};
/**
* Return the "bucket" for this tile
*/
- inline SGBucket get_tile_bucket() const { return tile_bucket; }
+ inline const SGBucket& get_tile_bucket() const { return tile_bucket; }
/**
* Apply ssgLeaf::makeDList to all leaf of a branch
write8(&data);\r
}\r
\r
-void FGMPSMessageBuf::writes(string data)\r
+void FGMPSMessageBuf::writes(const string& data)\r
{\r
put(data.length());\r
for (int i=0; i<data.length(); i++) put(data[i]);\r
public:\r
\r
FGMPSMessageBuf() { init(""); }\r
- FGMPSMessageBuf(string data) { init(data); }\r
+ FGMPSMessageBuf(const string& data) { init(data); }\r
\r
~FGMPSMessageBuf() {}\r
\r
- void init(string data)\r
+ void init(const string& data)\r
{\r
buf = data;\r
pos = 0;\r
}\r
\r
void clr() { buf = ""; }\r
- void add(string data) { buf += data; }\r
- void set(string data) { buf = data; }\r
- string& str() { return buf; }\r
+ void add(const string& data) { buf += data; }\r
+ void set(const string& data) { buf = data; }\r
+ const string& str() { return buf; }\r
size_t ofs() { return pos; }\r
void ofs(size_t val) { pos = val; }\r
\r
double readd();\r
string reads(size_t length);\r
\r
- string& buffer() { return buf; }\r
+ const string& buffer() { return buf; }\r
};\r
\r
#endif\r
int i, j;
for ( i = 0; i < trans_len; ++i ) {
- float level = ( sin( (double) i * 2.0 * SGD_PI / (BYTES_PER_SECOND / freq) ) )
+ float level = ( sin( (double) i * SGD_2PI / (BYTES_PER_SECOND / freq) ) )
* ((double)i / trans_len) / 2.0 + 0.5;
/* Convert to unsigned byte */
}
for ( i = trans_len; i < len - trans_len; ++i ) {
- float level = ( sin( (double) i * 2.0 * SGD_PI / (BYTES_PER_SECOND / freq) ) )
+ float level = ( sin( (double) i * SGD_2PI / (BYTES_PER_SECOND / freq) ) )
/ 2.0 + 0.5;
/* Convert to unsigned byte */
}
j = trans_len;
for ( i = len - trans_len; i < len; ++i ) {
- float level = ( sin( (double) i * 2.0 * SGD_PI / (BYTES_PER_SECOND / freq) ) )
+ float level = ( sin( (double) i * SGD_2PI / (BYTES_PER_SECOND / freq) ) )
* ((double)j / trans_len) / 2.0 + 0.5;
--j;
FGElectricalComponent();
virtual ~FGElectricalComponent() {}
- inline string get_name() { return name; }
+ inline const string& get_name() { return name; }
inline int get_kind() const { return kind; }
}
inline int get_num_props() const { return props.size(); }
- inline string get_prop( const int i ) {
+ inline const string& get_prop( const int i ) {
return props[i];
}
inline void add_prop( const string &s ) {
# include <math.h>
#endif
-#include <string>
-SG_USING_STD(string);
-
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/interpolater.hxx>
inline double get_sun_gc_lat () const { return _sun_gc_lat; }
inline void set_sun_gc_lat (double l) { _sun_gc_lat = l; }
- inline Point3D get_sunpos () const { return _sunpos; }
- inline void set_sunpos (Point3D p) { _sunpos = p; }
+ inline const Point3D& get_sunpos () const { return _sunpos; }
+ inline void set_sunpos (const Point3D& p) { _sunpos = p; }
inline float *sun_vec () const { return (float *)_sun_vec; }
inline float *sun_vec_inv () const { return (float *)_sun_vec_inv; }
inline double get_moon_gc_lat () const { return _moon_gc_lat; }
inline void set_moon_gc_lat (double l) { _moon_gc_lat = l; }
- inline Point3D get_moonpos () const { return _moonpos; }
- inline void set_moonpos (Point3D p) { _moonpos = p; }
+ inline const Point3D& get_moonpos () const { return _moonpos; }
+ inline void set_moonpos (const Point3D& p) { _moonpos = p; }
inline float *moon_vec () const { return (float *)_moon_vec; }
inline float *moon_vec_inv () const { return (float *)_moon_vec_inv; }
initialized = other.initialized;
}
-FGScheduledFlight::FGScheduledFlight(string cs,
- string fr,
- string depPrt,
- string arrPrt,
+FGScheduledFlight::FGScheduledFlight(const string& cs,
+ const string& fr,
+ const string& depPrt,
+ const string& arrPrt,
int cruiseAlt,
- string deptime,
- string arrtime,
- string rep)
+ const string& deptime,
+ const string& arrtime,
+ const string& rep)
{
callsign = cs;
fltRules = fr;
{
}
-time_t FGScheduledFlight::processTimeString(string theTime)
+time_t FGScheduledFlight::processTimeString(const string& theTime)
{
int weekday;
int timeOffsetInDays;
FGScheduledFlight();
FGScheduledFlight(const FGScheduledFlight &other);
// FGScheduledFlight(const string);
- FGScheduledFlight::FGScheduledFlight(string cs,
- string fr,
- string depPrt,
- string arrPrt,
+ FGScheduledFlight::FGScheduledFlight(const string& cs,
+ const string& fr,
+ const string& depPrt,
+ const string& arrPrt,
int cruiseAlt,
- string deptime,
- string arrtime,
- string rep
+ const string& deptime,
+ const string& arrtime,
+ const string& rep
);
~FGScheduledFlight();
return (departureTime < other.departureTime);
};
- time_t processTimeString(string time);
- string getCallSign() {return callsign; };
+ time_t processTimeString(const string& time);
+ const string& getCallSign() {return callsign; };
};
typedef vector<FGScheduledFlight> FGScheduledFlightVec;
int getCruiseAlt () { return flights.begin()->getCruiseAlt (); };
double getRadius () { return radius; };
double getGroundOffset () { return groundOffset;};
- string getFlightType () { return flightType;};
- string getAirline () { return airline; };
- string getAircraft () { return acType; };
- string getCallSign () { return flights.begin()->getCallSign (); };
- string getRegistration () { return registration;};
+ const string& getFlightType () { return flightType;};
+ const string& getAirline () { return airline; };
+ const string& getAircraft () { return acType; };
+ const string& getCallSign () { return flights.begin()->getCallSign (); };
+ const string& getRegistration () { return registration;};
bool getHeavy () { return heavy; };
bool operator< (const FGAISchedule &other) const { return (distanceToUser < other.distanceToUser); };
//void * getAiRef () { return AIManagerRef; };