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.
This commit is contained in:
curt 1998-08-27 17:01:55 +00:00 committed by Tim Moore
parent 424ef2f6e9
commit 5cbbd7a14e
2 changed files with 38 additions and 24 deletions

View File

@ -29,6 +29,7 @@
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include <string>
#include <Debug/fg_debug.h> #include <Debug/fg_debug.h>
#include <Include/fg_constants.h> #include <Include/fg_constants.h>
@ -114,27 +115,24 @@ int fgReadOrbElements(struct OrbElements *dest, gzFile src) {
int fgSolarSystemInit(fgTIME t) int fgSolarSystemInit(fgTIME t)
{ {
char path[256], gzpath[256]; string path, gzpath;
int i, ret_val; int i, ret_val;
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 */ /* build the full path name to the orbital elements database file */
current_options.get_fg_root(path); path = current_options.get_fg_root() + "/Astro/planets";
strcat(path, "/Astro/"); gzpath = path + ".gz";
strcat(path, "planets");
if ( (data = fgopen(path, "rb")) == NULL ) { if ( (data = fgopen(path.c_str(), "rb")) == NULL ) {
strcpy(gzpath, path); if ( (data = fgopen(gzpath.c_str(), "rb")) == NULL ) {
strcat(gzpath, ".gz");
if ( (data = fgopen(gzpath, "rb")) == NULL ) {
fgPrintf( FG_ASTRO, FG_EXIT, 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); */ /* 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 all the objects... */
for (i = 0; i < 9; i ++) { for (i = 0; i < 9; i ++) {
@ -170,9 +168,18 @@ void fgSolarSystemUpdate(struct OrbElements *planet, fgTIME t)
/* $Log$ /* $Log$
/* Revision 1.9 1998/08/25 20:53:28 curt /* Revision 1.10 1998/08/27 17:02:00 curt
/* Shuffled $FG_ROOT file layout. /* 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 * Revision 1.8 1998/08/22 01:18:59 curt
* Minor tweaks to avoid using unitialized memory. * Minor tweaks to avoid using unitialized memory.
* *

View File

@ -35,6 +35,7 @@
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <string>
#include <time.h> #include <time.h>
#include <GL/glut.h> #include <GL/glut.h>
@ -67,7 +68,7 @@ int fgStarsInit( void ) {
fgPoint3d starlist[FG_MAX_STARS]; fgPoint3d starlist[FG_MAX_STARS];
fgFile fd; fgFile fd;
/* struct CelestialCoord pltPos; */ /* struct CelestialCoord pltPos; */
char path[256], gzpath[256]; string path, gzpath;
char line[256], name[256]; char line[256], name[256];
char *front, *end; char *front, *end;
double right_ascension, declination, magnitude; double right_ascension, declination, magnitude;
@ -79,24 +80,21 @@ int fgStarsInit( void ) {
fgPrintf( FG_ASTRO, FG_INFO, "Initializing stars\n"); fgPrintf( FG_ASTRO, FG_INFO, "Initializing stars\n");
/* build the full path name to the stars data base file */ /* build the full path name to the stars data base file */
current_options.get_fg_root(path); path = current_options.get_fg_root() + "/Astro/stars";
strcat(path, "/Astro/"); gzpath = path + ".gz";
strcat(path, "stars");
if ( FG_STAR_LEVELS < 4 ) { if ( FG_STAR_LEVELS < 4 ) {
fgPrintf( FG_ASTRO, FG_EXIT, "Big whups in stars.cxx\n"); 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 // load star data file
if ( (fd = fgopen(path, "rb")) == NULL ) { if ( (fd = fgopen(path.c_str(), "rb")) == NULL ) {
strcpy(gzpath, path); if ( (fd = fgopen(gzpath.c_str(), "rb")) == NULL ) {
strcat(gzpath, ".gz");
if ( (fd = fgopen(gzpath, "rb")) == NULL ) {
// Oops, lets not even try to continue. This is critical. // Oops, lets not even try to continue. This is critical.
fgPrintf( FG_ASTRO, FG_EXIT, 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$ /* $Log$
/* Revision 1.11 1998/08/25 20:53:29 curt /* Revision 1.12 1998/08/27 17:02:01 curt
/* Shuffled $FG_ROOT file layout. /* 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 * Revision 1.10 1998/08/10 20:33:09 curt
* Rewrote star loading and rendering to: * Rewrote star loading and rendering to:
* 1. significantly improve load speed * 1. significantly improve load speed