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:
parent
fec4bef345
commit
283a23159a
13 changed files with 568 additions and 576 deletions
|
@ -40,35 +40,32 @@ fgAIRPORTS::fgAIRPORTS( void ) {
|
|||
|
||||
|
||||
// load the data
|
||||
int fgAIRPORTS::load( char *file ) {
|
||||
int fgAIRPORTS::load( const string& file ) {
|
||||
fgAIRPORT a;
|
||||
char path[256], fgpath[256], line[256];
|
||||
char id[5];
|
||||
string id_str;
|
||||
string path, fgpath, id;
|
||||
char id_raw[256], line[256];
|
||||
fgFile f;
|
||||
|
||||
// build the path name to the airport file
|
||||
current_options.get_fg_root(path);
|
||||
strcat(path, "/Airports/");
|
||||
strcat(path, file);
|
||||
strcpy(fgpath, path);
|
||||
strcat(fgpath, ".gz");
|
||||
path = current_options.get_fg_root() + "/Airports/" + file;
|
||||
fgpath = path + ".gz";
|
||||
|
||||
// first try "path.gz"
|
||||
if ( (f = fgopen(fgpath, "rb")) == NULL ) {
|
||||
if ( (f = fgopen(fgpath.c_str(), "rb")) == NULL ) {
|
||||
// next try "path"
|
||||
if ( (f = fgopen(path, "rb")) == NULL ) {
|
||||
fgPrintf(FG_GENERAL, FG_EXIT, "Cannot open file: %s\n", path);
|
||||
if ( (f = fgopen(path.c_str(), "rb")) == NULL ) {
|
||||
fgPrintf( FG_GENERAL, FG_EXIT, "Cannot open file: %s\n",
|
||||
path.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
while ( fggets(f, line, 250) != NULL ) {
|
||||
// printf("%s", line);
|
||||
|
||||
sscanf( line, "%s %lf %lf %lfl\n", id, &a.longitude, &a.latitude,
|
||||
sscanf( line, "%s %lf %lf %lfl\n", id_raw, &a.longitude, &a.latitude,
|
||||
&a.elevation );
|
||||
id_str = id;
|
||||
airports[id_str] = a;
|
||||
id = id_raw;
|
||||
airports[id] = a;
|
||||
}
|
||||
|
||||
fgclose(f);
|
||||
|
@ -100,6 +97,15 @@ fgAIRPORTS::~fgAIRPORTS( void ) {
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.3 1998/08/27 17:01:55 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.2 1998/08/25 20:53:24 curt
|
||||
// Shuffled $FG_ROOT file layout.
|
||||
//
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
fgAIRPORTS( void );
|
||||
|
||||
// load the data
|
||||
int load( char *file );
|
||||
int load( const string& file );
|
||||
|
||||
// search for the specified id
|
||||
fgAIRPORT search( char *id );
|
||||
|
@ -74,6 +74,15 @@ public:
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.2 1998/08/27 17:01:56 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.1 1998/08/25 17:19:14 curt
|
||||
// Moved from ../Main/
|
||||
//
|
||||
|
|
|
@ -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");
|
||||
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 <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.
|
||||
*
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include <Aircraft/aircraft.h>
|
||||
#include <Debug/fg_debug.h>
|
||||
|
@ -286,7 +287,7 @@ static IMAGE *ImageLoad(char *fileName)
|
|||
|
||||
|
||||
void fgPanelInit ( void ) {
|
||||
char tpath[256];
|
||||
string tpath;
|
||||
int x, y;
|
||||
|
||||
#ifdef GL_VERSION_1_1
|
||||
|
@ -307,13 +308,11 @@ void fgPanelInit ( void ) {
|
|||
xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
/* load in the texture data */
|
||||
current_options.get_fg_root(tpath);
|
||||
strcat(tpath, "/Textures/");
|
||||
strcat(tpath, "panel1.rgb");
|
||||
tpath = current_options.get_fg_root() + "/Textures/panel1.rgb";
|
||||
|
||||
if ( (img = ImageLoad(tpath)) == NULL ){
|
||||
if ( (img = ImageLoad((char *)tpath.c_str()) ) == NULL ){
|
||||
fgPrintf( FG_COCKPIT, FG_EXIT,
|
||||
"Error loading cockpit texture %s\n", tpath );
|
||||
"Error loading cockpit texture %s\n", tpath.c_str() );
|
||||
}
|
||||
|
||||
for ( y = 0; y < 256; y++ ) {
|
||||
|
@ -416,10 +415,19 @@ void fgPanelUpdate ( void ) {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.4 1998/07/24 21:37:00 curt
|
||||
/* Ran dos2unix to get rid of extraneous ^M's. Tweaked parameter in
|
||||
/* ImageGetRawData() to match usage.
|
||||
/* Revision 1.5 1998/08/27 17:02:03 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.4 1998/07/24 21:37:00 curt
|
||||
* Ran dos2unix to get rid of extraneous ^M's. Tweaked parameter in
|
||||
* ImageGetRawData() to match usage.
|
||||
*
|
||||
* Revision 1.3 1998/07/13 21:00:52 curt
|
||||
* Integrated Charlies latest HUD updates.
|
||||
* Wrote access functions for current fgOPTIONS.
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <XGL/xgl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
|
@ -454,6 +455,8 @@ void fgInitTimeDepCalcs( void ) {
|
|||
|
||||
}
|
||||
|
||||
static const double alt_adjust_ft = 3.758099;
|
||||
static const double alt_adjust_m = alt_adjust_ft * FEET_TO_METER;
|
||||
|
||||
// What should we do when we have nothing else to do? Let's get ready
|
||||
// for the next move and update the display?
|
||||
|
@ -485,15 +488,14 @@ static void fgMainLoop( void ) {
|
|||
|
||||
if ( scenery.cur_elev > -9990 ) {
|
||||
if ( FG_Altitude * FEET_TO_METER <
|
||||
(scenery.cur_elev + 3.758099 * FEET_TO_METER - 3.0) ) {
|
||||
(scenery.cur_elev + alt_adjust_m - 3.0) ) {
|
||||
// now set aircraft altitude above ground
|
||||
printf("Current Altitude = %.2f < %.2f forcing to %.2f\n",
|
||||
FG_Altitude * FEET_TO_METER,
|
||||
scenery.cur_elev + 3.758099 * FEET_TO_METER - 3.0,
|
||||
scenery.cur_elev + 3.758099 * FEET_TO_METER);
|
||||
scenery.cur_elev + alt_adjust_m - 3.0,
|
||||
scenery.cur_elev + alt_adjust_m );
|
||||
fgFlightModelSetAltitude( current_options.get_flight_model(), f,
|
||||
scenery.cur_elev +
|
||||
3.758099 * FEET_TO_METER);
|
||||
scenery.cur_elev + alt_adjust_m );
|
||||
|
||||
fgPrintf( FG_ALL, FG_BULK,
|
||||
"<*> resetting altitude to %.0f meters\n",
|
||||
|
@ -597,8 +599,6 @@ static void fgMainLoop( void ) {
|
|||
|
||||
static void fgIdleFunction ( void ) {
|
||||
fgGENERAL *g;
|
||||
char path[256], mp3file[256], command[256], slfile[256];
|
||||
static char *lockfile = "/tmp/mpg123.running";
|
||||
|
||||
g = &general;
|
||||
|
||||
|
@ -615,16 +615,14 @@ static void fgIdleFunction ( void ) {
|
|||
// Start the intro music
|
||||
#if !defined(WIN32)
|
||||
if ( current_options.get_intro_music() ) {
|
||||
current_options.get_fg_root(mp3file);
|
||||
strcat(mp3file, "/Sounds/");
|
||||
strcat(mp3file, "intro.mp3");
|
||||
|
||||
sprintf(command,
|
||||
"(touch %s; mpg123 %s > /dev/null 2>&1; /bin/rm %s) &",
|
||||
lockfile, mp3file, lockfile );
|
||||
string lockfile = "/tmp/mpg123.running";
|
||||
string mp3file = current_options.get_fg_root() +
|
||||
"/Sounds/intro.mp3";
|
||||
string command = "(touch " + lockfile + "; mpg123 " + mp3file +
|
||||
"> /dev/null 2>&1; /bin/rm " + lockfile + ") &";
|
||||
fgPrintf( FG_GENERAL, FG_INFO,
|
||||
"Starting intro music: %s\n", mp3file);
|
||||
system ( command );
|
||||
"Starting intro music: %s\n", mp3file.c_str() );
|
||||
system ( command.c_str() );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -672,11 +670,12 @@ static void fgIdleFunction ( void ) {
|
|||
#if !defined(WIN32)
|
||||
if ( current_options.get_intro_music() ) {
|
||||
// Let's wait for mpg123 to finish
|
||||
string lockfile = "/tmp/mpg123.running";
|
||||
struct stat stat_buf;
|
||||
|
||||
fgPrintf( FG_GENERAL, FG_INFO,
|
||||
"Waiting for mpg123 player to finish ...\n" );
|
||||
while ( stat(lockfile, &stat_buf) == 0 ) {
|
||||
while ( stat(lockfile.c_str(), &stat_buf) == 0 ) {
|
||||
// file exist, wait ...
|
||||
sleep(1);
|
||||
fgPrintf( FG_GENERAL, FG_INFO, ".");
|
||||
|
@ -689,12 +688,9 @@ static void fgIdleFunction ( void ) {
|
|||
audio_mixer = new smMixer;
|
||||
audio_mixer -> setMasterVolume ( 80 ) ; /* 80% of max volume. */
|
||||
audio_sched -> setSafetyMargin ( 1.0 ) ;
|
||||
current_options.get_fg_root(path);
|
||||
strcat(path, "/Sounds/");
|
||||
strcpy(slfile, path);
|
||||
strcat(slfile, "wasp.wav");
|
||||
string slfile = current_options.get_fg_root() + "/Sounds/wasp.wav";
|
||||
|
||||
s1 = new slSample ( slfile );
|
||||
s1 = new slSample ( (char *)slfile.c_str() );
|
||||
printf("Rate = %d Bps = %d Stereo = %d\n",
|
||||
s1 -> getRate(), s1 -> getBps(), s1 -> getStereo());
|
||||
audio_sched -> loopSample ( s1 );
|
||||
|
@ -805,8 +801,6 @@ int fgGlutInitEvents( void ) {
|
|||
// Main ...
|
||||
int main( int argc, char **argv ) {
|
||||
fgFLIGHT *f;
|
||||
char config[256];
|
||||
int result; // Used in command line argument.
|
||||
|
||||
f = current_aircraft.flight;
|
||||
|
||||
|
@ -821,21 +815,22 @@ int main( int argc, char **argv ) {
|
|||
|
||||
// Attempt to locate and parse a config file
|
||||
// First check fg_root
|
||||
current_options.get_fg_root(config);
|
||||
strcat(config, "/system.fgfsrc");
|
||||
result = current_options.parse_config_file(config);
|
||||
string config = current_options.get_fg_root() + "/system.fgfsrc";
|
||||
current_options.parse_config_file( config );
|
||||
|
||||
// Next check home directory
|
||||
if ( getenv("HOME") != NULL ) {
|
||||
strcpy(config, getenv("HOME"));
|
||||
strcat(config, "/.fgfsrc");
|
||||
result = current_options.parse_config_file(config);
|
||||
char* envp = ::getenv( "HOME" );
|
||||
if ( envp != NULL ) {
|
||||
config = envp;
|
||||
config += "/.fgfsrc";
|
||||
current_options.parse_config_file( config );
|
||||
}
|
||||
|
||||
// Parse remaining command line options
|
||||
// These will override anything specified in a config file
|
||||
result = current_options.parse_command_line(argc, argv);
|
||||
if ( result != FG_OPTIONS_OK ) {
|
||||
if ( current_options.parse_command_line(argc, argv) !=
|
||||
fgOPTIONS::FG_OPTIONS_OK )
|
||||
{
|
||||
// Something must have gone horribly wrong with the command
|
||||
// line parsing or maybe the user just requested help ... :-)
|
||||
current_options.usage();
|
||||
|
@ -872,6 +867,15 @@ int main( int argc, char **argv ) {
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.47 1998/08/27 17:02:04 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.46 1998/08/22 14:49:56 curt
|
||||
// Attempting to iron out seg faults and crashes.
|
||||
// Did some shuffling to fix a initialization order problem between view
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include <Include/fg_constants.h>
|
||||
#include <Include/general.h>
|
||||
|
@ -74,13 +75,13 @@ extern const char *default_root;
|
|||
|
||||
// Set initial position and orientation
|
||||
int fgInitPosition( void ) {
|
||||
char id[5];
|
||||
string id;
|
||||
fgFLIGHT *f;
|
||||
|
||||
f = current_aircraft.flight;
|
||||
|
||||
current_options.get_airport_id(id);
|
||||
if ( strlen(id) ) {
|
||||
id = current_options.get_airport_id();
|
||||
if ( id.length() ) {
|
||||
// set initial position from airport id
|
||||
|
||||
fgAIRPORTS airports;
|
||||
|
@ -88,15 +89,15 @@ int fgInitPosition( void ) {
|
|||
|
||||
fgPrintf( FG_GENERAL, FG_INFO,
|
||||
"Attempting to set starting position from airport code %s.\n",
|
||||
id);
|
||||
id.c_str() );
|
||||
|
||||
airports.load("apt_simple");
|
||||
a = airports.search(id);
|
||||
a = airports.search( (char *)id.c_str() );
|
||||
if ( (fabs(a.longitude) < FG_EPSILON) &&
|
||||
(fabs(a.latitude) < FG_EPSILON) &&
|
||||
(fabs(a.elevation) < FG_EPSILON) ) {
|
||||
fgPrintf( FG_GENERAL, FG_EXIT,
|
||||
"Failed to find %s in database.\n", id);
|
||||
"Failed to find %s in database.\n", id.c_str() );
|
||||
} else {
|
||||
FG_Longitude = ( a.longitude ) * DEG_TO_RAD;
|
||||
FG_Latitude = ( a.latitude ) * DEG_TO_RAD;
|
||||
|
@ -125,7 +126,7 @@ int fgInitPosition( void ) {
|
|||
// General house keeping initializations
|
||||
int fgInitGeneral( void ) {
|
||||
fgGENERAL *g;
|
||||
char root[256];
|
||||
string root;
|
||||
int i;
|
||||
|
||||
g = &general;
|
||||
|
@ -137,14 +138,14 @@ int fgInitGeneral( void ) {
|
|||
g->glRenderer = (char *)glGetString ( GL_RENDERER );
|
||||
g->glVersion = (char *)glGetString ( GL_VERSION );
|
||||
|
||||
current_options.get_fg_root(root);
|
||||
if ( !strlen(root) ) {
|
||||
root = current_options.get_fg_root();
|
||||
if ( ! root.length() ) {
|
||||
// No root path set? Then bail ...
|
||||
fgPrintf( FG_GENERAL, FG_EXIT, "%s %s\n",
|
||||
"Cannot continue without environment variable FG_ROOT",
|
||||
"being defined.");
|
||||
}
|
||||
fgPrintf( FG_GENERAL, FG_INFO, "FG_ROOT = %s\n\n", root);
|
||||
fgPrintf( FG_GENERAL, FG_INFO, "FG_ROOT = %s\n\n", root.c_str() );
|
||||
|
||||
// prime the frame rate counter pump
|
||||
for ( i = 0; i < FG_FRAME_RATE_HISTORY; i++ ) {
|
||||
|
@ -388,6 +389,15 @@ int fgInitSubsystems( void ) {
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.34 1998/08/27 17:02:06 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.33 1998/08/25 20:53:32 curt
|
||||
// Shuffled $FG_ROOT file layout.
|
||||
//
|
||||
|
|
576
Main/options.cxx
576
Main/options.cxx
|
@ -31,6 +31,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h> // atof(), atoi()
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include <Debug/fg_debug.h>
|
||||
#include <Flight/flight.h>
|
||||
|
@ -39,187 +40,154 @@
|
|||
|
||||
#include "options.hxx"
|
||||
|
||||
inline double
|
||||
atof( const string& str )
|
||||
{
|
||||
return ::atof( str.c_str() );
|
||||
}
|
||||
|
||||
inline int
|
||||
atoi( const string& str )
|
||||
{
|
||||
return ::atoi( str.c_str() );
|
||||
}
|
||||
|
||||
// Defined the shared options class here
|
||||
fgOPTIONS current_options;
|
||||
|
||||
|
||||
// Constructor
|
||||
fgOPTIONS::fgOPTIONS( void ) {
|
||||
// set initial values/defaults
|
||||
fgOPTIONS::fgOPTIONS() :
|
||||
// starting longitude in degrees (west = -)
|
||||
// starting latitude in degrees (south = -)
|
||||
|
||||
if ( getenv("FG_ROOT") != NULL ) {
|
||||
// Default initial position is Globe, AZ (P13)
|
||||
lon(-110.6642444),
|
||||
lat( 33.3528917),
|
||||
|
||||
// North of the city of Globe
|
||||
// lon(-110.7),
|
||||
// lat( 33.4),
|
||||
|
||||
// North of the city of Globe
|
||||
// lon(-110.742578),
|
||||
// lat( 33.507122),
|
||||
|
||||
// Near where I used to live in Globe, AZ
|
||||
// lon(-110.766000),
|
||||
// lat( 33.377778),
|
||||
|
||||
// 10125 Jewell St. NE
|
||||
// lon(-93.15),
|
||||
// lat( 45.15),
|
||||
|
||||
// Near KHSP (Hot Springs, VA)
|
||||
// lon(-79.8338964 + 0.01),
|
||||
// lat( 37.9514564 + 0.008),
|
||||
|
||||
// (SEZ) SEDONA airport
|
||||
// lon(-111.7884614 + 0.01),
|
||||
// lat( 34.8486289 - 0.015),
|
||||
|
||||
// Somewhere near the Grand Canyon
|
||||
// lon(-112.5),
|
||||
// lat( 36.5),
|
||||
|
||||
// Jim Brennon's Kingmont Observatory
|
||||
// lon(-121.1131667),
|
||||
// lat( 38.8293917),
|
||||
|
||||
// Huaras, Peru (S09d 31.871' W077d 31.498')
|
||||
// lon(-77.5249667),
|
||||
// lat( -9.5311833),
|
||||
|
||||
// Eclipse Watching w73.5 n10 (approx) 18:00 UT
|
||||
// lon(-73.5),
|
||||
// lat( 10.0),
|
||||
|
||||
// Test Position
|
||||
// lon( 8.5),
|
||||
// lat(47.5),
|
||||
|
||||
// Timms Hill (WI)
|
||||
// lon(-90.1953055556),
|
||||
// lat( 45.4511388889),
|
||||
|
||||
// starting altitude in meters (this will be reset to ground level
|
||||
// if it is lower than the terrain
|
||||
altitude(-9999.0),
|
||||
|
||||
// Initial Orientation
|
||||
heading(270.0), // heading (yaw) angle in degress (Psi)
|
||||
roll(0.0), // roll angle in degrees (Phi)
|
||||
pitch(0.424), // pitch angle in degrees (Theta)
|
||||
|
||||
// Miscellaneous
|
||||
game_mode(0),
|
||||
splash_screen(1),
|
||||
intro_music(1),
|
||||
mouse_pointer(0),
|
||||
pause(0),
|
||||
|
||||
// Features
|
||||
hud_status(1),
|
||||
panel_status(0),
|
||||
sound(1),
|
||||
|
||||
// Flight Model options
|
||||
flight_model(FG_LARCSIM),
|
||||
|
||||
// Rendering options
|
||||
fog(FG_FOG_NICEST), // nicest
|
||||
fov(55.0),
|
||||
fullscreen(0),
|
||||
shading(1),
|
||||
skyblend(1),
|
||||
textures(1),
|
||||
wireframe(0),
|
||||
|
||||
// Scenery options
|
||||
tile_diameter(5),
|
||||
|
||||
// HUD options
|
||||
tris_or_culled(0),
|
||||
|
||||
// Time options
|
||||
time_offset(0)
|
||||
{
|
||||
// set initial values/defaults
|
||||
char* envp = ::getenv( "FG_ROOT" );
|
||||
|
||||
if ( envp != NULL ) {
|
||||
// fg_root could be anywhere, so default to environmental
|
||||
// variable $FG_ROOT if it is set.
|
||||
|
||||
strcpy(fg_root, getenv("FG_ROOT"));
|
||||
fg_root = envp;
|
||||
} else {
|
||||
// Otherwise, default to a random compiled in location if
|
||||
// $FG_ROOT is not set. This can still be overridden from the
|
||||
// command line or a config file.
|
||||
|
||||
#if defined(WIN32)
|
||||
strcpy(fg_root, "\\FlightGear");
|
||||
fg_root = "\\FlightGear";
|
||||
#else
|
||||
strcpy(fg_root, "/usr/local/lib/FlightGear");
|
||||
fg_root = "/usr/local/lib/FlightGear";
|
||||
#endif
|
||||
}
|
||||
|
||||
// Starting posistion and orientation
|
||||
strcpy(airport_id, ""); // default airport id
|
||||
lon = 0.0; // starting longitude in degrees (west = -)
|
||||
lat = 0.0; // starting latitude in degrees (south = -)
|
||||
|
||||
// If nothing else is specified, default initial position is
|
||||
// Globe, AZ (P13)
|
||||
lon = -110.6642444;
|
||||
lat = 33.3528917;
|
||||
|
||||
// North of the city of Globe
|
||||
// lon = -110.7;
|
||||
// lat = 33.4;
|
||||
|
||||
// North of the city of Globe
|
||||
// lon = -110.742578;
|
||||
// lat = 33.507122;
|
||||
|
||||
// Near where I used to live in Globe, AZ
|
||||
// lon = -110.766000;
|
||||
// lat = 33.377778;
|
||||
|
||||
// 10125 Jewell St. NE
|
||||
// lon = -93.15;
|
||||
// lat = 45.15;
|
||||
|
||||
// Near KHSP (Hot Springs, VA)
|
||||
// lon = -79.8338964 + 0.01;
|
||||
// lat = 37.9514564 + 0.008;
|
||||
|
||||
// (SEZ) SEDONA airport
|
||||
// lon = -111.7884614 + 0.01;
|
||||
// lat = 34.8486289 - 0.015;
|
||||
|
||||
// Somewhere near the Grand Canyon
|
||||
// lon = -112.5;
|
||||
// lat = 36.5;
|
||||
|
||||
// Jim Brennon's Kingmont Observatory
|
||||
// lon = -121.1131667;
|
||||
// lat = 38.8293917;
|
||||
|
||||
// Huaras, Peru (S09d 31.871' W077d 31.498')
|
||||
// lon = -77.5249667;
|
||||
// lat = -9.5311833;
|
||||
|
||||
// Eclipse Watching w73.5 n10 (approx) 18:00 UT
|
||||
// lon = -73.5;
|
||||
// lat = 10.0;
|
||||
|
||||
// Test Position
|
||||
// lon = 8.5;
|
||||
// lat = 47.5;
|
||||
|
||||
// Timms Hill (WI)
|
||||
// lon = -90.1953055556;
|
||||
// lat = 45.4511388889;
|
||||
|
||||
altitude = -9999.0; // starting altitude in meters (this will be
|
||||
// reset to ground level if it is lower
|
||||
// than the terrain
|
||||
|
||||
// Initial Orientation
|
||||
heading = 270.0; // heading (yaw) angle in degress (Psi)
|
||||
roll = 0.0; // roll angle in degrees (Phi)
|
||||
pitch = 0.424; // pitch angle in degrees (Theta)
|
||||
|
||||
// Miscellaneous
|
||||
game_mode = 0;
|
||||
splash_screen = 1;
|
||||
intro_music = 1;
|
||||
mouse_pointer = 0;
|
||||
pause = 0;
|
||||
|
||||
// Features
|
||||
hud_status = 1;
|
||||
panel_status = 0;
|
||||
sound = 1;
|
||||
|
||||
// Flight Model options
|
||||
flight_model = FG_LARCSIM;
|
||||
|
||||
// Rendering options
|
||||
fog = 2; // nicest
|
||||
fov = 55.0;
|
||||
fullscreen = 0;
|
||||
shading = 1;
|
||||
skyblend = 1;
|
||||
textures = 1;
|
||||
wireframe = 0;
|
||||
|
||||
// Scenery options
|
||||
tile_diameter = 5;
|
||||
|
||||
// HUD options
|
||||
tris_or_culled = 0;
|
||||
|
||||
// Time options
|
||||
time_offset = 0;
|
||||
airport_id = ""; // default airport id
|
||||
}
|
||||
|
||||
|
||||
// Parse an int out of a --foo-bar=n type option
|
||||
static int parse_int(char *arg) {
|
||||
int result;
|
||||
|
||||
// advance past the '='
|
||||
while ( (arg[0] != '=') && (arg[0] != '\0') ) {
|
||||
arg++;
|
||||
}
|
||||
|
||||
if ( arg[0] == '=' ) {
|
||||
arg++;
|
||||
}
|
||||
|
||||
// printf("parse_int(): arg = %s\n", arg);
|
||||
|
||||
result = atoi(arg);
|
||||
|
||||
// printf("parse_int(): result = %d\n", result);
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
// Parse an int out of a --foo-bar=n type option
|
||||
static double parse_double(char *arg) {
|
||||
double result;
|
||||
|
||||
// advance past the '='
|
||||
while ( (arg[0] != '=') && (arg[0] != '\0') ) {
|
||||
arg++;
|
||||
}
|
||||
|
||||
if ( arg[0] == '=' ) {
|
||||
arg++;
|
||||
}
|
||||
|
||||
// printf("parse_double(): arg = %s\n", arg);
|
||||
|
||||
result = atof(arg);
|
||||
|
||||
// printf("parse_double(): result = %.4f\n", result);
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
static double parse_time(char *time_str) {
|
||||
char num[256];
|
||||
double
|
||||
fgOPTIONS::parse_time(const string& time_in) {
|
||||
char *time_str, num[256];
|
||||
double hours, minutes, seconds;
|
||||
double result = 0.0;
|
||||
int sign = 1;
|
||||
int i;
|
||||
|
||||
time_str = (char *)time_in.c_str();
|
||||
|
||||
// printf("parse_time(): %s\n", time_str);
|
||||
|
||||
// check for sign
|
||||
|
@ -290,19 +258,9 @@ static double parse_time(char *time_str) {
|
|||
|
||||
|
||||
// parse degree in the form of [+/-]hhh:mm:ss
|
||||
static double parse_degree(char *degree_str) {
|
||||
double result;
|
||||
|
||||
// advance past the '='
|
||||
while ( (degree_str[0] != '=') && (degree_str[0] != '\0') ) {
|
||||
degree_str++;
|
||||
}
|
||||
|
||||
if ( degree_str[0] == '=' ) {
|
||||
degree_str++;
|
||||
}
|
||||
|
||||
result = parse_time(degree_str);
|
||||
double
|
||||
fgOPTIONS::parse_degree( const string& degree_str) {
|
||||
double result = parse_time( degree_str );
|
||||
|
||||
// printf("Degree = %.4f\n", result);
|
||||
|
||||
|
@ -311,18 +269,10 @@ static double parse_degree(char *degree_str) {
|
|||
|
||||
|
||||
// parse time offset command line option
|
||||
static int parse_time_offset(char *time_str) {
|
||||
int
|
||||
fgOPTIONS::parse_time_offset( const string& time_str) {
|
||||
int result;
|
||||
|
||||
// advance past the '='
|
||||
while ( (time_str[0] != '=') && (time_str[0] != '\0') ) {
|
||||
time_str++;
|
||||
}
|
||||
|
||||
if ( time_str[0] == '=' ) {
|
||||
time_str++;
|
||||
}
|
||||
|
||||
// printf("time offset = %s\n", time_str);
|
||||
|
||||
#ifdef HAVE_RINT
|
||||
|
@ -339,13 +289,9 @@ static int parse_time_offset(char *time_str) {
|
|||
|
||||
// Parse --tile-diameter=n type option
|
||||
|
||||
#define FG_RADIUS_MIN 1
|
||||
#define FG_RADIUS_MAX 4
|
||||
|
||||
static int parse_tile_radius(char *arg) {
|
||||
int radius;
|
||||
|
||||
radius = parse_int(arg);
|
||||
int
|
||||
fgOPTIONS::parse_tile_radius( const string& arg ) {
|
||||
int radius = atoi( arg );
|
||||
|
||||
if ( radius < FG_RADIUS_MIN ) { radius = FG_RADIUS_MIN; }
|
||||
if ( radius > FG_RADIUS_MAX ) { radius = FG_RADIUS_MAX; }
|
||||
|
@ -357,19 +303,17 @@ static int parse_tile_radius(char *arg) {
|
|||
|
||||
|
||||
// Parse --flightmode=abcdefg type option
|
||||
static int parse_flight_model(char *fm) {
|
||||
fm += 15;
|
||||
|
||||
int
|
||||
fgOPTIONS::parse_flight_model( const string& fm ) {
|
||||
// printf("flight model = %s\n", fm);
|
||||
|
||||
if ( strcmp(fm, "slew") == 0 ) {
|
||||
if ( fm == "slew" ) {
|
||||
return(FG_SLEW);
|
||||
} else if ( strcmp(fm, "larcsim") == 0 ) {
|
||||
return(FG_LARCSIM);
|
||||
} else if ( strcmp(fm, "LaRCsim") == 0 ) {
|
||||
} else if ( (fm == "larcsim") || (fm == "LaRCsim") ) {
|
||||
return(FG_LARCSIM);
|
||||
} else {
|
||||
fgPrintf( FG_GENERAL, FG_EXIT, "Unknown flight model = %s\n", fm);
|
||||
fgPrintf( FG_GENERAL, FG_EXIT, "Unknown flight model = %s\n",
|
||||
fm.c_str());
|
||||
}
|
||||
|
||||
// we'll never get here, but it makes the compiler happy.
|
||||
|
@ -378,10 +322,9 @@ static int parse_flight_model(char *fm) {
|
|||
|
||||
|
||||
// Parse --fov=x.xx type option
|
||||
static double parse_fov(char *arg) {
|
||||
double fov;
|
||||
|
||||
fov = parse_double(arg);
|
||||
double
|
||||
fgOPTIONS::parse_fov( const string& arg ) {
|
||||
double fov = atof(arg);
|
||||
|
||||
if ( fov < FG_FOV_MIN ) { fov = FG_FOV_MIN; }
|
||||
if ( fov > FG_FOV_MAX ) { fov = FG_FOV_MAX; }
|
||||
|
@ -393,103 +336,101 @@ static double parse_fov(char *arg) {
|
|||
|
||||
|
||||
// Parse a single option
|
||||
int fgOPTIONS::parse_option( char *arg ) {
|
||||
int fgOPTIONS::parse_option( const string& arg ) {
|
||||
// General Options
|
||||
if ( (strcmp(arg, "--help") == 0) ||
|
||||
(strcmp(arg, "-h") == 0) ) {
|
||||
if ( (arg == "--help") || (arg == "-h") ) {
|
||||
// help/usage request
|
||||
return(FG_OPTIONS_HELP);
|
||||
} else if ( strcmp(arg, "--disable-game-mode") == 0 ) {
|
||||
game_mode = 0;
|
||||
} else if ( strcmp(arg, "--enable-game-mode") == 0 ) {
|
||||
game_mode = 1;
|
||||
} else if ( strcmp(arg, "--disable-splash-screen") == 0 ) {
|
||||
splash_screen = 0;
|
||||
} else if ( strcmp(arg, "--enable-splash-screen") == 0 ) {
|
||||
splash_screen = 1;
|
||||
} else if ( strcmp(arg, "--disable-intro-music") == 0 ) {
|
||||
intro_music = 0;
|
||||
} else if ( strcmp(arg, "--enable-intro-music") == 0 ) {
|
||||
intro_music = 1;
|
||||
} else if ( strcmp(arg, "--disable-mouse-pointer") == 0 ) {
|
||||
} else if ( arg == "--disable-game-mode") {
|
||||
game_mode = false;
|
||||
} else if ( arg == "--enable-game-mode" ) {
|
||||
game_mode = true;
|
||||
} else if ( arg == "--disable-splash-screen" ) {
|
||||
splash_screen = false;
|
||||
} else if ( arg == "--enable-splash-screen" ) {
|
||||
splash_screen = true;
|
||||
} else if ( arg == "--disable-intro-music" ) {
|
||||
intro_music = false;
|
||||
} else if ( arg == "--enable-intro-music" ) {
|
||||
intro_music = true;
|
||||
} else if ( arg == "--disable-mouse-pointer" ) {
|
||||
mouse_pointer = 1;
|
||||
} else if ( strcmp(arg, "--enable-mouse-pointer") == 0 ) {
|
||||
} else if ( arg == "--enable-mouse-pointer" ) {
|
||||
mouse_pointer = 2;
|
||||
} else if ( strcmp(arg, "--disable-pause") == 0 ) {
|
||||
pause = 0;
|
||||
} else if ( strcmp(arg, "--enable-pause") == 0 ) {
|
||||
pause = 1;
|
||||
} else if ( strcmp(arg, "--disable-hud") == 0 ) {
|
||||
hud_status = 0;
|
||||
} else if ( strcmp(arg, "--enable-hud") == 0 ) {
|
||||
hud_status = 1;
|
||||
} else if ( strcmp(arg, "--disable-panel") == 0 ) {
|
||||
panel_status = 0;
|
||||
} else if ( strcmp(arg, "--enable-panel") == 0 ) {
|
||||
panel_status = 1;
|
||||
} else if ( strcmp(arg, "--disable-sound") == 0 ) {
|
||||
sound = 0;
|
||||
} else if ( strcmp(arg, "--enable-sound") == 0 ) {
|
||||
sound = 1;
|
||||
} else if ( strncmp(arg, "--airport-id=", 13) == 0 ) {
|
||||
arg += 13;
|
||||
strncpy(airport_id, arg, 4);
|
||||
} else if ( strncmp(arg, "--lon=", 6) == 0 ) {
|
||||
lon = parse_degree(arg);
|
||||
} else if ( strncmp(arg, "--lat=", 6) == 0 ) {
|
||||
lat = parse_degree(arg);
|
||||
} else if ( strncmp(arg, "--altitude=", 11) == 0 ) {
|
||||
altitude = parse_double(arg);
|
||||
} else if ( strncmp(arg, "--heading=", 6) == 0 ) {
|
||||
heading = parse_double(arg);
|
||||
} else if ( strncmp(arg, "--roll=", 7) == 0 ) {
|
||||
roll = parse_double(arg);
|
||||
} else if ( strncmp(arg, "--pitch=", 8) == 0 ) {
|
||||
pitch = parse_double(arg);
|
||||
} else if ( strncmp(arg, "--fg-root=", 10) == 0 ) {
|
||||
arg += 10;
|
||||
strcpy(fg_root, arg);
|
||||
} else if ( strncmp(arg, "--flight-model=", 15) == 0 ) {
|
||||
flight_model = parse_flight_model(arg);
|
||||
} else if ( strcmp(arg, "--fog-disable") == 0 ) {
|
||||
fog = 0;
|
||||
} else if ( strcmp(arg, "--fog-fastest") == 0 ) {
|
||||
fog = 1;
|
||||
} else if ( strcmp(arg, "--fog-nicest") == 0 ) {
|
||||
fog = 2;
|
||||
} else if ( strncmp(arg, "--fov=", 6) == 0 ) {
|
||||
fov = parse_fov(arg);
|
||||
} else if ( strcmp(arg, "--disable-fullscreen") == 0 ) {
|
||||
fullscreen = 0;
|
||||
} else if ( strcmp(arg, "--enable-fullscreen") == 0 ) {
|
||||
fullscreen = 1;
|
||||
} else if ( strcmp(arg, "--shading-flat") == 0 ) {
|
||||
} else if ( arg == "--disable-pause" ) {
|
||||
pause = false;
|
||||
} else if ( arg == "--enable-pause" ) {
|
||||
pause = true;
|
||||
} else if ( arg == "--disable-hud" ) {
|
||||
hud_status = false;
|
||||
} else if ( arg == "--enable-hud" ) {
|
||||
hud_status = true;
|
||||
} else if ( arg == "--disable-panel" ) {
|
||||
panel_status = false;
|
||||
} else if ( arg == "--enable-panel" ) {
|
||||
panel_status = true;
|
||||
} else if ( arg == "--disable-sound" ) {
|
||||
sound = false;
|
||||
} else if ( arg == "--enable-sound" ) {
|
||||
sound = true;
|
||||
} else if ( arg.find( "--airport-id=") != string::npos ) {
|
||||
airport_id = arg.substr( 13 );
|
||||
} else if ( arg.find( "--lon=" ) != string::npos ) {
|
||||
lon = parse_degree( arg.substr(6) );
|
||||
} else if ( arg.find( "--lat=" ) != string::npos ) {
|
||||
lat = parse_degree( arg.substr(6) );
|
||||
} else if ( arg.find( "--altitude=" ) != string::npos ) {
|
||||
altitude = atof( arg.substr(11) );
|
||||
} else if ( arg.find( "--heading=" ) != string::npos ) {
|
||||
heading = atof( arg.substr(10) );
|
||||
} else if ( arg.find( "--roll=" ) != string::npos ) {
|
||||
roll = atof( arg.substr(7) );
|
||||
} else if ( arg.find( "--pitch=" ) != string::npos ) {
|
||||
pitch = atof( arg.substr(8) );
|
||||
} else if ( arg.find( "--fg-root=" ) != string::npos ) {
|
||||
fg_root = arg.substr( 10 );
|
||||
} else if ( arg.find( "--flight-model=" ) != string::npos ) {
|
||||
flight_model = parse_flight_model( arg.substr(15) );
|
||||
} else if ( arg == "--fog-disable" ) {
|
||||
fog = FG_FOG_DISABLED;
|
||||
} else if ( arg == "--fog-fastest" ) {
|
||||
fog = FG_FOG_FASTEST;
|
||||
} else if ( arg == "--fog-nicest" ) {
|
||||
fog = FG_FOG_NICEST;
|
||||
} else if ( arg.find( "--fov=" ) != string::npos ) {
|
||||
fov = parse_fov( arg.substr(6) );
|
||||
} else if ( arg == "--disable-fullscreen" ) {
|
||||
fullscreen = false;
|
||||
} else if ( arg== "--enable-fullscreen") {
|
||||
fullscreen = true;
|
||||
} else if ( arg == "--shading-flat") {
|
||||
shading = 0;
|
||||
} else if ( strcmp(arg, "--shading-smooth") == 0 ) {
|
||||
} else if ( arg == "--shading-smooth") {
|
||||
shading = 1;
|
||||
} else if ( strcmp(arg, "--disable-skyblend") == 0 ) {
|
||||
skyblend = 0;
|
||||
} else if ( strcmp(arg, "--enable-skyblend") == 0 ) {
|
||||
skyblend = 1;
|
||||
} else if ( strcmp(arg, "--disable-textures") == 0 ) {
|
||||
textures = 0;
|
||||
} else if ( strcmp(arg, "--enable-textures") == 0 ) {
|
||||
textures = 1;
|
||||
} else if ( strcmp(arg, "--disable-wireframe") == 0 ) {
|
||||
wireframe = 0;
|
||||
} else if ( strcmp(arg, "--enable-wireframe") == 0 ) {
|
||||
wireframe = 1;
|
||||
} else if ( strncmp(arg, "--tile-radius=", 14) == 0 ) {
|
||||
tile_radius = parse_tile_radius(arg);
|
||||
} else if ( arg == "--disable-skyblend") {
|
||||
skyblend = false;
|
||||
} else if ( arg== "--enable-skyblend" ) {
|
||||
skyblend = true;
|
||||
} else if ( arg == "--disable-textures" ) {
|
||||
textures = false;
|
||||
} else if ( arg == "--enable-textures" ) {
|
||||
textures = true;
|
||||
} else if ( arg == "--disable-wireframe" ) {
|
||||
wireframe = false;
|
||||
} else if ( arg == "--enable-wireframe" ) {
|
||||
wireframe = true;
|
||||
} else if ( arg.find( "--tile-radius=" ) != string::npos ) {
|
||||
tile_radius = parse_tile_radius( arg.substr(14) );
|
||||
tile_diameter = tile_radius * 2 + 1;
|
||||
} else if ( strncmp(arg, "--time-offset=", 14) == 0 ) {
|
||||
time_offset = parse_time_offset(arg);
|
||||
} else if ( strcmp(arg, "--hud-tris") == 0 ) {
|
||||
} else if ( arg.find( "--time-offset=" ) != string::npos ) {
|
||||
time_offset = parse_time_offset( (arg.substr(14)) );
|
||||
} else if ( arg == "--hud-tris" ) {
|
||||
tris_or_culled = 0;
|
||||
} else if ( strcmp(arg, "--hud-culled") == 0 ) {
|
||||
} else if ( arg == "--hud-culled" ) {
|
||||
tris_or_culled = 1;
|
||||
} else {
|
||||
fgPrintf( FG_GENERAL, FG_EXIT, "Unknown option '%s'\n", arg);
|
||||
fgPrintf( FG_GENERAL, FG_EXIT, "Unknown option '%s'\n",
|
||||
arg.c_str() );
|
||||
return(FG_OPTIONS_ERROR);
|
||||
}
|
||||
|
||||
|
@ -519,24 +460,23 @@ int fgOPTIONS::parse_command_line( int argc, char **argv ) {
|
|||
}
|
||||
|
||||
|
||||
// Parse the command line options
|
||||
int fgOPTIONS::parse_config_file( char *path ) {
|
||||
char fgpath[256], line[256];
|
||||
// Parse config file options
|
||||
int fgOPTIONS::parse_config_file( const string& path ) {
|
||||
char line[256];
|
||||
fgFile f;
|
||||
int len, result;
|
||||
|
||||
strcpy(fgpath, path);
|
||||
strcat(fgpath, ".gz");
|
||||
int len;
|
||||
string fgpath = path + ".gz";
|
||||
|
||||
// first try "path.gz"
|
||||
if ( (f = fgopen(fgpath, "rb")) == NULL ) {
|
||||
if ( (f = fgopen(fgpath.c_str(), "rb")) == NULL ) {
|
||||
// next try "path"
|
||||
if ( (f = fgopen(path, "rb")) == NULL ) {
|
||||
if ( (f = fgopen(path.c_str(), "rb")) == NULL ) {
|
||||
return(FG_OPTIONS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
fgPrintf(FG_GENERAL, FG_INFO, "Processing config file: %s\n", path);
|
||||
fgPrintf( FG_GENERAL, FG_INFO, "Processing config file: %s\n",
|
||||
path.c_str() );
|
||||
|
||||
while ( fggets(f, line, 250) != NULL ) {
|
||||
// strip trailing newline if it exists
|
||||
|
@ -551,15 +491,15 @@ int fgOPTIONS::parse_config_file( char *path ) {
|
|||
line[len-1] = '\0';
|
||||
}
|
||||
|
||||
result = parse_option(line);
|
||||
if ( result == FG_OPTIONS_ERROR ) {
|
||||
if ( parse_option( line ) == FG_OPTIONS_ERROR ) {
|
||||
fgPrintf( FG_GENERAL, FG_EXIT,
|
||||
"Config file parse error: %s '%s'\n", path, line );
|
||||
"Config file parse error: %s '%s'\n",
|
||||
path.c_str(), line );
|
||||
}
|
||||
}
|
||||
|
||||
fgclose(f);
|
||||
return(FG_OPTIONS_OK);
|
||||
return FG_OPTIONS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -633,47 +573,21 @@ void fgOPTIONS::usage ( void ) {
|
|||
}
|
||||
|
||||
|
||||
#if 0
|
||||
// Query functions
|
||||
void fgOPTIONS::get_fg_root(char *root) { strcpy(root, fg_root); }
|
||||
void fgOPTIONS::get_airport_id(char *id) { strcpy(id, airport_id); }
|
||||
double fgOPTIONS::get_lon( void ) { return(lon); }
|
||||
double fgOPTIONS::get_lat( void ) { return(lat); }
|
||||
double fgOPTIONS::get_altitude( void ) { return(altitude); }
|
||||
double fgOPTIONS::get_heading( void ) { return(heading); }
|
||||
double fgOPTIONS::get_roll( void ) { return(roll); }
|
||||
double fgOPTIONS::get_pitch( void ) { return(pitch); }
|
||||
int fgOPTIONS::get_game_mode( void ) { return(game_mode); }
|
||||
int fgOPTIONS::get_splash_screen( void ) { return(splash_screen); }
|
||||
int fgOPTIONS::get_intro_music( void ) { return(intro_music); }
|
||||
int fgOPTIONS::get_mouse_pointer( void ) { return(mouse_pointer); }
|
||||
int fgOPTIONS::get_pause( void ) { return(pause); }
|
||||
int fgOPTIONS::get_hud_status( void ) { return(hud_status); }
|
||||
int fgOPTIONS::get_panel_status( void ) { return(panel_status); }
|
||||
int fgOPTIONS::get_sound( void ) { return(sound); }
|
||||
int fgOPTIONS::get_flight_model( void ) { return(flight_model); }
|
||||
int fgOPTIONS::get_fog( void ) { return(fog); }
|
||||
double fgOPTIONS::get_fov( void ) { return(fov); }
|
||||
int fgOPTIONS::get_fullscreen( void ) { return(fullscreen); }
|
||||
int fgOPTIONS::get_shading( void ) { return(shading); }
|
||||
int fgOPTIONS::get_skyblend( void ) { return(skyblend); }
|
||||
int fgOPTIONS::get_textures( void ) { return(textures); }
|
||||
int fgOPTIONS::get_wireframe( void ) { return(wireframe); }
|
||||
int fgOPTIONS::get_tile_radius( void ) { return(tile_radius); }
|
||||
int fgOPTIONS::get_tile_diameter( void ) { return(tile_diameter); }
|
||||
int fgOPTIONS::get_time_offset( void ) { return(time_offset); }
|
||||
|
||||
|
||||
// Update functions
|
||||
void fgOPTIONS::set_hud_status( int status ) { hud_status = status; }
|
||||
void fgOPTIONS::set_fov( double amount ) { fov = amount; }
|
||||
#endif
|
||||
// Destructor
|
||||
fgOPTIONS::~fgOPTIONS( void ) {
|
||||
}
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.23 1998/08/27 17:02:07 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.22 1998/08/24 20:11:13 curt
|
||||
// Added i/I to toggle full vs. minimal HUD.
|
||||
// Added a --hud-tris vs --hud-culled option.
|
||||
|
|
177
Main/options.hxx
177
Main/options.hxx
|
@ -31,22 +31,35 @@
|
|||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
|
||||
#define FG_OPTIONS_OK 0
|
||||
#define FG_OPTIONS_HELP 1
|
||||
#define FG_OPTIONS_ERROR 2
|
||||
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
|
||||
class fgOPTIONS {
|
||||
public:
|
||||
enum
|
||||
{
|
||||
FG_OPTIONS_OK = 0,
|
||||
FG_OPTIONS_HELP = 1,
|
||||
FG_OPTIONS_ERROR = 2
|
||||
};
|
||||
|
||||
enum fgFogKind
|
||||
{
|
||||
FG_FOG_DISABLED = 0,
|
||||
FG_FOG_FASTEST = 1,
|
||||
FG_FOG_NICEST = 2
|
||||
};
|
||||
|
||||
const int FG_RADIUS_MIN = 1;
|
||||
const int FG_RADIUS_MAX = 4;
|
||||
|
||||
private:
|
||||
|
||||
// The flight gear "root" directory
|
||||
char fg_root[256];
|
||||
string fg_root;
|
||||
|
||||
// Starting position and orientation
|
||||
|
||||
// ID of initial starting airport, only need 5 bytes but I guess
|
||||
// 16 is good for memory alignment.
|
||||
char airport_id[16];
|
||||
string airport_id; // ID of initial starting airport
|
||||
double lon; // starting longitude in degrees (west = -)
|
||||
double lat; // starting latitude in degrees (south = -)
|
||||
double altitude; // starting altitude in meters
|
||||
|
@ -55,28 +68,28 @@ class fgOPTIONS {
|
|||
double pitch; // pitch angle in degrees (Theta)
|
||||
|
||||
// Miscellaneous
|
||||
int game_mode; // Game mode enabled/disabled
|
||||
int splash_screen; // show splash screen
|
||||
int intro_music; // play introductory music
|
||||
bool game_mode; // Game mode enabled/disabled
|
||||
bool splash_screen; // show splash screen
|
||||
bool intro_music; // play introductory music
|
||||
int mouse_pointer; // show mouse pointer
|
||||
int pause; // pause intially enabled/disabled
|
||||
bool pause; // pause intially enabled/disabled
|
||||
|
||||
// Features
|
||||
int hud_status; // HUD on/off
|
||||
int panel_status; // Panel on/off
|
||||
int sound; // play sound effects
|
||||
bool hud_status; // HUD on/off
|
||||
bool panel_status; // Panel on/off
|
||||
bool sound; // play sound effects
|
||||
|
||||
// Flight Model options
|
||||
int flight_model; // Flight Model: FG_SLEW, FG_LARCSIM, etc.
|
||||
|
||||
// Rendering options
|
||||
int fog; // Fog enabled/disabled
|
||||
fgFogKind fog; // Fog nicest/fastest/disabled
|
||||
double fov; // Field of View
|
||||
int fullscreen; // Full screen mode enabled/disabled
|
||||
bool fullscreen; // Full screen mode enabled/disabled
|
||||
int shading; // shading method, 0 = Flat, 1 = Smooth
|
||||
int skyblend; // Blend sky to haze (using polygons) or just clear
|
||||
int textures; // Textures enabled/disabled
|
||||
int wireframe; // Wireframe mode enabled/disabled
|
||||
bool skyblend; // Blend sky to haze (using polygons) or just clear
|
||||
bool textures; // Textures enabled/disabled
|
||||
bool wireframe; // Wireframe mode enabled/disabled
|
||||
|
||||
// Scenery options
|
||||
int tile_radius; // Square radius of rendered tiles (around center
|
||||
|
@ -94,93 +107,64 @@ class fgOPTIONS {
|
|||
|
||||
public:
|
||||
|
||||
// Constructor
|
||||
fgOPTIONS( void );
|
||||
fgOPTIONS();
|
||||
~fgOPTIONS();
|
||||
|
||||
// Parse a single option
|
||||
int parse_option( char *arg );
|
||||
int parse_option( const string& arg );
|
||||
|
||||
// Parse the command line options
|
||||
int parse_command_line( int argc, char **argv );
|
||||
|
||||
// Parse the command line options
|
||||
int parse_config_file( char *path );
|
||||
int parse_config_file( const string& path );
|
||||
|
||||
// Print usage message
|
||||
void usage ( void );
|
||||
|
||||
// Query functions
|
||||
void get_fg_root(char *root) { strcpy(root, fg_root); }
|
||||
void get_airport_id(char *id) { strcpy(id, airport_id); }
|
||||
double get_lon( void ) { return(lon); }
|
||||
double get_lat( void ) { return(lat); }
|
||||
double get_altitude( void ) { return(altitude); }
|
||||
double get_heading( void ) { return(heading); }
|
||||
double get_roll( void ) { return(roll); }
|
||||
double get_pitch( void ) { return(pitch); }
|
||||
int get_game_mode( void ) { return(game_mode); }
|
||||
int get_splash_screen( void ) { return(splash_screen); }
|
||||
int get_intro_music( void ) { return(intro_music); }
|
||||
int get_mouse_pointer( void ) { return(mouse_pointer); }
|
||||
int get_pause( void ) { return(pause); }
|
||||
int get_hud_status( void ) { return(hud_status); }
|
||||
int get_panel_status( void ) { return(panel_status); }
|
||||
int get_sound( void ) { return(sound); }
|
||||
int get_flight_model( void ) { return(flight_model); }
|
||||
int get_fog( void ) { return(fog); }
|
||||
double get_fov( void ) { return(fov); }
|
||||
int get_fullscreen( void ) { return(fullscreen); }
|
||||
int get_shading( void ) { return(shading); }
|
||||
int get_skyblend( void ) { return(skyblend); }
|
||||
int get_textures( void ) { return(textures); }
|
||||
int get_wireframe( void ) { return(wireframe); }
|
||||
int get_tile_radius( void ) { return(tile_radius); }
|
||||
int get_tile_diameter( void ) { return(tile_diameter); }
|
||||
int get_time_offset( void ) { return(time_offset); }
|
||||
int get_tris_or_culled( void ) { return(tris_or_culled); }
|
||||
string get_fg_root() const { return fg_root; }
|
||||
string get_airport_id() const { return airport_id; }
|
||||
double get_lon() const { return lon; }
|
||||
double get_lat() const { return lat; }
|
||||
double get_altitude() const { return altitude; }
|
||||
double get_heading() const { return heading; }
|
||||
double get_roll() const { return roll; }
|
||||
double get_pitch() const { return pitch; }
|
||||
bool get_game_mode() const { return game_mode; }
|
||||
bool get_splash_screen() const { return splash_screen; }
|
||||
bool get_intro_music() const { return intro_music; }
|
||||
int get_mouse_pointer() const { return mouse_pointer; }
|
||||
bool get_pause() const { return pause; }
|
||||
bool get_hud_status() const { return hud_status; }
|
||||
bool get_panel_status() const { return panel_status; }
|
||||
bool get_sound() const { return sound; }
|
||||
int get_flight_model() const { return flight_model; }
|
||||
bool fog_enabled() const { return fog != FG_FOG_DISABLED; }
|
||||
fgFogKind get_fog() const { return fog; }
|
||||
double get_fov() const { return fov; }
|
||||
bool get_fullscreen() const { return fullscreen; }
|
||||
int get_shading() const { return shading; }
|
||||
bool get_skyblend() const { return skyblend; }
|
||||
bool get_textures() const { return textures; }
|
||||
bool get_wireframe() const { return wireframe; }
|
||||
int get_tile_radius() const { return tile_radius; }
|
||||
int get_tile_diameter() const { return tile_diameter; }
|
||||
int get_time_offset() const { return time_offset; }
|
||||
int get_tris_or_culled() const { return tris_or_culled; }
|
||||
|
||||
// Update functions
|
||||
void set_hud_status( int status ) { hud_status = status; }
|
||||
void set_hud_status( bool status ) { hud_status = status; }
|
||||
void set_fov( double amount ) { fov = amount; }
|
||||
|
||||
#if 0
|
||||
void get_fg_root(char *root);
|
||||
void get_airport_id(char *id);
|
||||
double get_lon( void );
|
||||
double get_lat( void );
|
||||
double get_altitude( void );
|
||||
double get_heading( void );
|
||||
double get_roll( void );
|
||||
double get_pitch( void );
|
||||
int get_game_mode( void );
|
||||
int get_splash_screen( void );
|
||||
int get_intro_music( void );
|
||||
int get_mouse_pointer( void );
|
||||
int get_pause( void );
|
||||
int get_hud_status( void );
|
||||
int get_panel_status( void );
|
||||
int get_sound( void );
|
||||
int get_flight_model( void );
|
||||
int get_fog( void );
|
||||
double get_fov( void );
|
||||
int get_fullscreen( void );
|
||||
int get_shading( void );
|
||||
int get_skyblend( void );
|
||||
int get_textures( void );
|
||||
int get_wireframe( void );
|
||||
int get_tile_radius( void );
|
||||
int get_tile_diameter( void );
|
||||
int get_time_offset( void );
|
||||
int get_tris_or_culled( void ) { return(tris_or_culled); }
|
||||
|
||||
// Update functions
|
||||
void set_hud_status( int status );
|
||||
void set_fov( double amount );
|
||||
#endif
|
||||
|
||||
// Destructor
|
||||
~fgOPTIONS( void );
|
||||
private:
|
||||
|
||||
double parse_time( const string& time_str );
|
||||
double parse_degree( const string& degree_str );
|
||||
int parse_time_offset( const string& time_str );
|
||||
int parse_tile_radius( const string& arg );
|
||||
int parse_flight_model( const string& fm );
|
||||
double parse_fov( const string& arg );
|
||||
};
|
||||
|
||||
|
||||
|
@ -191,6 +175,15 @@ extern fgOPTIONS current_options;
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.16 1998/08/27 17:02:08 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.15 1998/08/24 20:11:15 curt
|
||||
// Added i/I to toggle full vs. minimal HUD.
|
||||
// Added a --hud-tris vs --hud-culled option.
|
||||
|
|
|
@ -50,7 +50,7 @@ static GLubyte *splash_texbuf;
|
|||
|
||||
// Initialize the splash screen
|
||||
void fgSplashInit ( void ) {
|
||||
char tpath[256], fg_tpath[256];
|
||||
string tpath, fg_tpath;
|
||||
int width, height;
|
||||
|
||||
fgPrintf( FG_GENERAL, FG_INFO, "Initializing splash screen\n");
|
||||
|
@ -70,18 +70,19 @@ void fgSplashInit ( void ) {
|
|||
xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
// load in the texture data
|
||||
current_options.get_fg_root(tpath);
|
||||
strcat(tpath, "/Textures/");
|
||||
strcat(tpath, "Splash2.rgb");
|
||||
tpath = current_options.get_fg_root() + "/Textures/Splash2.rgb";
|
||||
|
||||
if ( (splash_texbuf = read_rgb_texture(tpath, &width, &height)) == NULL ) {
|
||||
if ( (splash_texbuf =
|
||||
read_rgb_texture(tpath.c_str(), &width, &height)) == NULL )
|
||||
{
|
||||
// Try compressed
|
||||
strcpy(fg_tpath, tpath);
|
||||
strcat(fg_tpath, ".gz");
|
||||
if ( (splash_texbuf = read_rgb_texture(fg_tpath, &width, &height))
|
||||
== NULL ) {
|
||||
fg_tpath = tpath + ".gz";
|
||||
if ( (splash_texbuf =
|
||||
read_rgb_texture(fg_tpath.c_str(), &width, &height)) == NULL )
|
||||
{
|
||||
fgPrintf( FG_GENERAL, FG_EXIT,
|
||||
"Error in loading splash screen texture %s\n", tpath );
|
||||
"Error in loading splash screen texture %s\n",
|
||||
tpath.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,6 +144,15 @@ void fgSplashUpdate ( double progress ) {
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.4 1998/08/27 17:02:08 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.3 1998/08/25 16:59:10 curt
|
||||
// Directory reshuffling.
|
||||
//
|
||||
|
|
|
@ -75,7 +75,7 @@ fgMATERIAL_MGR::fgMATERIAL_MGR ( void ) {
|
|||
int fgMATERIAL_MGR::load_lib ( void ) {
|
||||
fgMATERIAL m;
|
||||
char material_name[256];
|
||||
char mpath[256], fg_mpath[256], tpath[256], fg_tpath[256];
|
||||
string mpath, fg_mpath, tpath, fg_tpath;
|
||||
char line[256], *line_ptr, value[256];
|
||||
GLubyte *texbuf;
|
||||
fgFile f;
|
||||
|
@ -83,17 +83,15 @@ int fgMATERIAL_MGR::load_lib ( void ) {
|
|||
int alpha;
|
||||
|
||||
// build the path name to the material db
|
||||
current_options.get_fg_root(mpath);
|
||||
strcat(mpath, "/");
|
||||
strcat(mpath, "materials");
|
||||
strcpy(fg_mpath, mpath);
|
||||
strcat(fg_mpath, ".gz");
|
||||
mpath = current_options.get_fg_root() + "/materials";
|
||||
fg_mpath = mpath + ".gz";
|
||||
|
||||
// first try "path.gz"
|
||||
if ( (f = fgopen(fg_mpath, "rb")) == NULL ) {
|
||||
if ( (f = fgopen(fg_mpath.c_str(), "rb")) == NULL ) {
|
||||
// next try "path"
|
||||
if ( (f = fgopen(mpath, "rb")) == NULL ) {
|
||||
fgPrintf(FG_GENERAL, FG_EXIT, "Cannot open file: %s\n", mpath);
|
||||
if ( (f = fgopen(mpath.c_str(), "rb")) == NULL ) {
|
||||
fgPrintf( FG_GENERAL, FG_EXIT, "Cannot open file: %s\n",
|
||||
mpath.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,24 +177,26 @@ int fgMATERIAL_MGR::load_lib ( void ) {
|
|||
GL_LINEAR_MIPMAP_LINEAR ) ;
|
||||
|
||||
/* load in the texture data */
|
||||
current_options.get_fg_root(tpath);
|
||||
strcat(tpath, "/Textures/");
|
||||
strcat(tpath, m.texture_name);
|
||||
strcat(tpath, ".rgb");
|
||||
tpath = current_options.get_fg_root() + "/Textures/" +
|
||||
m.texture_name + ".rgb";
|
||||
fg_tpath = tpath + ".gz";
|
||||
|
||||
if ( alpha == 0 ) {
|
||||
// load rgb texture
|
||||
|
||||
// Try uncompressed
|
||||
if ( (texbuf = read_rgb_texture(tpath, &width, &height))
|
||||
== NULL ) {
|
||||
if ( (texbuf =
|
||||
read_rgb_texture(tpath.c_str(), &width, &height)) ==
|
||||
NULL )
|
||||
{
|
||||
// Try compressed
|
||||
strcpy(fg_tpath, tpath);
|
||||
strcat(fg_tpath, ".gz");
|
||||
if ( (texbuf = read_rgb_texture(fg_tpath, &width, &height))
|
||||
== NULL ) {
|
||||
if ( (texbuf =
|
||||
read_rgb_texture(fg_tpath.c_str(), &width, &height))
|
||||
== NULL )
|
||||
{
|
||||
fgPrintf( FG_GENERAL, FG_EXIT,
|
||||
"Error in loading texture %s\n", tpath );
|
||||
"Error in loading texture %s\n",
|
||||
tpath.c_str() );
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
@ -210,15 +210,18 @@ int fgMATERIAL_MGR::load_lib ( void ) {
|
|||
// load rgba (alpha) texture
|
||||
|
||||
// Try uncompressed
|
||||
if ( (texbuf = read_alpha_texture(tpath, &width, &height))
|
||||
== NULL ) {
|
||||
if ( (texbuf =
|
||||
read_alpha_texture(tpath.c_str(), &width, &height))
|
||||
== NULL )
|
||||
{
|
||||
// Try compressed
|
||||
strcpy(fg_tpath, tpath);
|
||||
strcat(fg_tpath, ".gz");
|
||||
if ((texbuf = read_alpha_texture(fg_tpath, &width, &height))
|
||||
== NULL ) {
|
||||
if ((texbuf =
|
||||
read_alpha_texture(fg_tpath.c_str(), &width, &height))
|
||||
== NULL )
|
||||
{
|
||||
fgPrintf( FG_GENERAL, FG_EXIT,
|
||||
"Error in loading texture %s\n", tpath );
|
||||
"Error in loading texture %s\n",
|
||||
tpath.c_str() );
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
@ -303,6 +306,15 @@ fgMATERIAL_MGR::~fgMATERIAL_MGR ( void ) {
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.3 1998/08/27 17:02:09 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.2 1998/08/25 20:53:33 curt
|
||||
// Shuffled $FG_ROOT file layout.
|
||||
//
|
||||
|
|
|
@ -88,7 +88,7 @@ int fgTILECACHE::Exists( fgBUCKET *p ) {
|
|||
|
||||
// Fill in a tile cache entry with real data for the specified bucket
|
||||
void fgTILECACHE::EntryFillIn( int index, fgBUCKET *p ) {
|
||||
char root[256];
|
||||
string root;
|
||||
char base_path[256];
|
||||
char file_name[256];
|
||||
|
||||
|
@ -103,8 +103,8 @@ void fgTILECACHE::EntryFillIn( int index, fgBUCKET *p ) {
|
|||
|
||||
// Load the appropriate data file and built tile fragment list
|
||||
fgBucketGenBasePath(p, base_path);
|
||||
current_options.get_fg_root(root);
|
||||
sprintf(file_name, "%s/Scenery/%s/%ld", root,
|
||||
root = current_options.get_fg_root();
|
||||
sprintf(file_name, "%s/Scenery/%s/%ld", root.c_str(),
|
||||
base_path, fgBucketGenIndex(p));
|
||||
fgObjLoad(file_name, &tile_cache[index]);
|
||||
/*
|
||||
|
@ -212,6 +212,15 @@ fgTILECACHE::~fgTILECACHE( void ) {
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.15 1998/08/27 17:02:10 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.14 1998/08/25 16:52:43 curt
|
||||
// material.cxx material.hxx obj.cxx obj.hxx texload.c texload.h moved to
|
||||
// ../Objects
|
||||
|
|
|
@ -60,31 +60,25 @@ fgLIGHT::fgLIGHT( void ) {
|
|||
|
||||
// initialize lighting tables
|
||||
void fgLIGHT::Init( void ) {
|
||||
char path[256];
|
||||
string path, ambient, diffuse, sky;
|
||||
|
||||
fgPrintf( FG_EVENT, FG_INFO,
|
||||
"Initializing Lighting interpolation tables.\n" );
|
||||
|
||||
// build the path name to the ambient lookup table
|
||||
current_options.get_fg_root(path);
|
||||
strcat(path, "/Lighting/");
|
||||
strcat(path, "ambient");
|
||||
path = current_options.get_fg_root();
|
||||
ambient = path + "/Lighting/ambient";
|
||||
diffuse = path + "/Lighting/diffuse";
|
||||
sky = path + "/Lighting/sky";
|
||||
|
||||
// initialize ambient table
|
||||
ambient_tbl = new fgINTERPTABLE(path);
|
||||
ambient_tbl = new fgINTERPTABLE((char *)ambient.c_str());
|
||||
|
||||
// build the path name to the diffuse lookup table
|
||||
current_options.get_fg_root(path);
|
||||
strcat(path, "/Lighting/");
|
||||
strcat(path, "diffuse");
|
||||
// initialize diffuse table
|
||||
diffuse_tbl = new fgINTERPTABLE(path);
|
||||
diffuse_tbl = new fgINTERPTABLE((char *)diffuse.c_str());
|
||||
|
||||
// build the path name to the sky lookup table
|
||||
current_options.get_fg_root(path);
|
||||
strcat(path, "/Lighting/");
|
||||
strcat(path, "sky");
|
||||
// initialize sky table
|
||||
sky_tbl = new fgINTERPTABLE(path);
|
||||
sky_tbl = new fgINTERPTABLE((char *)sky.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -227,6 +221,15 @@ void fgLightUpdate ( void ) {
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.16 1998/08/27 17:02:11 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.15 1998/08/25 20:53:33 curt
|
||||
// Shuffled $FG_ROOT file layout.
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue