bool XMLLoader::findAirportData(const std::string& aICAO,
const std::string& aFileName, SGPath& aPath)
{
+ string fileName(aFileName);
+ int extPos = fileName.size() - 4;
+ if ((int) fileName.rfind(".xml") != extPos) {
+ fileName.append(".xml");
+ }
+
string_list sc = globals->get_fg_scenery();
char buffer[128];
- ::snprintf(buffer, 128, "%c/%c/%c/%s.%s.xml",
+ ::snprintf(buffer, 128, "%c/%c/%c/%s.%s",
aICAO[0], aICAO[1], aICAO[2],
- aICAO.c_str(), aFileName.c_str());
+ aICAO.c_str(), fileName.c_str());
for (string_list_iterator it = sc.begin(); it != sc.end(); ++it) {
SGPath path(*it);
#include <Scripting/NasalSys.hxx>
#include <Sound/sample_queue.hxx>
#include <Time/sunsolver.hxx>
+#include <Airports/xmlloader.hxx>
#include "fg_init.hxx"
#include "fg_io.hxx"
if (file.extension() != "xml")
file.concat(".xml");
-
- if (file.isRelative()) {
- file = globals->resolve_maybe_aircraft_path(file.str());
+
+ std::string icao = arg->getStringValue("icao");
+ if (icao.empty()) {
+ if (file.isRelative()) {
+ file = globals->resolve_maybe_aircraft_path(file.str());
+ }
+ } else {
+ if (!XMLLoader::findAirportData(icao, file.str(), file)) {
+ SG_LOG(SG_IO, SG_INFO, "loadxml: failed to find airport data for "
+ << file.str() << " at ICAO:" << icao);
+ return false;
+ }
}
-
+
if (!fgValidatePath(file.c_str(), false)) {
SG_LOG(SG_IO, SG_ALERT, "loadxml: reading '" << file.str() << "' denied "
"(unauthorized access)");
string_list path_list = sgPathSplit( s.str() );
fg_scenery.clear();
-
+ SGPropertyNode* sim = fgGetNode("/sim", true);
+
for (unsigned i = 0; i < path_list.size(); i++) {
SGPath path(path_list[i]);
if (!path.exists()) {
// FG_SCENERY=A:B becomes list ["A/Terrain", "A/Objects", "",
// "B/Terrain", "B/Objects", ""]
fg_scenery.push_back("");
+
+ // make scenery dirs available to Nasal
+ sim->removeChild("fg-scenery", i, false);
+ SGPropertyNode* n = sim->getChild("fg-scenery", i, true);
+ n->setStringValue(path.str());
+ n->setAttribute(SGPropertyNode::WRITE, false);
} // of path list iteration
}