diff --git a/Main/GLUTmain.cxx b/Main/GLUTmain.cxx index 86b4131f3..f0d0c6d31 100644 --- a/Main/GLUTmain.cxx +++ b/Main/GLUTmain.cxx @@ -339,7 +339,6 @@ static void fgRenderFrame( void ) { double angle; GLfloat black[4] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat gray90[4] = { 0.9, 0.9, 0.9, 1.0 }; GLfloat terrain_color[4] = { 0.54, 0.44, 0.29, 1.0 }; l = &cur_light_params; @@ -429,12 +428,14 @@ static void fgRenderFrame( void ) { xglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ) ; xglHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ) ; // set base color (I don't think this is doing anything here) - xglMaterialfv (GL_FRONT, GL_AMBIENT, gray90); + xglMaterialfv (GL_FRONT, GL_AMBIENT, white); xglMaterialfv (GL_FRONT, GL_DIFFUSE, white); } else { xglDisable( GL_TEXTURE_2D ); - xglMaterialfv (GL_FRONT, GL_AMBIENT, terrain_color); - xglMaterialfv (GL_FRONT, GL_DIFFUSE, terrain_color); + // xglMaterialfv (GL_FRONT, GL_AMBIENT, terrain_color); + // xglMaterialfv (GL_FRONT, GL_DIFFUSE, terrain_color); + xglMaterialfv (GL_FRONT, GL_AMBIENT, white); + xglMaterialfv (GL_FRONT, GL_DIFFUSE, white); } fgTileMgrRender(); @@ -778,6 +779,11 @@ extern "C" { // $Log$ +// Revision 1.18 1998/05/29 20:37:19 curt +// Tweaked material properties & lighting a bit in GLUTmain.cxx. +// Read airport list into a "map" STL for dynamic list sizing and fast tree +// based lookups. +// // Revision 1.17 1998/05/22 21:28:52 curt // Modifications to use the new fgEVENT_MGR class. // diff --git a/Main/airports.cxx b/Main/airports.cxx index f6e4aa343..b9222dcfe 100644 --- a/Main/airports.cxx +++ b/Main/airports.cxx @@ -41,10 +41,11 @@ fgAIRPORTS::fgAIRPORTS( void ) { // load the data int fgAIRPORTS::load( char *file ) { + fgAIRPORT a; fgOPTIONS *o; char path[256], fgpath[256], line[256]; char id[5]; - double lon, lat, elev; + string id_str; fgFile f; o = ¤t_options; @@ -65,22 +66,13 @@ int fgAIRPORTS::load( char *file ) { } } - size = 0; while ( fggets(f, line, 250) != NULL ) { // printf("%s", line); - if ( size < MAX_AIRPORTS ) { - sscanf( line, "%s %lf %lf %lfl\n", id, &lon, &lat, &elev ); - strcpy(airports[size].id, id); - airports[size].longitude = lon; - airports[size].latitude = lat; - airports[size].elevation = elev; - } else { - fgPrintf( FG_GENERAL, FG_EXIT, - "Overran size of airport list in fgAIRPORTS::load()\n"); - } - - size++; + sscanf( line, "%s %lf %lf %lfl\n", id, &a.longitude, &a.latitude, + &a.elevation ); + id_str = id; + airports[id_str] = a; } fgclose(f); @@ -91,16 +83,17 @@ int fgAIRPORTS::load( char *file ) { // search for the specified id fgAIRPORT fgAIRPORTS::search( char *id ) { + map < string, fgAIRPORT, less > :: iterator find; fgAIRPORT a; - int i; - for ( i = 0; i < size; i++ ) { - if ( strcmp(airports[i].id, id) == 0 ) { - return(airports[i]); - } + find = airports.find(id); + if ( find == airports.end() ) { + // not found + a.longitude = a.latitude = a.elevation = 0; + } else { + a = (*find).second; } - strcpy(a.id, "none"); return(a); } @@ -111,6 +104,11 @@ fgAIRPORTS::~fgAIRPORTS( void ) { // $Log$ +// Revision 1.5 1998/05/29 20:37:22 curt +// Tweaked material properties & lighting a bit in GLUTmain.cxx. +// Read airport list into a "map" STL for dynamic list sizing and fast tree +// based lookups. +// // Revision 1.4 1998/05/13 18:26:25 curt // Root path info moved to fgOPTIONS. // diff --git a/Main/airports.hxx b/Main/airports.hxx index af4ea1eb0..b4e2686c1 100644 --- a/Main/airports.hxx +++ b/Main/airports.hxx @@ -34,18 +34,25 @@ #endif -#define MAX_AIRPORTS 10000 +#include // STL associative "array" + +#if defined(__CYGWIN32__) +# include // Standard C++ string library +#elif defined(WIN32) +# include // Standard C++ string library +#else +# include // Standard C++ string library +#endif typedef struct { - char id[5]; + // char id[5]; double longitude, latitude, elevation; } fgAIRPORT; class fgAIRPORTS { - fgAIRPORT airports[MAX_AIRPORTS]; - int size; + map < string, fgAIRPORT, less > airports; public: @@ -68,6 +75,11 @@ public: // $Log$ +// Revision 1.2 1998/05/29 20:37:22 curt +// Tweaked material properties & lighting a bit in GLUTmain.cxx. +// Read airport list into a "map" STL for dynamic list sizing and fast tree +// based lookups. +// // Revision 1.1 1998/04/25 15:11:11 curt // Added an command line option to set starting position based on airport ID. // diff --git a/Main/fg_init.cxx b/Main/fg_init.cxx index 8a7af36bb..8110bedfe 100644 --- a/Main/fg_init.cxx +++ b/Main/fg_init.cxx @@ -146,7 +146,9 @@ int fgInitPosition( void ) { airports.load("Airports"); a = airports.search(o->airport_id); - if ( strcmp(a.id, "none") == 0 ) { + if ( (fabs(a.longitude) < FG_EPSILON) && + (fabs(a.latitude) < FG_EPSILON) && + (fabs(a.elevation) < FG_EPSILON) ) { fgPrintf( FG_GENERAL, FG_EXIT, "Failed to find %s in database.\n", o->airport_id); } else { @@ -384,6 +386,11 @@ int fgInitSubsystems( void ) { // $Log$ +// Revision 1.16 1998/05/29 20:37:24 curt +// Tweaked material properties & lighting a bit in GLUTmain.cxx. +// Read airport list into a "map" STL for dynamic list sizing and fast tree +// based lookups. +// // Revision 1.15 1998/05/22 21:28:53 curt // Modifications to use the new fgEVENT_MGR class. //