diff --git a/src/AIModel/AIAircraft.cxx b/src/AIModel/AIAircraft.cxx index 1dd60baa8..1223ca52a 100644 --- a/src/AIModel/AIAircraft.cxx +++ b/src/AIModel/AIAircraft.cxx @@ -188,12 +188,12 @@ void FGAIAircraft::setPerformance(const std::string& acType, const std::string& // enough const bool isUserAircraft = (manager == nullptr); - bool outOfSight = false, - flightplanActive = true; + bool flightplanActive = true; // user aircraft speed, heading and position are synchronzied in // FGAIManager::fetchUserState() if (!isUserAircraft) { + bool outOfSight = false; updatePrimaryTargetValues(dt, flightplanActive, outOfSight); // target hdg, alt, speed if (outOfSight) { return; @@ -1057,7 +1057,7 @@ void FGAIAircraft::controlSpeed(FGAIWaypoint* curr, FGAIWaypoint* next) { if (fabs(speed_diff) > 10) { prevSpeed = speed; if (next) { - if (next && !curr->contains("END") && !curr->contains("PushBackPointlegend")) { + if (!curr->contains("END") && !curr->contains("PushBackPointlegend")) { fp->setLeadDistance(speed, tgt_heading, curr, next); } else { // If we are ending in a parking the heading will be a @@ -1183,23 +1183,21 @@ void FGAIAircraft::updateHeading(double dt) { headingChangeRate = -30; } } else { - if (speed != 0) { - if( sign(headingChangeRate) == sign(headingDiff)) { - // left/right change - headingChangeRate = 3 * dt * sign(headingDiff) * -1; - } else { - headingChangeRate -= 3 * dt * sign(headingDiff); - } - /* - if (headingChangeRate > headingDiff || - headingChangeRate < headingDiff) { - headingChangeRate = headingDiff*sign(roll); - } - else { - headingChangeRate += dt * sign(roll); - } - */ + if( sign(headingChangeRate) == sign(headingDiff)) { + // left/right change + headingChangeRate = 3 * dt * sign(headingDiff) * -1; + } else { + headingChangeRate -= 3 * dt * sign(headingDiff); } + /* + if (headingChangeRate > headingDiff || + headingChangeRate < headingDiff) { + headingChangeRate = headingDiff*sign(roll); + } + else { + headingChangeRate += dt * sign(roll); + } + */ } } @@ -1653,4 +1651,4 @@ std::string FGAIAircraft::getTimeString(int timeOffset) tm* timeinfo = gmtime(&rawtime); strftime(ret, 11, "%w/%H:%M:%S", timeinfo); return ret; -} \ No newline at end of file +} diff --git a/src/AIModel/AIWingman.cxx b/src/AIModel/AIWingman.cxx index 3cf282102..889c5231a 100644 --- a/src/AIModel/AIWingman.cxx +++ b/src/AIModel/AIWingman.cxx @@ -280,16 +280,12 @@ void FGAIWingman::formateToAC(double dt){ if(p_agl <= 10 || p_wow == 1) { _height = p_ht; - //cout << "ht case1 " ; - } else if (p_agl > 10 && p_agl <= 150 ) { + } else if (p_agl <= 150 ) { setHt(p_ht, dt, 1.0); - //cout << "ht case2 " ; - } else if (p_agl > 150 && p_agl <= 250) { - setHt(_offsetpos.getElevationFt()+ h_feet, dt, 0.75); - //cout << "ht case3 " ; + } else if (p_agl <= 250) { + setHt(_offsetpos.getElevationFt() + h_feet, dt, 0.75); } else{ - setHt(_offsetpos.getElevationFt()+ h_feet, dt, 0.5); - //cout << "ht case4 " ; + setHt(_offsetpos.getElevationFt() + h_feet, dt, 0.5); } pos.setElevationFt(_height); @@ -404,7 +400,7 @@ void FGAIWingman::Join(double dt) { setPch(angle, dt, _coeff_pch); //cout << _name << " backing up HEADING " << hdg // << " RANGE " << range; - } else if (rel_brg >= -5 || rel_brg <= 5) { + } else if (rel_brg >= -5 && rel_brg <= 5) { // station is in front of us - slow down setSpeed(parent_spd + ((frm_spd/100) * range)); //SGMiscd::clip