diff -u C:/FGCVS/Atlas/src/Atlas.cxx ../../src/Atlas.cxx --- C:/FGCVS/Atlas/src/Atlas.cxx Sun Jan 11 13:39:29 2009 +++ ../../src/Atlas.cxx Sat Jan 17 11:49:35 2009 @@ -19,11 +19,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ---------------------------------------------------------------------------*/ - -#ifdef _MSC_VER - // For access -# include -# define F_OK 00 +#ifdef HAVE_CONFIG_H +#include "config.h" #endif #include @@ -125,6 +122,12 @@ // represents the first tile. unsigned int nthTile = 0; +void atlas_exit( int status ) +{ + prefs.savePreferences(); // output preferences + exit(status); +} + /*****************************************************************************/ /* Convert degrees to dd mm'ss.s" (DMS-Format) */ /*****************************************************************************/ @@ -435,7 +438,11 @@ tile = new Tile(latitude, longitude, prefs); // We always ask for scenery and a hires map. - tasks = Tile::SYNC_SCENERY | Tile::GENERATE_HIRES_MAP; + tasks = 0; +#ifndef NO_RSYNC_APP + tasks = Tile::SYNC_SCENERY; +#endif // #ifndef NO_RSYNC_APP + tasks |= Tile::GENERATE_HIRES_MAP; // Ask for a lowres map only if the user wants them. if (prefs.lowres_map_size != 0) { tasks |= Tile::GENERATE_LOWRES_MAP; @@ -489,6 +496,7 @@ } } +#ifndef NO_RSYNC_APP // Checks to see if we need to download new tiles as our aircraft // moves. This routine expects that the latitude and longitude global // variables contain the aircraft's latest position, and should be @@ -556,6 +564,7 @@ } } } +#endif // #ifndef NO_RSYNC_APP // Updates the sync interface. void updateSyncInterface() { @@ -600,6 +609,7 @@ dial_sync_progress->setValue((float)(progress / 10.0)); progress = (progress + 1) % 10; +#ifndef NO_RSYNC_APP if ((t->taskState() == Tile::CHECKING_OBJECTS) || (t->taskState() == Tile::CHECKING_TERRAIN)) { fbuf << t->toBeSyncedFiles() << " files"; @@ -639,7 +649,9 @@ } txt_sync_files->setLabel(files_str.c_str()); txt_sync_bytes->setLabel(bytes_str.c_str()); - } else if (t->taskState() == Tile::MAPPING) { + } else +#endif // #ifndef NO_RSYNC_APP + if (t->taskState() == Tile::MAPPING) { if (t->currentTask() == Tile::GENERATE_HIRES_MAP) { txt_sync_phase->setLabel("Mapping"); } else { @@ -822,6 +834,12 @@ fileDialog = NULL; } +void save_file_cb_exit(puObject *cb) +{ + save_file_cb(cb); + atlas_exit(0); +} + // Called when the user presses OK or Cancel on the load file dialog. void load_file_cb(puObject *cb) { @@ -1295,11 +1313,13 @@ // Check for input on all live tracks. for (int i = 0; i < tracks.size(); i++) { if (tracks[i]->live() && tracks[i]->checkForInput()) { +#ifndef NO_RSYNC_APP // If we're in terrasync mode, we need to check for // unloaded tiles as the aircraft moves. if (prefs.terrasync_mode) { terrasyncUpdate(); } +#endif // #ifndef NO_RSYNC_APP // If we're in auto-center mode, and this track is the // currently displayed track, then recenter the map. @@ -1550,6 +1570,7 @@ } glutPostRedisplay(); break; +#ifndef NO_RSYNC_APP case 'L': // Show the next downloading tile. nextTile(); @@ -1560,6 +1581,7 @@ toggleTile(latitude * SG_RADIANS_TO_DEGREES, longitude * SG_RADIANS_TO_DEGREES); break; +#endif // #ifndef NO_RSYNC_APP case 'N': case 'n': show_nav->setValue(!show_nav->getValue()); @@ -1576,6 +1598,25 @@ glutPostRedisplay(); } break; + case 'q': + // 20081227 - Added a QUIT key, which SAVES the track, + // or prompts to save the track, if current track is + // NOT NULL or empty(). + if( !track || track->empty() ) + atlas_exit(0); + if (track->hasFile()) { + track->save(); + glutPostWindowRedisplay(graphs_window); + atlas_exit(0); + } else if (fileDialog == NULL) { + fileDialog = new puaFileSelector(250, 150, 500, 400, "", + "Save Flight Track"); + fileDialog->setCallback(save_file_cb_exit); + glutPostRedisplay(); + } else { + atlas_exit(0); + } + break; case 'S': case 's': // We should warn the user if Atlas quits with unsaved tracks. @@ -1715,6 +1756,10 @@ latitude = prefs.latitude * SG_DEGREES_TO_RADIANS; longitude = prefs.longitude * SG_DEGREES_TO_RADIANS; +#ifdef _MSC_VER + check_map_executable( prefs.map_executable.str() ); +#endif // _MSC_VER + glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ); glutInitWindowSize( prefs.width, prefs.height ); main_window = glutCreateWindow( "Atlas" ); @@ -1727,6 +1772,13 @@ glutKeyboardFunc( keyPressed ); glutSpecialFunc( specPressed ); +#ifdef _MSC_VER + glutPositionWindow(0,0); // set window in upper left position, + // so the graph window can fit below it ... in WIN32 + // else the 'graph' window can be OFF SCREEN if this window is too low!!! + // could check the current actual screen size ... some day ... +#endif // _MSC_VER + mapsize = (float)( (prefs.width>prefs.height)?prefs.width:prefs.height ); map_object = new MapBrowser( 0.0f, 0.0f, mapsize, Overlays::OVERLAY_AIRPORTS | @@ -1847,7 +1899,8 @@ // EYE - I wonder if all this setup stuff should be done in a // visibility callback? (see glutVisibilityFunc()). glutSetWindow(main_window); - if (tracks.size() > 0) { + if ((tracks.size() > 0) && ((tracks.size() > 1)|| + (tracks[0] && (tracks[0]->size() > 0)))) { // If we've loaded some tracks, display the first one. setFlightTrack(0); } else { Common subdirectories: C:\FGCVS\Atlas\src\CVS and ..\..\src\CVS Common subdirectories: C:\FGCVS\Atlas\src\data and ..\..\src\data diff -u C:/FGCVS/Atlas/src/FlightTrack.cxx ../../src/FlightTrack.cxx --- C:/FGCVS/Atlas/src/FlightTrack.cxx Thu May 08 09:46:33 2008 +++ ../../src/FlightTrack.cxx Sat Jan 17 16:47:39 2009 @@ -19,7 +19,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ---------------------------------------------------------------------------*/ - +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include @@ -203,6 +205,7 @@ // add some flight data. FlightData tmp; buffer[noOfBytes] = '\0'; + // sprtf("%s\n", buffer); // DEBUG: diagnostic output of udp data if (_parse_message(buffer, &tmp)) { result = true; diff -u C:/FGCVS/Atlas/src/GetMap.cxx ../../src/GetMap.cxx --- C:/FGCVS/Atlas/src/GetMap.cxx Sat Oct 01 08:40:26 2005 +++ ../../src/GetMap.cxx Mon Jan 12 15:06:02 2009 @@ -24,8 +24,13 @@ --------------------------------------------------------------------------- CHANGES + 2009-01-11 Minor changes for WIN32 2005-09-28 Initial version ---------------------------------------------------------------------------*/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#define OUT_HTML_FILE "tempmaps.htm" #include #include @@ -104,8 +109,48 @@ return 0; } +// helper to condition the URL give +void ensure_trailing_at( std::string & s) +{ + std::string::size_type len, ind; + len = s.length(); + if(len) { + len--; + ind = s.find("&"); + if( ind != len ) + s += "&"; + } +} + +size_t _instri( const char * str, char * fnd ) +{ + size_t iret = -1; + if( stricmp( str, fnd ) == 0 ) + iret = 0; + else { + size_t len = strlen(str); + size_t fl = strlen(fnd); + if(len && (len > fl)) { + if(fl == 0) + iret = 0; // everything matches nothing!!! + else { + size_t i, max; + max = len - fl; + for( i = 0; i <= max; i++ ) { + if( strnicmp( &str[i], fnd, fl ) == 0 ) { + iret = i; + break; + } + } + } + } + } + return iret; +} + + int main( int argc, char **argv ) { - if (argc == 0) + if (argc < 5) // need, base url, plus min, max, lat, lon print_help(); // process command line arguments @@ -125,6 +170,11 @@ if ( outp.empty() ) { fprintf(stderr, "%s: --atlas option missing.\n", argv[0]); exit(1); + } else { + if( access(outp.c_str(), F_OK) == -1 ) { + fprintf(stderr, "%s: --atlas=%s directory is NOT accessable.\n", argv[0], outp.c_str()); + exit(1); + } } if ( base_url.empty() ) { @@ -168,24 +218,61 @@ max_lon += 360; } + std::string::size_type indexCh = base_url.find("?"); // is there a '?' + if( indexCh == std::string.npos ) // no, add full command + base_url += "?layers=modis,global_mosaic&styles=default,visual"; + else { + std::string ss = base_url.substr(indexCh+1); // get the SUB-string, after '?' + if( _instri( ss.c_str(), "layers=" ) == -1 ) { + ensure_trailing_at(base_url); + base_url += "layers=modis,global_mosaic"; + } + if( _instri( ss.c_str(), "styles=" ) == -1 ) { + ensure_trailing_at(base_url); + base_url += "styles=default,visual"; + } + } + ensure_trailing_at(base_url); + std::cout << "Getting landsat images from " << base_url.c_str() << std::endl; CURL *ceh = curl_easy_init(); + std::ostringstream html; // for simple HTML output + html << "" << std::endl; + html << "" << std::endl; + html << "Images from landsat" << std::endl; + html << "" << std::endl; + html << "" << std::endl; + html << "

Images from " << max_lat << "," << min_lon << " to " << + min_lon << "," << max_lon << "

" << std::endl; + html << "" << std::endl; + if ( ceh != 0 ) { - for ( int y = min_lat; y < max_lat; y += 1 ) { - for ( int x = min_lon; x < max_lon; x += 1 ) { + for ( int y = max_lat; y > min_lat; y -= 1 ) { // top, down to bottom + html << "" << std::endl; + for ( int x = min_lon; x < max_lon; x += 1 ) { // left, to right int rx = x; if ( rx >= 180 ) { rx -= 360; } std::ostringstream fname; + std::ostringstream fn; // file name ONLY, for HTML output fname << outp << "/" << ( rx < 0 ? "w" : "e" ) << std::setw( 3 ) << std::setfill( '0' ) << abs(rx) << ( y < 0 ? "s" : "n" ) << std::setw( 2 ) << std::setfill( '0' ) << abs(y) << ".jpg"; + fn << ( rx < 0 ? "w" : "e" ) << std::setw( 3 ) << std::setfill( '0' ) << abs(rx) + << ( y < 0 ? "s" : "n" ) << std::setw( 2 ) << std::setfill( '0' ) << abs(y) + << ".jpg"; struct stat stat_buf; - if ( stat( fname.str().c_str(), &stat_buf ) == 0 ) - continue; + if ( stat( fname.str().c_str(), &stat_buf ) == 0 ) { + html << "" << std::endl; + if(verbose) + std::cout << "Skipping existing '" << fname.str().c_str() << "'" << std::endl; + continue; + } std::ostringstream surl; surl << base_url << "REQUEST=GetMap&VERSION=1.1.1&WIDTH=" << size << "&HEIGHT=" << size << "&BBOX=" @@ -200,21 +287,49 @@ curl_easy_setopt( ceh, CURLOPT_PROGRESSDATA, 0 ); //curl_easy_setopt( ceh, CURLOPT_INFILESIZE, -1 ); + if( verbose ) + std::cout << "Fetching '" << fname.str().c_str() << "'" << std::endl; + file_size = 0; memstream.str(""); int success = curl_easy_perform( ceh ); - + html << "" << std::endl; } + html << "" << std::endl; } + // finish off HTML + html << "
"; + html << "\"Existing"; + html << ""; if ( success == 0 ) { char *cType; curl_easy_getinfo( ceh, CURLINFO_CONTENT_TYPE, &cType ); if ( strcmp( cType, "image/jpeg" ) == 0 ) { std::ofstream fstr( fname.str().c_str(), std::ios::binary ); - fstr.write( memstream.str().data(), file_size ); - fstr.close(); - std::cout << "Written '" << fname.str().c_str() << "'" << std::endl; + if( fstr.good() ) { + fstr.write( memstream.str().data(), file_size ); + fstr.close(); + std::cout << "Written '" << fname.str().c_str() << "', size " << + file_size << " bytes." << std::endl; + html << "\"""; + } else { + std::cout << "FAILED Write '" << fname.str().c_str() << "'" << std::endl; + html << "no image"; + } + } else { + std::cout << "FAILED to fetch image/jpeg! Got '" << cType << "'?" << std::endl; + html << "no image"; } + } else { + std::cout << "FAILED to in curl fetch!" << std::endl; + html << "no image"; } + html << "
" << std::endl; + html << "" << std::endl; + html << "" << std::endl; + std::ostringstream htmname; + htmname << outp << "/" << OUT_HTML_FILE; + std::ofstream fil( htmname.str().c_str(), std::ios::out ); + fil.write( html.str().c_str(), html.str().length() ); + fil.close(); + std::cout << "Written '" << htmname.str().c_str() << "'" << std::endl; } } diff -u C:/FGCVS/Atlas/src/Graphs.cxx ../../src/Graphs.cxx --- C:/FGCVS/Atlas/src/Graphs.cxx Sun Jan 11 13:39:29 2009 +++ ../../src/Graphs.cxx Mon Jan 12 19:22:59 2009 @@ -19,7 +19,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ---------------------------------------------------------------------------*/ - +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include //#include SG_GLUT_H #include @@ -448,18 +450,18 @@ // Break it down into an exponent (base-10) and mantissa. int exponent = floor(log10(actual)); - float mantissa = actual / pow(10, exponent); + float mantissa = actual / pow(10.0, exponent); // Our heuristic: good mantissa values are 2, 5, and 10. We move // up from our actual mantissa to the next good mantissa value, // which means that our ticks are spaced no less than 'minimum' // pixels apart. if (mantissa < 2) { - values.d = 2 * pow(10, exponent); + values.d = 2 * pow(10.0, exponent); } else if (mantissa < 5) { - values.d = 5 * pow(10, exponent); + values.d = 5 * pow(10.0, exponent); } else { - values.d = 10 * pow(10, exponent); + values.d = 10 * pow(10.0, exponent); } // Large ticks are always placed every 5 small ticks. values.D = values.d * 5; diff -u C:/FGCVS/Atlas/src/Map.cxx ../../src/Map.cxx --- C:/FGCVS/Atlas/src/Map.cxx Sun Jan 11 13:39:29 2009 +++ ../../src/Map.cxx Sat Jan 17 16:41:11 2009 @@ -34,6 +34,9 @@ 2005-02-26 FB: Arbitrary size by tiling. Move fg_set_scenery to a specific file. ---------------------------------------------------------------------------*/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif // Needs to be included *before* the UL_GLX check! #include @@ -98,6 +101,8 @@ ulDirEnt *ent = NULL; RenderTexture *rt2 = 0; +char * pmap_program = ""; + /*****************************************************************************/ void reshapeMap( int width, int height ) { glViewport( 0, 0, width, height ); @@ -251,6 +256,9 @@ printf(" --jpeg Create JPEG images with default quality (75)\n"); printf(" --jpeg=integer Create JPEG images with specified quality\n"); printf(" --aafactor=integer Do antialiasing on image ( factor must be a power of two )\n"); +#ifdef _MSC_VER + printf(" --version Output version, and exit.\n"); +#endif // _MSC_VER } bool parse_arg(char* arg) { @@ -314,6 +322,13 @@ // Do nothing - only for backwards compatibility } else if ( strcmp(arg, "--disable-navaids" ) == 0 ) { // Do nothing - only for backwards compatibility +#ifdef _MSC_VER + } else if ( strcmp(arg, "--version" ) == 0 ) { + // care with changing this string, as Atlas uses it for verification + printf("%s: version: %s\n", basename(pmap_program), VERSION); + printf("%s\n", get_compiler_version_string().c_str()); + exit(0); +#endif // _MSC_VER } else { return false; } @@ -342,6 +357,7 @@ #ifdef UL_GLX XSetErrorHandler( mapXerrorHandler ); #endif + if( features & MapMaker::DO_VERBOSE ) fprintf(stderr, "Trying size %d : ", tex_size ); while (!(cur_ok = rt2->Initialize(tex_size, tex_size)) && tex_size > 1) { @@ -349,6 +365,7 @@ fprintf( stderr, "Error\n" ); #endif tex_size >>= 1; + if( features & MapMaker::DO_VERBOSE ) fprintf(stderr, "Trying size %d : ", tex_size ); } #ifdef UL_GLX @@ -356,10 +373,11 @@ #endif if ( !cur_ok ) { - fprintf(stderr, "RenderTexture Initialization failed!\n"); + fprintf(stderr, "RenderTexture Initialization failed of size %d!\n", tex_size); } else { + if( features & MapMaker::DO_VERBOSE ) fprintf(stderr, "Ok\n"); } @@ -377,6 +395,7 @@ } int main( int argc, char **argv ) { + pmap_program = argv[0]; if (argc == 0) print_help(); diff -u C:/FGCVS/Atlas/src/MapMaker.cxx ../../src/MapMaker.cxx --- C:/FGCVS/Atlas/src/MapMaker.cxx Sun Jan 11 13:39:29 2009 +++ ../../src/MapMaker.cxx Tue Jan 13 14:17:15 2009 @@ -20,7 +20,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ---------------------------------------------------------------------------*/ - +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include #include @@ -38,6 +40,45 @@ using std::cout; /*#include */ +// Just to REDUCE the REPEATED noise, when verbose is ON +typedef std::map StrMap; + +static StrMap missing_materials; +static StrMap unknown_formats; + +int is_already_in_missing( string s ) +{ + int fnd = 0; + StrMap::iterator it = missing_materials.find(s); + if( it == missing_materials.end() ) + { + missing_materials[s] = 1; + } + else + { + missing_materials[s]++; + fnd = 1; + } + return fnd; +} + +int is_already_in_unknown( char * path ) +{ + int fnd = 0; + string s = path; + StrMap::iterator it = unknown_formats.find(s); + if( it == unknown_formats.end() ) + { + unknown_formats[s] = 1; + } + else + { + unknown_formats[s]++; + fnd = 1; + } + return fnd; +} + // Utility function that I needed to put somewhere - this probably isn't the best place for it. // Appends a path separator to a directory path if not present. // Calling function MUST ENSURE that there is space allocated for the potential strcat. @@ -411,7 +452,7 @@ vector &v, vector &n, int col) { - bool smooth = features & DO_SMOOTH_COLOR; + bool smooth = (features & DO_SMOOTH_COLOR) ? true : false; sgVec3 t[3], nrm[3]; sgVec2 p[3]; int index[3]; @@ -814,8 +855,9 @@ StrMap::const_iterator mat_it = materials.find( tri_mats[i] ); if ( mat_it == materials.end() ) { if (getVerbose()) { - fprintf( stderr, "Warning: unknown material \"%s\" encountered.\n", - tri_mats[i].c_str() ); + if( !is_already_in_missing(tri_mats[i]) ) + fprintf( stderr, "Warning: unknown material \"%s\" encountered in tri_mats.\n", + tri_mats[i].c_str() ); } material = -1; } else { @@ -840,8 +882,9 @@ StrMap::const_iterator mat_it = materials.find( fan_mats[i] ); if ( mat_it == materials.end() ) { if (getVerbose()) { - fprintf( stderr, "Warning: unknown material \"%s\" encountered.\n", - fan_mats[i].c_str() ); + if( !is_already_in_missing( fan_mats[i] ) ) + fprintf( stderr, "Warning: unknown material \"%s\" encountered in fan_mats.\n", + fan_mats[i].c_str() ); } material = -1; } else { @@ -866,8 +909,9 @@ StrMap::const_iterator mat_it = materials.find( strip_mats[i] ); if ( mat_it == materials.end() ) { if (getVerbose()) { - fprintf( stderr, "Warning: unknown material \"%s\" encountered.\n", - strip_mats[i].c_str() ); + if( !is_already_in_missing( strip_mats[i] ) ) + fprintf( stderr, "Warning: unknown material \"%s\" encountered in strip_mats.\n", + strip_mats[i].c_str() ); } material = -1; } else { @@ -1064,6 +1108,15 @@ return 1; } +static int is_scene_terra_gear( char * file ) +{ + size_t len = strlen(file); + if ( len > 4 ) + if ( stricmp( &file[len - 4], ".stg" ) == 0 ) + return 1; + + return 0; +} // path must be to the base of the 10x10/1x1 tile tree - more will be appended. // plen is path length @@ -1100,6 +1153,10 @@ if ( !(stat_buf.st_mode & S_IFREG) ) continue; + /* skip master .stg (scene terra gear) files */ + if ( is_scene_terra_gear( ent->d_name ) ) + continue; + if (getVerbose()) { putc( '.', stdout ); fflush(stdout); @@ -1110,6 +1167,7 @@ if ( !process_binary_file( path, xyz ) ) { if ( !process_ascii_file( path, xyz ) ) { if ( getVerbose() ) + if( !is_already_in_unknown( path ) ) fprintf( stderr, "Tile \"%s\" is of unknown format.\n", path ); } } diff -u C:/FGCVS/Atlas/src/MapPS.cxx ../../src/MapPS.cxx --- C:/FGCVS/Atlas/src/MapPS.cxx Sun Jan 11 13:39:29 2009 +++ ../../src/MapPS.cxx Mon Jan 12 18:56:25 2009 @@ -29,7 +29,9 @@ 2000-04-29 New, cuter, airports 2005-02-26 --fg-scenery option ---------------------------------------------------------------------------*/ - +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include #include diff -u C:/FGCVS/Atlas/src/OutputGL.cxx ../../src/OutputGL.cxx --- C:/FGCVS/Atlas/src/OutputGL.cxx Mon Dec 10 09:14:21 2007 +++ ../../src/OutputGL.cxx Tue Jan 13 15:52:39 2009 @@ -1,3 +1,8 @@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include extern "C" { diff -u C:/FGCVS/Atlas/src/Overlays.cxx ../../src/Overlays.cxx --- C:/FGCVS/Atlas/src/Overlays.cxx Sun Jan 11 13:39:30 2009 +++ ../../src/Overlays.cxx Mon Jan 12 17:27:56 2009 @@ -19,6 +19,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ---------------------------------------------------------------------------*/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include @@ -37,41 +40,6 @@ using std::istringstream; using std::ostringstream; using std::fixed; - - -#ifdef _MSC_VER - - -double rint( double x) -// Copyright (C) 2001 Tor M. Aamodt, University of Toronto -// Permisssion to use for all purposes commercial and otherwise granted. -// THIS MATERIAL IS PROVIDED "AS IS" WITHOUT WARRANTY, OR ANY CONDITION OR -// OTHER TERM OF ANY KIND INCLUDING, WITHOUT LIMITATION, ANY WARRANTY -// OF MERCHANTABILITY, SATISFACTORY QUALITY, OR FITNESS FOR A PARTICULAR -// PURPOSE. -{ - if( x > 0 ) { - __int64 xint = (__int64) (x+0.5); - if( xint % 2 ) { - // then we might have an even number... - double diff = x - (double)xint; - if( diff == -0.5 ) - return double(xint-1); - } - return double(xint); - } else { - __int64 xint = (__int64) (x-0.5); - if( xint % 2 ) { - // then we might have an even number... - double diff = x - (double)xint; - if( diff == 0.5 ) - return double(xint+1); - } - return double(xint); - } -} - -#endif bool Overlays::airports_loaded = false; bool Overlays::navaids_loaded = false; diff -u C:/FGCVS/Atlas/src/Overlays.hxx ../../src/Overlays.hxx --- C:/FGCVS/Atlas/src/Overlays.hxx Sun Jan 11 13:39:30 2009 +++ ../../src/Overlays.hxx Tue Jan 13 13:54:56 2009 @@ -237,8 +237,9 @@ vector tokens; vector matches; void tokenizeLocation(LocationType lType, void *loc, vector &vec); + friend bool operator< (const Overlays::TOKEN& left, const Overlays::TOKEN& right); + }; -bool operator< (const Overlays::TOKEN& left, const Overlays::TOKEN& right); #endif // __OVERLAYS_H__ diff -u C:/FGCVS/Atlas/src/Preferences.cxx ../../src/Preferences.cxx --- C:/FGCVS/Atlas/src/Preferences.cxx Thu Dec 13 14:37:04 2007 +++ ../../src/Preferences.cxx Sat Jan 17 12:54:16 2009 @@ -19,11 +19,14 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ---------------------------------------------------------------------------*/ - +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include -#include "config.h" +#ifndef _MSC_VER #include "libgen.h" +#endif // !_MSC_VER #include // This is a space-saving macro used when parsing command-line @@ -48,9 +51,16 @@ LAT_OPTION, LON_OPTION, AIRPORT_OPTION, PATH_OPTION, FG_ROOT_OPTION, GLUTFONTS_OPTION, GEOMETRY_OPTION, SOFTCURSOR_OPTION, UDP_OPTION, SERIAL_OPTION, BAUD_OPTION, - SQUARE_OPTION, FG_SCENERY_OPTION, SERVER_OPTION, MAP_PATH_OPTION, + SQUARE_OPTION, FG_SCENERY_OPTION, +#ifndef NO_RSYNC_APP + SERVER_OPTION, +#endif // #ifndef NO_RSYNC_APP + MAP_PATH_OPTION, SIZE_OPTION, LOWRES_SIZE_OPTION, MAX_TRACK_OPTION, - TERRASYNC_MODE_OPTION, CONCURRENCY_OPTION, UPDATE_OPTION, +#ifndef NO_RSYNC_APP + TERRASYNC_MODE_OPTION, +#endif // #ifndef NO_RSYNC_APP + CONCURRENCY_OPTION, UPDATE_OPTION, AUTO_CENTER_MODE_OPTION, VERSION_OPTION, HELP_OPTION, LAST_OPTION }; @@ -71,12 +81,16 @@ {"update", required_argument, 0, UPDATE_OPTION}, {"square", no_argument, 0, SQUARE_OPTION}, {"fg-scenery", required_argument, 0, FG_SCENERY_OPTION}, +#ifndef NO_RSYNC_APP {"server", required_argument, 0, SERVER_OPTION}, +#endif // #ifndef NO_RSYNC_APP {"map-executable", required_argument, 0, MAP_PATH_OPTION}, {"size", required_argument, 0, SIZE_OPTION}, {"lowres-size", required_argument, 0, LOWRES_SIZE_OPTION}, {"max-track", required_argument, 0, MAX_TRACK_OPTION}, +#ifndef NO_RSYNC_APP {"terrasync-mode", no_argument, 0, TERRASYNC_MODE_OPTION}, +#endif // #ifndef NO_RSYNC_APP {"concurrency", required_argument, 0, CONCURRENCY_OPTION}, {"autocenter-mode", no_argument, 0, AUTO_CENTER_MODE_OPTION}, {"version", no_argument, 0, VERSION_OPTION}, @@ -88,9 +102,17 @@ printf("usage: %s [--lat=] [--lon=] [--airport=] [--path=]\n", name); printf("\t[--fg-root=] [--glutfonts] [--geometry=x]\n"); printf("\t[--softcursor] [--udp[=]] [--serial=[]] [--baud=]\n"); - printf("\t[--square] [--fg-scenery=] [--server=]\n"); + printf("\t[--square] [--fg-scenery=] "); +#ifndef NO_RSYNC_APP + printf("[--server=]"); +#endif // #ifndef NO_RSYNC_APP + printf("\n"); printf("\t[--map-executable=] [--size=] [--lowres-size=]\n"); - printf("\t[--max-track=] [--terrasync-mode] [--concurrency=]\n"); + printf("\t[--max-track=] "); +#ifndef NO_RSYNC_APP + printf("[--terrasync-mode] "); +#endif // #ifndef NO_RSYNC_APP + printf("[--concurrency=]\n"); printf("\t[--update=] [--autocenter-mode] [--version]\n"); printf("\t[--help] [] ...\n"); } @@ -145,10 +167,12 @@ printf("--fg-scenery=\tLocation of FlightGear scenery (defaults to\n"); printf("\t/Scenery-Terrasync)\n"); break; +#ifndef NO_RSYNC_APP case SERVER_OPTION: printf("--server=\tRsync scenery server (defaults to\n"); printf("\t'scenery.flightgear.org')\n"); break; +#endif // #ifndef NO_RSYNC_APP case MAP_PATH_OPTION: printf("--map-executable=\tLocation of Map executable (defaults to 'Map')\n"); break; @@ -163,10 +187,12 @@ printf("--max-track=\tMaximum number of points to record while tracking a\n"); printf("\tflight (defaults to 2000, 0 = unlimited)\n"); break; +#ifndef NO_RSYNC_APP case TERRASYNC_MODE_OPTION: printf("--terrasync-mode\tDownload scenery while tracking a flight (default is\n"); printf("\tto not download)\n"); break; +#endif // #ifndef NO_RSYNC_APP case CONCURRENCY_OPTION: printf("--concurrency=\tNumber of tiles to simultaneously update (defaults to\n"); printf("\t1, 0 = unlimited)\n"); @@ -184,6 +210,32 @@ } } +static char * atlas_keyboard_help( void ) +{ + static char keyhelp[] = + "Atlas keyboard, when running ...\n" + " +/- Zoom In/Out.\n" + " A/a Toggle Airport show.\n" + " C Toggle Auto Centering.\n" + " c Center Map on Aircraft.\n" + " D/d Toggle Hide/Show the info interface and the graphs window.\n" + " F/f Select the next ('f') or previous ('F') flight track.\n" + " J/j Toggle the search interface.\n" +#ifndef NO_RSYNC_APP + " L Show the next downloading tile.\n" + " l Schedule or de-schedule the 1x1 tile at our current lat/lon for updating.\n" +#endif // #ifndef NO_RSYNC_APP + " N/n Toggle Show Navigation Aids.\n" + " O/o Open a Flight Track File.\n" + " q Quit, prompting for save of any active track.\n" + " S/s Save Flight Track File.\n" + " T/t Toggle Texturing.\n" + " W/w Clear/Close the current track. No warning if the track is unsaved.\n" + " U/u Un-attach (detach) Network, and restart tracking.\n" + " V/v Toggle Show Names.\n"; + return keyhelp; +} + // This prints a long help message. static void print_help() { // EYE - use executable name here? @@ -194,6 +246,7 @@ printf(" "); print_help_for(i); } + printf( atlas_keyboard_help() ); } // All preferences should be given default values here. @@ -225,7 +278,11 @@ // device = strdup("/dev/ttyS0"); // baud = strdup("4800"); _port = 5500; +#ifdef _MSC_VER + _serial.device = strdup("COM1"); +#else // !_MSC_VER _serial.device = strdup("/dev/ttyS0"); +#endif // _MSC_VER y/n _serial.baud = 4800; update = 1.0; mode = MapBrowser::ATLAS; @@ -233,12 +290,16 @@ scenery_root.set(fg_root.str()); scenery_root.append("Scenery-Terrasync"); +#ifndef NO_RSYNC_APP rsync_server = strdup("scenery.flightgear.org"); +#endif // #ifndef NO_RSYNC_APP map_executable.set("Map"); map_size = 256; lowres_map_size = 0; max_track = 2000; +#ifndef NO_RSYNC_APP terrasync_mode = false; +#endif // #ifndef NO_RSYNC_APP concurrency = 1; autocenter_mode = false; } @@ -250,6 +311,32 @@ // Check for a preferences file. char* homedir = getenv("HOME"); SGPath rcpath; + +#ifdef _MSC_VER + std::ifstream locrc("tempatlasrc"); + if (locrc.is_open()) { + char *lines[2]; + string line; + lines[0] = argv[0]; + while (!locrc.eof()) { + getline(locrc, line); + if (line.length() == 0) + continue; + if (line[0] == '#') + continue; + lines[1] = (char *)line.c_str(); + // Try to make sense of it. + if (!_loadPreferences(2, lines)) { + fprintf(stderr, "%s: Error in %s: '%s'.\n", + basename(argv[0]), atlasrc, lines[1]); + locrc.close(); + return false; + } + } + locrc.close(); + } +#endif // _MSC_VER + if (homedir != NULL) { rcpath.set(homedir); rcpath.append(atlasrc); @@ -310,39 +397,86 @@ return _loadPreferences(argc, argv); } +/* ============================================= + Output current settings, per 'rc' file format + ============================================== */ void Preferences::savePreferences() { - printf("%.2f\n", latitude); - printf("%.2f\n", longitude); - printf("%s\n", icao); - printf("%s\n", path.c_str()); - printf("%s\n", fg_root.c_str()); - printf("%d\n", textureFonts); - printf("%d\n", width); - printf("%d\n", height); - printf("%d\n", softcursor); - for (int i = 0; i < networkConnections.size(); i++) { - printf("net: %u\n", networkConnections[i]); - } - for (int i = 0; i < serialConnections.size(); i++) { - printf("serial: %s@%u\n", - serialConnections[i].device, serialConnections[i].baud); - } - printf("%.1f\n", update); - printf("%d\n", mode); - printf("%s\n", scenery_root.c_str()); - printf("%s\n", rsync_server); - printf("%s\n", map_executable.c_str()); - printf("%d\n", map_size); - printf("%d\n", lowres_map_size); - printf("%d\n", max_track); - printf("%d\n", terrasync_mode); - printf("%d\n", concurrency); - printf("%d\n", autocenter_mode); - - for (int i = 0; i < flightFiles.size(); i++) { - printf("%s\n", flightFiles[i].c_str()); - } +#ifdef _MSC_VER + int i; + char * tmprc = "tempatlasrc"; + FILE * fp = fopen( tmprc, "w" ); + if ( fp ) + { + fprintf( fp, "#ATLASRC Version %s\n", VERSION ); + fprintf( fp, "# List of current preferences - \n" ); + // Start browsing at latitude x (deg. south i neg.) + fprintf( fp, "--lat=%.2f\n", latitude ); + // Start browsing at longitude x (deg. west i neg.) + fprintf( fp, "--lon=%.2f\n", longitude ); + // Start browsing at an airport specified by ICAO code icao + fprintf( fp, "--airport=%s\n", icao ); + // Set path for map images + fprintf( fp, "--path=%s\n", path.c_str() ); + // Overrides FG_ROOT environment variable + fprintf( fp, "--fg-root=%s\n", fg_root.c_str() ); + if( !textureFonts ) // Use GLUT bitmap fonts (fast for software rendering) + fprintf( fp, "# " ); + fprintf( fp, "--glutfonts\n" ); + // Set initial window size (geometry) + fprintf( fp, "--geometry=%dx%d\n", width, height ); + if( !softcursor ) // Draw mouse cursor using OpenGL (for fullscreen Voodoo cards) + fprintf( fp, "# " ); + fprintf( fp, "--softcursor\n" ); + + fprintf( fp, "# Networks connections %d\n", networkConnections.size() ); + for (i = 0; i < networkConnections.size(); i++) { + fprintf( fp, "--udp=%u\n", networkConnections[i]) ; // Input read from UDP socket at specified port + } + + fprintf( fp, "# Serial connections %d\n", serialConnections.size() ); + for (i = 0; i < serialConnections.size(); i++) { + fprintf( fp, "--serial=%s\n", serialConnections[i].device ); // Input read from serial port with specified device + fprintf( fp, "--baud=%u\n", serialConnections[i].baud ); // Set serial port baud rate (defaults to 4800) + } + if( !mode ) + fprintf( fp, "# " ); + fprintf( fp, "--square\n" ); // Set square mode (map 1x1 degree area on the whole image) + // to be compatible with images retrieved by GetMap + fprintf( fp, "--fg-scenery=%s\n", scenery_root.c_str() ); // Location of FlightGear scenery +#ifndef NO_RSYNC_APP + fprintf( fp, "--server=%s\n", rsync_server ); // Rsync scenery server +#endif // #ifndef NO_RSYNC_APP + fprintf( fp, "--map-executable=%s\n", map_executable.c_str() ); // Location of Map exe + fprintf( fp, "--size=%d\n", map_size ); // Create maps of size pixels*pixels + fprintf( fp, "--lowres-size=%d\n", lowres_map_size ); // Create lowres maps of size pixels*pixels + // (defaults to 0, meaning don't generate lowres maps) + fprintf( fp, "--max-track=%d\n", max_track ); // Maximum number of points to record + // while tracking a flight (defaults to 2000, 0 = unlimited) +#ifndef NO_RSYNC_APP + if( !terrasync_mode ) // Download scenery while tracking a flight + fprintf( fp, "# " ); // kill it + fprintf( fp, "--terrasync-mode\n" ); // (default is to not download) +#endif // #ifndef NO_RSYNC_APP + fprintf( fp, "--concurrency=%d\n", concurrency ); // Number of tiles to simultaneously update + // (defaults to 1, 0 = unlimited) + if( !autocenter_mode ) // Automatically center map on aircraft + fprintf( fp, "# " ); + fprintf( fp, "--autocenter-mode\n" ); // (default is to not auto-center) + fprintf( fp, "--update=%.1f\n", update ); // Check for position updates every x seconds + // (defaults to 1.0) + fprintf( fp, "# Flight Track file(s) %d\n", flightFiles.size() ); + for (i = 0; i < flightFiles.size(); i++) { + fprintf( fp, "%s\n", flightFiles[i].c_str() ); + } + fprintf( fp, "# eof - end of preferences\n" ); + printf("Preferences written to [%s] file.\n", tmprc ); + } + else + { + printf("WARNING: Failed to write preferences to %s file.\n", tmprc ); + } +#endif // _MSC_VER } // Checks the given set of preferences. Returns true (and sets the @@ -410,7 +544,16 @@ if (optarg) { OPTION_CHECK(sscanf(optarg, "%u", &thisPort), 1, UDP_OPTION); } - networkConnections.push_back(thisPort); + int fnd = 0; // do not generate another UDP connection, + // which then also generates another track for same PORT + for( size_t st = 0; st < networkConnections.size(); st++ ) { + if( networkConnections[st] == thisPort ) { + fnd = 1; + break; + } + } + if( !fnd ) + networkConnections.push_back(thisPort); break; } case SERIAL_OPTION: { @@ -436,10 +579,12 @@ case FG_SCENERY_OPTION: scenery_root.set(optarg); break; +#ifndef NO_RSYNC_APP case SERVER_OPTION: free(rsync_server); rsync_server = strdup(optarg); break; +#endif // #ifndef NO_RSYNC_APP case MAP_PATH_OPTION: map_executable.set(optarg); break; @@ -452,9 +597,11 @@ case MAX_TRACK_OPTION: OPTION_CHECK(sscanf(optarg, "%d", &max_track), 1, MAX_TRACK_OPTION); break; +#ifndef NO_RSYNC_APP case TERRASYNC_MODE_OPTION: terrasync_mode = true; break; +#endif // #ifndef NO_RSYNC_APP case CONCURRENCY_OPTION: OPTION_CHECK(sscanf(optarg, "%d", &concurrency), 1, CONCURRENCY_OPTION); break; @@ -477,7 +624,9 @@ break; default: // We should never get here. - assert(false); + assert(false); // but in case we do + fprintf(stderr, "%s: unknown option!\n", basename(argv[0]) ); + return false; } } while (optind < argc) { diff -u C:/FGCVS/Atlas/src/Preferences.hxx ../../src/Preferences.hxx --- C:/FGCVS/Atlas/src/Preferences.hxx Thu Dec 13 14:37:04 2007 +++ ../../src/Preferences.hxx Tue Jan 13 17:55:46 2009 @@ -99,12 +99,16 @@ float update; int mode; SGPath scenery_root; +//#ifndef NO_RSYNC_APP char *rsync_server; +//#endif // #ifndef NO_RSYNC_APP SGPath map_executable; int map_size; int lowres_map_size; int max_track; +//#ifndef NO_RSYNC_APP bool terrasync_mode; +//#endif // #ifndef NO_RSYNC_APP int concurrency; bool autocenter_mode; diff -u C:/FGCVS/Atlas/src/Projection.cxx ../../src/Projection.cxx --- C:/FGCVS/Atlas/src/Projection.cxx Mon Jan 31 18:28:46 2005 +++ ../../src/Projection.cxx Sun Jan 11 17:14:24 2009 @@ -19,6 +19,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ---------------------------------------------------------------------------*/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include diff -u C:/FGCVS/Atlas/src/Search.cxx ../../src/Search.cxx --- C:/FGCVS/Atlas/src/Search.cxx Fri Aug 03 10:24:24 2007 +++ ../../src/Search.cxx Sun Jan 11 17:29:12 2009 @@ -19,7 +19,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ---------------------------------------------------------------------------*/ - +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include "Search.hxx" // EYE - put in .hxx file? @@ -221,7 +223,7 @@ break; default: char *before = strdup(searchString()); - bool result = _input->checkKey(key, updown); + bool result = _input->checkKey(key, updown) ? true : false; // Hack! PUI will "turn off" the input field if it isn't // active, but we want to force it to keep accepting input. // It also turns off the active widget, so we reset it. diff -u C:/FGCVS/Atlas/src/Tile.cxx ../../src/Tile.cxx --- C:/FGCVS/Atlas/src/Tile.cxx Thu Aug 28 09:52:44 2008 +++ ../../src/Tile.cxx Sat Jan 17 11:06:21 2009 @@ -19,13 +19,19 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ---------------------------------------------------------------------------*/ - +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include #include #include +#ifdef _MSC_VER +#include +#else // !_MSC_VER #include +#endif // _MSC_VER y/n #include @@ -119,9 +125,12 @@ Tile::Task Tile::currentTask() { +#ifndef NO_RSYNC_APP if (_tasks & SYNC_SCENERY) { return SYNC_SCENERY; - } else if (_tasks & GENERATE_HIRES_MAP) { + } else +#endif // #ifndef NO_RSYNC_APP + if (_tasks & GENERATE_HIRES_MAP) { return GENERATE_HIRES_MAP; } else if (_tasks & GENERATE_LOWRES_MAP) { return GENERATE_LOWRES_MAP; @@ -134,6 +143,7 @@ // preparation for the next task. void Tile::nextTask() { +#ifndef NO_RSYNC_APP if (_tasks & SYNC_SCENERY) { _tasks ^= SYNC_SCENERY; @@ -154,7 +164,9 @@ _tasks = NO_TASK; } } - } else if (_tasks & GENERATE_HIRES_MAP) { + } else +#endif // #ifndef NO_RSYNC_APP + if (_tasks & GENERATE_HIRES_MAP) { _tasks ^= GENERATE_HIRES_MAP; } else if (_tasks & GENERATE_LOWRES_MAP) { _tasks ^= GENERATE_LOWRES_MAP; @@ -180,6 +192,9 @@ int setNonBlocking(FILE *f) { +#ifdef _MSC_VER + return 0; // need alternative coding for WIN32 +#else // !_MSC_VER int fd; int flags; @@ -190,6 +205,7 @@ } return fcntl(fd, F_SETFL, flags | O_NONBLOCK); +#endif // _MSC_VER } // Starts the given command using popen, and sets the file descriptor @@ -292,6 +308,7 @@ Tile::Task Tile::doSomeWork() { switch (currentTask()) { +#ifndef NO_RSYNC_APP case SYNC_SCENERY: switch (_taskState) { case NOT_STARTED: @@ -350,6 +367,7 @@ break; } break; +#endif // !NO_RSYNC_APP case GENERATE_HIRES_MAP: case GENERATE_LOWRES_MAP: switch (_taskState) { @@ -373,6 +391,7 @@ return currentTask(); } +#ifndef NO_RSYNC_APP // Starts a "checking" rsync process, for either objects or terrain. void Tile::_startChecking() { @@ -535,6 +554,7 @@ return !_eof; } +#endif // !#ifndef NO_RSYNC_APP // Starts a Map process. void Tile::_startMapping() @@ -564,6 +584,28 @@ // so that Atlas doesn't try to read an incomplete png file. // After the file has been downloaded in its entirety and is // safe for Atlas to read, we rename it. +#ifdef _MSC_VER + // many reason for converting all PATHS back to windows form! + // eg a relative path of "Release/Map/Map.exe" will try to run + // "Release", with command arguments "/Map/Map.exe" + string s = _prefs.map_executable.str(); + set_win_path_sep(s); + cmd << s; + s = _prefs.fg_root.str(); + set_win_path_sep(s); + cmd << " --fg-root=" << s; + s = _prefs.scenery_root.str(); + set_win_path_sep(s); + cmd << " --fg-scenery=" << s + << " --lat=" << _lat + << " --lon=" << _lon; + s = output.str(); + set_win_path_sep(s); + cmd << " --output=" << s + << " --size=" << size + << " --headless --autoscale"; + //cmd << "2>nul"; // maybe not required in WIN32 +#else // !_MSC_VER cmd << _prefs.map_executable.str() << " --fg-root=" << _prefs.fg_root.str() << " --fg-scenery=" << _prefs.scenery_root.str() @@ -574,6 +616,7 @@ << " --headless --autoscale 2> /dev/null"; // EYE - I pipe stderr into /dev/null because I get messages like // this if I try to run more than one instance of Map: +#endif // _MSC_VER y/n // 2007-07-10 17:11:00.547 Map[18200] CFLog (0): CFMessagePort: bootstrap_register(): failed 1103 (0x44f), port = 0x3203, name = 'Map.ServiceProvider' // See /usr/include/servers/bootstrap_defs.h for the error codes. @@ -598,6 +641,7 @@ // We won't try to parse the output, which really isn't very // useful anyway. while (_getRealLine(str)) { + // printf("%s\n", str.c_str() ); // uncomment to SEE what happened } if (_eof) { @@ -616,7 +660,61 @@ dest.concat(".png"); // EYE - Windows? +#ifdef _MSC_VER + // GRM - Try 'ren' (RENAME) in WINDOWS + // while using '/' in paths is ok for lots of windows commands, + // it is NOT true for all, and it seems RENAME is one of them, + // and since SGPath UNCONDITIONALLY uses '/', we have to ... + string src = source.str(); // get SG path string + string dst = dest.str(); // so the PATH can be FIXED + set_win_path_sep( src ); // put them back to WINDOWS form + set_win_path_sep( dst ); + cmd = "ren " + src + " " + dst; + { + // but some more things need to be carefully checked !!! + struct stat sb; + bool ok = false; + string emsg = "not ok"; + if( stat( src.c_str(), &sb ) == 0 ) { + if( sb.st_mode & _S_IFDIR ) + emsg += " is directory!"; + else { // if( !( sb.st_mode & _S_IFDIR ) ) + // ok, it is a FILE, + // but RENAME only works if there is no destination + if( stat( dst.c_str(), &sb ) == 0 ) { + emsg += " destination exists!"; // cannot RENAME to an existing file + if( DeleteFile( dst.c_str() ) ) { // delete it + if( stat( dst.c_str(), &sb ) ) { // and check again + ok = true; + emsg = "all ok"; + } else + emsg += ", HUH!! delete failed!"; + } else + emsg += ", and delete FAILED!"; + } else { + ok = true; // we have a file to RENAME, + // and no current distination file + } + } + } else { + emsg += " source does NOT exist!"; // cannot RENAME what does NOT exist! + } + // finally RENAME if path\file new-name, without the path, so + string tmp = dst; + size_t fnd = tmp.rfind("\\"); // find LAST '\' + if(fnd != -1) + tmp = tmp.substr(fnd + 1); // get ONLY filename + cmd = "ren " + src + " " + tmp; // create WINDOWS command + if ( !ok ) { + fprintf(stderr, "ren error: CMD=[%s], error=%s, bailing\n", + cmd.c_str(), emsg.c_str() ); + _taskState = FINISHED; + return false; + } + } +#else /* !_MSC_VER */ cmd = "mv " + source.str() + " " + dest.str(); +#endif /* _MSC_VER y/n */ if (err = system(cmd.c_str())) { // EYE - need to do more cleanup? fprintf(stderr, "mv error: %d, bailing\n", err); @@ -674,7 +772,8 @@ char buf[24]; uint32_t n; - if (!(f = open(file, O_RDONLY, 0))) { + // WIN32 - default is character mode, so MUST add O_BINARY + if (!(f = open(file, O_RDONLY | O_BINARY, 0))) { return false; } diff -u C:/FGCVS/Atlas/src/Tile.hxx ../../src/Tile.hxx --- C:/FGCVS/Atlas/src/Tile.hxx Thu Dec 13 14:38:27 2007 +++ ../../src/Tile.hxx Mon Jan 12 15:49:35 2009 @@ -44,12 +44,16 @@ class Tile { public: enum TaskState {NOT_STARTED, +#ifndef NO_RSYNC_APP CHECKING_OBJECTS, SYNCING_OBJECTS, CHECKING_TERRAIN, SYNCING_TERRAIN, +#endif // !NO_RSYNC_APP MAPPING, FINISHED}; enum Task {NO_TASK = 0, +#ifndef NO_RSYNC_APP SYNC_SCENERY = 1 << 0, +#endif // !NO_RSYNC_APP GENERATE_HIRES_MAP = 1 << 1, GENERATE_LOWRES_MAP = 1 << 2}; @@ -91,10 +95,12 @@ bool _getRealLine(std::string& str); void _latLonToNames(float latitude, float longitude, char *oneDegName, char *tenDegName); +#ifndef NO_RSYNC_APP void _startChecking(); bool _continueChecking(); void _startSyncing(); bool _continueSyncing(); +#endif // !NO_RSYNC_APP void _startMapping(); bool _continueMapping(); bool _pngSize(const char *file, unsigned int *width, unsigned int *height);