]> git.mxchange.org Git - flightgear.git/commitdiff
traffic: more pass by reference + member init
authorThorstenB <brehmt@gmail.com>
Sun, 25 Nov 2012 15:41:10 +0000 (16:41 +0100)
committerThorstenB <brehmt@gmail.com>
Sun, 25 Nov 2012 15:41:10 +0000 (16:41 +0100)
src/AIModel/AIAircraft.cxx
src/AIModel/AIAircraft.hxx
src/AIModel/AIFlightPlan.cxx
src/AIModel/AIFlightPlan.hxx
src/ATC/trafficcontrol.cxx
src/ATC/trafficcontrol.hxx
src/Traffic/SchedFlight.cxx

index 7622402474324c561b0d2073323e7c82fe9bcc96..2ad2b489ddaeafc856239f1048051499afcf51a7 100644 (file)
@@ -96,6 +96,7 @@ FGAIAircraft::FGAIAircraft(FGAISchedule *ref) :
     takeOffStatus = 0;
 
     trackCache.remainingLength = 0;
+    trackCache.startWptName = "-";
 }
 
 
@@ -631,7 +632,7 @@ void FGAIAircraft::scheduleForATCTowerDepartureControl(int state) {
 
 // Process ATC instructions and report back
 
-void FGAIAircraft::processATC(FGATCInstruction instruction) {
+void FGAIAircraft::processATC(const FGATCInstruction& instruction) {
     if (instruction.getCheckForCircularWait()) {
         // This is not exactly an elegant solution, 
         // but at least it gives me a chance to check
index 3ce0d62832aaaf2d8aa8383a62a0f18325c04bcc..3a149857fdd1b02d3bcae508894d146cd167ad4b 100644 (file)
@@ -73,7 +73,7 @@ public:
     void setCompany(const std::string& comp) { company = comp;};
 
     void announcePositionToController(); //TODO have to be public?
-    void processATC(FGATCInstruction instruction);
+    void processATC(const FGATCInstruction& instruction);
     void setTaxiClearanceRequest(bool arg) { needsTaxiClearance = arg; };
     bool getTaxiClearanceRequest() { return needsTaxiClearance; };
     FGAISchedule * getTrafficRef() { return trafficRef; };
index 5e17a3d9aff7b11c8c764d85828477edb9ba0623..f2e5421d72fe77fa06693d0aa0790b1cb56f7777 100644 (file)
@@ -447,7 +447,7 @@ int FGAIFlightPlan::getRouteIndex(int i) {
     return 0;
 }
 
-double FGAIFlightPlan::checkTrackLength(const string& wptName) {
+double FGAIFlightPlan::checkTrackLength(const string& wptName) const {
     // skip the first two waypoints: first one is behind, second one is partially done;
     double trackDistance = 0;
     wpt_vector_iterator wptvec = waypoints.begin();
@@ -471,7 +471,7 @@ void FGAIFlightPlan::shortenToFirst(unsigned int number, string name)
     (waypoints.back())->setName((waypoints.back())->getName() + name);
 }
 
-void FGAIFlightPlan::setGate(ParkingAssignment pka)
+void FGAIFlightPlan::setGate(const ParkingAssignment& pka)
 {
   gate = pka;
 }
index 120e80851dc243c775326eca7fc2a9e44ef8a732..7c9881ada3235b5b4bc5c51f8cf6f391c43e5328 100644 (file)
@@ -130,7 +130,7 @@ public:
    double getBearing(FGAIWaypoint* previous, FGAIWaypoint* next) const;
    double getBearing(const SGGeod& aPos, FGAIWaypoint* next) const;
   
-   double checkTrackLength(const std::string& wptName);
+   double checkTrackLength(const std::string& wptName) const;
   time_t getStartTime() const { return start_time; }
    time_t getArrivalTime() const { return arrivalTime; }
 
@@ -173,7 +173,7 @@ public:
   
   void shortenToFirst(unsigned int number, std::string name);
 
-  void setGate(ParkingAssignment pka);
+  void setGate(const ParkingAssignment& pka);
   FGParking* getParkingGate();
 
 private:
index e475763f778f2788bb935d036cc9381350d524d1..8d5c801fb373f8bcd086f17bd4c28a783fb549b5 100644 (file)
@@ -179,7 +179,9 @@ FGTrafficRecord::FGTrafficRecord():
         allowTransmission(true),
         allowPushback(true),
         priority(0),
-        latitude(0), longitude(0), heading(0), speed(0), altitude(0), radius(0)
+        timer(0),
+        latitude(0), longitude(0), heading(0), speed(0), altitude(0), radius(0),
+        aircraft(NULL)
 {
 }
 
@@ -413,7 +415,7 @@ bool FGTrafficRecord::isOpposing(FGGroundNetwork * net,
     return false;
 }
 
-bool FGTrafficRecord::isActive(int margin)
+bool FGTrafficRecord::isActive(int margin) const
 {
     time_t now = time(NULL) + fgGetLong("/sim/time/warp");
     time_t deptime = aircraft->getTrafficRef()->getDepartureTime();
@@ -433,7 +435,7 @@ void FGTrafficRecord::setHeadingAdjustment(double heading)
     instruction.setHeading(heading);
 }
 
-bool FGTrafficRecord::pushBackAllowed()
+bool FGTrafficRecord::pushBackAllowed() const
 {
     return allowPushback;
 }
@@ -460,7 +462,7 @@ FGATCInstruction::FGATCInstruction()
 }
 
 
-bool FGATCInstruction::hasInstruction()
+bool FGATCInstruction::hasInstruction() const
 {
     return (holdPattern || holdPosition || changeSpeed || changeHeading
             || changeAltitude || resolveCircularWait);
@@ -481,6 +483,8 @@ FGATCController::FGATCController()
     available = true;
     lastTransmission = 0;
     initialized = false;
+    lastTransmissionDirection = ATC_AIR_TO_GROUND;
+    group = NULL;
 }
 
 FGATCController::~FGATCController()
index 26d40001584a387deb96fdfceac1a307dc46ba99..3d58d58068fd0a9ed911c50fbe45376d30ab0d7e 100644 (file)
@@ -67,34 +67,34 @@ private:
 public:
 
     FGATCInstruction();
-    bool hasInstruction   ();
-    bool getHoldPattern   () {
+    bool hasInstruction   () const;
+    bool getHoldPattern   () const {
         return holdPattern;
     };
-    bool getHoldPosition  () {
+    bool getHoldPosition  () const {
         return holdPosition;
     };
-    bool getChangeSpeed   () {
+    bool getChangeSpeed   () const {
         return changeSpeed;
     };
-    bool getChangeHeading () {
+    bool getChangeHeading () const {
         return changeHeading;
     };
-    bool getChangeAltitude() {
+    bool getChangeAltitude() const {
         return changeAltitude;
     };
 
-    double getSpeed       () {
+    double getSpeed       () const {
         return speed;
     };
-    double getHeading     () {
+    double getHeading     () const {
         return heading;
     };
-    double getAlt         () {
+    double getAlt         () const {
         return alt;
     };
 
-    bool getCheckForCircularWait() {
+    bool getCheckForCircularWait() const {
         return resolveCircularWait;
     };
 
@@ -192,34 +192,34 @@ public:
     int  crosses                   (FGGroundNetwork *, FGTrafficRecord &other);
     bool isOpposing                (FGGroundNetwork *, FGTrafficRecord &other, int node);
     
-    bool isActive(int margin);
+    bool isActive(int margin) const;
 
     bool onRoute(FGGroundNetwork *, FGTrafficRecord &other);
 
-    bool getSpeedAdjustment() {
+    bool getSpeedAdjustment() const {
         return instruction.getChangeSpeed();
     };
 
-    double getLatitude () {
+    double getLatitude () const {
         return latitude ;
     };
-    double getLongitude() {
+    double getLongitude() const {
         return longitude;
     };
-    double getHeading  () {
+    double getHeading  () const {
         return heading  ;
     };
-    double getSpeed    () {
+    double getSpeed    () const {
         return speed    ;
     };
-    double getAltitude () {
+    double getAltitude () const {
         return altitude ;
     };
-    double getRadius   () {
+    double getRadius   () const {
         return radius   ;
     };
 
-    int getWaitsForId  () {
+    int getWaitsForId  () const {
         return waitsForId;
     };
 
@@ -232,10 +232,10 @@ public:
         instruction.setChangeHeading(false);
     };
 
-    bool hasHeadingAdjustment() {
+    bool hasHeadingAdjustment() const {
         return instruction.getChangeHeading();
     };
-    bool hasHoldPosition() {
+    bool hasHoldPosition() const {
         return instruction.getHoldPosition();
     };
     void setHoldPosition (bool inst) {
@@ -253,7 +253,7 @@ public:
         instruction.setResolveCircularWait(false);
     };
 
-    const std::string& getRunway() {
+    const std::string& getRunway() const {
         return runway;
     };
     //void setCallSign(string clsgn) { callsign = clsgn; };
@@ -265,21 +265,21 @@ public:
         allowTransmission=true;
     };
     //string getCallSign() { return callsign; };
-    FGAIAircraft *getAircraft() {
+    FGAIAircraft *getAircraft() const {
         return aircraft;
     };
-    int getTime() {
+    int getTime() const {
         return timer;
     };
-    int getLeg() {
+    int getLeg() const {
         return leg;
     };
     void setTime(time_t time) {
         timer = time;
     };
 
-    bool pushBackAllowed();
-    bool allowTransmissions() {
+    bool pushBackAllowed() const;
+    bool allowTransmissions() const {
         return allowTransmission;
     };
     void allowPushBack() { allowPushback =true;};
@@ -293,17 +293,17 @@ public:
     void nextFrequency() {
         frequencyId++;
     };
-    int  getNextFrequency() {
+    int  getNextFrequency() const {
         return frequencyId;
     };
     intVec& getIntentions() {
         return intentions;
     };
-    int getCurrentPosition() {
+    int getCurrentPosition() const {
         return currentPos;
     };
     void setPriority(int p) { priority = p; };
-    int getPriority()       { return priority; };
+    int getPriority() const { return priority; };
 };
 
 typedef std::list<FGTrafficRecord> TrafficVector;
index 6ca4ed0a60589b0a1e97c27d2bb2935fa859deeb..784c1443aed4bb4c67b2b4af57981252b16ce41c 100644 (file)
@@ -79,6 +79,8 @@ FGScheduledFlight::FGScheduledFlight()
     repeatPeriod   = 0;
     initialized = false;
     available = true;
+    departurePort = NULL;
+    arrivalPort = NULL;
 }
   
 FGScheduledFlight::FGScheduledFlight(const FGScheduledFlight &other)