terrasync improvements
Detach from console to make "Ctrl-C" work for fgfs on Linux. Immediately start synchronization of current position when starting at run-time.
This commit is contained in:
parent
a4b788980c
commit
3477e1a4f5
@ -486,7 +486,18 @@ bool SGTerraSync::SvnThread::syncTreeExternal(const char* dir)
|
||||
command = buf.str();
|
||||
#endif
|
||||
SG_LOG(SG_TERRAIN,SG_DEBUG, "sync command '" << command << "'");
|
||||
|
||||
#ifdef SG_WINDOWS
|
||||
// tbd: does Windows support "popen"?
|
||||
int rc = system( command.c_str() );
|
||||
#else
|
||||
FILE* pipe = popen( command.c_str(), "r");
|
||||
int rc=-1;
|
||||
// wait for external process to finish
|
||||
if (pipe)
|
||||
rc = pclose(pipe);
|
||||
#endif
|
||||
|
||||
if (rc)
|
||||
{
|
||||
SG_LOG(SG_TERRAIN,SG_ALERT,
|
||||
@ -701,12 +712,21 @@ void SGTerraSync::reinit()
|
||||
_svnThread->setExtSvnUtility(_terraRoot->getStringValue("ext-svn-utility","svn"));
|
||||
|
||||
if (_svnThread->start())
|
||||
{
|
||||
syncAirportsModels();
|
||||
if (last_lat != NOWHERE && last_lon != NOWHERE)
|
||||
{
|
||||
// reschedule most recent position
|
||||
int lat = last_lat;
|
||||
int lon = last_lon;
|
||||
last_lat = NOWHERE;
|
||||
last_lon = NOWHERE;
|
||||
schedulePosition(lat, lon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_stalled_node->setBoolValue(_svnThread->_stalled);
|
||||
last_lat = NOWHERE;
|
||||
last_lon = NOWHERE;
|
||||
}
|
||||
|
||||
void SGTerraSync::bind()
|
||||
@ -897,18 +917,20 @@ void SGTerraSync::syncAreas( int lat, int lon, int lat_dir, int lon_dir )
|
||||
|
||||
bool SGTerraSync::schedulePosition(int lat, int lon)
|
||||
{
|
||||
bool Ok = false;
|
||||
|
||||
// Ignore messages where the location does not change
|
||||
if ( lat != last_lat || lon != last_lon )
|
||||
{
|
||||
if (_svnThread->_running)
|
||||
{
|
||||
SG_LOG(SG_TERRAIN,SG_DEBUG, "Requesting scenery update for position " <<
|
||||
lat << "," << lon);
|
||||
int lat_dir, lon_dir, dist;
|
||||
if ( last_lat == NOWHERE || last_lon == NOWHERE )
|
||||
int lat_dir=0;
|
||||
int lon_dir=0;
|
||||
if ( last_lat != NOWHERE && last_lon != NOWHERE )
|
||||
{
|
||||
lat_dir = lon_dir = 0;
|
||||
} else
|
||||
{
|
||||
dist = lat - last_lat;
|
||||
int dist = lat - last_lat;
|
||||
if ( dist != 0 )
|
||||
{
|
||||
lat_dir = dist / abs(dist);
|
||||
@ -933,10 +955,11 @@ bool SGTerraSync::schedulePosition(int lat, int lon)
|
||||
"lon_dir = " << lon_dir);
|
||||
|
||||
syncAreas( lat, lon, lat_dir, lon_dir );
|
||||
|
||||
Ok = true;
|
||||
}
|
||||
last_lat = lat;
|
||||
last_lon = lon;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user