1
0
Fork 0

src/AIModel/: fixed some compiler warnings

src/AIModel/AICarrier.cxx
    Avoid warning about unused angle_tdp variable.
src/AIModel/AIFlightPlanCreate.cxx
    Increased a buffer size that was giving warning with snprintf(). Also
    always use sizeof(buffer) instead of duplicating the explicit size.
This commit is contained in:
Julian Smith 2021-12-02 10:14:22 +00:00
parent 05cb7fc2be
commit 77c362a9d4
2 changed files with 8 additions and 8 deletions

View file

@ -268,16 +268,16 @@ void FGAICarrier::update(double dt) {
// the distance from the eyepoint to the flols
double dist_tdp = norm(eyeWrtFlols_tdp);
double angle_tdp = 0;
//double angle_tdp = 0;
// now the angle, positive angles are upwards
if (fabs(dist_tdp) < SGLimits<double>::min()) {
angle_tdp = 0;
//angle_tdp = 0;
}
else {
double sAngle = -eyeWrtFlols_tdp(2) / dist_tdp;
sAngle = SGMiscd::min(1, SGMiscd::max(-1, sAngle));
angle_tdp = SGMiscd::rad2deg(asin(sAngle));
//angle_tdp = SGMiscd::rad2deg(asin(sAngle));
}
// printf("angle %5.2f td angle %5.2f \n", _flols_angle, angle_tdp);
//angle += 1.481; // adjust for FLOLS offset (measured on Nimitz class)

View file

@ -369,7 +369,7 @@ bool FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft * ac, bool firstFlight,
// These can probably be generated on the fly however.
while (taxiRoute.next(node, &route)) {
char buffer[10];
snprintf(buffer, 10, "%d", node->getIndex());
snprintf(buffer, sizeof(buffer), "%d", node->getIndex());
FGAIWaypoint *wpt =
createOnGround(ac, buffer, node->geod(), apt->getElevation(),
ac->getPerformance()->vTaxi());
@ -871,7 +871,7 @@ bool FGAIFlightPlan::createDescent(FGAIAircraft * ac, FGAirport * apt,
double currentDist = i * (newDistance / nPoints);
double currentAltitude = alt - (i * (dAlt / nPoints));
SGGeodesy::direct(origin, azimuth, currentDist, result, dummyAz2);
snprintf(buffer, 16, "descent%03d", i);
snprintf(buffer, sizeof(buffer), "descent%03d", i);
wpt = createInAir(ac, buffer, result, currentAltitude, vDescent);
wpt->setCrossat(currentAltitude);
wpt->setTrackLength((newDistance / nPoints));
@ -923,7 +923,7 @@ bool FGAIFlightPlan::createDescent(FGAIAircraft * ac, FGAirport * apt,
SGGeodesy::direct(secondaryTarget, i,
initialTurnRadius, result, dummyAz2);
snprintf(buffer, 16, "turn%03d", i);
snprintf(buffer, sizeof(buffer), "turn%03d", i);
wpt = createInAir(ac, buffer, result, currentAltitude, vDescent);
wpt->setCrossat(currentAltitude);
wpt->setTrackLength(trackLength);
@ -1011,7 +1011,7 @@ bool FGAIFlightPlan::createLanding(FGAIAircraft * ac, FGAirport * apt,
double vTaxiMetric = vTaxi * SG_KT_TO_MPS;
double decelMetric = decel * SG_KT_TO_MPS;
char buffer[12];
char buffer[20];
if (!apt->hasRunwayWithIdent(activeRunway)) {
SG_LOG(SG_AI, SG_WARN, "FGAIFlightPlan::createLanding: No such runway " << activeRunway << " at " << apt->ident());
return false;
@ -1065,7 +1065,7 @@ bool FGAIFlightPlan::createLanding(FGAIAircraft * ac, FGAirport * apt,
int nPoints = (int)(rolloutDistance/30);
for (int i = 1; i < nPoints; i++) {
snprintf(buffer, 12, "landing%03d", i);
snprintf(buffer, sizeof(buffer), "landing%03d", i);
double t = ((double) i) / nPoints;
coord = rwy->pointOnCenterline(touchdownDistance + (rolloutDistance * t));
double vel = (vTouchdownMetric * (1.0 - t)) + (vTaxiMetric * t);