1
0
Fork 0

AIWingman Join bug fix

Also removal of redundant code (always true conditions).
This commit is contained in:
Scott Giese 2021-12-26 12:41:06 -06:00
parent 27b518e306
commit f008531fd5
2 changed files with 23 additions and 29 deletions

View file

@ -188,12 +188,12 @@ void FGAIAircraft::setPerformance(const std::string& acType, const std::string&
// enough // enough
const bool isUserAircraft = (manager == nullptr); const bool isUserAircraft = (manager == nullptr);
bool outOfSight = false, bool flightplanActive = true;
flightplanActive = true;
// user aircraft speed, heading and position are synchronzied in // user aircraft speed, heading and position are synchronzied in
// FGAIManager::fetchUserState() // FGAIManager::fetchUserState()
if (!isUserAircraft) { if (!isUserAircraft) {
bool outOfSight = false;
updatePrimaryTargetValues(dt, flightplanActive, outOfSight); // target hdg, alt, speed updatePrimaryTargetValues(dt, flightplanActive, outOfSight); // target hdg, alt, speed
if (outOfSight) { if (outOfSight) {
return; return;
@ -1057,7 +1057,7 @@ void FGAIAircraft::controlSpeed(FGAIWaypoint* curr, FGAIWaypoint* next) {
if (fabs(speed_diff) > 10) { if (fabs(speed_diff) > 10) {
prevSpeed = speed; prevSpeed = speed;
if (next) { if (next) {
if (next && !curr->contains("END") && !curr->contains("PushBackPointlegend")) { if (!curr->contains("END") && !curr->contains("PushBackPointlegend")) {
fp->setLeadDistance(speed, tgt_heading, curr, next); fp->setLeadDistance(speed, tgt_heading, curr, next);
} else { } else {
// If we are ending in a parking the heading will be a // If we are ending in a parking the heading will be a
@ -1183,23 +1183,21 @@ void FGAIAircraft::updateHeading(double dt) {
headingChangeRate = -30; headingChangeRate = -30;
} }
} else { } else {
if (speed != 0) { if( sign(headingChangeRate) == sign(headingDiff)) {
if( sign(headingChangeRate) == sign(headingDiff)) { // left/right change
// left/right change headingChangeRate = 3 * dt * sign(headingDiff) * -1;
headingChangeRate = 3 * dt * sign(headingDiff) * -1; } else {
} else { headingChangeRate -= 3 * dt * sign(headingDiff);
headingChangeRate -= 3 * dt * sign(headingDiff);
}
/*
if (headingChangeRate > headingDiff ||
headingChangeRate < headingDiff) {
headingChangeRate = headingDiff*sign(roll);
}
else {
headingChangeRate += dt * sign(roll);
}
*/
} }
/*
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); tm* timeinfo = gmtime(&rawtime);
strftime(ret, 11, "%w/%H:%M:%S", timeinfo); strftime(ret, 11, "%w/%H:%M:%S", timeinfo);
return ret; return ret;
} }

View file

@ -280,16 +280,12 @@ void FGAIWingman::formateToAC(double dt){
if(p_agl <= 10 || p_wow == 1) { if(p_agl <= 10 || p_wow == 1) {
_height = p_ht; _height = p_ht;
//cout << "ht case1 " ; } else if (p_agl <= 150 ) {
} else if (p_agl > 10 && p_agl <= 150 ) {
setHt(p_ht, dt, 1.0); setHt(p_ht, dt, 1.0);
//cout << "ht case2 " ; } else if (p_agl <= 250) {
} else if (p_agl > 150 && p_agl <= 250) { setHt(_offsetpos.getElevationFt() + h_feet, dt, 0.75);
setHt(_offsetpos.getElevationFt()+ h_feet, dt, 0.75);
//cout << "ht case3 " ;
} else{ } else{
setHt(_offsetpos.getElevationFt()+ h_feet, dt, 0.5); setHt(_offsetpos.getElevationFt() + h_feet, dt, 0.5);
//cout << "ht case4 " ;
} }
pos.setElevationFt(_height); pos.setElevationFt(_height);
@ -404,7 +400,7 @@ void FGAIWingman::Join(double dt) {
setPch(angle, dt, _coeff_pch); setPch(angle, dt, _coeff_pch);
//cout << _name << " backing up HEADING " << hdg //cout << _name << " backing up HEADING " << hdg
// << " RANGE " << range; // << " 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 // station is in front of us - slow down
setSpeed(parent_spd + ((frm_spd/100) * range)); setSpeed(parent_spd + ((frm_spd/100) * range));
//SGMiscd::clip //SGMiscd::clip