Improve the terrasync strategy
This commit is contained in:
parent
cde8b0c54a
commit
155701aaeb
1 changed files with 28 additions and 25 deletions
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
#include <plib/netSocket.h>
|
#include <plib/netSocket.h>
|
||||||
#include <plib/ul.h>
|
#include <plib/ul.h>
|
||||||
|
@ -87,6 +88,8 @@ static void usage( const string& prog ) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::queue<std::string> waitingTiles;
|
||||||
|
|
||||||
#ifdef HAVE_SVN_CLIENT_H
|
#ifdef HAVE_SVN_CLIENT_H
|
||||||
|
|
||||||
// Things we need for doing subversion checkout - often
|
// Things we need for doing subversion checkout - often
|
||||||
|
@ -328,18 +331,13 @@ static void sync_area( int lat, int lon ) {
|
||||||
baselon = (int)(lon / 10) * 10;
|
baselon = (int)(lon / 10) * 10;
|
||||||
EW = 'e';
|
EW = 'e';
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* terrainobjects[3] = { "Terrain", "Objects", 0 };
|
|
||||||
const char** tree;
|
|
||||||
char dir[512];
|
char dir[512];
|
||||||
|
snprintf( dir, 512, "%c%03d%c%02d/%c%03d%c%02d",
|
||||||
for (tree = &terrainobjects[0]; *tree; tree++) {
|
EW, abs(baselon), NS, abs(baselat),
|
||||||
snprintf( dir, 512, "%s/%c%03d%c%02d/%c%03d%c%02d",
|
EW, abs(lon), NS, abs(lat) );
|
||||||
*tree,
|
|
||||||
EW, abs(baselon), NS, abs(baselat),
|
waitingTiles.push( dir );
|
||||||
EW, abs(lon), NS, abs(lat) );
|
|
||||||
sync_tree(dir);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -440,7 +438,7 @@ 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;
|
||||||
int synced_other = 0;
|
char synced_other = 'K';
|
||||||
|
|
||||||
while ( true ) {
|
while ( true ) {
|
||||||
recv_msg = false;
|
recv_msg = false;
|
||||||
|
@ -449,11 +447,12 @@ int main( int argc, char **argv ) {
|
||||||
recv_msg = true;
|
recv_msg = true;
|
||||||
|
|
||||||
parse_message( msg, &lat, &lon );
|
parse_message( msg, &lat, &lon );
|
||||||
cout << "pos in msg = " << lat << "," << lon << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( recv_msg ) {
|
if ( recv_msg ) {
|
||||||
if ( lat != last_lat || lon != last_lon ) {
|
if ( lat != last_lat || lon != last_lon ) {
|
||||||
|
cout << "pos in msg = " << lat << "," << lon << endl;
|
||||||
|
waitingTiles.c.clear();
|
||||||
int lat_dir, lon_dir, dist;
|
int lat_dir, lon_dir, dist;
|
||||||
if ( last_lat == nowhere || last_lon == nowhere ) {
|
if ( last_lat == nowhere || last_lon == nowhere ) {
|
||||||
lat_dir = lon_dir = 0;
|
lat_dir = lon_dir = 0;
|
||||||
|
@ -477,18 +476,23 @@ int main( int argc, char **argv ) {
|
||||||
sync_areas( lat, lon, lat_dir, lon_dir );
|
sync_areas( lat, lon, lat_dir, lon_dir );
|
||||||
} else if ( last_lat == nowhere || last_lon == nowhere ) {
|
} else if ( last_lat == nowhere || last_lon == nowhere ) {
|
||||||
cout << "Waiting for FGFS to finish startup" << endl;
|
cout << "Waiting for FGFS to finish startup" << endl;
|
||||||
} else {
|
} else if ( !waitingTiles.empty() ) {
|
||||||
switch (synced_other++) {
|
const char* terrainobjects[3] = { "Terrain", "Objects", 0 };
|
||||||
case 0:
|
const char** tree;
|
||||||
sync_tree((char*) "Airports/K");
|
char dir[512];
|
||||||
break;
|
|
||||||
case 1:
|
for (tree = &terrainobjects[0]; *tree; tree++) {
|
||||||
sync_tree((char*) "Airports");
|
snprintf( dir, 512, "%s/%s", *tree, waitingTiles.front().c_str() );
|
||||||
break;
|
sync_tree(dir);
|
||||||
default:
|
|
||||||
cout << "Done non-tile syncs" << endl;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
waitingTiles.pop();
|
||||||
|
} else {
|
||||||
|
char c;
|
||||||
|
while ( !isdigit( c = synced_other++ ) && !isupper( c ) );
|
||||||
|
|
||||||
|
char dir[512];
|
||||||
|
snprintf( dir, 512, "Airports/%c", c );
|
||||||
|
sync_tree( dir );
|
||||||
}
|
}
|
||||||
|
|
||||||
last_lat = lat;
|
last_lat = lat;
|
||||||
|
@ -500,4 +504,3 @@ int main( int argc, char **argv ) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue