Merge branch 'aperry/tsync'
This commit is contained in:
commit
5edbb79ec7
1 changed files with 51 additions and 27 deletions
|
@ -99,6 +99,7 @@ CompletedTiles completedTiles;
|
||||||
apr_pool_t *mysvn_pool = NULL;
|
apr_pool_t *mysvn_pool = NULL;
|
||||||
svn_client_ctx_t *mysvn_ctx = NULL;
|
svn_client_ctx_t *mysvn_ctx = NULL;
|
||||||
svn_opt_revision_t *mysvn_rev = NULL;
|
svn_opt_revision_t *mysvn_rev = NULL;
|
||||||
|
svn_opt_revision_t *mysvn_rev_peg = NULL;
|
||||||
|
|
||||||
static const svn_version_checklist_t mysvn_checklist[] = {
|
static const svn_version_checklist_t mysvn_checklist[] = {
|
||||||
{ "svn_subr", svn_subr_version },
|
{ "svn_subr", svn_subr_version },
|
||||||
|
@ -162,11 +163,17 @@ int mysvn_setup(void) {
|
||||||
mysvn_ctx->auth_baton = ab;
|
mysvn_ctx->auth_baton = ab;
|
||||||
mysvn_ctx->conflict_func = NULL;
|
mysvn_ctx->conflict_func = NULL;
|
||||||
mysvn_ctx->conflict_baton = NULL;
|
mysvn_ctx->conflict_baton = NULL;
|
||||||
|
// Now our magic revisions
|
||||||
mysvn_rev = (svn_opt_revision_t*) apr_palloc(pool,
|
mysvn_rev = (svn_opt_revision_t*) apr_palloc(pool,
|
||||||
sizeof(svn_opt_revision_t));
|
sizeof(svn_opt_revision_t));
|
||||||
if (!mysvn_rev)
|
if (!mysvn_rev)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
mysvn_rev_peg = (svn_opt_revision_t*) apr_palloc(pool,
|
||||||
|
sizeof(svn_opt_revision_t));
|
||||||
|
if (!mysvn_rev_peg)
|
||||||
|
return EXIT_FAILURE;
|
||||||
mysvn_rev->kind = svn_opt_revision_head;
|
mysvn_rev->kind = svn_opt_revision_head;
|
||||||
|
mysvn_rev_peg->kind = svn_opt_revision_unspecified;
|
||||||
// Success if we got this far
|
// Success if we got this far
|
||||||
mysvn_pool = pool;
|
mysvn_pool = pool;
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
@ -200,11 +207,14 @@ void sync_tree(const char* dir) {
|
||||||
if (mysvn_setup() != EXIT_SUCCESS)
|
if (mysvn_setup() != EXIT_SUCCESS)
|
||||||
exit(1);
|
exit(1);
|
||||||
apr_pool_t *subpool = svn_pool_create(mysvn_pool);
|
apr_pool_t *subpool = svn_pool_create(mysvn_pool);
|
||||||
err = svn_client_checkout(NULL,
|
err = svn_client_checkout3(NULL,
|
||||||
command,
|
command,
|
||||||
dest_base_dir,
|
dest_base_dir,
|
||||||
|
mysvn_rev_peg,
|
||||||
mysvn_rev,
|
mysvn_rev,
|
||||||
1,
|
svn_depth_infinity,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
mysvn_ctx,
|
mysvn_ctx,
|
||||||
subpool);
|
subpool);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -428,12 +438,6 @@ int main( int argc, char **argv ) {
|
||||||
source_base = rsync_base;
|
source_base = rsync_base;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We just want one grid square, no FGFS communications
|
|
||||||
if (testing) {
|
|
||||||
sync_areas( 37, -123, 0, 0 );
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Must call this before any other net stuff
|
// Must call this before any other net stuff
|
||||||
netInit( &argc,argv );
|
netInit( &argc,argv );
|
||||||
|
|
||||||
|
@ -458,10 +462,30 @@ int main( int argc, char **argv ) {
|
||||||
int last_lat = nowhere;
|
int last_lat = nowhere;
|
||||||
int last_lon = nowhere;
|
int last_lon = nowhere;
|
||||||
bool recv_msg = false;
|
bool recv_msg = false;
|
||||||
char synced_other = 'J';
|
|
||||||
|
char synced_other;
|
||||||
|
for ( synced_other = 'K'; synced_other <= 'Z'; synced_other++ ) {
|
||||||
|
char dir[512];
|
||||||
|
snprintf( dir, 512, "Airports/%c", synced_other );
|
||||||
|
waitingTiles.push_back( dir );
|
||||||
|
}
|
||||||
|
for ( synced_other = 'A'; synced_other <= 'J'; synced_other++ ) {
|
||||||
|
char dir[512];
|
||||||
|
snprintf( dir, 512, "Airports/%c", synced_other );
|
||||||
|
waitingTiles.push_back( dir );
|
||||||
|
}
|
||||||
|
if ( use_svn ) {
|
||||||
|
waitingTiles.push_back( "Models" );
|
||||||
|
}
|
||||||
|
|
||||||
while ( true ) {
|
while ( true ) {
|
||||||
recv_msg = false;
|
recv_msg = false;
|
||||||
|
if ( testing ) {
|
||||||
|
// No FGFS communications
|
||||||
|
lat = 37;
|
||||||
|
lon = -123;
|
||||||
|
recv_msg = (lat != last_lat) || (lon != last_lon);
|
||||||
|
}
|
||||||
while ( (len = s.recv(msg, maxlen, 0)) >= 0 ) {
|
while ( (len = s.recv(msg, maxlen, 0)) >= 0 ) {
|
||||||
msg[len] = '\0';
|
msg[len] = '\0';
|
||||||
recv_msg = true;
|
recv_msg = true;
|
||||||
|
@ -470,7 +494,8 @@ int main( int argc, char **argv ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( recv_msg ) {
|
if ( recv_msg ) {
|
||||||
if ( lat != last_lat || lon != last_lon ) {
|
// Ignore messages where the location does not change
|
||||||
|
if ( lat != last_lat || lon != last_lon ) {
|
||||||
cout << "pos in msg = " << lat << "," << lon << endl;
|
cout << "pos in msg = " << lat << "," << lon << endl;
|
||||||
std::deque<std::string> oldRequests;
|
std::deque<std::string> oldRequests;
|
||||||
oldRequests.swap( waitingTiles );
|
oldRequests.swap( waitingTiles );
|
||||||
|
@ -499,25 +524,24 @@ int main( int argc, char **argv ) {
|
||||||
waitingTiles.push_back( oldRequests.front() );
|
waitingTiles.push_back( oldRequests.front() );
|
||||||
oldRequests.pop_front();
|
oldRequests.pop_front();
|
||||||
}
|
}
|
||||||
} else if ( !waitingTiles.empty() ) {
|
last_lat = lat;
|
||||||
getWaitingTile();
|
last_lon = lon;
|
||||||
} else {
|
}
|
||||||
if ( last_lat == nowhere || last_lon == nowhere ) {
|
} else
|
||||||
cout << "Waiting for FGFS to finish startup" << endl;
|
|
||||||
}
|
|
||||||
char c;
|
|
||||||
while ( !isdigit( c = ++synced_other ) && !isupper( c ) );
|
|
||||||
|
|
||||||
char dir[512];
|
// No messages inbound, so process some pending work
|
||||||
snprintf( dir, 512, "Airports/%c", c );
|
if ( !waitingTiles.empty() ) {
|
||||||
waitingTiles.push_back( dir );
|
|
||||||
}
|
|
||||||
|
|
||||||
last_lat = lat;
|
|
||||||
last_lon = lon;
|
|
||||||
} else if ( !waitingTiles.empty() ) {
|
|
||||||
getWaitingTile();
|
getWaitingTile();
|
||||||
}
|
} else
|
||||||
|
|
||||||
|
if ( testing ) {
|
||||||
|
exit( 0 );
|
||||||
|
} else
|
||||||
|
|
||||||
|
if ( last_lat == nowhere || last_lon == nowhere ) {
|
||||||
|
cout << "FlightGear is not running, exiting." << endl;
|
||||||
|
exit( 1 );
|
||||||
|
} else
|
||||||
|
|
||||||
ulSleep( 1 );
|
ulSleep( 1 );
|
||||||
} // while true
|
} // while true
|
||||||
|
|
Loading…
Add table
Reference in a new issue