1
0
Fork 0

Maintenance: runways

whitespace formatting.
increase buf size
convert atoi() to stoi()
This commit is contained in:
Scott Giese 2021-02-21 00:03:47 -06:00
parent 4a2cbc7389
commit eb708eb5fe

View file

@ -25,9 +25,9 @@
#include <config.h>
#endif
#include <cassert>
#include <cstdio> // sprintf()
#include <cstdlib> // atoi()
#include <cassert>
#include <simgear/compiler.h>
@ -38,9 +38,9 @@
#include "runways.hxx"
#include <Airports/airport.hxx>
#include <Navaids/procedure.hxx>
#include <Navaids/navrecord.hxx>
#include <Navaids/NavDataCache.hxx>
#include <Navaids/navrecord.hxx>
#include <Navaids/procedure.hxx>
using std::string;
@ -51,8 +51,7 @@ FGRunway::FGRunway(PositionedID aGuid,
const double width,
const double displ_thresh,
const double stopway,
const int surface_code) :
FGRunwayBase(aGuid, RUNWAY, aIdent, aGeod,
const int surface_code) : FGRunwayBase(aGuid, RUNWAY, aIdent, aGeod,
heading, length, width, surface_code),
_airport(aAirport),
_reciprocal(0),
@ -71,14 +70,15 @@ string FGRunway::reverseIdent(const string& aRunwayIdent)
std::string ident(aRunwayIdent);
char buf[4];
int rn = atoi(ident.substr(0,2).c_str());
int rn = std::stoi(ident.substr(0, 2));
rn += 18;
while (rn > 36) {
rn -= 36;
}
snprintf(buf, sizeof(buf), "%02i", rn);
char buf[16];
snprintf(buf, sizeof(buf) - 1, "%02i", rn);
if (ident.size() == 3) {
char suffix = toupper(ident[2]);
if (suffix == 'L') {
@ -193,12 +193,9 @@ FGRunway::getApproaches(flightgear::ProcedureType type) const
{
FGAirport* apt = airport();
flightgear::ApproachList result;
for (unsigned int i=0; i<apt->numApproaches(); ++i)
{
for (unsigned int i = 0; i < apt->numApproaches(); ++i) {
flightgear::Approach* s = apt->getApproachByIndex(i);
if( s->runway() == this
&& (type == flightgear::PROCEDURE_INVALID || type == s->type()) )
{
if (s->runway() == this && (type == flightgear::PROCEDURE_INVALID || type == s->type())) {
result.push_back(s);
}
} // of approaches at the airport iteration
@ -221,8 +218,7 @@ FGHelipad::FGHelipad(PositionedID aGuid,
const SGGeod& aGeod,
const double heading, const double length,
const double width,
const int surface_code) :
FGRunwayBase(aGuid, HELIPAD, aIdent, aGeod,
const int surface_code) : FGRunwayBase(aGuid, HELIPAD, aIdent, aGeod,
heading, length, width, surface_code)
{
}