From: curt Date: Thu, 12 Feb 1998 21:58:27 +0000 (+0000) Subject: Incorporated code changes contributed by Charlie Hotchkiss X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=913fe75558df520f5b30927d8fd9852b01bf448a;p=flightgear.git Incorporated code changes contributed by Charlie Hotchkiss --- diff --git a/Aircraft/aircraft.c b/Aircraft/aircraft.c index 5d478b832..edd8cd332 100644 --- a/Aircraft/aircraft.c +++ b/Aircraft/aircraft.c @@ -39,7 +39,7 @@ fgAIRCRAFT current_aircraft; void fgAircraftInit( void ) { fgPrintf( FG_AIRCRAFT, FG_INFO, "Initializing Aircraft structure\n" ); - current_aircraft.flight = &cur_flight_params; + current_aircraft.flight = &cur_flight_params; current_aircraft.controls = &cur_control_params; } @@ -64,10 +64,14 @@ void fgAircraftOutputCurrent(fgAIRCRAFT *a) { /* $Log$ -/* Revision 1.16 1998/02/07 15:29:31 curt -/* Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss +/* Revision 1.17 1998/02/12 21:59:31 curt +/* Incorporated code changes contributed by Charlie Hotchkiss /* /* + * Revision 1.16 1998/02/07 15:29:31 curt + * Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss + * + * * Revision 1.15 1998/01/27 00:47:46 curt * Incorporated Paul Bleisch's new debug message * system and commandline/config file processing code. diff --git a/Astro/orbits.c b/Astro/orbits.c index 6c82f79a4..50da74503 100644 --- a/Astro/orbits.c +++ b/Astro/orbits.c @@ -101,6 +101,8 @@ double fgCalcEccAnom(double M, double e) } +// This function assumes that if the FILE ptr is valid that the contents +// will be valid. Should we check the file for validity? void fgReadOrbElements(struct OrbElements *dest, FILE *src) { @@ -119,49 +121,51 @@ void fgReadOrbElements(struct OrbElements *dest, FILE *src) } while (!(strlen(line))); sscanf(line, "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf\n", - &dest->NFirst, &dest->NSec, - &dest->iFirst, &dest->iSec, - &dest->wFirst, &dest->wSec, - &dest->aFirst, &dest->aSec, - &dest->eFirst, &dest->eSec, - &dest->MFirst, &dest->MSec); + &dest->NFirst, &dest->NSec, + &dest->iFirst, &dest->iSec, + &dest->wFirst, &dest->wSec, + &dest->aFirst, &dest->aSec, + &dest->eFirst, &dest->eSec, + &dest->MFirst, &dest->MSec); } -void fgSolarSystemInit(struct fgTIME t) +int fgSolarSystemInit(struct fgTIME t) { - struct fgGENERAL *g; - char path[80]; - int i; - FILE *data; + struct fgGENERAL *g; + char path[80]; + int i; + FILE *data; + int ret_val = 0; - fgPrintf( FG_ASTRO, FG_INFO, "Initializing solar system\n"); + fgPrintf( FG_ASTRO, FG_INFO, "Initializing solar system\n"); /* build the full path name to the orbital elements database file */ - g = &general; - path[0] = '\0'; - strcat(path, g->root_dir); - strcat(path, "/Scenery/"); - strcat(path, "Planets.dat"); - - if ( (data = fopen(path, "r")) == NULL ) - { - fgPrintf( FG_ASTRO, FG_ALERT, - "Cannot open data file: '%s'\n", path); - return; - } - /* printf(" reading datafile %s\n", path); */ - fgPrintf( FG_ASTRO, FG_INFO, " reading datafile %s\n", path); - - /* for all the objects... */ - for (i = 0; i < 9; i ++) - { - /* ...read from the data file ... */ - fgReadOrbElements(&pltOrbElements[i], data); - /* ...and calculate the actual values */ - fgSolarSystemUpdate(&pltOrbElements[i], t); - } + g = &general; + path[0] = '\0'; + strcat(path, g->root_dir); + strcat(path, "/Scenery/"); + strcat(path, "Planets.dat"); + if ( (data = fopen(path, "r")) == NULL ) + { + fgPrintf( FG_ASTRO, FG_ALERT, + "Cannot open data file: '%s'\n", path); + } else { + /* printf(" reading datafile %s\n", path); */ + fgPrintf( FG_ASTRO, FG_INFO, " reading datafile %s\n", path); + + /* for all the objects... */ + for (i = 0; i < 9; i ++) + { + /* ...read from the data file ... */ + fgReadOrbElements(&pltOrbElements[i], data); + /* ...and calculate the actual values */ + fgSolarSystemUpdate(&pltOrbElements[i], t); + } + ret_val = 1; + } + return ret_val; } @@ -183,12 +187,16 @@ void fgSolarSystemUpdate(struct OrbElements *planet, struct fgTIME t) /* $Log$ -/* Revision 1.6 1998/02/03 23:20:11 curt -/* Lots of little tweaks to fix various consistency problems discovered by -/* Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper -/* passed arguments along to the real printf(). Also incorporated HUD changes -/* by Michele America. +/* Revision 1.7 1998/02/12 21:59:33 curt +/* Incorporated code changes contributed by Charlie Hotchkiss +/* /* + * Revision 1.6 1998/02/03 23:20:11 curt + * Lots of little tweaks to fix various consistency problems discovered by + * Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper + * passed arguments along to the real printf(). Also incorporated HUD changes + * by Michele America. + * * Revision 1.5 1998/02/02 20:53:22 curt * To version 0.29 * diff --git a/Astro/orbits.h b/Astro/orbits.h index fcabc6593..658edd311 100644 --- a/Astro/orbits.h +++ b/Astro/orbits.h @@ -73,7 +73,7 @@ double fgCalcEccAnom(double M, double e); double fgCalcActTime(struct fgTIME t); void fgReadOrbElements(struct OrbElements *dest, FILE *src); -void fgSolarSystemInit(struct fgTIME t); +int fgSolarSystemInit(struct fgTIME t); void fgSolarSystemUpdate(struct OrbElements *planets, struct fgTIME t); @@ -81,9 +81,13 @@ void fgSolarSystemUpdate(struct OrbElements *planets, struct fgTIME t); /* $Log$ -/* Revision 1.4 1998/02/02 20:53:22 curt -/* To version 0.29 +/* Revision 1.5 1998/02/12 21:59:35 curt +/* Incorporated code changes contributed by Charlie Hotchkiss +/* /* + * Revision 1.4 1998/02/02 20:53:22 curt + * To version 0.29 + * * Revision 1.3 1998/01/22 02:59:27 curt * Changed #ifdef FILE_H to #ifdef _FILE_H * diff --git a/Astro/planets.c b/Astro/planets.c index 90dea620a..0def3af76 100644 --- a/Astro/planets.c +++ b/Astro/planets.c @@ -131,7 +131,7 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet, fgPrintf( FG_ASTRO, FG_ALERT, "index %d out of range !!!!\n", idx); } fgPrintf( FG_ASTRO, FG_DEBUG, - " Planet found at %f (ra), %f (dec)\n", + " Planet found at %f (ra), %f (dec)\n", result.RightAscension, result.Declination); fgPrintf( FG_ASTRO, FG_DEBUG, " Geocentric dist %f\n" @@ -188,7 +188,7 @@ void fgPlanetsInit( void ) xglVertex3f( 50000.0 * cos(pltPos.RightAscension) * cos(pltPos.Declination), - 50000.0 * sin(pltPos.RightAscension) * + 50000.0 * sin(pltPos.RightAscension) * cos(pltPos.Declination), 50000.0 * sin(pltPos.Declination) ); } @@ -204,12 +204,16 @@ void fgPlanetsRender( void ) { /* $Log$ -/* Revision 1.5 1998/02/03 23:20:12 curt -/* Lots of little tweaks to fix various consistency problems discovered by -/* Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper -/* passed arguments along to the real printf(). Also incorporated HUD changes -/* by Michele America. +/* Revision 1.6 1998/02/12 21:59:36 curt +/* Incorporated code changes contributed by Charlie Hotchkiss +/* /* + * Revision 1.5 1998/02/03 23:20:12 curt + * Lots of little tweaks to fix various consistency problems discovered by + * Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper + * passed arguments along to the real printf(). Also incorporated HUD changes + * by Michele America. + * * Revision 1.4 1998/02/02 20:53:23 curt * To version 0.29 * diff --git a/Astro/planets.h b/Astro/planets.h index c5468ad6d..bdd1d7b5e 100644 --- a/Astro/planets.h +++ b/Astro/planets.h @@ -32,17 +32,21 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet, struct fgTIME t, int idx); -void fgPlanetsInit(); -void fgPlanetsRender(); +void fgPlanetsInit( void ); +void fgPlanetsRender( void ); #endif /* PLANETS_H */ /* $Log$ -/* Revision 1.3 1998/02/02 20:53:23 curt -/* To version 0.29 +/* Revision 1.4 1998/02/12 21:59:38 curt +/* Incorporated code changes contributed by Charlie Hotchkiss +/* /* + * Revision 1.3 1998/02/02 20:53:23 curt + * To version 0.29 + * * Revision 1.2 1998/01/22 02:59:28 curt * Changed #ifdef FILE_H to #ifdef _FILE_H * diff --git a/Astro/stars.c b/Astro/stars.c index 8b23ffdcc..420c95168 100644 --- a/Astro/stars.c +++ b/Astro/stars.c @@ -56,7 +56,7 @@ /* Initialize the Star Management Subsystem */ -void fgStarsInit( void ) { +int fgStarsInit( void ) { FILE *fd; struct fgGENERAL *g; /* struct CelestialCoord pltPos; */ @@ -81,15 +81,15 @@ void fgStarsInit( void ) { max_stars = FG_MAX_STARS; for ( i = 0; i < FG_STAR_LEVELS; i++ ) { - fgPrintf( FG_ASTRO, FG_INFO, + fgPrintf( FG_ASTRO, FG_INFO, " Loading %d Stars: %s\n", max_stars, path); if ( (fd = fopen(path, "r")) == NULL ) { - fgPrintf( FG_ASTRO, FG_ALERT, + fgPrintf( FG_ASTRO, FG_ALERT, "Cannot open star file: '%s'\n", path); - return; + return 0; // Oops, lets not even try to continue. This is critical. } - + stars[i] = xglGenLists(1); xglNewList( stars[i], GL_COMPILE ); xglBegin( GL_POINTS ); @@ -114,7 +114,7 @@ void fgStarsInit( void ) { /* blank line */ } else { /* star data line */ - + /* get name */ end = front; while ( end[0] != ',' ) { @@ -125,24 +125,24 @@ void fgStarsInit( void ) { front = end; front++; - sscanf(front, "%lf,%lf,%lf\n", + sscanf(front, "%lf,%lf,%lf\n", &right_ascension, &declination, &magnitude); /* - if ( strcmp(name, "Betelgeuse") == 0 ) { - printf(" *** Marking %s\n", name); - ra_save = right_ascension; - decl_save = declination; - } - */ + if ( strcmp(name, "Betelgeuse") == 0 ) { + printf(" *** Marking %s\n", name); + ra_save = right_ascension; + decl_save = declination; + } + */ /* - if ( strcmp(name, "Alnilam") == 0 ) { - printf(" *** Marking %s\n", name); - ra_save1 = right_ascension; - decl_save1 = declination; - } - */ + if ( strcmp(name, "Alnilam") == 0 ) { + printf(" *** Marking %s\n", name); + ra_save1 = right_ascension; + decl_save1 = declination; + } + */ /* scale magnitudes to (0.0 - 1.0) */ magnitude = (0.0 - magnitude) / 5.0 + 1.0; @@ -150,19 +150,19 @@ void fgStarsInit( void ) { /* scale magnitudes again so they look ok */ if ( magnitude > 1.0 ) { magnitude = 1.0; } if ( magnitude < 0.0 ) { magnitude = 0.0; } - magnitude = + magnitude = magnitude * 0.7 + (((FG_STAR_LEVELS - 1) - i) * 0.1); /* printf(" Found star: %d %s, %.3f %.3f %.3f\n", count, - name, right_ascension, declination, magnitude); */ + name, right_ascension, declination, magnitude); */ xglColor3f( magnitude, magnitude, magnitude ); /*xglColor3f(0,0,0);*/ xglVertex3f( 50000.0 * cos(right_ascension) * cos(declination), 50000.0 * sin(right_ascension) * cos(declination), 50000.0 * sin(declination) ); - + count++; - } /* if valid line */ + } // valid line } /* while */ @@ -205,11 +205,13 @@ void fgStarsInit( void ) { 50000.0 * sin(decl_save1+0.2) ); xglEnd(); */ - + xglEndList(); max_stars /= 2; } + + return 1; // OK, we got here because initialization worked. } @@ -253,9 +255,13 @@ void fgStarsRender( void ) { /* $Log$ -/* Revision 1.7 1998/02/09 15:07:48 curt -/* Minor tweaks. +/* Revision 1.8 1998/02/12 21:59:38 curt +/* Incorporated code changes contributed by Charlie Hotchkiss +/* /* + * Revision 1.7 1998/02/09 15:07:48 curt + * Minor tweaks. + * * Revision 1.6 1998/02/02 20:53:23 curt * To version 0.29 * diff --git a/Astro/stars.h b/Astro/stars.h index e510f7b56..b56934cc3 100644 --- a/Astro/stars.h +++ b/Astro/stars.h @@ -33,7 +33,7 @@ #define FG_MIN_STAR_MAG 0.738750 /* magnitude of weakest star we'll display */ /* Initialize the Star Management Subsystem */ -void fgStarsInit( void ); +int fgStarsInit( void ); /* Draw the Stars */ void fgStarsRender( void ); @@ -44,9 +44,13 @@ extern struct fgTIME cur_time_params; /* $Log$ -/* Revision 1.3 1998/01/22 02:59:28 curt -/* Changed #ifdef FILE_H to #ifdef _FILE_H +/* Revision 1.4 1998/02/12 21:59:39 curt +/* Incorporated code changes contributed by Charlie Hotchkiss +/* /* + * Revision 1.3 1998/01/22 02:59:28 curt + * Changed #ifdef FILE_H to #ifdef _FILE_H + * * Revision 1.2 1998/01/19 18:40:18 curt * Tons of little changes to clean up the code and to remove fatal errors * when building with the c++ compiler. diff --git a/Astro/sun.c b/Astro/sun.c index 49c146e82..673fea64f 100644 --- a/Astro/sun.c +++ b/Astro/sun.c @@ -114,8 +114,9 @@ void fgSunInit( void ) { fgSolarSystemUpdate(&(pltOrbElements[0]), cur_time_params); sunPos = fgCalculateSun(pltOrbElements[0], cur_time_params); - fgPrintf( FG_ASTRO, FG_INFO, - "Sun found at %f (ra), %f (dec)\n", + + fgPrintf( FG_ASTRO, FG_INFO, + "Sun found at %f (ra), %f (dec)\n", sunPos.RightAscension, sunPos.Declination); xSun = 60000.0 * cos(sunPos.RightAscension) * cos(sunPos.Declination); @@ -155,12 +156,12 @@ void fgSunInit( void ) { if (amb[1] > 1.0) amb[1] = 1.0; if (amb[2] > 1.0) amb[2] = 1.0; - fgPrintf( FG_ASTRO, FG_DEBUG, - "Color of the sun: %f, %f, %f\n" - "Ambient value : %f\n" - "Sun Angle : %f\n" , - amb[0], amb[1], amb[2], ambient, l->sun_angle); - + fgPrintf( FG_ASTRO, FG_DEBUG, + "Color of the sun: %f, %f, %f\n" + "Ambient value : %f\n" + "Sun Angle : %f\n" , + amb[0], amb[1], amb[2], ambient, l->sun_angle); + /* set lighting parameters */ /*xglLightfv(GL_LIGHT0, GL_AMBIENT, color ); xglLightfv(GL_LIGHT0, GL_DIFFUSE, color ); @@ -195,9 +196,13 @@ void fgSunRender( void ) { /* $Log$ -/* Revision 1.5 1998/02/02 20:53:24 curt -/* To version 0.29 +/* Revision 1.6 1998/02/12 21:59:39 curt +/* Incorporated code changes contributed by Charlie Hotchkiss +/* /* + * Revision 1.5 1998/02/02 20:53:24 curt + * To version 0.29 + * * Revision 1.4 1998/01/27 00:47:50 curt * Incorporated Paul Bleisch's new debug message * system and commandline/config file processing code. diff --git a/Cockpit/hud.c b/Cockpit/hud.c index f0dc7e7f1..0b40ec834 100644 --- a/Cockpit/hud.c +++ b/Cockpit/hud.c @@ -33,8 +33,8 @@ #include #ifndef WIN32 -# include /* for MAXINT */ -#endif /* not WIN32 */ +# include // for MAXINT +#endif // #include "hud.h" @@ -45,7 +45,6 @@ #include #include #include -// #include /* not used any more :-) */ #include