From 5cbbd7a14ea3f8f10bcfd00260f0692045e96a14 Mon Sep 17 00:00:00 2001 From: curt Date: Thu, 27 Aug 1998 17:01:55 +0000 Subject: [PATCH] Contributions from Bernie Bright - 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 | 31 +++++++++++++++++++------------ Astro/stars.cxx | 31 +++++++++++++++++++------------ 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/Astro/orbits.cxx b/Astro/orbits.cxx index ac74a222..eeca3ce6 100644 --- a/Astro/orbits.cxx +++ b/Astro/orbits.cxx @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -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"); + path = current_options.get_fg_root() + "/Astro/planets"; + gzpath = path + ".gz"; - if ( (data = fgopen(path, "rb")) == NULL ) { - strcpy(gzpath, path); - strcat(gzpath, ".gz"); - if ( (data = fgopen(gzpath, "rb")) == NULL ) { + 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 +/* - 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. * diff --git a/Astro/stars.cxx b/Astro/stars.cxx index b3954bd3..3eed6dc9 100644 --- a/Astro/stars.cxx +++ b/Astro/stars.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -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 +/* - 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