]> git.mxchange.org Git - flightgear.git/commitdiff
Incorporated code changes contributed by Charlie Hotchkiss
authorcurt <curt>
Thu, 12 Feb 1998 21:58:27 +0000 (21:58 +0000)
committercurt <curt>
Thu, 12 Feb 1998 21:58:27 +0000 (21:58 +0000)
<chotchkiss@namg.us.anritsu.com>

23 files changed:
Aircraft/aircraft.c
Astro/orbits.c
Astro/orbits.h
Astro/planets.c
Astro/planets.h
Astro/stars.c
Astro/stars.h
Astro/sun.c
Cockpit/hud.c
Cockpit/hud.h
Joystick/joystick.c
Main/GLUTkey.h
Main/GLUTmain.c
Main/Makefile
Main/fg_debug.c
Main/fg_debug.h
Main/fg_init.c
Main/fg_init.h
Scenery/texload.c
Scenery/tilemgr.c
Scenery/tilemgr.h
Simulator/Todo
Simulator/commondefs

index 5d478b8325b64f2fa848429c846dff621a54a768..edd8cd3321b3bff88fdaeec3c1f7c39fb0afff5a 100644 (file)
@@ -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
 /* <chotchkiss@namg.us.anritsu.com>
 /*
+ * Revision 1.16  1998/02/07 15:29:31  curt
+ * Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
+ * <chotchkiss@namg.us.anritsu.com>
+ *
  * Revision 1.15  1998/01/27 00:47:46  curt
  * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
  * system and commandline/config file processing code.
index 6c82f79a42ca2919dfa55e13ebb6720229bb0a83..50da74503f6b0075e7125a93fc6342b881c76625 100644 (file)
@@ -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
+/* <chotchkiss@namg.us.anritsu.com>
 /*
+ * 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
  *
index fcabc6593fadce98f2f1f99ca42b10206b4960b7..658edd311f9f56f0fee74286343404f16333c57f 100644 (file)
@@ -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
+/* <chotchkiss@namg.us.anritsu.com>
 /*
+ * 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
  *
index 90dea620aef4ae88dcb73e0b7566fda6a850a004..0def3af76a28a8d5c357f40c5271b2452a95982a 100644 (file)
@@ -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
+/* <chotchkiss@namg.us.anritsu.com>
 /*
+ * 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
  *
index c5468ad6dbb8ea14d874b31c937234c9496d1a0f..bdd1d7b5e16d89dc7b545f9e3635c0a17d029299 100644 (file)
@@ -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
+/* <chotchkiss@namg.us.anritsu.com>
 /*
+ * 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
  *
index 8b23ffdcc838fe3c13e55ddd239acc0903befa32..420c95168876c7bc08537f0f436f7dabe79203c8 100644 (file)
@@ -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
+/* <chotchkiss@namg.us.anritsu.com>
 /*
+ * 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
  *
index e510f7b56236c1b811ea8563faec5d9ba9ef205c..b56934cc359b32dbed528c8af14f7ab3391e0efc 100644 (file)
@@ -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
+/* <chotchkiss@namg.us.anritsu.com>
 /*
+ * 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.
index 49c146e826fa69971cecd33c8144a5b1f05c08e9..673fea64fa1662ab323e4b7855b347409ac1a1b9 100644 (file)
@@ -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
+/* <chotchkiss@namg.us.anritsu.com>
 /*
+ * 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 <bleisch@chromatic.com> new debug message
  * system and commandline/config file processing code.
index f0dc7e7f13d5a5204ec2d6fc14573d9d98ff7ba8..0b40ec8344d295d2803639565d3d0e902af15a69 100644 (file)
@@ -33,8 +33,8 @@
 #include <string.h>
 
 #ifndef WIN32
-#  include <values.h>  /* for MAXINT */
-#endif /* not WIN32 */
+#  include <values.h>  // for MAXINT
+#endif //
 
 #include "hud.h"
 
@@ -45,7 +45,6 @@
 #include <Math/mat3.h>
 #include <Math/polar.h>
 #include <Scenery/scenery.h>
-// #include <Scenery/mesh.h>   /* not used any more :-) */
 #include <Time/fg_timer.h>
 #include <Weather/weather.h>
 
@@ -216,53 +215,61 @@ static void drawscale( HUD_scale * pscale )
 
     factor = (pscale->scr_max - pscale->scr_min)/pscale->width_units;
 
-    for( i=vmin; i<=vmax; i+=1 )
+    for( i = vmin; i <= vmax; i++ )
       {
-      if( pscale->sub_type == LIMIT )
-        condition = i>= pscale->minimum_value;
-      else
-        if( pscale->sub_type == NOLIMIT )
+      if( pscale->sub_type == LIMIT ) {
+        condition = (i >= pscale->minimum_value);
+        }
+      else {
+        if( pscale->sub_type == NOLIMIT ) {
           condition = 1;
-
+          }
+        }
       if( condition )
         {
-        marker_y = pscale->scr_min+(i-vmin)*factor;
-        if( i%pscale->div_min==0 )
+        marker_y = pscale->scr_min + (i - vmin) * factor;
+        if( !(i%pscale->div_min)) {
           if( pscale->orientation == LEFT )
             {
-            drawOneLine( marker_x+3, marker_y, marker_x+6, marker_y );
+            drawOneLine( marker_x + 3, marker_y, marker_x + 6, marker_y );
             }
-          else
+          else {
             if( pscale->orientation == RIGHT )
               {
-              drawOneLine( marker_x, marker_y, marker_x+3, marker_y );
+              drawOneLine( marker_x, marker_y, marker_x + 3, marker_y );
               }
             if( i%pscale->div_max==0 )
               {
-              drawOneLine( marker_x, marker_y, marker_x+6, marker_y );
+              drawOneLine( marker_x, marker_y, marker_x + 6, marker_y );
               sprintf( TextScale, "%d", i );
               if( pscale->orientation == LEFT )
                 {
-                textString( marker_x-8*strlen(TextScale)-2, marker_y-4,
+                textString( marker_x - 8 * strlen(TextScale) - 2, marker_y - 4,
                             TextScale, GLUT_BITMAP_8_BY_13 );
                 }
-              else
+              else  {
                 if( pscale->orientation == RIGHT )
                   {
                   textString( marker_x+10, marker_y-4,
                               TextScale, GLUT_BITMAP_8_BY_13 );
                   }
+                }
               }
-         }
+            }
+          }
+        }
       } // End for range of i from vmin to vmax
     }
   if( pscale->type == HORIZONTAL )     // Horizontal scale
     {
-    if( pscale->orientation == TOP )
+    if( pscale->orientation == TOP ) {
       marker_y = pscale->scr_pos;
-    else
-      if( pscale->orientation == BOTTOM )
-        marker_y = pscale->scr_pos-6;
+      }
+    else {
+      if( pscale->orientation == BOTTOM ) {
+        marker_y = pscale->scr_pos - 6;
+        }
+      }
     drawOneLine( pscale->scr_min,
                  pscale->scr_pos,
                  pscale->scr_max,
@@ -285,7 +292,7 @@ static void drawscale( HUD_scale * pscale )
                    pscale->scr_pos-6 );
 
       }
-    else
+    else {
       if( pscale->orientation == BOTTOM )
         {
         drawOneLine( pscale->scr_min,
@@ -303,58 +310,61 @@ static void drawscale( HUD_scale * pscale )
                      mid_scr,
                      pscale->scr_pos+6 );
         }
-
+      }
     factor = (pscale->scr_max - pscale->scr_min)/pscale->width_units;
 
-    for( i=vmin; i<=vmax; i+=1 )
+    for( i = vmin; i <= vmax; i++ )  // increment is faster than addition
       {
-      if( pscale->sub_type == LIMIT )
-        condition = i>= pscale->minimum_value;
-      else
-        if( pscale->sub_type == NOLIMIT )
+      if( pscale->sub_type == LIMIT ) {
+        condition = (i >= pscale->minimum_value);
+        }
+      else {
+        if( pscale->sub_type == NOLIMIT ) {
           condition = 1;
-
+          }
+        }
       if( condition )
         {
         marker_x = pscale->scr_min+(i-vmin)*factor;
-        if( i%pscale->div_min==0 )
+        if( i%pscale->div_min==0 ) {
           if( pscale->orientation == TOP )
             {
             drawOneLine( marker_x, marker_y, marker_x, marker_y+3 );
             }
-          else
+          else {
             if( pscale->orientation == BOTTOM )
               {
               drawOneLine( marker_x, marker_y+3, marker_x, marker_y+6 );
               }
-          if( i%pscale->div_max==0 )
+            }
+          }
+        if( i%pscale->div_max==0 )
+          {
+          sprintf( TextScale, "%d", i );
+          if( pscale->orientation == TOP )
             {
-            sprintf( TextScale, "%d", i );
-            if( pscale->orientation == TOP )
+            drawOneLine( marker_x, marker_y, marker_x, marker_y+6 );
+            textString ( marker_x-4*strlen(TextScale), marker_y+14,
+                         TextScale, GLUT_BITMAP_8_BY_13 );
+            }
+          else {
+            if( pscale->orientation == BOTTOM )
               {
               drawOneLine( marker_x, marker_y, marker_x, marker_y+6 );
-              textString ( marker_x-4*strlen(TextScale), marker_y+14,
+              textString ( marker_x+10, marker_y-4,
                            TextScale, GLUT_BITMAP_8_BY_13 );
               }
-            else
-              if( pscale->orientation == BOTTOM )
-                {
-                drawOneLine( marker_x, marker_y, marker_x, marker_y+6 );
-                textString ( marker_x+10, marker_y-4,
-                             TextScale, GLUT_BITMAP_8_BY_13 );
-                }
             }
+          }
         }
       }
     }
 
 }
 
-/*
-
-       Draws a climb ladder in the center of the HUD
-
-*/
+//
+//     Draws a climb ladder in the center of the HUD
+//
 
 static void drawladder( HUD_ladder *ladder )
 {
@@ -379,7 +389,7 @@ static void drawladder( HUD_ladder *ladder )
 
   vmin = pitch_value - ladder->width_units/2;
   vmax = pitch_value + ladder->width_units/2;
-    
+
   scr_min = ladder->y_pos - (ladder->scr_height/2);
   scr_max = scr_min       + ladder->scr_height;
 
@@ -402,10 +412,12 @@ static void drawladder( HUD_ladder *ladder )
         sprintf( TextLadder, "%d", i );
         if( ladder->scr_hole == 0 )
           {
-          if( i )
+          if( i ) {
             x_ini = ladder->x_pos - ladder->scr_width/2;
-          else
+            }
+          else {
             x_ini = ladder->x_pos - ladder->scr_width/2 - 10;
+            }
           y_ini = marker_y;
           x_end = ladder->x_pos + ladder->scr_width/2;
           y_end = marker_y;
@@ -442,10 +454,12 @@ static void drawladder( HUD_ladder *ladder )
           }
         else
           {
-          if( i != 0 )
+          if( i != 0 )  {
             x_ini = ladder->x_pos - ladder->scr_width/2;
-          else
+            }
+          else          {
             x_ini = ladder->x_pos - ladder->scr_width/2 - 10;
+            }
           y_ini = marker_y;
           x_end = ladder->x_pos - ladder->scr_width/2 + ladder->scr_hole/2;
           y_end = marker_y;
@@ -479,10 +493,12 @@ static void drawladder( HUD_ladder *ladder )
 
           x_ini = ladder->x_pos + ladder->scr_width/2 - ladder->scr_hole/2;
           y_ini = marker_y;
-          if( i != 0 )
+          if( i != 0 )  {
             x_end = ladder->x_pos + ladder->scr_width/2;
-          else
+            }
+          else          {
             x_end = ladder->x_pos + ladder->scr_width/2 + 10;
+            }
           y_end = marker_y;
           new_x_ini = ladder->x_pos +                        \
                       (x_ini-ladder->x_pos)*cos(roll_value) -\
@@ -571,14 +587,12 @@ static void drawhorizon( HUD_horizon *horizon )
                  horizon->x_pos + x_inc1, horizon->y_pos + y_inc1 );
     }
 }
-/*
 
-       Draws a representation of the control surfaces in their current state
-               anywhere in the HUD
-       
-       Needs: struct HUD_control_surfaces
+//  drawControlSurfaces()
+//     Draws a representation of the control surfaces in their current state
+//     anywhere in the HUD
+//
 
-*/
 static void drawControlSurfaces( HUD_control_surfaces *ctrl_surf )
 {
        int x_ini, y_ini;
@@ -647,19 +661,19 @@ static void drawControlSurfaces( HUD_control_surfaces *ctrl_surf )
                drawOneLine( x_ini + 35 + (int)(((FG_Rudder + 1.0)/2)*50.0), y_ini + 25, \
                                x_ini + 35 + (int)(((FG_Rudder + 1.0)/2)*50.0), y_ini + 5 );
        }
-       
-       
+
+
        /* Draw throttle diagram */
-       textString( x_ini + 90 + 1, y_end-11, "T", GLUT_BITMAP_8_BY_13 );       
-       textString( x_ini + 90 + 1, y_end-21, "r", GLUT_BITMAP_8_BY_13 );       
+       textString( x_ini + 90 + 1, y_end-11, "T", GLUT_BITMAP_8_BY_13 );
+       textString( x_ini + 90 + 1, y_end-21, "r", GLUT_BITMAP_8_BY_13 );
        drawOneLine( x_ini + 105, y_ini + 5, x_ini + 105, y_ini + 55 );
        drawOneLine( x_ini + 100, y_ini + 5 + (int)(FG_Throttle[0]*50.0), \
                        x_ini + 110, y_ini + 5 + (int)(FG_Throttle[0]*50.0) );
-       
-       
+
+
        /* Draw elevator trim diagram */
-       textString( x_ini + 121, y_end-11, "T", GLUT_BITMAP_8_BY_13 );  
-       textString( x_ini + 121, y_end-22, "m", GLUT_BITMAP_8_BY_13 );  
+       textString( x_ini + 121, y_end-11, "T", GLUT_BITMAP_8_BY_13 );
+       textString( x_ini + 121, y_end-22, "m", GLUT_BITMAP_8_BY_13 );
        drawOneLine( x_ini + 135, y_ini + 5, x_ini + 135, y_ini + 55 );
        drawOneLine( x_ini + 134, y_ini + 30, x_ini + 136, y_ini + 30 );
        if( FG_Elev_Trim <= -0.01 || FG_Elev_Trim >= 0.01 )
@@ -672,7 +686,7 @@ static void drawControlSurfaces( HUD_control_surfaces *ctrl_surf )
                drawOneLine( x_ini + 127, y_ini + 5 + (int)(((FG_Elev_Trim + 1.0)/2)*50.0), \
                                x_ini + 143, y_ini + 5 + (int)(((FG_Elev_Trim + 1.0)/2)*50.0) );
        }
-       
+
 }
 
 //
@@ -711,12 +725,12 @@ static void drawlabel( HUD_label *label )
 
 
   sprintf( string, buffer, (*label->load_value)() );
-
+#ifdef DEBUGHUD
        fgPrintf( FG_COCKPIT, FG_DEBUG,  buffer );
        fgPrintf( FG_COCKPIT, FG_DEBUG,  "\n" );
        fgPrintf( FG_COCKPIT, FG_DEBUG, string );
        fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
-
+#endif
   lenstr = strlen( string );
   if( label->justify == LEFT_JUST ) {
    posincr = -lenstr*8;
@@ -767,7 +781,7 @@ Hptr fgHUDInit( fgAIRCRAFT *current_aircraft )
   hud->code = 1;
   hud->status = 0;
 
-  // For now lets just hardcode the hud here .
+  // For now lets just hardcode the hud here.
   // In the future, hud information has to come from the same place
   // aircraft information came from.
 
@@ -784,7 +798,7 @@ Hptr fgHUDInit( fgAIRCRAFT *current_aircraft )
                    RIGHT_JUST, NULL, " m", "%5.0f", get_altitude );
   fgHUDAddLadder ( hud, 330, 190, 90, 180, 70, 10,
                    NONE, 45, get_roll, get_pitch );
-  // fgHUDAddControlSurfaces( hud, 10, 10, get_heading );
+  fgHUDAddControlSurfaces( hud, 10, 10, get_heading );
 
   return( hud );
 }
@@ -1011,6 +1025,50 @@ Hptr fgHUDAddLadder( Hptr hud,        \
        return hud;
 }
 
+//   fgHUDAddControlSurfaces()
+//
+//   Adds the control surface indicators which make up for the lack of seat
+//   of the pants feel. Should be unnecessary with joystick and pedals
+//   enabled. But that is another improvement. Also, what of flaps? Spoilers?
+//   This may need to be expanded or flattened into multiple indicators,
+//   vertical and horizontal.
+
+Hptr fgHUDAddControlSurfaces( Hptr hud,
+                              int x_pos,
+                              int y_pos,
+                              double (*load_value)() )
+{
+    HUD_control_surfaces *pctrl_surf;
+    HUD_instr *pinstrument;
+
+    if( !hud ) {
+       return NULL;
+    }
+
+    // Construct shell
+    pinstrument = (HIptr)calloc(sizeof(HUD_instr),1);
+    if( !pinstrument )
+       return NULL;
+
+    pinstrument->type = HUDcontrols;
+
+    // Construct core
+    pctrl_surf = (HUD_control_surfaces *)calloc(sizeof(HUD_control_surfaces),1);
+    if( !(pctrl_surf == NULL) )
+       return( NULL );
+
+    pctrl_surf->x_pos      = x_pos;
+    pctrl_surf->y_pos      = y_pos;
+    pctrl_surf->load_value = load_value;
+                                                   // Integrate
+    pinstrument->instr     = pctrl_surf;
+                                                   // Install
+    add_instrument( hud, pinstrument);
+
+    return hud;
+}
+
+
 /*
 Hptr fgHUDAddMovingHorizon(  Hptr hud,     \
                              int x_pos,    \
@@ -1073,9 +1131,8 @@ void fgUpdateHUD( Hptr hud ) {
     glLineWidth(1);
     glColor3f (0.1, 0.9, 0.1);
 
-    fgPrintf( FG_COCKPIT, FG_DEBUG,
-             "HUD Code %d  Status %d\n",
-             hud->code, hud->status );
+    fgPrintf( FG_COCKPIT, FG_DEBUG, "HUD Code %d  Status %d\n",
+              hud->code, hud->status );
 
     phud_instr = hud->instruments;
     while( phud_instr ) {
@@ -1100,6 +1157,7 @@ void fgUpdateHUD( Hptr hud ) {
 
        case HUDcontrols:
            drawControlSurfaces( (pHUDControlSurface) phud_instr->instr );
+           break;
            
        default:; // Ignore anything you don't know about.
        }
@@ -1117,8 +1175,9 @@ void fgUpdateHUD( Hptr hud ) {
 
 
 /* $Log$
-/* Revision 1.13  1998/02/11 02:50:19  curt
-/* Added changes submitted by Michele America.
+/* Revision 1.14  1998/02/12 21:59:41  curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
 /*
  * Revision 1.12  1998/02/09 15:07:48  curt
  * Minor tweaks.
index 0a2a9ac5a1edb15fc448ed2893b566e65d0cf947..034bc5cbaef732bb53275a9d8b811a65abfc9ad2 100644 (file)
 #include <Flight/flight.h>
 #include <Controls/controls.h>
 
+// View mode definitions
 
-/* Instrument types */
+enum VIEW_MODES { HUD_VIEW, PANEL_VIEW, CHASE_VIEW, TOWER_VIEW };
+
+// Instrument types
 #define ARTIFICIAL_HORIZON     1
 #define SCALE              2
 #define LADDER             3
 #define LABEL              4
 
-/* Scale constants */
+// Scale constants
 #define HORIZONTAL         1
 #define TOP                2
 #define BOTTOM             3
@@ -50,7 +53,7 @@
 #define NOLIMIT            8
 #define ROUNDROB           9
 
-/* Label constants */
+// Label constants
 #define SMALL              1
 #define LARGE              2
 #define BLINK              3
@@ -59,7 +62,7 @@
 #define CENTER_JUST        6
 #define RIGHT_JUST         7
 
-/* Ladder constants */
+// Ladder constants
 #define NONE               1
 #define UPPER_LEFT         2
 #define UPPER_CENTER       3
 #define DASHED_LINES      11
 #define DASHED_NEG_LINES  12
 
-/* Ladder orientaion */
+// Ladder orientaion
 // #define HUD_VERTICAL        1
 // #define HUD_HORIZONTAL              2
 // #define HUD_FREEFLOAT               3
 
-/* Ladder orientation modes */
+// Ladder orientation modes
 // #define HUD_LEFT                    1
 // #define HUD_RIGHT           2
 // #define HUD_TOP             1
@@ -89,7 +92,7 @@
 // #define HUD_H_BOTTOM                2
 
 
-/* Ladder sub-types */
+// Ladder sub-types
 // #define HUD_LIM                             1
 // #define HUD_NOLIM                   2
 // #define HUD_CIRC                    3
@@ -203,7 +206,7 @@ typedef struct {
 
 // Removed union HUD_instr_data to evolve this to oop code.
 
-enum hudinstypes { HUDno_instr,
+typedef enum{ HUDno_instr,
                    HUDscale,
                    HUDcirc_scale,
                    HUDladder,
@@ -211,10 +214,10 @@ enum hudinstypes { HUDno_instr,
                    HUDhorizon,
                    HUDlabel,
                    HUDcontrols
-                   };
+                   } hudinstype;
 
 typedef struct HUD_INSTR_STRUCT{
-  int type;
+  hudinstype  type;
   int sub_type;
   int orientation;
   void *instr;   // For now we will cast this pointer accoring to the value
@@ -312,12 +315,12 @@ void fgUpdateHUD ( Hptr hud );
 void fgUpdateHUD2( Hptr hud ); // Future use?
 
 
-#endif /* _HUD_H */
-
+#endif // _HUD_H  
 
 /* $Log$
-/* Revision 1.9  1998/02/11 02:50:22  curt
-/* Added changes submitted by Michele America.
+/* Revision 1.10  1998/02/12 21:59:42  curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
 /*
  * Revision 1.8  1998/02/07 15:29:35  curt
  * Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
index 0bc02ab4df031f978b47532c6a56ad848f76c96d..18ddb8ba108e519e2e8caf88a0cbe55d200fd0fc 100644 (file)
@@ -208,7 +208,7 @@ int fgJoystickInit( int joy_num ) {
        
        return( joystick_fd );
 #else
-       return( 0 );
+       return( 1 );
 #endif
 }
 
@@ -256,12 +256,16 @@ int fgJoystickRead( double *joy_x, double *joy_y, int *joy_b1, int *joy_b2 )
 
 
 /* $Log$
-/* Revision 1.4  1998/02/03 23:20:20  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/12 21:59:44  curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
 /*
+ * Revision 1.4  1998/02/03 23:20:20  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.3  1998/01/27 00:47:54  curt
  * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
  * system and commandline/config file processing code.
index 671eabece92b781782b01f88e1a479988b44670a..d9ede1b59a2c2c4b5143b6799bdee7e49689a2cf 100644 (file)
 #define _GLUTKEY_H
 
 
-#ifdef GLUT
-    #include <GL/glut.h>
-#elif TIGER
-    /* assumes -I/usr/include/mesa in compile command */
-    #include "gltk.h"
+#ifdef WIN32
+#  include <windows.h>                     
 #endif
 
+#include <GL/glut.h>
+#include <XGL/xgl.h>
+
 /* Handle keyboard events */
 void GLUTkey(unsigned char k, int x, int y);
 void GLUTspecialkey(int k, int x, int y);
@@ -44,9 +44,13 @@ void GLUTspecialkey(int k, int x, int y);
 
 
 /* $Log$
-/* Revision 1.6  1998/01/22 02:59:36  curt
-/* Changed #ifdef FILE_H to #ifdef _FILE_H
+/* Revision 1.7  1998/02/12 21:59:44  curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
 /*
+ * Revision 1.6  1998/01/22 02:59:36  curt
+ * Changed #ifdef FILE_H to #ifdef _FILE_H
+ *
  * Revision 1.5  1997/07/23 21:52:23  curt
  * Put comments around the text after an #endif for increased portability.
  *
index 2f89d20d6f2b1ba117961e46afe862d5e44282fe..2cc6474a36bdf02424d52c6a4113421909335571 100644 (file)
 #include <XGL/xgl.h>
 #include <stdio.h>
 
+#include <getopt.h>
 #include <Main/GLUTkey.h>
 #include <Main/fg_init.h>
 #include <Main/fg_debug.h>
+#include <Main/fg_getopt.h>
 #include <Main/views.h>
 
+#include <Include/cmdargs.h>       // Line to command line arguments
 #include <Include/fg_constants.h>
 #include <Include/general.h>
 
@@ -82,21 +85,114 @@ int show_hud;
 /* Yet another other hack. Used for my prototype instrument code. (Durk) */
 int displayInstruments; 
 
-
+// The following defines flight gear options. Because glutlib will also
+// want to parse its own options, those options must not be included here
+// or they will get parsed by the main program option parser. Hence case
+// is significant for any option added that might be in conflict with
+// glutlib's parser.
+//
+// glutlib parses for:
+//    -display
+//    -direct   (invalid in Win32)
+//    -geometry
+//    -gldebug
+//    -iconized
+//    -indirect (invalid in Win32)
+//    -synce
+//
+// Note that glutlib depends upon strings while this program's
+// option parser wants only initial characters followed by numbers
+// or pathnames.
+//
+const char *fg_cmdargopts = "a:c:Hhp:r:v:x:?";
+//
+// Where
+//   -a aircraftfilename    aircraft start over ride
+//   -c0x0000 - 0xffffffff  debug class setting
+//    H,h.? help on command line use (does not need Option struct)
+//   -p  priority
+//   -r flightgear          root path to program support files
+//   -v0 -v1                initial view mode (hud/no_hud currently)
+//   -xlogpathname          debug logfile name
+//
+// Defaults in arguments to indicate not set on command line.
+// Program defaults set variables from constants if neither command
+// options or environmental variables effect values.
+//
+
+char  acArgbuf          [ MAXPATH + 1] = "\0";
+int   debugArgValue                    = -2;
+int   priorityArgValue                 = -1;
+char  rootArgbuf        [ MAXPATH + 1] = "\0";
+int   viewArg                          = -1;
+char  logArgbuf         [ MAXPATH + 1] = "\0";
+
+// There is a reason for defining the option structs by name and then
+// creating an array of pointers to options. C++ is unfriendly to
+// initializing arrays of objects that are not built in types. Always
+// look forward. (Besides, you can follow what is going on better and
+// add or modify with greater security. -ch
+//
+Option aircraftOption = { 'a',
+                          OPT_STRING,
+                          acArgbuf,
+                          "Startup aircraft pathname override"
+                        };
+Option debugOption    = { 'c',
+                          OPT_LHEX,       // Long int (32 bits)
+                          &debugArgValue,
+                          "Debug trace level"
+                        };
+Option priorityOption = { 'p',
+                          OPT_INTEGER,
+                          &priorityArgValue,
+                          "Debug priority Threshold"
+                        };
+Option rootOption     = { 'r',
+                          OPT_STRING,
+                          rootArgbuf,
+                          "Root directory for execution"
+                        };
+Option hudOption      = { 'v',
+                          OPT_SWITCH,
+                          &viewArg,
+                          "View mode start" // HUD,Panel,Chase,Tower
+                        };
+Option logfileOption  = { 'x',
+                          OPT_STRING,
+                          logArgbuf,
+                          "Debug log file name"
+                        };
+
+//
+#define OptsDefined 6
+Option *CmdLineOptions[ OptsDefined ] = {
+  &aircraftOption,
+  &debugOption,
+  &hudOption,
+  &priorityOption,
+  &rootOption,
+  &logfileOption
+  };
+
+const char *DefaultRootDir  = "\\Flightgear";
+const char *DefaultAircraft = "Navion.acf";
+const char *DefaultDebuglog = "fgdebug.log";
+const int   DefaultViewMode = HUD_VIEW;
+//
+// Debug defaults handled in fg_debug.c
+//
 /**************************************************************************
  * fgInitVisuals() -- Initialize various GL/view parameters
  **************************************************************************/
 
 static void fgInitVisuals( void ) {
     struct fgLIGHT *l;
-    struct fgTIME *t;
     struct fgWEATHER *w;
 
     l = &cur_light_params;
-    t = &cur_time_params;
     w = &current_weather;
 
-    
     /* xglDisable( GL_DITHER ); */
 
     /* If enabled, normal vectors specified with glNormal are scaled
@@ -125,12 +221,12 @@ static void fgInitVisuals( void ) {
 static void fgUpdateViewParams( void ) {
     fgFLIGHT *f;
     struct fgLIGHT *l;
-    struct fgTIME *t;
+//  struct fgTIME *t;
     struct fgVIEW *v;
 
     f = current_aircraft.flight;
     l = &cur_light_params;
-    t = &cur_time_params;
+//  t = &cur_time_params;
     v = &current_view;
 
     fgViewUpdate(f, v, l);
@@ -138,7 +234,7 @@ static void fgUpdateViewParams( void ) {
     if (displayInstruments)
       {
        xglViewport(0, (GLint)(winHeight / 2 ) , (GLint)winWidth, (GLint)winHeight / 2);
-       /* Tell GL we are about to modify the projection parameters */    
+       /* Tell GL we are about to modify the projection parameters */
        xglMatrixMode(GL_PROJECTION);
        xglLoadIdentity();
        gluPerspective(55.0, 2.0/win_ratio, 1.0, 100000.0);
@@ -195,7 +291,7 @@ static void fgUpdateInstrViewParams( void ) {
     xglMatrixMode(GL_MODELVIEW);
     xglPushMatrix();
     xglLoadIdentity();
-    
+
     xglColor3f(1.0, 1.0, 1.0);
     xglIndexi(7);
   
@@ -306,9 +402,7 @@ static void fgRenderFrame( void ) {
        fgUpdateInstrViewParams();
     }
 
-    #ifdef GLUT
-      xglutSwapBuffers();
-    #endif
+    xglutSwapBuffers();
 }
 
 
@@ -575,84 +669,129 @@ static void fgReshape( int width, int height ) {
 
 int main( int argc, char *argv[] ) {
     fgFLIGHT *f;
+    int parse_result;  // Used in command line argument.
 
     f = current_aircraft.flight;
+    //  First things first... We must have startup options dealt with.
 
+    #ifndef VERSION
+    #define VERSION "src-32A"
+    #endif
     printf("Flight Gear:  Version %s\n\n", VERSION);
 
-    /**********************************************************************
+     /*********************************************************************
      * Initialize the Window/Graphics environment.
      **********************************************************************/
 
-    #ifdef GLUT
-      /* initialize GLUT */
-      xglutInit(&argc, argv);
+    /* initialize GLUT */
+    xglutInit(&argc, argv);
 
-      /* Define Display Parameters */
-      xglutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
+    /* Define Display Parameters */
+    xglutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
 
-      /* Define initial window size */
-      xglutInitWindowSize(640, 480);
+    /* Define initial window size */
+    xglutInitWindowSize(640, 480);
 
-      /* Initialize windows */
-      xglutCreateWindow("Flight Gear");
-    #endif
+    /* Initialize windows */
+    xglutCreateWindow("Flight Gear");
 
-    /* This is the general house keeping init routine */
-    fgInitGeneral();
+    // xglutInit above will extract all non-general program command line.
+    // We only need wory about our own.
 
-    /* This is the top level init routine which calls all the other
-     * subsystem initialization routines.  If you are adding a
-     * subsystem to flight gear, its initialization call should
-     * located in this routine.*/
-    fgInitSubsystems();
+    parse_result = getargs( argc, argv, OptsDefined, CmdLineOptions, NULL);
 
-    /* setup view parameters, only makes GL calls */
-    fgInitVisuals();
+    switch( parse_result ) {
+    case ALLDONE:
+       break;
 
-    if ( use_signals ) {
-       /* init timer routines, signals, etc.  Arrange for an alarm
-          signal to be generated, etc. */
-       fgInitTimeDepCalcs();
+    case HELP:
+        print_desc( OptsDefined, CmdLineOptions );
+        exit(0);
+
+    case INVALID:
+    default:
+        printf( "Flight Gear: Command line invalid.");
+        exit(0);
     }
 
-   /**********************************************************************
-     * Initialize the Event Handlers.
-     **********************************************************************/
+    // Deal with the effects of options no set by manipulating the command
+    // line, or possibly set to invalid states.
+
+    if(( viewArg >= 0) && (viewArg < 1)) {
+       show_hud = viewArg; // For now view_mode TRUE - no HUD, else show_hud.
+    } else {
+       show_hud = DefaultViewMode;
+    }
 
-    #ifdef GLUT
-      /* call fgReshape() on window resizes */
-      xglutReshapeFunc( fgReshape );
+    // All other command line option responses are handled in the various
+    // initialization routines (or ignored if not implemented.
 
-      /* call key() on keyboard event */
-      xglutKeyboardFunc( GLUTkey );
-      glutSpecialFunc( GLUTspecialkey );
+    // This is the general house keeping init routine. It initializes the
+    // debug trail scheme and then any other stuff.
 
-      /* call fgMainLoop() whenever there is nothing else to do */
-      xglutIdleFunc( fgMainLoop );
+    if( !fgInitGeneral()) {
 
-      /* draw the scene */
-      xglutDisplayFunc( fgRenderFrame );
+       // This is the top level init routine which calls all the other
+       // subsystem initialization routines.  If you are adding a
+       // subsystem to flight gear, its initialization call should
+       // located in this routine.
+       if( !fgInitSubsystems()) {
 
-      /* pass control off to the GLUT event handler */
-      glutMainLoop();
-    #endif
+           // setup view parameters, only makes GL calls
+           fgInitVisuals();
+
+           if ( use_signals ) {
+               /* init timer routines, signals, etc.  Arrange for an alarm
+                  signal to be generated, etc. */
+               fgInitTimeDepCalcs();
+           }
+
+           /**********************************************************
+            * Initialize the GLUT Event Handlers.
+            **********************************************************/
+
+           // call fgReshape() on window resizes
+           xglutReshapeFunc( fgReshape );
+
+           // call key() on keyboard event
+           xglutKeyboardFunc( GLUTkey );
+           glutSpecialFunc( GLUTspecialkey );
+
+           // call fgMainLoop() whenever there is
+           // nothing else to do
+           xglutIdleFunc( fgMainLoop );
 
+           // draw the scene
+           xglutDisplayFunc( fgRenderFrame );
+
+           // pass control off to the GLUT event handler
+           glutMainLoop();
+
+        }  // End if subsystems initialize ok
+    } // End if general initializations went ok
+
+    if( fg_DebugOutput ) {
+       fclose( fg_DebugOutput );
+    }
     return(0);
 }
 
 
 #ifdef __SUNPRO_CC
-    extern "C" {
-       void __eprintf( void ) {
-       }
+extern "C" {
+    void __eprintf( void ) {
     }
+}
 #endif
 
 /* $Log$
-/* Revision 1.60  1998/02/11 02:50:40  curt
-/* Minor changes.
+/* Revision 1.61  1998/02/12 21:59:46  curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
 /*
+ * Revision 1.60  1998/02/11 02:50:40  curt
+ * Minor changes.
+ *
  * Revision 1.59  1998/02/09 22:56:54  curt
  * Removed "depend" files from cvs control.  Other minor make tweaks.
  *
index adfd1748c313efec438bfa714ea0eb7573b29c78..dd10a724f55aa0217e30184a7a59f127b7d96a66 100644 (file)
@@ -25,7 +25,7 @@
 
 TARGET = fg-$(FG_VERSION)
 
-CFILES = fg_init.c fg_debug.c views.c $(INTERFACE_FILES)
+CFILES = fg_debug.c fg_getopt.c fg_init.c views.c GLUTmain.c GLUTkey.c
 
 FGLIBS = -lAircraft -lAstro -lCockpit -lControls -lFlight \
        -lJoystick -lLaRCsim -lSlew -lScenery -lTime -lWeather -lMath \
@@ -34,8 +34,7 @@ FGLIBS = -lAircraft -lAstro -lCockpit -lControls -lFlight \
 
 LCDEFS = -DGLUT
 LLDFLAGS =
-LDLIBS = $(FGLIBS) $(FG_DEBUG_LIBS) \
-       $(INTERFACE_LIBS) $(GRAPHICS_LIBS) -lm
+LDLIBS = $(FGLIBS) $(FG_DEBUG_LIBS) $(INTERFACE_LIBS) $(GRAPHICS_LIBS) -lm
 
 include $(FG_ROOT_SRC)/commondefs
 
@@ -52,6 +51,10 @@ include $(COMMONRULES)
 
 #---------------------------------------------------------------------------
 # $Log$
+# Revision 1.48  1998/02/12 21:59:47  curt
+# Incorporated code changes contributed by Charlie Hotchkiss
+# <chotchkiss@namg.us.anritsu.com>
+#
 # Revision 1.47  1998/02/09 22:56:56  curt
 # Removed "depend" files from cvs control.  Other minor make tweaks.
 #
index 4767a1524d9401c6036e57f5f4192abdd0d54642..a315096c0d61f05f9bff9e270e9075579a21e067 100644 (file)
  **************************************************************************/
 
 #include <string.h>
-#include <Main/fg_debug.h>
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h>
 
-static int fg_DebugSem = 1;
-static fgDebugClass fg_DebugClass = FG_ALL;
-static fgDebugPriority fg_DebugPriority = FG_INFO;
+#include <Include/cmdargs.h> // Line to command line arguments
+#include <Main/fg_debug.h>
+
+static int             fg_DebugSem      = 1;
+fgDebugClass           fg_DebugClass    = FG_ALL;  // Need visibility for
+fgDebugPriority        fg_DebugPriority = FG_INFO; // command line processing.
 static fgDebugCallback fg_DebugCallback = NULL;
 
-#ifndef __CYGWIN32__
-    static FILE *fg_DebugOutput = stderr;
-#else /* __CYGWIN32__ */
-    static FILE *fg_DebugOutput = NULL;
-#endif /* __CYGWIN32 */
+FILE *fg_DebugOutput = NULL;  // Visibility needed for command line processor.
+                              // This can be set to a FILE from the command
+                              // line. If not, it will be set to stderr.
 
 /* TODO: Actually make this thing thread safe */
 #ifdef USETHREADS
-#define FG_GRABDEBUGSEM  while( --fg_DebugSem < 0 ) { fg_DebugSem++; } 
+#define FG_GRABDEBUGSEM  while( --fg_DebugSem < 0 ) { fg_DebugSem++; }
 #define FG_RELEASEDEBUGSEM fg_DebugSem++;
 #else
 #define FG_GRABDEBUGSEM
-#define FG_RELEASEDEBUGSEM 
+#define FG_RELEASEDEBUGSEM
 #endif
 
 /* Used for convienence initialization from env variables.
@@ -77,28 +77,59 @@ static fgDebugClass fgDebugStrToClass( char *str );
 /* fgInitDebug =============================================================*/
 void fgInitDebug( void )
 {
-  char *pszClass, *pszPrio;
+  char *pszClass, *pszPrio, *pszFile;
+
+  // Support for log file/alt debug output via command line, environment or
+  // reasonable default.
+
+  if( strlen( logArgbuf ) > 3) {   // First check for command line option
+    fg_DebugOutput = fopen(logArgbuf, "a+" );  // Assumed that we will append.
+    }
+
+  if( !fg_DebugOutput ) {          // If not set on command line, environment?
+    pszFile = getenv( "FG_DEBUGFILE" );
+    if( pszFile ) {          // There is such an environmental variable.
+      fg_DebugOutput = fopen( pszFile, "a+" );
+      }
+    }
 
-#ifdef __CYGWIN32__
-    fg_DebugOutput = stderr;
-#endif /* __CYGWIN32 */
+  if( !fg_DebugOutput ) {         // If neither command line nor environment
+    fg_DebugOutput = stderr;      // then we use the fallback position
+    }                       
 
   FG_GRABDEBUGSEM;
-  fg_DebugSem=fg_DebugSem;  /* shut up GCC */
+  fg_DebugSem = fg_DebugSem;  /* shut up GCC */
 
-  pszPrio = getenv( "FG_DEBUGPRIORITY" );
-  if( pszPrio ) {
-    fg_DebugPriority = atoi( pszPrio );
-    fprintf( stderr, "fg_debug.c: Environment overrides default debug priority (%d)\n",
-            fg_DebugPriority );
-  }
+  // Test command line option overridge of debug priority. If the value
+  // is in range (properly optioned) the we will override both defaults
+  // and the environmental value.
 
-  pszClass = getenv( "FG_DEBUGCLASS" );
-  if( pszClass ) {
-    fg_DebugClass = fgDebugStrToClass( pszClass );
-    fprintf( stderr, "fg_debug.c: Environment overrides default debug class (0x%08X)\n",
-            fg_DebugClass );
-  }
+  if ((priorityArgValue >= FG_BULK) && (priorityArgValue <= FG_ABORT)) {
+    fg_DebugPriority = priorityArgValue;
+    }
+  else {  // Either not set or out of range. We will not warn the user.
+    pszPrio = getenv( "FG_DEBUGPRIORITY" );
+    if( pszPrio ) {
+      fg_DebugPriority = atoi( pszPrio );
+      fprintf( stderr,
+           "fg_debug.c: Environment overrides default debug priority (%d)\n",
+           fg_DebugPriority );
+      }
+    }
+
+
+  if ((debugArgValue >= FG_ALL) && (debugArgValue < FG_UNDEFD)) {
+    fg_DebugPriority = priorityArgValue;
+    }
+  else {  // Either not set or out of range. We will not warn the user.
+    pszClass = getenv( "FG_DEBUGCLASS" );
+    if( pszClass ) {
+      fg_DebugClass = fgDebugStrToClass( pszClass );
+      fprintf( stderr,
+            "fg_debug.c: Environment overrides default debug class (0x%08X)\n",
+                 fg_DebugClass );
+      }
+    }
 
   FG_RELEASEDEBUGSEM;
 }
@@ -108,7 +139,7 @@ fgDebugClass fgDebugStrToClass( char *str )
 {
   char *hex = "0123456789ABCDEF";
   char *hexl = "0123456789abcdef";
-  char *pt, *p, *ph, ps=1;
+  char *pt, *p, *ph, ps = 1;
   unsigned int val = 0, i;
   
   if( str == NULL ) {
@@ -195,12 +226,15 @@ int fgPrintf( fgDebugClass dbg_class, fgDebugPriority prio, char *fmt, ... )
   va_list ap;
   int ret = 0;
 
-  FG_GRABDEBUGSEM;
+  // If no action to take, then don't bother with the semaphore activity
+  // Slight speed benefit.
 
   if( !(dbg_class & fg_DebugClass) || (prio < fg_DebugPriority) ) {
-    FG_RELEASEDEBUGSEM;
-    return 0;
-  } 
+    return ret;        // Its zero anyway. But we might think about changing
+                       // it upon some error condition?
+  }
+
+  FG_GRABDEBUGSEM;
 
   /* ret = vsprintf( szOut, fmt, (&fmt+1)); (but it didn't work, thus ... */
   va_start (ap, fmt);
@@ -210,13 +244,13 @@ int fgPrintf( fgDebugClass dbg_class, fgDebugPriority prio, char *fmt, ... )
   if( fg_DebugCallback!=NULL && fg_DebugCallback(dbg_class, prio, szOut) ) {
     FG_RELEASEDEBUGSEM;
     return ret;
-  } 
+  }
   else {
     fprintf( fg_DebugOutput, szOut );
     FG_RELEASEDEBUGSEM;
     if( prio == FG_EXIT ) {
       exit(0);
-    } 
+    }
     else if( prio == FG_ABORT ) {
       abort();
     }
@@ -224,3 +258,6 @@ int fgPrintf( fgDebugClass dbg_class, fgDebugPriority prio, char *fmt, ... )
   return ret;  
 } 
 
+// Revision history?
+//
+
index 09943db0d6cf545d2a46169dcdb7fb7d9a10a84a..4aa9026136b23fb61de711dce04772ad81d73c66 100644 (file)
@@ -31,7 +31,7 @@
 /* NB:  To add a dbg_class, add it here, and add it to the structure
    in fg_debug.c
 */
-typedef enum {
+typedef enum{
   FG_NONE    = 0x00000000,
 
   FG_TERRAIN = 0x00000001,
@@ -45,20 +45,21 @@ typedef enum {
   FG_MATH    = 0x00000100,
   FG_EVENT   = 0x00000200,
   FG_AIRCRAFT= 0x00000400,
+  FG_UNDEFD  = 0x00001000, // For range checking
 
-  FG_ALL     = 0xFFFFFFFF
-} fgDebugClass;
+  FG_ALL     = 0xFFFFFFFFL  // -1!
+  } fgDebugClass;
 
 /* NB:  To add a priority, add it here.
 */
-typedef enum {
-  FG_BULK,     /* For frequent messages */ 
-  FG_DEBUG,    /* Less frequent debug type messages */
-  FG_INFO,      /* Informatory messages */
-  FG_WARN,     /* Possible impending problem */
-  FG_ALERT,    /* Very possible impending problem */
-  FG_EXIT,      /* Problem (no core) */
-  FG_ABORT      /* Abandon ship (core) */
+typedef enum  {
+  FG_BULK,         /* For frequent messages */
+  FG_DEBUG,        /* Less frequent debug type messages */
+  FG_INFO,          /* Informatory messages */
+  FG_WARN,         /* Possible impending problem */
+  FG_ALERT,         /* Very possible impending problem */
+  FG_EXIT,          /* Problem (no core) */
+  FG_ABORT          /* Abandon ship (core) */
 } fgDebugPriority;
 
 /* Initialize the debuggin stuff. */
@@ -122,9 +123,19 @@ void fgSetDebugOutput( FILE *out );
    processing of the message.**  Only one callback may be installed at a 
    time.
 */
-typedef int (*fgDebugCallback)(fgDebugClass, fgDebugPriority, char *outstr);
+
+//typedef int (*fgDebugCallback)(fgDebugClass, fgDebugPriority, char *outstr);
+//fgDebugCallback fgRegisterDebugCallback( fgDebugCallback callback );
+
+typedef int (*fgDebugCallback)( int DebugClass, int DebugPriority, char *outstr);
 fgDebugCallback fgRegisterDebugCallback( fgDebugCallback callback );
 
+// Leave these alone. Access intended for fg_debug and command line processing.
+//
+extern fgDebugClass    fg_DebugClass;
+extern fgDebugPriority fg_DebugPriority;
+
+extern FILE *          fg_DebugOutput;
 
 #endif /* _FG_DEBUG_H */
 
index 0e997dad4a52adbf34b8f71660c67fda8c0bf952..837699ebdc8d7922558857e8ea61ecb6df4966fa 100644 (file)
@@ -30,6 +30,7 @@
 #include <Main/fg_init.h>
 #include <Main/views.h>
 
+#include <Include/cmdargs.h>
 #include <Include/fg_constants.h>
 #include <Include/general.h>
 
 
 extern int show_hud;             /* HUD state */
 extern int displayInstruments;
-
+extern const char *default_root;
 
 /* General house keeping initializations */
 
-void fgInitGeneral( void ) {
+int fgInitGeneral( void ) {
     struct fgGENERAL *g;
 
     g = &general;
@@ -69,23 +70,37 @@ void fgInitGeneral( void ) {
     /* seed the random number generater */
     fg_srandom();
 
-    /* determine the fg root path */
-    if ( (g->root_dir = getenv("FG_ROOT")) == NULL ) {
-       /* environment variable not defined */
-       fgPrintf(FG_GENERAL, FG_EXIT, "FG_ROOT needs to be defined!  "
-                                 "See the documentation.\n");
-    } 
+    // determine the fg root path. The command line parser getargs() will
+    // fill in a root directory if the option was used.
+
+    if( !(g->root_dir) ) { 
+       // If not set by command line test for environmental var..
+       g->root_dir = getenv("FG_ROOT");
+       if ( !g->root_dir ) { 
+           // No root path set? Then assume, we will exit if this is
+           // wrong when looking for support files.
+           g->root_dir = (char *)DefaultRootDir;
+       }
+    }
     fgPrintf( FG_GENERAL, FG_INFO, "FG_ROOT = %s\n\n", g->root_dir);
+
+    // Dummy value can be changed if future initializations
+    // fail a critical task.
+    return ( 0 /* FALSE */ ); 
 }
 
 
-/* This is the top level init routine which calls all the other
- * initialization routines.  If you are adding a subsystem to flight
- * gear, its initialization call should located in this routine.*/
+// This is the top level init routine which calls all the other
+// initialization routines.  If you are adding a subsystem to flight
+// gear, its initialization call should located in this routine.
+// Returns non-zero if a problem encountered.
 
-void fgInitSubsystems( void ) {
+int fgInitSubsystems( void ) {
     double cur_elev;
 
+    // Ok will be flagged only if we get EVERYTHING done.
+    int ret_val = 1 /* TRUE */;
+
     fgFLIGHT *f;
     struct fgLIGHT *l;
     struct fgTIME *t;
@@ -99,13 +114,14 @@ void fgInitSubsystems( void ) {
     fgPrintf( FG_GENERAL, FG_INFO, "========== ==========\n");
 
     /****************************************************************
-     * The following section sets up the flight model EOM parameters and 
+     * The following section sets up the flight model EOM parameters and
      * should really be read in from one or more files.
      ****************************************************************/
 
     /* Must happen before any of the flight model or control
      * parameters are set */
-    fgAircraftInit();
+
+    fgAircraftInit();   // In the future this might not be the case.
     f = current_aircraft.flight;
 
     /* Globe Aiport, AZ */
@@ -155,7 +171,7 @@ void fgInitSubsystems( void ) {
     /* FG_Latitude  = 45.145 * DEG_TO_RAD; */
     /* FG_Runway_altitude = 912; */
     /* FG_Altitude = FG_Runway_altitude + 3.758099; */
-    
+
     /* Initial Position north of the city of Globe */
     /* FG_Longitude = ( -398673.28 / 3600.0 ) * DEG_TO_RAD; */
     /* FG_Latitude  = (  120625.64 / 3600.0 ) * DEG_TO_RAD; */
@@ -180,11 +196,17 @@ void fgInitSubsystems( void ) {
     /* FG_Runway_altitude = 5000.0; */
     /* FG_Altitude = FG_Runway_altitude + 3.758099; */
 
-    /* Initial Position: (GCN) Grand Canyon Airport, AZ */
-    FG_Longitude = ( -112.1469647 ) * DEG_TO_RAD;
-    FG_Latitude  = (   35.9523539 ) * DEG_TO_RAD;
-    FG_Runway_altitude = 6606.0;
-    FG_Altitude = FG_Runway_altitude + 3.758099;
+    // Initial Position: (GCN) Grand Canyon Airport, AZ
+    // FG_Longitude = ( -112.1469647 ) * DEG_TO_RAD;
+    // FG_Latitude  = (   35.9523539 ) * DEG_TO_RAD;
+    // FG_Runway_altitude = 6606.0;
+    // FG_Altitude = FG_Runway_altitude + 3.758099;
+
+    // Initial Position: Jim Brennon's Kingmont Observatory
+    // FG_Longitude = ( -121.1131666 ) * DEG_TO_RAD;
+    // FG_Latitude  = (   38.8293916 ) * DEG_TO_RAD;
+    // FG_Runway_altitude = 920.0;
+    // FG_Altitude = FG_Runway_altitude + 3.758099;
 
     /* A random test position */
     /* FG_Longitude = ( 88128.00 / 3600.0 ) * DEG_TO_RAD; */
@@ -233,7 +255,7 @@ void fgInitSubsystems( void ) {
     fgEventInit();
 
     /* Dump event stats every 60 seconds */
-    fgEventRegister( "fgEventPrintStats()", fgEventPrintStats, 
+    fgEventRegister( "fgEventPrintStats()", fgEventPrintStats,
                     FG_EVENT_READY, 60000 );
 
     /* Initialize "time" */
@@ -257,48 +279,55 @@ void fgInitSubsystems( void ) {
     fgWeatherInit();
 
     /* update the weather for our current position */
-    fgEventRegister( "fgWeatherUpdate()", fgWeatherUpdate, 
+    fgEventRegister( "fgWeatherUpdate()", fgWeatherUpdate,
                     FG_EVENT_READY, 120000 );
 
     /* Initialize the Cockpit subsystem */
-    if( fgCockpitInit( &current_aircraft ) == NULL ) {
+    if( fgCockpitInit( &current_aircraft )) {
+       // Cockpit initialized ok.
+    } else {
        fgPrintf( FG_GENERAL, FG_EXIT, "Error in Cockpit initialization!\n" );
     }
 
-    /* Initialize the orbital elements of sun, moon and mayor planets */
+    // Initialize the orbital elements of sun, moon and mayor planets
     fgSolarSystemInit(*t);
 
-    /* Initialize the Stars subsystem */
-    fgStarsInit();
+    // Initialize the Stars subsystem
+    if( fgStarsInit() ) {
+       // Stars initialized ok.
+    } else {
+       fgPrintf( FG_GENERAL, FG_EXIT, "Error in Stars initialization!\n" );
+    }
 
-    /* Initialize the planetary subsystem */
+    // Initialize the planetary subsystem
     fgEventRegister("fgPlanetsInit()", fgPlanetsInit, FG_EVENT_READY, 600000);
 
-    /* Initialize the sun's position */
-    fgEventRegister( "fgSunInit()", fgSunInit, FG_EVENT_READY, 60000 );
+    // Initialize the sun's position 
+    fgEventRegister("fgSunInit()", fgSunInit, FG_EVENT_READY, 60000 );
 
-    /* Intialize the moon's position */
+    // Intialize the moon's position
     fgEventRegister( "fgMoonInit()", fgMoonInit, FG_EVENT_READY, 600000 );
 
-    /* Initialize the "sky" */
+    // Initialize the "sky"
     fgSkyInit();
 
-    /* Initialize the Scenery Management subsystem */
-    fgTileMgrInit();
-    /* fgSceneryInit(); */
-
-    /* Tell the Scenery Management system where we are so it can load
-     * the correct scenery data */
-    fgTileMgrUpdate();
-    /* fgSceneryUpdate(FG_Latitude, FG_Longitude, FG_Altitude); */
-
-    /* I'm just sticking this here for now, it should probably move 
-     * eventually */
-    /* cur_elev = mesh_altitude(FG_Longitude * RAD_TO_DEG * 3600.0, 
-                            FG_Latitude  * RAD_TO_DEG * 3600.0); */
-    /* fgPrintf( FG_GENERAL, FG_INFO, 
-       "True ground elevation is %.2f meters here.\n",
-       cur_elev); */
+    // Initialize the Scenery Management subsystem
+    if( fgTileMgrInit() ) {
+       // Load the local scenery data
+       fgTileMgrUpdate();
+    } else {
+       fgPrintf( FG_GENERAL, FG_EXIT, 
+                 "Error in Tile Manager initialization!\n" );
+    }
+
+    // I'm just sticking this here for now, it should probably move
+    // eventually
+    // cur_elev = mesh_altitude(FG_Longitude * RAD_TO_DEG * 3600.0,
+    //           FG_Latitude  * RAD_TO_DEG * 3600.0); */
+    // fgPrintf( FG_GENERAL, FG_INFO,
+    //   "True ground elevation is %.2f meters here.\n",
+    //   cur_elev); */
+
     cur_elev = FG_Runway_altitude * FEET_TO_METER;
     if ( cur_elev > -9990.0 ) {
        FG_Runway_altitude = cur_elev * METER_TO_FEET;
@@ -307,36 +336,49 @@ void fgInitSubsystems( void ) {
     if ( FG_Altitude < FG_Runway_altitude ) {
        FG_Altitude = FG_Runway_altitude + 3.758099;
     }
+
     fgPrintf(FG_GENERAL, FG_INFO,
-          "Updated position (after elevation adj): (%.4f, %.4f, %.2f)\n", 
-          FG_Latitude * RAD_TO_DEG, FG_Longitude * RAD_TO_DEG, 
-          FG_Altitude * FEET_TO_METER);
-    /* end of thing that I just stuck in that I should probably move */
+            "Updated position (after elevation adj): (%.4f, %.4f, %.2f)\n",
+            FG_Latitude * RAD_TO_DEG, FG_Longitude * RAD_TO_DEG,
+            FG_Altitude * FEET_TO_METER);
 
+    /* end of thing that I just stuck in that I should probably move */
+               
     /* Initialize the flight model subsystem data structures base on
      * above values */
+
     fgFlightModelInit( FG_LARCSIM, f, 1.0 / DEFAULT_MODEL_HZ );
 
-    /* To HUD or not to HUD */
-    show_hud = 0;
+    // To HUD or not to HUD  - Now a command line issue
+    //              show_hud = 0;
 
-    /* Let's show the instrument panel */
+    // Let's not show the instrument panel
     displayInstruments = 0;
 
-    /* Joystick support */
-    fgJoystickInit( 0 );
+    // Joystick support
+    if (fgJoystickInit(0) ) {
+       // Joystick initialized ok.
+    } else {
+       fgPrintf( FG_GENERAL, FG_EXIT, "Error in Joystick initialization!\n" );
+    }
 
-    /* One more try here to get the sky synced up */
+    // One more try here to get the sky synced up
     fgSkyColorsInit();
+    ret_val = 0;
 
     fgPrintf(FG_GENERAL, FG_INFO,"\n");
+    return ret_val;
 }
 
 
 /* $Log$
-/* Revision 1.43  1998/02/11 02:50:40  curt
-/* Minor changes.
+/* Revision 1.44  1998/02/12 21:59:50  curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
 /*
+ * Revision 1.43  1998/02/11 02:50:40  curt
+ * Minor changes.
+ *
  * Revision 1.42  1998/02/09 22:56:58  curt
  * Removed "depend" files from cvs control.  Other minor make tweaks.
  *
index 46c8d9b931553206430aafaf34089bb0fe332bcb..30dc5230de44f78087c2e5d18a5f95cacb1566d9 100644 (file)
 #define _FG_INIT_H
 
 
-/* General house keeping initializations */
-void fgInitGeneral( void );
+// General house keeping initializations
+int fgInitGeneral ( void );
 
-/* This is the top level init routine which calls all the other
- * initialization routines.  If you are adding a subsystem to flight
- * gear, its initialization call should located in this routine.*/
-void fgInitSubsystems( void );
+// This is the top level init routine which calls all the other
+// initialization routines.  If you are adding a subsystem to flight
+// gear, its initialization call should located in this routine.
+int fgInitSubsystems( void );
 
 
 #endif /* _FG_INIT_H */
 
 
 /* $Log$
-/* Revision 1.2  1998/01/22 02:59:38  curt
-/* Changed #ifdef FILE_H to #ifdef _FILE_H
+/* Revision 1.3  1998/02/12 21:59:50  curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
 /*
+ * Revision 1.2  1998/01/22 02:59:38  curt
+ * Changed #ifdef FILE_H to #ifdef _FILE_H
+ *
  * Revision 1.1  1997/08/23 01:46:20  curt
  * Initial revision.
  *
index 0995f1654c0fb8498bae6d4df1e3230a16a1d012..dde6c85da7c41ff2da597c62b598ac00df8175ce 100644 (file)
@@ -65,10 +65,11 @@ ConvertUint(unsigned *array, unsigned int length) {
 
 static ImageRec *ImageOpen(char *fileName)
 {
-    union {
-        int testWord;
-        char testByte[4];
-    } endianTest;
+     union {
+       int testWord;
+       char testByte[4];
+     } endianTest;
+
     ImageRec *image;
     int swapFlag;
     int x;
@@ -86,7 +87,7 @@ static ImageRec *ImageOpen(char *fileName)
         exit(1);
     }
     if ((image->file = fopen(fileName, "rb")) == NULL) {
-       return NULL;
+      return NULL;
     }
 
     fread(image, 1, 12, image->file);
index 3887282e45bca3a6a5f69c4d3a442f557488f0ec..c46110142b42cfab9750bf15f5d120fad08a17f7 100644 (file)
@@ -53,8 +53,9 @@ int tiles[FG_LOCAL_X_Y];
 
 
 /* Initialize the Tile Manager subsystem */
-void fgTileMgrInit( void ) {
+int fgTileMgrInit( void ) {
     fgPrintf( FG_TERRAIN, FG_INFO, "Initializing Tile Manager subsystem.\n");
+    return 1;
 }
 
 
@@ -75,7 +76,7 @@ void fgTileMgrLoadTile( struct fgBUCKET *p, int *index) {
 
 /* given the current lon/lat, fill in the array of local chunks.  If
  * the chunk isn't already in the cache, then read it from disk. */
-void fgTileMgrUpdate( void ) {
+int fgTileMgrUpdate( void ) {
     fgFLIGHT *f;
     struct fgBUCKET p1, p2;
     static struct fgBUCKET p_last = {-1000, 0, 0, 0};
@@ -87,7 +88,7 @@ void fgTileMgrUpdate( void ) {
     dw = FG_LOCAL_X / 2;
     dh = FG_LOCAL_Y / 2;
 
-    if ( (p1.lon == p_last.lon) && (p1.lat == p_last.lat) && 
+    if ( (p1.lon == p_last.lon) && (p1.lat == p_last.lat) &&
         (p1.x == p_last.x) && (p1.y == p_last.y) ) {
        /* same bucket as last time */
        fgPrintf( FG_TERRAIN, FG_DEBUG, "Same bucket as last time\n");
@@ -96,8 +97,8 @@ void fgTileMgrUpdate( void ) {
          * relavant tiles */
 
        fgPrintf( FG_TERRAIN, FG_DEBUG, "First time through ... \n");
-       fgPrintf( FG_TERRAIN, FG_DEBUG, "Updating Tile list for %d,%d %d,%d\n", 
-              p1.lon, p1.lat, p1.x, p1.y);
+       fgPrintf( FG_TERRAIN, FG_DEBUG, "Updating Tile list for %d,%d %d,%d\n",
+                 p1.lon, p1.lat, p1.x, p1.y);
 
        /* wipe tile cache */
        fgTileCacheInit();
@@ -117,7 +118,7 @@ void fgTileMgrUpdate( void ) {
            AT ULTRA HIGH SPEEDS THIS ASSUMPTION MAY NOT BE VALID IF
            THE AIRCRAFT CAN SKIP A TILE IN A SINGLE ITERATION. */
 
-       if ( (p1.lon > p_last.lon) || 
+       if ( (p1.lon > p_last.lon) ||
             ( (p1.lon == p_last.lon) && (p1.x > p_last.x) ) ) {
            for ( j = 0; j < FG_LOCAL_Y; j++ ) {
                /* scrolling East */
@@ -128,7 +129,7 @@ void fgTileMgrUpdate( void ) {
                fgBucketOffset(&p_last, &p2, dw + 1, j - dh);
                fgTileMgrLoadTile(&p2, &tiles[(j*FG_LOCAL_Y) + FG_LOCAL_X - 1]);
            }
-       } else if ( (p1.lon < p_last.lon) || 
+       } else if ( (p1.lon < p_last.lon) ||
                    ( (p1.lon == p_last.lon) && (p1.x < p_last.x) ) ) {
            for ( j = 0; j < FG_LOCAL_Y; j++ ) {
                /* scrolling West */
@@ -141,20 +142,19 @@ void fgTileMgrUpdate( void ) {
            }
        }
 
-       if ( (p1.lat > p_last.lat) || 
+       if ( (p1.lat > p_last.lat) ||
             ( (p1.lat == p_last.lat) && (p1.y > p_last.y) ) ) {
            for ( i = 0; i < FG_LOCAL_X; i++ ) {
                /* scrolling North */
                for ( j = 0; j < FG_LOCAL_Y - 1; j++ ) {
-                   tiles[(j * FG_LOCAL_Y) + i] = 
+                   tiles[(j * FG_LOCAL_Y) + i] =
                        tiles[((j+1) * FG_LOCAL_Y) + i];
                }
                /* load in new column */
                fgBucketOffset(&p_last, &p2, i - dw, dh + 1);
-               fgTileMgrLoadTile(&p2, 
-                   &tiles[((FG_LOCAL_Y-1)*FG_LOCAL_Y) + i]);
+               fgTileMgrLoadTile(&p2, &tiles[((FG_LOCAL_Y-1)*FG_LOCAL_Y) + i]);
            }
-       } else if ( (p1.lat < p_last.lat) || 
+       } else if ( (p1.lat < p_last.lat) ||
                    ( (p1.lat == p_last.lat) && (p1.y < p_last.y) ) ) {
            for ( i = 0; i < FG_LOCAL_X; i++ ) {
                /* scrolling South */
@@ -166,12 +166,13 @@ void fgTileMgrUpdate( void ) {
                fgBucketOffset(&p_last, &p2, i - dw, -dh - 1);
                fgTileMgrLoadTile(&p2, &tiles[0 + i]);
            }
-       } 
+       }
     }
     p_last.lon = p1.lon;
     p_last.lat = p1.lat;
     p_last.x = p1.x;
     p_last.y = p1.y;
+    return 1;
 }
 
 
@@ -224,8 +225,9 @@ void fgTileMgrRender( void ) {
 
 
 /* $Log$
-/* Revision 1.15  1998/02/11 02:50:44  curt
-/* Minor changes.
+/* Revision 1.16  1998/02/12 21:59:53  curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
 /*
  * Revision 1.14  1998/02/09 21:30:19  curt
  * Fixed a nagging problem with terrain tiles not "quite" matching up perfectly.
index d61146846f7de316c3f113b58fa5444a0375e4e4..955314807fcab04137a152b2bae23cb78d03e9fa 100644 (file)
 
 
 /* Initialize the Tile Manager subsystem */
-void fgTileMgrInit( void );
+int fgTileMgrInit( void );
 
 
 /* given the current lon/lat, fill in the array of local chunks.  If
  * the chunk isn't already in the cache, then read it from disk. */
-void fgTileMgrUpdate( void );
+int fgTileMgrUpdate( void );
 
 
 /* Render the local tiles --- hack, hack, hack */
@@ -45,9 +45,13 @@ void fgTileMgrRender( void );
 
 
 /* $Log$
-/* Revision 1.4  1998/01/22 02:59:42  curt
-/* Changed #ifdef FILE_H to #ifdef _FILE_H
+/* Revision 1.5  1998/02/12 21:59:53  curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
 /*
+ * Revision 1.4  1998/01/22 02:59:42  curt
+ * Changed #ifdef FILE_H to #ifdef _FILE_H
+ *
  * Revision 1.3  1998/01/19 18:40:38  curt
  * Tons of little changes to clean up the code and to remove fatal errors
  * when building with the c++ compiler.
index a44205402d0402045ed4cbd2374c1161c516d2ca..6e65dc5875d9e7e871886ab0463ee4405edb49dc 100644 (file)
@@ -2,6 +2,8 @@
 | Todo 
 --------------------------------------------------------------------------
 
+1/12/98  - Fix time problem on win32
+
 12/29/97 - View frustum culling
 
 1/5/98 -   Create a development "roadmap"
index 7846ca5c16ed0bb401fd621a060795ecf2bc7af0..f4b2413e6dfc166575053855cb6a2dc7720f0f3b 100644 (file)
@@ -43,7 +43,7 @@ TAR = tar
 #
 #---------------------------------------------------------------------------
 
-GLOBAL_CFLAGS = -g -Wall -DVERSION=\"$(FG_VERSION)\"
+GLOBAL_CFLAGS = -Wall -DVERSION=\"$(FG_VERSION)\"
 
 
 #---------------------------------------------------------------------------
@@ -85,9 +85,7 @@ GLOBAL_CFLAGS = -g -Wall -DVERSION=\"$(FG_VERSION)\"
 #---------------------------------------------------------------------------
 # Linux/Mesa with the GLUT toolkit
 #
-INTERFACE_FLAGS = -DGLUT
 INTERFACE_LIBS = -lglut
-INTERFACE_FILES = GLUTmain.c GLUTkey.c
 MESA_LIBS = -L/usr/lib/mesa -lMesatk -lMesaaux -lMesaGLU -lMesaGL
 X11_LIBS =  -L/usr/X11R6/lib -lXext -lXmu -lXi -lX11
 GRAPHICS_LIBS = $(MESA_LIBS) $(X11_LIBS)
@@ -100,9 +98,7 @@ EXT =
 #     (Surprisingly, this also works on our SunOS 4.x machine with the 
 #     way we have Mesa & Glut installed.)
 #
-# INTERFACE_FLAGS = -DGLUT
 # INTERFACE_LIBS = -lglut
-# INTERFACE_FILES = GLUTmain.c GLUTkey.c
 # GRAPHICS_LIBS = -lGLU -lGL -lXmu -lX11
 # FG_CFLAGS = $(GLOBAL_CFLAGS) $(FG_DEBUG_FLAGS)
 # EXT =
@@ -113,9 +109,7 @@ EXT =
 # Sun/Solaris with the GLUT toolkit
 #
 # VERSION=\"$(VERSION)\"
-# INTERFACE_FLAGS = -DGLUT
 # INTERFACE_LIBS = -lglut
-# INTERFACE_FILES = GLUTmain.c GLUTkey.c
 # GRAPHICS_LIBS =  -L/opt/X11R6/lib -lGLU -lGL -lXext -lXmu -lXi -lX11 -lsocket
 # FG_CFLAGS = $(GLOBAL_CFLAGS) $(FG_DEBUG_FLAGS)
 # EXT =
@@ -125,9 +119,7 @@ EXT =
 #---------------------------------------------------------------------------
 # Cygnus Win32 (gcc based) with a static version of the GLUT toolkit
 #
-# INTERFACE_FLAGS = -DGLUT 
 # INTERFACE_LIBS = ../Win32/libglut.a
-# INTERFACE_FILES = GLUTmain.c GLUTkey.c
 # GRAPHICS_LIBS = -lglu32 -lopengl32 -luser32 -lgdi32
 # FG_CFLAGS = $(GLOBAL_CFLAGS) $(FG_DEBUG_FLAGS) -DWIN32 -DUSE_RAND
 # EXT = .exe