restore consistent coding-style; remove obsolete code; fix typo
This commit is contained in:
parent
d3b2b9f1e3
commit
92510697f3
1 changed files with 22 additions and 33 deletions
|
@ -496,22 +496,22 @@ static naRef f_geodinfo(naContext c, naRef me, int argc, naRef* args)
|
||||||
#undef HASHSET
|
#undef HASHSET
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class AirportInfoFilter : public FGAirport::AirportFilter
|
class AirportInfoFilter : public FGAirport::AirportFilter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AirportInfoFilter() :
|
AirportInfoFilter() : type(FGPositioned::AIRPORT) {
|
||||||
type(FGPositioned::AIRPORT)
|
}
|
||||||
{ }
|
|
||||||
|
virtual FGPositioned::Type minType() const {
|
||||||
virtual FGPositioned::Type minType() const {
|
return type;
|
||||||
return type;
|
}
|
||||||
}
|
|
||||||
|
virtual FGPositioned::Type maxType() const {
|
||||||
virtual FGPositioned::Type maxType() const {
|
return type;
|
||||||
return type;
|
}
|
||||||
}
|
|
||||||
|
FGPositioned::Type type;
|
||||||
FGPositioned::Type type;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Returns data hash for particular or nearest airport of a <type>, or nil
|
// Returns data hash for particular or nearest airport of a <type>, or nil
|
||||||
|
@ -527,7 +527,7 @@ static naRef f_airportinfo(naContext c, naRef me, int argc, naRef* args)
|
||||||
static SGConstPropertyNode_ptr lonn = fgGetNode("/position/longitude-deg", true);
|
static SGConstPropertyNode_ptr lonn = fgGetNode("/position/longitude-deg", true);
|
||||||
SGGeod pos;
|
SGGeod pos;
|
||||||
FGAirport* apt = NULL;
|
FGAirport* apt = NULL;
|
||||||
|
|
||||||
if(argc >= 2 && naIsNum(args[0]) && naIsNum(args[1])) {
|
if(argc >= 2 && naIsNum(args[0]) && naIsNum(args[1])) {
|
||||||
pos = SGGeod::fromDeg(args[1].num, args[0].num);
|
pos = SGGeod::fromDeg(args[1].num, args[0].num);
|
||||||
args += 2;
|
args += 2;
|
||||||
|
@ -541,17 +541,17 @@ static naRef f_airportinfo(naContext c, naRef me, int argc, naRef* args)
|
||||||
AirportInfoFilter filter; // defaults to airports only
|
AirportInfoFilter filter; // defaults to airports only
|
||||||
|
|
||||||
if(argc == 0) {
|
if(argc == 0) {
|
||||||
// fine, just fall through and use AIRPORT
|
// fall through and use AIRPORT
|
||||||
} else if(argc == 1 && naIsString(args[0])) {
|
} else if(argc == 1 && naIsString(args[0])) {
|
||||||
const char *s = naStr_data(args[0]);
|
const char *s = naStr_data(args[0]);
|
||||||
if (!strcmp(s, "airport")) filter.type = FGPositioned::AIRPORT;
|
if(!strcmp(s, "airport")) filter.type = FGPositioned::AIRPORT;
|
||||||
else if(!strcmp(s, "seaport")) filter.type = FGPositioned::SEAPORT;
|
else if(!strcmp(s, "seaport")) filter.type = FGPositioned::SEAPORT;
|
||||||
else if(!strcmp(s, "heliport")) filter.type = FGPositioned::HELIPORT;
|
else if(!strcmp(s, "heliport")) filter.type = FGPositioned::HELIPORT;
|
||||||
else {
|
else {
|
||||||
// user provided an <id>, hopefully
|
// user provided an <id>, hopefully
|
||||||
apt = FGAirport::findByIdent(s);
|
apt = FGAirport::findByIdent(s);
|
||||||
if (!apt) {
|
if (!apt) {
|
||||||
naRuntimeError(c, "airportinfo() couldn't find airport:%s", s);
|
naRuntimeError(c, "airportinfo() couldn't find airport: %s", s);
|
||||||
return naNil();
|
return naNil();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -559,18 +559,18 @@ static naRef f_airportinfo(naContext c, naRef me, int argc, naRef* args)
|
||||||
naRuntimeError(c, "airportinfo() with invalid function arguments");
|
naRuntimeError(c, "airportinfo() with invalid function arguments");
|
||||||
return naNil();
|
return naNil();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!apt) {
|
if(!apt) {
|
||||||
apt = FGAirport::findClosest(pos, maxRange, &filter);
|
apt = FGAirport::findClosest(pos, maxRange, &filter);
|
||||||
if(!apt) return naNil();
|
if(!apt) return naNil();
|
||||||
}
|
}
|
||||||
|
|
||||||
string id = apt->ident();
|
string id = apt->ident();
|
||||||
string name = apt->name();
|
string name = apt->name();
|
||||||
|
|
||||||
// set runway hash
|
// set runway hash
|
||||||
naRef rwys = naNewHash(c);
|
naRef rwys = naNewHash(c);
|
||||||
for (unsigned int r=0; r<apt->numRunways(); ++r) {
|
for(unsigned int r=0; r<apt->numRunways(); ++r) {
|
||||||
FGRunway* rwy(apt->getRunwayByIndex(r));
|
FGRunway* rwy(apt->getRunwayByIndex(r));
|
||||||
|
|
||||||
naRef rwyid = naStr_fromdata(naNewString(c),
|
naRef rwyid = naStr_fromdata(naNewString(c),
|
||||||
|
@ -730,7 +730,7 @@ void FGNasalSys::loadPropertyScripts()
|
||||||
if(n->hasChild("module"))
|
if(n->hasChild("module"))
|
||||||
module = n->getStringValue("module");
|
module = n->getStringValue("module");
|
||||||
|
|
||||||
// allow multiple files to be specified within in a single
|
// allow multiple files to be specified within a single
|
||||||
// Nasal module tag
|
// Nasal module tag
|
||||||
int j = 0;
|
int j = 0;
|
||||||
SGPropertyNode *fn;
|
SGPropertyNode *fn;
|
||||||
|
@ -744,17 +744,6 @@ void FGNasalSys::loadPropertyScripts()
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Old code which only allowed a single file to be specified per module
|
|
||||||
/*
|
|
||||||
const char* file = n->getStringValue("file");
|
|
||||||
if(!n->hasChild("file")) file = 0; // Hrm...
|
|
||||||
if(file) {
|
|
||||||
SGPath p(globals->get_fg_root());
|
|
||||||
p.append(file);
|
|
||||||
loadModule(p, module);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
const char* src = n->getStringValue("script");
|
const char* src = n->getStringValue("script");
|
||||||
if(!n->hasChild("script")) src = 0; // Hrm...
|
if(!n->hasChild("script")) src = 0; // Hrm...
|
||||||
if(src)
|
if(src)
|
||||||
|
|
Loading…
Add table
Reference in a new issue