]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIAircraft.cxx
- Added ultra-light traffic is now a separate traffic class that can have its
[flightgear.git] / src / AIModel / AIAircraft.cxx
index 8cc5089ad4e3c0de814af03691e43b51a29d0417..39c97f8622fd77598caf73e8cd970a7c65a36e99 100644 (file)
@@ -55,8 +55,10 @@ class FP_Inactive{};
 
 FGAIAircraft::FGAIAircraft(FGAISchedule *ref) : FGAIBase(otAircraft) {
     trafficRef = ref;
-    if (trafficRef)
+    if (trafficRef) {
         groundOffset = trafficRef->getGroundOffset();
+       setCallSign(trafficRef->getCallSign());
+    }
     else
         groundOffset = 0;
 
@@ -81,6 +83,7 @@ FGAIAircraft::FGAIAircraft(FGAISchedule *ref) : FGAIBase(otAircraft) {
     holdPos = false;
 
     _performance = 0; //TODO initialize to JET_TRANSPORT from PerformanceDB
+    
 }
 
 
@@ -110,7 +113,6 @@ void FGAIAircraft::bind() {
     props->tie("controls/gear/gear-down",
                SGRawValueMethods<FGAIAircraft,bool>(*this,
                                                     &FGAIAircraft::_getGearDown));
-    props->setStringValue("callsign", callsign.c_str());
 }
 
 
@@ -324,6 +326,8 @@ void FGAIAircraft::loadNextLeg() {
     int leg;
     if ((leg = fp->getLeg())  == 10) {
         trafficRef->next();
+        setCallSign(trafficRef->getCallSign());
+       //props->setStringValue("callsign", callsign.c_str());
         leg = 1;
         fp->setLeg(leg);
     }
@@ -397,11 +401,6 @@ void FGAIAircraft::getGroundElev(double dt) {
 }
 
 
-void FGAIAircraft::setCallSign(const string& s) {
-    callsign = s;
-}
-
-
 void FGAIAircraft::doGroundAltitude() {
     if (fabs(altitude_ft - (tgt_altitude_ft+groundOffset)) > 1000.0)
         altitude_ft = (tgt_altitude_ft + groundOffset);
@@ -692,7 +691,7 @@ void FGAIAircraft::controlHeading(FGAIFlightPlan::waypoint* curr) {
 
     if (finite(calc_bearing)) {
         double hdg_error = calc_bearing - tgt_heading;
-        if (fabs(hdg_error) > 1.0) {
+        if (fabs(hdg_error) > 0.01) {
             TurnTo( calc_bearing );
         }
 
@@ -719,7 +718,9 @@ void FGAIAircraft::controlSpeed(FGAIFlightPlan::waypoint* curr, FGAIFlightPlan::
 
     if (fabs(speed_diff) > 10) {
         prevSpeed = speed;
-        fp->setLeadDistance(speed, tgt_heading, curr, next);
+        if (next) {
+            fp->setLeadDistance(speed, tgt_heading, curr, next);
+        }
     }
 }