Maintenance: runways
whitespace formatting. increase buf size convert atoi() to stoi()
This commit is contained in:
parent
4a2cbc7389
commit
eb708eb5fe
1 changed files with 112 additions and 116 deletions
|
@ -22,12 +22,12 @@
|
|||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#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,17 +70,18 @@ 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) {
|
||||
while (rn > 36) {
|
||||
rn -= 36;
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "%02i", rn);
|
||||
if(ident.size() == 3) {
|
||||
char buf[16];
|
||||
snprintf(buf, sizeof(buf) - 1, "%02i", rn);
|
||||
|
||||
if (ident.size() == 3) {
|
||||
char suffix = toupper(ident[2]);
|
||||
if(suffix == 'L') {
|
||||
if (suffix == 'L') {
|
||||
buf[2] = 'R';
|
||||
} else if (suffix == 'R') {
|
||||
buf[2] = 'L';
|
||||
|
@ -126,7 +126,7 @@ SGGeod FGRunway::threshold() const
|
|||
|
||||
void FGRunway::setReciprocalRunway(PositionedID other)
|
||||
{
|
||||
assert(_reciprocal==0);
|
||||
assert(_reciprocal == 0);
|
||||
_reciprocal = other;
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ flightgear::SIDList FGRunway::getSIDs() const
|
|||
{
|
||||
FGAirport* apt = airport();
|
||||
flightgear::SIDList result;
|
||||
for (unsigned int i=0; i<apt->numSIDs(); ++i) {
|
||||
for (unsigned int i = 0; i < apt->numSIDs(); ++i) {
|
||||
flightgear::SID* s = apt->getSIDByIndex(i);
|
||||
if (s->isForRunway(this)) {
|
||||
result.push_back(s);
|
||||
|
@ -178,7 +178,7 @@ flightgear::STARList FGRunway::getSTARs() const
|
|||
{
|
||||
FGAirport* apt = airport();
|
||||
flightgear::STARList result;
|
||||
for (unsigned int i=0; i<apt->numSTARs(); ++i) {
|
||||
for (unsigned int i = 0; i < apt->numSTARs(); ++i) {
|
||||
flightgear::STAR* s = apt->getSTARByIndex(i);
|
||||
if (s->isForRunway(this)) {
|
||||
result.push_back(s);
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue