]> git.mxchange.org Git - simgear.git/commitdiff
Contributions from Bernie Bright <bbright@c031.aone.net.au>
authorcurt <curt>
Thu, 27 Aug 1998 17:01:55 +0000 (17:01 +0000)
committerTim Moore <timoore@redhat.com>
Tue, 15 Sep 2009 16:31:30 +0000 (18:31 +0200)
- use strings for fg_root and airport_id and added methods to return
  them as strings,
- inlined all access methods,
- made the parsing functions private methods,
- deleted some unused functions.
- propogated some of these changes out a bit further.

Astro/orbits.cxx
Astro/stars.cxx

index ac74a2226e6c9c4a39fad7e91588e490a15a8b00..eeca3ce6b7aa9709bbb16feeb679baee0b12783f 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <math.h>
 #include <string.h>
+#include <string>
 
 #include <Debug/fg_debug.h>
 #include <Include/fg_constants.h>
@@ -114,27 +115,24 @@ int fgReadOrbElements(struct OrbElements *dest, gzFile src) {
 
 int fgSolarSystemInit(fgTIME t)
 {
-    char path[256], gzpath[256];
+    string path, gzpath;
     int i, ret_val;
 
     fgPrintf( FG_ASTRO, FG_INFO, "Initializing solar system\n");
 
     /* build the full path name to the orbital elements database file */
-    current_options.get_fg_root(path);
-    strcat(path, "/Astro/");
-    strcat(path, "planets");
-
-    if ( (data = fgopen(path, "rb")) == NULL ) {
-       strcpy(gzpath, path);
-       strcat(gzpath, ".gz");
-       if ( (data = fgopen(gzpath, "rb")) == NULL ) {
+    path = current_options.get_fg_root() + "/Astro/planets";
+    gzpath = path + ".gz";
+
+    if ( (data = fgopen(path.c_str(), "rb")) == NULL ) {
+       if ( (data = fgopen(gzpath.c_str(), "rb")) == NULL ) {
            fgPrintf( FG_ASTRO, FG_EXIT,
-                     "Cannot open data file: '%s'\n", path);
+                     "Cannot open data file: '%s'\n", path.c_str());
        }
     }
 
     /* printf("  reading datafile %s\n", path); */
-    fgPrintf( FG_ASTRO, FG_INFO, "  reading datafile %s\n", path);
+    fgPrintf( FG_ASTRO, FG_INFO, "  reading datafile %s\n", path.c_str());
 
     /* for all the objects... */
     for (i = 0; i < 9; i ++) {
@@ -170,9 +168,18 @@ void fgSolarSystemUpdate(struct OrbElements *planet, fgTIME t)
 
 
 /* $Log$
-/* Revision 1.9  1998/08/25 20:53:28  curt
-/* Shuffled $FG_ROOT file layout.
+/* Revision 1.10  1998/08/27 17:02:00  curt
+/* Contributions from Bernie Bright <bbright@c031.aone.net.au>
+/* - use strings for fg_root and airport_id and added methods to return
+/*   them as strings,
+/* - inlined all access methods,
+/* - made the parsing functions private methods,
+/* - deleted some unused functions.
+/* - propogated some of these changes out a bit further.
 /*
+ * Revision 1.9  1998/08/25 20:53:28  curt
+ * Shuffled $FG_ROOT file layout.
+ *
  * Revision 1.8  1998/08/22 01:18:59  curt
  * Minor tweaks to avoid using unitialized memory.
  *
index b3954bd3bf6f66b3ec9de20458b0b159e7741fd3..3eed6dc9168946d95bdf87042541150c0a944bcd 100644 (file)
@@ -35,6 +35,7 @@
 #include <math.h>
 #include <stdio.h>
 #include <string.h>
+#include <string>
 #include <time.h>
 
 #include <GL/glut.h>
@@ -67,7 +68,7 @@ int fgStarsInit( void ) {
     fgPoint3d starlist[FG_MAX_STARS];
     fgFile fd;
     /* struct CelestialCoord pltPos; */
-    char path[256], gzpath[256];
+    string path, gzpath;
     char line[256], name[256];
     char *front, *end;
     double right_ascension, declination, magnitude;
@@ -79,24 +80,21 @@ int fgStarsInit( void ) {
     fgPrintf( FG_ASTRO, FG_INFO, "Initializing stars\n");
 
     /* build the full path name to the stars data base file */
-    current_options.get_fg_root(path);
-    strcat(path, "/Astro/");
-    strcat(path, "stars");
+    path = current_options.get_fg_root() + "/Astro/stars";
+    gzpath = path + ".gz";
 
     if ( FG_STAR_LEVELS < 4 ) {
        fgPrintf( FG_ASTRO, FG_EXIT, "Big whups in stars.cxx\n");
     }
 
-    fgPrintf( FG_ASTRO, FG_INFO, "  Loading stars from %s\n", path);
+    fgPrintf( FG_ASTRO, FG_INFO, "  Loading stars from %s\n", path.c_str() );
 
     // load star data file
-    if ( (fd = fgopen(path, "rb")) == NULL ) {
-       strcpy(gzpath, path);
-       strcat(gzpath, ".gz");
-       if ( (fd = fgopen(gzpath, "rb")) == NULL ) {
+    if ( (fd = fgopen(path.c_str(), "rb")) == NULL ) {
+       if ( (fd = fgopen(gzpath.c_str(), "rb")) == NULL ) {
            // Oops, lets not even try to continue. This is critical.
            fgPrintf( FG_ASTRO, FG_EXIT,
-                     "Cannot open star file: '%s'\n", path);
+                     "Cannot open star file: '%s'\n", path.c_str() );
        }
     }
 
@@ -288,9 +286,18 @@ void fgStarsRender( void ) {
 
 
 /* $Log$
-/* Revision 1.11  1998/08/25 20:53:29  curt
-/* Shuffled $FG_ROOT file layout.
+/* Revision 1.12  1998/08/27 17:02:01  curt
+/* Contributions from Bernie Bright <bbright@c031.aone.net.au>
+/* - use strings for fg_root and airport_id and added methods to return
+/*   them as strings,
+/* - inlined all access methods,
+/* - made the parsing functions private methods,
+/* - deleted some unused functions.
+/* - propogated some of these changes out a bit further.
 /*
+ * Revision 1.11  1998/08/25 20:53:29  curt
+ * Shuffled $FG_ROOT file layout.
+ *
  * Revision 1.10  1998/08/10 20:33:09  curt
  * Rewrote star loading and rendering to:
  *   1. significantly improve load speed