} else if ( idle_state == 2 ) {
// start TerraSync up now, so it can be synchronizing shared models
- // and airports data in parallel with a nav-cahce rebuild.
+ // and airports data in parallel with a nav-cache rebuild.
SGPath tsyncCache(globals->get_fg_home());
tsyncCache.append("terrasync-cache.xml");
fgSetString("/sim/terrasync/cache-path", tsyncCache.c_str());
simgear::SGTerraSync* terra_sync = new simgear::SGTerraSync(globals->get_props());
globals->add_subsystem("terrasync", terra_sync);
+
+
terra_sync->bind();
terra_sync->init();
+ // add the terrasync root as a data path so data can be retrieved from it
+ std::string terraSyncDir(fgGetString("/sim/terrasync/scenery-dir"));
+ globals->append_data_path(terraSyncDir);
+
idle_state++;
fgSplashProgress("loading-nav-dat");
#include <simgear/xml/easyxml.hxx>
#include <simgear/threads/SGThread.hxx>
#include <simgear/threads/SGGuard.hxx>
+#include <simgear/scene/tsync/terrasync.hxx>
#include <AIModel/AIAircraft.hxx>
#include <AIModel/AIFlightPlan.hxx>
BOOST_FOREACH(SGPath p, d) {
simgear::Dir d2(p);
+ SG_LOG(SG_AI, SG_INFO, "parsing traffic in:" << p);
simgear::PathList trafficFiles = d2.children(simgear::Dir::TYPE_FILE, ".xml");
BOOST_FOREACH(SGPath xml, trafficFiles) {
readXML(xml.str(), *this);
FGTrafficManager::FGTrafficManager() :
inited(false),
doingInit(false),
+ trafficSyncRequested(false),
waitingMetarTime(0.0),
enabled("/sim/traffic-manager/enabled"),
aiEnabled("/sim/ai/enabled"),
currAircraft = scheduledAircraft.begin();
doingInit = false;
inited = false;
+ trafficSyncRequested = false;
}
void FGTrafficManager::init()
}
assert(!doingInit);
+ simgear::SGTerraSync* terraSync = static_cast<simgear::SGTerraSync*>(globals->get_subsystem("terrasync"));
+
+ if (terraSync) {
+ if (!trafficSyncRequested) {
+ terraSync->scheduleDataDir("AI/Traffic");
+ trafficSyncRequested = true;
+ }
+
+ if (terraSync->isDataDirPending("AI/Traffic")) {
+ return; // remain in the init state
+ }
+
+ SG_LOG(SG_AI, SG_INFO, "Traffic files sync complete");
+ }
+
doingInit = true;
- if (string(fgGetString("/sim/traffic-manager/datafile")).empty()) {
+ if (string(fgGetString("/sim/traffic-manager/datafile")).empty()) {
PathList dirs = globals->get_data_paths("AI/Traffic");
+
+ // temporary flag to restrict loading while traffic data is found
+ // through terrasync /and/ fgdata. Ultimatley we *do* want to be able to
+ // overlay sources.
+
+ if (dirs.size() > 1) {
+ SGPath p = dirs.back();
+ if (simgear::strutils::starts_with(p.str(), globals->get_fg_root())) {
+ dirs.pop_back();
+ }
+ }
+
if (dirs.empty()) {
doingInit = false;
return;
if (!doingInit) {
init();
}
-
- if (!scheduleParser->isFinished()) {
+
+ if (!doingInit || !scheduleParser->isFinished()) {
return;
}