]> git.mxchange.org Git - flightgear.git/blob - src/Main/options.cxx
Updated to support new weather subsystem (visibility variable determins
[flightgear.git] / src / Main / options.cxx
1 // options.cxx -- class to handle command line options
2 //
3 // Written by Curtis Olson, started April 1998.
4 //
5 // Copyright (C) 1998  Curtis L. Olson  - curt@me.umn.edu
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #ifdef HAVE_CONFIG_H
25 #  include <config.h>
26 #endif
27
28 #if defined(FX) && defined(XMESA)
29 bool global_fullscreen = true;
30 #endif
31
32 #include <Include/compiler.h>
33
34 #include <math.h>            // rint()
35 #include <stdio.h>
36 #include <stdlib.h>          // atof(), atoi()
37 #include <string.h>
38
39 #include STL_STRING
40
41 #include <Include/fg_constants.h>
42 #include <Include/general.hxx>
43 #include <Cockpit/cockpit.hxx>
44 #include <Debug/logstream.hxx>
45 #include <FDM/flight.hxx>
46 #include <Misc/fgstream.hxx>
47 #ifdef FG_NETWORK_OLK
48 #  include <Network/network.h>
49 #endif
50 #include <Time/fg_time.hxx>
51
52 #include "options.hxx"
53 #include "fg_serial.hxx"
54
55 FG_USING_STD(string);
56 FG_USING_NAMESPACE(std);
57
58 // from GLUTmain.cxx
59 extern void fgReshape( int width, int height );
60
61 inline double
62 atof( const string& str )
63 {
64
65 #ifdef __MWERKS__ 
66     // -dw- if ::atof is called, then we get an infinite loop
67     return std::atof( str.c_str() );
68 #else
69     return ::atof( str.c_str() );
70 #endif
71 }
72
73 inline int
74 atoi( const string& str )
75 {
76 #ifdef __MWERKS__ 
77     // -dw- if ::atoi is called, then we get an infinite loop
78     return std::atoi( str.c_str() );
79 #else
80     return ::atoi( str.c_str() );
81 #endif
82 }
83
84 // Defined the shared options class here
85 fgOPTIONS current_options;
86
87
88 // Constructor
89 fgOPTIONS::fgOPTIONS() :
90     // starting longitude in degrees (west = -)
91     // starting latitude in degrees (south = -)
92
93     // Default initial position is Globe, AZ (P13)
94     lon(-110.6642444),
95     lat(  33.3528917),
96
97     // North of the city of Globe
98     // lon(-110.7),
99     // lat(  33.4),
100
101     // North of the city of Globe
102     // lon(-110.742578),
103     // lat(  33.507122),
104
105     // Near where I used to live in Globe, AZ
106     // lon(-110.766000),
107     // lat(  33.377778),
108
109     // 10125 Jewell St. NE
110     // lon(-93.15),
111     // lat( 45.15),
112
113     // Near KHSP (Hot Springs, VA)
114     // lon(-79.8338964 + 0.01),
115     // lat( 37.9514564 + 0.008),
116
117     // (SEZ) SEDONA airport
118     // lon(-111.7884614 + 0.01),
119     // lat(  34.8486289 - 0.015),
120
121     // Jim Brennon's Kingmont Observatory
122     // lon(-121.1131667),
123     // lat(  38.8293917),
124
125     // Huaras, Peru (S09d 31.871'  W077d 31.498')
126     // lon(-77.5249667),
127     // lat( -9.5311833),
128  
129     // Eclipse Watching w73.5 n10 (approx) 18:00 UT
130     // lon(-73.5),
131     // lat( 10.0),
132
133     // Timms Hill (WI)
134     // lon(-90.1953055556),
135     // lat( 45.4511388889),
136
137     // starting altitude in meters (this will be reset to ground level
138     // if it is lower than the terrain
139     altitude(-9999.0),
140
141     // Initial Orientation
142     heading(270.0),      // heading (yaw) angle in degress (Psi)
143     roll(0.0),           // roll angle in degrees (Phi)
144     pitch(0.424),        // pitch angle in degrees (Theta)
145
146     // Initialize current options velocities to 0.0
147     uBody(0.0), vBody(0.0), wBody(0.0),
148
149     // Miscellaneous
150     game_mode(0),
151     splash_screen(1),
152     intro_music(1),
153     mouse_pointer(0),
154     pause(0),
155     control_mode(FG_JOYSTICK),
156
157     // Features
158     hud_status(1),
159     panel_status(0),
160     sound(1),
161
162     // Flight Model options
163     flight_model( FGInterface::FG_LARCSIM ),
164     speed_up( 1 ),
165
166     // Rendering options
167     fog(FG_FOG_NICEST),  // nicest
168     fov(55.0),
169     fullscreen(0),
170     shading(1),
171     skyblend(1),
172     textures(1),
173     wireframe(0),
174     xsize(640),
175     ysize(480),
176
177     // Scenery options
178     tile_diameter(5),
179
180     // HUD options
181     units(FG_UNITS_FEET),
182     tris_or_culled(0),
183         
184     // Time options
185     time_offset(0),
186     start_gst(0),
187     start_lst(0)
188
189 {
190     // set initial values/defaults
191     char* envp = ::getenv( "FG_ROOT" );
192
193     if ( envp != NULL ) {
194         // fg_root could be anywhere, so default to environmental
195         // variable $FG_ROOT if it is set.
196         fg_root = envp;
197     } else {
198         // Otherwise, default to a random compiled in location if
199         // $FG_ROOT is not set.  This can still be overridden from the
200         // command line or a config file.
201
202 #if defined( WIN32 )
203         fg_root = "\\FlightGear";
204 #elif defined( MACOS )
205         fg_root = "";
206 #else
207         fg_root = PKGLIBDIR;
208 #endif
209     }
210
211     airport_id = "";            // default airport id
212     net_id = "Johnney";         // default pilot's name
213
214     // initialize port config string list
215     port_options_list.erase ( port_options_list.begin(), 
216                               port_options_list.end() );
217 }
218
219 void 
220 fgOPTIONS::toggle_panel() {
221     
222     FGTime *t = FGTime::cur_time_params;
223     
224     int toggle_pause = t->getPause();
225     
226     if( !toggle_pause )
227         t->togglePauseMode();
228     
229     if( panel_status ) {
230         panel_status = false;
231     } else {
232         panel_status = true;
233     }
234     if ( panel_status ) {
235         if( FGPanel::OurPanel == 0)
236             new FGPanel;
237         fov *= 0.4232;
238     } else {
239         fov *= (1.0 / 0.4232);
240     }
241     fgReshape( xsize, ysize);
242     
243     if( !toggle_pause )
244         t->togglePauseMode();
245 }
246
247 double
248 fgOPTIONS::parse_time(const string& time_in) {
249     char *time_str, num[256];
250     double hours, minutes, seconds;
251     double result = 0.0;
252     int sign = 1;
253     int i;
254
255     time_str = (char *)time_in.c_str();
256
257     // printf("parse_time(): %s\n", time_str);
258
259     // check for sign
260     if ( strlen(time_str) ) {
261         if ( time_str[0] == '+' ) {
262             sign = 1;
263             time_str++;
264         } else if ( time_str[0] == '-' ) {
265             sign = -1;
266             time_str++;
267         }
268     }
269     // printf("sign = %d\n", sign);
270
271     // get hours
272     if ( strlen(time_str) ) {
273         i = 0;
274         while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
275             num[i] = time_str[0];
276             time_str++;
277             i++;
278         }
279         if ( time_str[0] == ':' ) {
280             time_str++;
281         }
282         num[i] = '\0';
283         hours = atof(num);
284         // printf("hours = %.2lf\n", hours);
285
286         result += hours;
287     }
288
289     // get minutes
290     if ( strlen(time_str) ) {
291         i = 0;
292         while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
293             num[i] = time_str[0];
294             time_str++;
295             i++;
296         }
297         if ( time_str[0] == ':' ) {
298             time_str++;
299         }
300         num[i] = '\0';
301         minutes = atof(num);
302         // printf("minutes = %.2lf\n", minutes);
303
304         result += minutes / 60.0;
305     }
306
307     // get seconds
308     if ( strlen(time_str) ) {
309         i = 0;
310         while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
311             num[i] = time_str[0];
312             time_str++;
313             i++;
314         }
315         num[i] = '\0';
316         seconds = atof(num);
317         // printf("seconds = %.2lf\n", seconds);
318
319         result += seconds / 3600.0;
320     }
321
322     return(sign * result);
323 }
324
325
326 long int fgOPTIONS::parse_date( const string& date)
327 {
328     struct tm gmt;
329     char * date_str, num[256];
330     int i;
331     // initialize to zero
332     gmt.tm_sec = 0;
333     gmt.tm_min = 0;
334     gmt.tm_hour = 0;
335     gmt.tm_mday = 0;
336     gmt.tm_mon = 0;
337     gmt.tm_year = 0;
338     gmt.tm_isdst = 0; // ignore daylight savingtime for the moment
339     date_str = (char *)date.c_str();
340     // get year
341     if ( strlen(date_str) ) {
342         i = 0;
343         while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
344             num[i] = date_str[0];
345             date_str++;
346             i++;
347         }
348         if ( date_str[0] == ':' ) {
349             date_str++;
350         }
351         num[i] = '\0';
352         gmt.tm_year = atoi(num) - 1900;
353     }
354     // get month
355     if ( strlen(date_str) ) {
356         i = 0;
357         while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
358             num[i] = date_str[0];
359             date_str++;
360             i++;
361         }
362         if ( date_str[0] == ':' ) {
363             date_str++;
364         }
365         num[i] = '\0';
366         gmt.tm_mon = atoi(num) -1;
367     }
368     // get day
369     if ( strlen(date_str) ) {
370         i = 0;
371         while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
372             num[i] = date_str[0];
373             date_str++;
374             i++;
375         }
376         if ( date_str[0] == ':' ) {
377             date_str++;
378         }
379         num[i] = '\0';
380         gmt.tm_mday = atoi(num);
381     }
382     // get hour
383     if ( strlen(date_str) ) {
384         i = 0;
385         while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
386             num[i] = date_str[0];
387             date_str++;
388             i++;
389         }
390         if ( date_str[0] == ':' ) {
391             date_str++;
392         }
393         num[i] = '\0';
394         gmt.tm_hour = atoi(num);
395     }
396     // get minute
397     if ( strlen(date_str) ) {
398         i = 0;
399         while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
400             num[i] = date_str[0];
401             date_str++;
402             i++;
403         }
404         if ( date_str[0] == ':' ) {
405             date_str++;
406         }
407         num[i] = '\0';
408         gmt.tm_min = atoi(num);
409     }
410     // get second
411     if ( strlen(date_str) ) {
412         i = 0;
413         while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
414             num[i] = date_str[0];
415             date_str++;
416             i++;
417         }
418         if ( date_str[0] == ':' ) {
419             date_str++;
420         }
421         num[i] = '\0';
422         gmt.tm_sec = atoi(num);
423     }
424     time_t theTime = FGTime::cur_time_params->get_gmt(gmt.tm_year,
425                                                       gmt.tm_mon,
426                                                       gmt.tm_mday,
427                                                       gmt.tm_hour,
428                                                       gmt.tm_min,
429                                                       gmt.tm_sec);
430     //printf ("Date is %s\n", ctime(&theTime));
431     //printf ("in seconds that is %d\n", theTime);
432     //exit(1);
433     return (theTime);
434 }
435
436
437 // parse degree in the form of [+/-]hhh:mm:ss
438 void fgOPTIONS::parse_control( const string& mode ) {
439     if ( mode == "joystick" ) {
440         control_mode = FG_JOYSTICK;
441     } else if ( mode == "mouse" ) {
442         control_mode = FG_MOUSE;
443     } else {
444         control_mode = FG_KEYBOARD;
445     }
446 }
447
448
449 /// parse degree in the form of [+/-]hhh:mm:ss
450 double
451 fgOPTIONS::parse_degree( const string& degree_str) {
452     double result = parse_time( degree_str );
453
454     // printf("Degree = %.4f\n", result);
455
456     return(result);
457 }
458
459
460 // parse time offset command line option
461 int
462 fgOPTIONS::parse_time_offset( const string& time_str) {
463     int result;
464
465     // printf("time offset = %s\n", time_str);
466
467 #ifdef HAVE_RINT
468     result = (int)rint(parse_time(time_str) * 3600.0);
469 #else
470     result = (int)(parse_time(time_str) * 3600.0);
471 #endif
472
473     // printf("parse_time_offset(): %d\n", result);
474
475     return( result );
476 }
477
478
479 // Parse --tile-diameter=n type option 
480
481 int
482 fgOPTIONS::parse_tile_radius( const string& arg ) {
483     int radius = atoi( arg );
484
485     if ( radius < FG_RADIUS_MIN ) { radius = FG_RADIUS_MIN; }
486     if ( radius > FG_RADIUS_MAX ) { radius = FG_RADIUS_MAX; }
487
488     // printf("parse_tile_radius(): radius = %d\n", radius);
489
490     return(radius);
491 }
492
493
494 // Parse --fdm=abcdefg type option 
495 int
496 fgOPTIONS::parse_fdm( const string& fm ) {
497     // printf("fdm = %s\n", fm);
498
499     if ( fm == "slew" ) {
500         return FGInterface::FG_SLEW;
501     } else if ( fm == "jsb" ) {
502         return FGInterface::FG_JSBSIM;
503     } else if ( (fm == "larcsim") || (fm == "LaRCsim") ) {
504         return FGInterface::FG_LARCSIM;
505     } else if ( fm == "external" ) {
506         return FGInterface::FG_EXTERNAL;
507     } else {
508         FG_LOG( FG_GENERAL, FG_ALERT, "Unknown fdm = " << fm );
509         exit(-1);
510     }
511
512     // we'll never get here, but it makes the compiler happy.
513     return -1;
514 }
515
516
517 // Parse --fov=x.xx type option 
518 double
519 fgOPTIONS::parse_fov( const string& arg ) {
520     double fov = atof(arg);
521
522     if ( fov < FG_FOV_MIN ) { fov = FG_FOV_MIN; }
523     if ( fov > FG_FOV_MAX ) { fov = FG_FOV_MAX; }
524
525     // printf("parse_fov(): result = %.4f\n", fov);
526
527     return(fov);
528 }
529
530
531 // Parse serial port option --serial=/dev/ttyS1,nmea,4800,out
532 //
533 // Format is "--serial=device,format,baud,direction" where
534 // 
535 //  device = OS device name to be open()'ed
536 //  format = {nmea, garmin,fgfs,rul}
537 //  baud = {300, 1200, 2400, ..., 230400}
538 //  direction = {in, out, bi}
539
540 bool 
541 fgOPTIONS::parse_serial( const string& serial_str ) {
542     string::size_type pos;
543
544     // cout << "Serial string = " << serial_str << endl;
545
546     // a flailing attempt to see if the port config string has a
547     // chance at being valid
548     pos = serial_str.find(",");
549     if ( pos == string::npos ) {
550         FG_LOG( FG_GENERAL, FG_ALERT, 
551                 "Malformed serial port configure string" );
552         return false;
553     }
554     
555     port_options_list.push_back( serial_str );
556
557     return true;
558 }
559
560
561 // Parse a single option
562 int fgOPTIONS::parse_option( const string& arg ) {
563     // General Options
564     if ( (arg == "--help") || (arg == "-h") ) {
565         // help/usage request
566         return(FG_OPTIONS_HELP);
567     } else if ( arg == "--disable-game-mode") {
568         game_mode = false;
569     } else if ( arg == "--enable-game-mode" ) {
570         game_mode = true;
571     } else if ( arg == "--disable-splash-screen" ) {
572         splash_screen = false;
573     } else if ( arg == "--enable-splash-screen" ) {
574         splash_screen = true;
575     } else if ( arg == "--disable-intro-music" ) {
576         intro_music = false;
577     } else if ( arg == "--enable-intro-music" ) {
578         intro_music = true;
579     } else if ( arg == "--disable-mouse-pointer" ) {
580         mouse_pointer = 1;
581     } else if ( arg == "--enable-mouse-pointer" ) {
582         mouse_pointer = 2;
583     } else if ( arg == "--disable-pause" ) {
584         pause = false;  
585     } else if ( arg == "--enable-pause" ) {
586         pause = true;   
587     } else if ( arg.find( "--control=") != string::npos ) {
588         parse_control( arg.substr(10) );
589     } else if ( arg == "--disable-hud" ) {
590         hud_status = false;     
591     } else if ( arg == "--enable-hud" ) {
592         hud_status = true;      
593     } else if ( arg == "--disable-panel" ) {
594         panel_status = false;
595     } else if ( arg == "--enable-panel" ) {
596         panel_status = true;
597         fov *= 0.4232;
598     } else if ( arg == "--disable-sound" ) {
599         sound = false;
600     } else if ( arg == "--enable-sound" ) {
601         sound = true;
602     } else if ( arg.find( "--airport-id=") != string::npos ) {
603         airport_id = arg.substr( 13 );
604     } else if ( arg.find( "--lon=" ) != string::npos ) {
605         lon = parse_degree( arg.substr(6) );
606     } else if ( arg.find( "--lat=" ) != string::npos ) {
607         lat = parse_degree( arg.substr(6) );
608     } else if ( arg.find( "--altitude=" ) != string::npos ) {
609         if ( units == FG_UNITS_FEET ) {
610             altitude = atof( arg.substr(11) ) * FEET_TO_METER;
611         } else {
612             altitude = atof( arg.substr(11) );
613         }
614     } else if ( arg.find( "--uBody=" ) != string::npos ) {
615         if ( units == FG_UNITS_FEET ) {
616             uBody = atof( arg.substr(8) ) * FEET_TO_METER;
617         } else {
618             uBody = atof( arg.substr(8) );
619         }
620     } else if ( arg.find( "--vBody=" ) != string::npos ) {
621         if ( units == FG_UNITS_FEET ) {
622             vBody = atof( arg.substr(8) ) * FEET_TO_METER;
623         } else {
624             vBody = atof( arg.substr(8) );
625         }
626     } else if ( arg.find( "--wBody=" ) != string::npos ) {
627         if ( units == FG_UNITS_FEET ) {
628             wBody = atof( arg.substr(8) ) * FEET_TO_METER;
629         } else {
630             wBody = atof( arg.substr(8) );
631         }
632     } else if ( arg.find( "--heading=" ) != string::npos ) {
633         heading = atof( arg.substr(10) );
634     } else if ( arg.find( "--roll=" ) != string::npos ) {
635         roll = atof( arg.substr(7) );
636     } else if ( arg.find( "--pitch=" ) != string::npos ) {
637         pitch = atof( arg.substr(8) );
638     } else if ( arg.find( "--fg-root=" ) != string::npos ) {
639         fg_root = arg.substr( 10 );
640     } else if ( arg.find( "--fdm=" ) != string::npos ) {
641         flight_model = parse_fdm( arg.substr(6) );
642     } else if ( arg.find( "--speed=" ) != string::npos ) {
643         speed_up = atoi( arg.substr(8) );
644     } else if ( arg == "--fog-disable" ) {
645         fog = FG_FOG_DISABLED;  
646     } else if ( arg == "--fog-fastest" ) {
647         fog = FG_FOG_FASTEST;   
648     } else if ( arg == "--fog-nicest" ) {
649         fog = FG_FOG_NICEST;    
650     } else if ( arg.find( "--fov=" ) != string::npos ) {
651         fov = parse_fov( arg.substr(6) );
652     } else if ( arg == "--disable-fullscreen" ) {
653         fullscreen = false;     
654     } else if ( arg== "--enable-fullscreen") {
655         fullscreen = true;      
656     } else if ( arg == "--shading-flat") {
657         shading = 0;    
658     } else if ( arg == "--shading-smooth") {
659         shading = 1;    
660     } else if ( arg == "--disable-skyblend") {
661         skyblend = false;       
662     } else if ( arg== "--enable-skyblend" ) {
663         skyblend = true;        
664     } else if ( arg == "--disable-textures" ) {
665         textures = false;       
666     } else if ( arg == "--enable-textures" ) {
667         textures = true;
668     } else if ( arg == "--disable-wireframe" ) {
669         wireframe = false;      
670     } else if ( arg == "--enable-wireframe" ) {
671         wireframe = true;
672     } else if ( arg.find( "--geometry=" ) != string::npos ) {
673         string geometry = arg.substr( 11 );
674         if ( geometry == "640x480" ) {
675             xsize = 640;
676             ysize = 480;
677         } else if ( geometry == "800x600" ) {
678             xsize = 800;
679             ysize = 600;
680         } else if ( geometry == "1024x768" ) {
681             xsize = 1024;
682             ysize = 768;
683         } else {
684             FG_LOG( FG_GENERAL, FG_ALERT, "Unknown geometry: " << geometry );
685             exit(-1);
686         }
687     } else if ( arg == "--units-feet" ) {
688         units = FG_UNITS_FEET;  
689     } else if ( arg == "--units-meters" ) {
690         units = FG_UNITS_METERS;        
691     } else if ( arg.find( "--tile-radius=" ) != string::npos ) {
692         tile_radius = parse_tile_radius( arg.substr(14) );
693         tile_diameter = tile_radius * 2 + 1;
694     } else if ( arg.find( "--time-offset=" ) != string::npos ) {
695         time_offset = parse_time_offset( (arg.substr(14)) );
696     } else if (arg.find( "--start-date-gmt=") != string::npos ) {
697         start_gst = parse_date( (arg.substr(17)) );
698     } else if (arg.find( "--start-data-lst=") != string::npos ) {
699         start_lst = parse_date( (arg.substr(17)) );
700     } else if ( arg == "--hud-tris" ) {
701         tris_or_culled = 0;     
702     } else if ( arg == "--hud-culled" ) {
703         tris_or_culled = 1;
704     } else if ( arg.find( "--serial=" ) != string::npos ) {
705         parse_serial( arg.substr(9) );
706 #ifdef FG_NETWORK_OLK
707     } else if ( arg == "--net-hud" ) {
708         net_hud_display = 1;    
709     } else if ( arg.find( "--net-id=") != string::npos ) {
710         net_id = arg.substr( 9 );
711 #endif
712     } else {
713         FG_LOG( FG_GENERAL, FG_ALERT, "Unknown option '" << arg << "'" );
714         return FG_OPTIONS_ERROR;
715     }
716     
717     return FG_OPTIONS_OK;
718 }
719
720
721 // Parse the command line options
722 int fgOPTIONS::parse_command_line( int argc, char **argv ) {
723     int i = 1;
724     int result;
725
726     FG_LOG(FG_GENERAL, FG_INFO, "Processing command line arguments");
727
728     while ( i < argc ) {
729         FG_LOG( FG_GENERAL, FG_DEBUG, "argv[" << i << "] = " << argv[i] );
730
731         result = parse_option(argv[i]);
732         if ( (result == FG_OPTIONS_HELP) || (result == FG_OPTIONS_ERROR) ) {
733             return(result);
734         }
735
736         i++;
737     }
738     
739     return(FG_OPTIONS_OK);
740 }
741
742
743 // Parse config file options
744 int fgOPTIONS::parse_config_file( const string& path ) {
745     fg_gzifstream in( path );
746     if ( !in.is_open() )
747         return(FG_OPTIONS_ERROR);
748
749     FG_LOG( FG_GENERAL, FG_INFO, "Processing config file: " << path );
750
751     in >> skipcomment;
752 #ifndef __MWERKS__
753     while ( ! in.eof() ) {
754 #else
755     char c = '\0';
756     while ( in.get(c) && c != '\0' ) {
757         in.putback(c);
758 #endif
759         string line;
760
761 #ifdef GETLINE_NEEDS_TERMINATOR
762         getline( in, line, '\n' );
763 #else
764         getline( in, line );
765 #endif
766
767         if ( parse_option( line ) == FG_OPTIONS_ERROR ) {
768             FG_LOG( FG_GENERAL, FG_ALERT, 
769                     "Config file parse error: " << path << " '" 
770                     << line << "'" );
771             exit(-1);
772         }
773         in >> skipcomment;
774     }
775
776     return FG_OPTIONS_OK;
777 }
778
779
780 // Print usage message
781 void fgOPTIONS::usage ( void ) {
782     printf("Usage: fg [ options ... ]\n");
783     printf("\n");
784
785     printf("General Options:\n");
786     printf("\t--help -h:  print usage\n");
787     printf("\t--fg-root=path:  specify the root path for all the data files\n");
788     printf("\t--disable-game-mode:  disable full-screen game mode\n");
789     printf("\t--enable-game-mode:  enable full-screen game mode\n");
790     printf("\t--disable-splash-screen:  disable splash screen\n");
791     printf("\t--enable-splash-screen:  enable splash screen\n");
792     printf("\t--disable-intro-music:  disable introduction music\n");
793     printf("\t--enable-intro-music:  enable introduction music\n");
794     printf("\t--disable-mouse-pointer:  disable extra mouse pointer\n");
795     printf("\t--enable-mouse-pointer:  enable extra mouse pointer (i.e. for\n");
796     printf("\t\tfull screen voodoo/voodoo-II based cards.)\n");
797     printf("\t--disable-pause:  start out in an active state\n");
798     printf("\t--enable-pause:  start out in a paused state\n");
799     printf("\t--control=mode:  primary control mode (joystick, keyboard, mouse)\n");
800     printf("\n");
801
802     printf("Features:\n");
803     printf("\t--disable-hud:  disable heads up display\n");
804     printf("\t--enable-hud:  enable heads up display\n");
805     printf("\t--disable-panel:  disable instrument panel\n");
806     printf("\t--enable-panel:  enable instrumetn panel\n");
807     printf("\t--disable-sound:  disable sound effects\n");
808     printf("\t--enable-sound:  enable sound effects\n");
809     printf("\n");
810  
811     printf("Flight Model:\n");
812     printf("\t--fdm=abcd:  one of slew, jsb, larcsim, or external\n");
813     printf("\t--speed=n:  run the FDM this much faster than real time\n");
814     printf("\n");
815
816     printf("Initial Position and Orientation:\n");
817     printf("\t--airport-id=ABCD:  specify starting postion by airport id\n");
818     printf("\t--lon=degrees:  starting longitude in degrees (west = -)\n");
819     printf("\t--lat=degrees:  starting latitude in degrees (south = -)\n");
820     printf("\t--altitude=feet:  starting altitude in feet\n");
821     printf("\t\t(unless --units-meters specified\n");
822     printf("\t--heading=degrees:  heading (yaw) angle in degress (Psi)\n");
823     printf("\t--roll=degrees:  roll angle in degrees (Phi)\n");
824     printf("\t--pitch=degrees:  pitch angle in degrees (Theta)\n");
825     printf("\t--uBody=feet per second:  velocity along the body X axis\n");
826     printf("\t--vBody=feet per second:  velocity along the body Y axis\n");
827     printf("\t--wBody=feet per second:  velocity along the body Z axis\n");
828     printf("\t\t(unless --units-meters specified\n");
829     printf("\n");
830
831     printf("Rendering Options:\n");
832     printf("\t--fog-disable:  disable fog/haze\n");
833     printf("\t--fog-fastest:  enable fastest fog/haze\n");
834     printf("\t--fog-nicest:  enable nicest fog/haze\n");
835     printf("\t--fov=xx.x:  specify initial field of view angle in degrees\n");
836     printf("\t--disable-fullscreen:  disable fullscreen mode\n");
837     printf("\t--enable-fullscreen:  enable fullscreen mode\n");
838     printf("\t--shading-flat:  enable flat shading\n");
839     printf("\t--shading-smooth:  enable smooth shading\n");
840     printf("\t--disable-skyblend:  disable sky blending\n");
841     printf("\t--enable-skyblend:  enable sky blending\n");
842     printf("\t--disable-textures:  disable textures\n");
843     printf("\t--enable-textures:  enable textures\n");
844     printf("\t--disable-wireframe:  disable wireframe drawing mode\n");
845     printf("\t--enable-wireframe:  enable wireframe drawing mode\n");
846     printf("\t--geometry=WWWxHHH:  window geometry: 640x480, 800x600, etc.\n");
847     printf("\n");
848
849     printf("Scenery Options:\n");
850     printf("\t--tile-radius=n:  specify tile radius, must be 1 - 4\n");
851     printf("\n");
852
853     printf("Hud Options:\n");
854     printf("\t--units-feet:  Hud displays units in feet\n");
855     printf("\t--units-meters:  Hud displays units in meters\n");
856     printf("\t--hud-tris:  Hud displays number of triangles rendered\n");
857     printf("\t--hud-culled:  Hud displays percentage of triangles culled\n");
858     printf("\n");
859         
860     printf("Time Options:\n");
861     printf("\t--time-offset=[+-]hh:mm:ss:  offset local time by this amount\n");
862     printf("\t--start-date-gmt=yyyy:mm:dd:hh:mm:ss: specify a starting date/time. Time is Greenwich Mean Time\n");
863     printf("\t--start-date-lst=yyyy:mm:dd:hh:mm:ss: specify a starting date/time. Uses local sidereal time\n");
864 #ifdef FG_NETWORK_OLK
865     printf("\n");
866
867     printf("Network Options:\n");
868     printf("\t--net-hud:  Hud displays network info\n");
869     printf("\t--net-id=name:  specify your own callsign\n");
870 #endif
871 }
872
873
874 // Destructor
875 fgOPTIONS::~fgOPTIONS( void ) {
876 }