X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAirports%2Fxmlloader.cxx;h=198f81c9e7b6fda4d00bdadf33bd0126202fc986;hb=43c47f3823faa0829aada79d64a26c2960d2a1d2;hp=205defa8207c2d9fb68c96a67aad9139d5ad7dd1;hpb=4238a46faa8fc8e9ac9174fe960eb7c5df188a4c;p=flightgear.git diff --git a/src/Airports/xmlloader.cxx b/src/Airports/xmlloader.cxx index 205defa82..198f81c9e 100644 --- a/src/Airports/xmlloader.cxx +++ b/src/Airports/xmlloader.cxx @@ -14,7 +14,9 @@ // #include + #include
+#include
#include "xmlloader.hxx" #include "dynamicloader.hxx" @@ -26,40 +28,90 @@ XMLLoader::XMLLoader() {} XMLLoader::~XMLLoader() {} -void XMLLoader::load(FGAirportDynamics* d) { - FGAirportDynamicsXMLLoader visitor(d); +string XMLLoader::expandICAODirs(const string in){ + //cerr << "Expanding " << in << endl; + if (in.size() == 4) { + char buffer[11]; + snprintf(buffer, 11, "%c/%c/%c", in[0], in[1], in[2]); + //cerr << "result: " << buffer << endl; + return string(buffer); + } else { + return in; + } + //exit(1); +} - SGPath parkpath( globals->get_fg_root() ); - parkpath.append( "/AI/Airports/" ); - parkpath.append( d->getId() ); - parkpath.append( "parking.xml" ); - - if (parkpath.exists()) { - try { - readXML(parkpath.str(), visitor); - d->init(); - } catch (const sg_exception &e) { - //cerr << "unable to read " << parkpath.str() << endl; +void XMLLoader::load(FGAirportDynamics* d) { + FGAirportDynamicsXMLLoader visitor(d); + if (fgGetBool("/sim/traffic-manager/use-custom-scenery-data") == false) { + SGPath parkpath( globals->get_fg_root() ); + parkpath.append( "/AI/Airports/" ); + parkpath.append( d->getId() ); + parkpath.append( "parking.xml" ); + if (parkpath.exists()) { + try { + readXML(parkpath.str(), visitor); + d->init(); + } + catch (const sg_exception &e) { + } + } else { + string_list sc = globals->get_fg_scenery(); + char buffer[32]; + snprintf(buffer, 32, "%s.groundnet.xml", d->getId().c_str() ); + string airportDir = XMLLoader::expandICAODirs(d->getId()); + for (string_list_iterator i = sc.begin(); i != sc.end(); i++) { + SGPath parkpath( *i ); + parkpath.append( "Airports" ); + parkpath.append ( airportDir ); + parkpath.append( string (buffer) ); + if (parkpath.exists()) { + try { + readXML(parkpath.str(), visitor); + d->init(); + } + catch (const sg_exception &e) { + } + return; + } + } + } } - } - } void XMLLoader::load(FGRunwayPreference* p) { - FGRunwayPreferenceXMLLoader visitor(p); - - SGPath rwyPrefPath( globals->get_fg_root() ); - rwyPrefPath.append( "AI/Airports/" ); - rwyPrefPath.append( p->getId() ); - rwyPrefPath.append( "rwyuse.xml" ); - - //if (ai_dirs.find(id.c_str()) != ai_dirs.end() - // && rwyPrefPath.exists()) - if (rwyPrefPath.exists()) { - try { - readXML(rwyPrefPath.str(), visitor); - } catch (const sg_exception &e) { - //cerr << "unable to read " << rwyPrefPath.str() << endl; + FGRunwayPreferenceXMLLoader visitor(p); + if (fgGetBool("/sim/traffic-manager/use-custom-scenery-data") == false) { + SGPath rwyPrefPath( globals->get_fg_root() ); + rwyPrefPath.append( "AI/Airports/" ); + rwyPrefPath.append( p->getId() ); + rwyPrefPath.append( "rwyuse.xml" ); + if (rwyPrefPath.exists()) { + try { + readXML(rwyPrefPath.str(), visitor); + } + catch (const sg_exception &e) { + } + } + } else { + string_list sc = globals->get_fg_scenery(); + char buffer[32]; + snprintf(buffer, 32, "%s.rwyuse.xml", p->getId().c_str() ); + string airportDir = expandICAODirs(p->getId()); + for (string_list_iterator i = sc.begin(); i != sc.end(); i++) { + SGPath rwypath( *i ); + rwypath.append( "Airports" ); + rwypath.append ( airportDir ); + rwypath.append( string(buffer) ); + if (rwypath.exists()) { + try { + readXML(rwypath.str(), visitor); + } + catch (const sg_exception &e) { + } + return; + } + } } - } } +