Initial hacking on terra-sync of traffic files.
This commit is contained in:
parent
b35119d408
commit
f6fafffeb5
3 changed files with 43 additions and 4 deletions
src
|
@ -128,7 +128,7 @@ static void fgIdleFunction ( void ) {
|
|||
} 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());
|
||||
|
@ -136,9 +136,15 @@ static void fgIdleFunction ( void ) {
|
|||
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");
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#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>
|
||||
|
@ -371,6 +372,7 @@ private:
|
|||
|
||||
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);
|
||||
|
@ -412,6 +414,7 @@ private:
|
|||
FGTrafficManager::FGTrafficManager() :
|
||||
inited(false),
|
||||
doingInit(false),
|
||||
trafficSyncRequested(false),
|
||||
waitingMetarTime(0.0),
|
||||
enabled("/sim/traffic-manager/enabled"),
|
||||
aiEnabled("/sim/ai/enabled"),
|
||||
|
@ -478,6 +481,7 @@ void FGTrafficManager::shutdown()
|
|||
currAircraft = scheduledAircraft.begin();
|
||||
doingInit = false;
|
||||
inited = false;
|
||||
trafficSyncRequested = false;
|
||||
}
|
||||
|
||||
void FGTrafficManager::init()
|
||||
|
@ -487,9 +491,36 @@ 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()) {
|
||||
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;
|
||||
|
@ -650,7 +681,7 @@ void FGTrafficManager::update(double dt)
|
|||
init();
|
||||
}
|
||||
|
||||
if (!scheduleParser->isFinished()) {
|
||||
if (!doingInit || !scheduleParser->isFinished()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,6 +80,8 @@ class FGTrafficManager : public SGSubsystem
|
|||
private:
|
||||
bool inited;
|
||||
bool doingInit;
|
||||
bool trafficSyncRequested;
|
||||
|
||||
double waitingMetarTime;
|
||||
std::string waitingMetarStation;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue