1 // options.cxx -- class to handle command line options
3 // Written by Curtis Olson, started April 1998.
5 // Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
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.
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.
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.
28 #if defined(FX) && defined(XMESA)
29 bool global_fullscreen = true;
32 #include <simgear/compiler.h>
34 #include <math.h> // rint()
36 #include <stdlib.h> // atof(), atoi()
41 #include <simgear/constants.h>
42 #include <simgear/debug/logstream.hxx>
43 #include <simgear/misc/fgstream.hxx>
44 #include <simgear/misc/props.hxx>
45 #include <simgear/timing/sg_time.hxx>
47 #include <Include/general.hxx>
48 #include <Cockpit/cockpit.hxx>
49 #include <FDM/flight.hxx>
50 #include <FDM/UIUCModel/uiuc_aircraftdir.h>
52 # include <NetworkOLK/network.h>
55 #include "globals.hxx"
56 #include "options.hxx"
60 FG_USING_NAMESPACE(std);
63 extern void fgReshape( int width, int height );
66 atof( const string& str )
70 // -dw- if ::atof is called, then we get an infinite loop
71 return std::atof( str.c_str() );
73 return ::atof( str.c_str() );
78 atoi( const string& str )
81 // -dw- if ::atoi is called, then we get an infinite loop
82 return std::atoi( str.c_str() );
84 return ::atoi( str.c_str() );
89 // Defined the shared options class here
90 fgOPTIONS current_options;
94 fgOPTIONS::fgOPTIONS() :
95 // starting longitude in degrees (west = -)
96 // starting latitude in degrees (south = -)
98 // Default initial position is Globe, AZ (P13)
102 // North of the city of Globe
106 // North of the city of Globe
110 // Near where I used to live in Globe, AZ
114 // 10125 Jewell St. NE
118 // Near KHSP (Hot Springs, VA)
119 // lon(-79.8338964 + 0.01),
120 // lat( 37.9514564 + 0.008),
122 // (SEZ) SEDONA airport
123 // lon(-111.7884614 + 0.01),
124 // lat( 34.8486289 - 0.015),
126 // Jim Brennon's Kingmont Observatory
127 // lon(-121.1131667),
130 // Huaras, Peru (S09d 31.871' W077d 31.498')
134 // Eclipse Watching w73.5 n10 (approx) 18:00 UT
139 // lon(-90.1953055556),
140 // lat( 45.4511388889),
142 // starting altitude in meters (this will be reset to ground level
143 // if it is lower than the terrain
146 // Initial Orientation
147 heading(270.0), // heading (yaw) angle in degress (Psi)
148 roll(0.0), // roll angle in degrees (Phi)
149 pitch(0.424), // pitch angle in degrees (Theta)
151 // Initialize current options velocities to 0.0
152 uBody(0.0), vBody(0.0), wBody(0.0), vkcas(0.0), mach(0.0),
159 control_mode(FG_JOYSTICK),
160 auto_coordination(FG_AUTO_COORD_NOT_SPECIFIED),
168 // Flight Model options
169 flight_model( FGInterface::FG_LARCSIM ),
171 model_hz( NEW_DEFAULT_MODEL_HZ ),
176 fog(FG_FOG_NICEST), // nicest
178 clouds_asl(5000*FEET_TO_METER),
188 view_mode(FG_VIEW_PILOT),
194 units(FG_UNITS_FEET),
202 // set initial values/defaults
203 time_offset_type = FG_TIME_SYS_OFFSET;
204 char* envp = ::getenv( "FG_ROOT" );
206 if ( envp != NULL ) {
207 // fg_root could be anywhere, so default to environmental
208 // variable $FG_ROOT if it is set.
211 // Otherwise, default to a random compiled-in location if
212 // $FG_ROOT is not set. This can still be overridden from the
213 // command line or a config file.
216 fg_root = "\\FlightGear";
217 #elif defined( macintosh )
224 // set a possibly independent location for scenery data
225 envp = ::getenv( "FG_SCENERY" );
227 if ( envp != NULL ) {
228 // fg_root could be anywhere, so default to environmental
229 // variable $FG_ROOT if it is set.
232 // Otherwise, default to Scenery being in $FG_ROOT/Scenery
236 airport_id = "P13"; // default airport id
237 net_id = "Johnney"; // default pilot's name
239 // initialize port config string list
240 channel_options_list.clear();
244 fgOPTIONS::toggle_panel() {
246 bool freeze = globals->get_freeze();
249 globals->set_freeze(true);
252 panel_status = false;
253 if ( current_panel != NULL )
254 current_panel->setVisibility(false);
257 if ( current_panel != NULL )
258 current_panel->setVisibility(true);
261 // new rule .. "fov" shouldn't get messed with like this.
262 /* if ( panel_status ) {
265 fov *= (1.0 / 0.4232);
268 // fgReshape( xsize, ysize);
269 fgReshape( current_view.get_winWidth(), current_view.get_winHeight() );
272 globals->set_freeze( false );
276 fgOPTIONS::parse_time(const string& time_in) {
277 char *time_str, num[256];
278 double hours, minutes, seconds;
283 time_str = (char *)time_in.c_str();
285 // printf("parse_time(): %s\n", time_str);
288 if ( strlen(time_str) ) {
289 if ( time_str[0] == '+' ) {
292 } else if ( time_str[0] == '-' ) {
297 // printf("sign = %d\n", sign);
300 if ( strlen(time_str) ) {
302 while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
303 num[i] = time_str[0];
307 if ( time_str[0] == ':' ) {
312 // printf("hours = %.2lf\n", hours);
318 if ( strlen(time_str) ) {
320 while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
321 num[i] = time_str[0];
325 if ( time_str[0] == ':' ) {
330 // printf("minutes = %.2lf\n", minutes);
332 result += minutes / 60.0;
336 if ( strlen(time_str) ) {
338 while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
339 num[i] = time_str[0];
345 // printf("seconds = %.2lf\n", seconds);
347 result += seconds / 3600.0;
350 return(sign * result);
354 long int fgOPTIONS::parse_date( const string& date)
357 char * date_str, num[256];
359 // initialize to zero
366 gmt.tm_isdst = 0; // ignore daylight savings time for the moment
367 date_str = (char *)date.c_str();
369 if ( strlen(date_str) ) {
371 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
372 num[i] = date_str[0];
376 if ( date_str[0] == ':' ) {
380 gmt.tm_year = atoi(num) - 1900;
383 if ( strlen(date_str) ) {
385 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
386 num[i] = date_str[0];
390 if ( date_str[0] == ':' ) {
394 gmt.tm_mon = atoi(num) -1;
397 if ( strlen(date_str) ) {
399 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
400 num[i] = date_str[0];
404 if ( date_str[0] == ':' ) {
408 gmt.tm_mday = atoi(num);
411 if ( strlen(date_str) ) {
413 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
414 num[i] = date_str[0];
418 if ( date_str[0] == ':' ) {
422 gmt.tm_hour = atoi(num);
425 if ( strlen(date_str) ) {
427 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
428 num[i] = date_str[0];
432 if ( date_str[0] == ':' ) {
436 gmt.tm_min = atoi(num);
439 if ( strlen(date_str) ) {
441 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
442 num[i] = date_str[0];
446 if ( date_str[0] == ':' ) {
450 gmt.tm_sec = atoi(num);
452 time_t theTime = sgTimeGetGMT( gmt.tm_year, gmt.tm_mon, gmt.tm_mday,
453 gmt.tm_hour, gmt.tm_min, gmt.tm_sec );
454 //printf ("Date is %s\n", ctime(&theTime));
455 //printf ("in seconds that is %d\n", theTime);
461 // parse degree in the form of [+/-]hhh:mm:ss
462 void fgOPTIONS::parse_control( const string& mode ) {
463 if ( mode == "joystick" ) {
464 control_mode = FG_JOYSTICK;
465 } else if ( mode == "mouse" ) {
466 control_mode = FG_MOUSE;
468 control_mode = FG_KEYBOARD;
473 /// parse degree in the form of [+/-]hhh:mm:ss
475 fgOPTIONS::parse_degree( const string& degree_str) {
476 double result = parse_time( degree_str );
478 // printf("Degree = %.4f\n", result);
484 // parse time offset command line option
486 fgOPTIONS::parse_time_offset( const string& time_str) {
489 // printf("time offset = %s\n", time_str);
492 result = (int)rint(parse_time(time_str) * 3600.0);
494 result = (int)(parse_time(time_str) * 3600.0);
497 // printf("parse_time_offset(): %d\n", result);
503 // Parse --tile-diameter=n type option
506 fgOPTIONS::parse_tile_radius( const string& arg ) {
507 int radius = atoi( arg );
509 if ( radius < FG_RADIUS_MIN ) { radius = FG_RADIUS_MIN; }
510 if ( radius > FG_RADIUS_MAX ) { radius = FG_RADIUS_MAX; }
512 // printf("parse_tile_radius(): radius = %d\n", radius);
518 // Parse --fdm=abcdefg type option
520 fgOPTIONS::parse_fdm( const string& fm ) {
521 // cout << "fdm = " << fm << endl;
523 if ( fm == "balloon" ) {
524 return FGInterface::FG_BALLOONSIM;
525 } else if ( fm == "external" ) {
526 return FGInterface::FG_EXTERNAL;
527 } else if ( fm == "jsb" ) {
528 return FGInterface::FG_JSBSIM;
529 } else if ( (fm == "larcsim") || (fm == "LaRCsim") ) {
530 return FGInterface::FG_LARCSIM;
531 } else if ( fm == "magic" ) {
532 return FGInterface::FG_MAGICCARPET;
534 FG_LOG( FG_GENERAL, FG_ALERT, "Unknown fdm = " << fm );
538 // we'll never get here, but it makes the compiler happy.
543 // Parse --fov=x.xx type option
545 fgOPTIONS::parse_fov( const string& arg ) {
546 double fov = atof(arg);
548 if ( fov < FG_FOV_MIN ) { fov = FG_FOV_MIN; }
549 if ( fov > FG_FOV_MAX ) { fov = FG_FOV_MAX; }
551 // printf("parse_fov(): result = %.4f\n", fov);
557 // Parse I/O channel option
559 // Format is "--protocol=medium,direction,hz,medium_options,..."
561 // protocol = { native, nmea, garmin, fgfs, rul, pve, etc. }
562 // medium = { serial, socket, file, etc. }
563 // direction = { in, out, bi }
564 // hz = number of times to process channel per second (floating
565 // point values are ok.
567 // Serial example "--nmea=serial,dir,hz,device,baud" where
569 // device = OS device name of serial line to be open()'ed
570 // baud = {300, 1200, 2400, ..., 230400}
572 // Socket exacmple "--native=socket,dir,hz,machine,port,style" where
574 // machine = machine name or ip address if client (leave empty if server)
575 // port = port, leave empty to let system choose
576 // style = tcp or udp
578 // File example "--garmin=file,dir,hz,filename" where
580 // filename = file system file name
583 fgOPTIONS::parse_channel( const string& type, const string& channel_str ) {
584 // cout << "Channel string = " << channel_str << endl;
586 channel_options_list.push_back( type + "," + channel_str );
592 // Parse a single option
593 int fgOPTIONS::parse_option( const string& arg ) {
595 if ( (arg == "--help") || (arg == "-h") ) {
596 // help/usage request
597 return(FG_OPTIONS_HELP);
598 } else if ( arg == "--disable-game-mode") {
600 } else if ( arg == "--enable-game-mode" ) {
602 } else if ( arg == "--disable-splash-screen" ) {
603 splash_screen = false;
604 } else if ( arg == "--enable-splash-screen" ) {
605 splash_screen = true;
606 } else if ( arg == "--disable-intro-music" ) {
608 } else if ( arg == "--enable-intro-music" ) {
610 } else if ( arg == "--disable-mouse-pointer" ) {
612 } else if ( arg == "--enable-mouse-pointer" ) {
614 } else if ( arg == "--disable-freeze" ) {
615 globals->set_freeze( false );
616 } else if ( arg == "--enable-freeze" ) {
617 globals->set_freeze( true );
618 } else if ( arg == "--disable-anti-alias-hud" ) {
619 anti_alias_hud = false;
620 } else if ( arg == "--enable-anti-alias-hud" ) {
621 anti_alias_hud = true;
622 } else if ( arg.find( "--control=") != string::npos ) {
623 parse_control( arg.substr(10) );
624 } else if ( arg == "--disable-auto-coordination" ) {
625 auto_coordination = FG_AUTO_COORD_DISABLED;
626 } else if ( arg == "--enable-auto-coordination" ) {
627 auto_coordination = FG_AUTO_COORD_ENABLED;
628 } else if ( arg == "--disable-hud" ) {
630 } else if ( arg == "--enable-hud" ) {
632 } else if ( arg == "--disable-panel" ) {
633 panel_status = false;
634 if ( current_panel != NULL )
635 current_panel->setVisibility(false);
636 } else if ( arg == "--enable-panel" ) {
638 if ( current_panel != NULL )
639 current_panel->setVisibility(true);
640 // fov *= 0.4232; /* NO!!! */
641 } else if ( arg == "--disable-sound" ) {
643 } else if ( arg == "--enable-sound" ) {
645 } else if ( arg.find( "--airport-id=") != string::npos ) {
646 airport_id = arg.substr( 13 );
647 } else if ( arg.find( "--lon=" ) != string::npos ) {
648 lon = parse_degree( arg.substr(6) );
650 current_properties.setDoubleValue("/position/longitude", lon);
651 } else if ( arg.find( "--lat=" ) != string::npos ) {
652 lat = parse_degree( arg.substr(6) );
654 current_properties.setDoubleValue("/position/latitude", lat);
655 } else if ( arg.find( "--altitude=" ) != string::npos ) {
656 if ( units == FG_UNITS_FEET ) {
657 altitude = atof( arg.substr(11) ) * FEET_TO_METER;
659 altitude = atof( arg.substr(11) );
661 current_properties.setDoubleValue("/position/altitude", altitude);
662 } else if ( arg.find( "--uBody=" ) != string::npos ) {
664 if ( units == FG_UNITS_FEET ) {
665 uBody = atof( arg.substr(8) );
667 uBody = atof( arg.substr(8) ) * FEET_TO_METER;
669 current_properties.setDoubleValue("/velocities/speed-north", uBody);
670 } else if ( arg.find( "--vBody=" ) != string::npos ) {
672 if ( units == FG_UNITS_FEET ) {
673 vBody = atof( arg.substr(8) );
675 vBody = atof( arg.substr(8) ) * FEET_TO_METER;
677 current_properties.setDoubleValue("/velocities/speed-east", vBody);
678 } else if ( arg.find( "--wBody=" ) != string::npos ) {
680 if ( units == FG_UNITS_FEET ) {
681 wBody = atof( arg.substr(8) );
683 wBody = atof( arg.substr(8) ) * FEET_TO_METER;
685 current_properties.setDoubleValue("/velocities/speed-down", wBody);
686 } else if ( arg.find( "--vc=" ) != string::npos) {
688 vkcas=atof( arg.substr(5) );
689 cout << "Got vc: " << vkcas << endl;
690 } else if ( arg.find( "--mach=" ) != string::npos) {
692 mach=atof( arg.substr(7) );
693 } else if ( arg.find( "--heading=" ) != string::npos ) {
694 heading = atof( arg.substr(10) );
695 current_properties.setDoubleValue("/orientation/heading", heading);
696 } else if ( arg.find( "--roll=" ) != string::npos ) {
697 roll = atof( arg.substr(7) );
698 current_properties.setDoubleValue("/orientation/roll", roll);
699 } else if ( arg.find( "--pitch=" ) != string::npos ) {
700 pitch = atof( arg.substr(8) );
701 current_properties.setDoubleValue("/orientation/pitch", pitch);
702 } else if ( arg.find( "--fg-root=" ) != string::npos ) {
703 fg_root = arg.substr( 10 );
704 } else if ( arg.find( "--fg-scenery=" ) != string::npos ) {
705 fg_scenery = arg.substr( 13 );
706 } else if ( arg.find( "--fdm=" ) != string::npos ) {
707 flight_model = parse_fdm( arg.substr(6) );
708 current_properties.setIntValue("/sim/flight-model", flight_model);
709 if((flight_model == FGInterface::FG_JSBSIM) && (get_trim_mode() == 0)) {
714 } else if ( arg.find( "--aircraft=" ) != string::npos ) {
715 aircraft = arg.substr(11);
716 current_properties.setStringValue("/sim/aircraft", aircraft);
717 } else if ( arg.find( "--aircraft-dir=" ) != string::npos ) {
718 aircraft_dir = arg.substr(15); // (UIUC)
719 } else if ( arg.find( "--model-hz=" ) != string::npos ) {
720 model_hz = atoi( arg.substr(11) );
721 } else if ( arg.find( "--speed=" ) != string::npos ) {
722 speed_up = atoi( arg.substr(8) );
723 } else if ( arg.find( "--notrim") != string::npos) {
725 } else if ( arg == "--fog-disable" ) {
726 fog = FG_FOG_DISABLED;
727 } else if ( arg == "--fog-fastest" ) {
728 fog = FG_FOG_FASTEST;
729 } else if ( arg == "--fog-nicest" ) {
731 } else if ( arg == "--disable-clouds" ) {
733 } else if ( arg == "--enable-clouds" ) {
735 } else if ( arg.find( "--clouds-asl=" ) != string::npos ) {
736 if ( units == FG_UNITS_FEET ) {
737 clouds_asl = atof( arg.substr(13) ) * FEET_TO_METER;
739 clouds_asl = atof( arg.substr(13) );
741 } else if ( arg.find( "--fov=" ) != string::npos ) {
742 fov = parse_fov( arg.substr(6) );
743 } else if ( arg == "--disable-fullscreen" ) {
745 } else if ( arg== "--enable-fullscreen") {
747 } else if ( arg == "--shading-flat") {
749 } else if ( arg == "--shading-smooth") {
751 } else if ( arg == "--disable-skyblend") {
753 } else if ( arg== "--enable-skyblend" ) {
755 } else if ( arg == "--disable-textures" ) {
757 } else if ( arg == "--enable-textures" ) {
759 } else if ( arg == "--disable-wireframe" ) {
761 } else if ( arg == "--enable-wireframe" ) {
763 } else if ( arg.find( "--geometry=" ) != string::npos ) {
764 bool geometry_ok = true;
765 string geometry = arg.substr( 11 );
766 string::size_type i = geometry.find('x');
768 if (i != string::npos) {
769 xsize = atoi(geometry.substr(0, i));
770 ysize = atoi(geometry.substr(i+1));
771 // cout << "Geometry is " << xsize << 'x' << ysize << '\n';
776 if ( xsize <= 0 || ysize <= 0 ) {
782 if ( !geometry_ok ) {
783 FG_LOG( FG_GENERAL, FG_ALERT, "Unknown geometry: " << geometry );
784 FG_LOG( FG_GENERAL, FG_ALERT,
785 "Setting geometry to " << xsize << 'x' << ysize << '\n');
787 } else if ( arg.find( "--bpp=" ) != string::npos ) {
788 string bits_per_pix = arg.substr( 6 );
789 if ( bits_per_pix == "16" ) {
791 } else if ( bits_per_pix == "24" ) {
793 } else if ( bits_per_pix == "32" ) {
796 } else if ( arg == "--units-feet" ) {
797 units = FG_UNITS_FEET;
798 } else if ( arg == "--units-meters" ) {
799 units = FG_UNITS_METERS;
800 } else if ( arg.find( "--tile-radius=" ) != string::npos ) {
801 tile_radius = parse_tile_radius( arg.substr(14) );
802 tile_diameter = tile_radius * 2 + 1;
803 } else if ( arg.find( "--time-offset" ) != string::npos ) {
804 time_offset = parse_time_offset( (arg.substr(14)) );
805 //time_offset_type = FG_TIME_SYS_OFFSET;
806 } else if ( arg.find( "--time-match-real") != string::npos ) {
807 //time_offset = parse_time_offset(arg.substr(18));
808 time_offset_type = FG_TIME_SYS_OFFSET;
809 } else if ( arg.find( "--time-match-local") != string::npos ) {
810 //time_offset = parse_time_offset(arg.substr(18));
811 time_offset_type = FG_TIME_LAT_OFFSET;
812 } else if ( arg.find( "--start-date-sys=") != string::npos ) {
813 time_offset = parse_date( (arg.substr(17)) );
814 time_offset_type = FG_TIME_SYS_ABSOLUTE;
815 } else if ( arg.find( "--start-date-lat=") != string::npos ) {
816 time_offset = parse_date( (arg.substr(17)) );
817 time_offset_type = FG_TIME_LAT_ABSOLUTE;
818 } else if ( arg.find( "--start-date-gmt=") != string::npos ) {
819 time_offset = parse_date( (arg.substr(17)) );
820 time_offset_type = FG_TIME_GMT_ABSOLUTE;
822 } else if ( arg == "--hud-tris" ) {
824 } else if ( arg == "--hud-culled" ) {
826 } else if ( arg.find( "--native=" ) != string::npos ) {
827 parse_channel( "native", arg.substr(9) );
828 } else if ( arg.find( "--garmin=" ) != string::npos ) {
829 parse_channel( "garmin", arg.substr(9) );
830 } else if ( arg.find( "--nmea=" ) != string::npos ) {
831 parse_channel( "nmea", arg.substr(7) );
832 } else if ( arg.find( "--props=" ) != string::npos ) {
833 parse_channel( "props", arg.substr(8) );
834 } else if ( arg.find( "--pve=" ) != string::npos ) {
835 parse_channel( "pve", arg.substr(6) );
836 } else if ( arg.find( "--ray=" ) != string::npos ) {
837 parse_channel( "ray", arg.substr(6) );
838 } else if ( arg.find( "--rul=" ) != string::npos ) {
839 parse_channel( "rul", arg.substr(6) );
840 } else if ( arg.find( "--joyclient=" ) != string::npos ) {
841 parse_channel( "joyclient", arg.substr(12) );
842 #ifdef FG_NETWORK_OLK
843 } else if ( arg == "--disable-network-olk" ) {
845 } else if ( arg== "--enable-network-olk") {
847 } else if ( arg == "--net-hud" ) {
849 } else if ( arg.find( "--net-id=") != string::npos ) {
850 net_id = arg.substr( 9 );
852 } else if ( arg.find( "--prop:" ) == 0 ) {
853 string assign = arg.substr(7);
854 int pos = assign.find('=');
855 if (pos == arg.npos || pos == 0) {
856 FG_LOG(FG_GENERAL, FG_ALERT, "Bad property assignment: " << arg);
857 return FG_OPTIONS_ERROR;
859 string name = assign.substr(0, pos);
860 string value = assign.substr(pos + 1);
861 current_properties.setStringValue(name.c_str(), value);
862 FG_LOG(FG_GENERAL, FG_INFO, "Setting default value of property "
863 << name << " to \"" << value << '"');
865 FG_LOG( FG_GENERAL, FG_ALERT, "Unknown option '" << arg << "'" );
866 return FG_OPTIONS_ERROR;
869 return FG_OPTIONS_OK;
873 // Parse the command line options
874 int fgOPTIONS::parse_command_line( int argc, char **argv ) {
878 FG_LOG(FG_GENERAL, FG_INFO, "Processing command line arguments");
881 FG_LOG( FG_GENERAL, FG_DEBUG, "argv[" << i << "] = " << argv[i] );
883 result = parse_option(argv[i]);
884 if ( (result == FG_OPTIONS_HELP) || (result == FG_OPTIONS_ERROR) ) {
891 return(FG_OPTIONS_OK);
895 // Parse config file options
896 int fgOPTIONS::parse_config_file( const string& path ) {
897 fg_gzifstream in( path );
899 return(FG_OPTIONS_ERROR);
901 FG_LOG( FG_GENERAL, FG_INFO, "Processing config file: " << path );
905 while ( ! in.eof() ) {
908 while ( in.get(c) && c != '\0' ) {
913 #ifdef GETLINE_NEEDS_TERMINATOR
914 getline( in, line, '\n' );
915 #elif defined( macintosh )
916 getline( in, line, '\r' );
921 if ( parse_option( line ) == FG_OPTIONS_ERROR ) {
922 FG_LOG( FG_GENERAL, FG_ALERT,
923 "Config file parse error: " << path << " '"
930 return FG_OPTIONS_OK;
934 // Print usage message
935 void fgOPTIONS::usage ( void ) {
936 cout << "Usage: fg [ options ... ]" << endl;
939 cout << "General Options:" << endl;
940 cout << "\t--help -h: print usage" << endl;
941 cout << "\t--fg-root=path: specify the root path for all the data files"
943 cout << "\t--fg-scenery=path: specify the base path for all the scenery"
945 << "\t\tdefaults to $FG_ROOT/Scenery" << endl;
946 cout << "\t--disable-game-mode: disable full-screen game mode" << endl;
947 cout << "\t--enable-game-mode: enable full-screen game mode" << endl;
948 cout << "\t--disable-splash-screen: disable splash screen" << endl;
949 cout << "\t--enable-splash-screen: enable splash screen" << endl;
950 cout << "\t--disable-intro-music: disable introduction music" << endl;
951 cout << "\t--enable-intro-music: enable introduction music" << endl;
952 cout << "\t--disable-mouse-pointer: disable extra mouse pointer" << endl;
953 cout << "\t--enable-mouse-pointer: enable extra mouse pointer (i.e. for"
955 cout << "\t\tfull screen voodoo/voodoo-II based cards.)" << endl;
956 cout << "\t--disable-freeze: start out in an running state" << endl;
957 cout << "\t--enable-freeze: start out in a frozen state" << endl;
958 cout << "\t--control=mode: primary control mode "
959 << "(joystick, keyboard, mouse)" << endl;
962 cout << "Features:" << endl;
963 cout << "\t--disable-hud: disable heads up display" << endl;
964 cout << "\t--enable-hud: enable heads up display" << endl;
965 cout << "\t--disable-panel: disable instrument panel" << endl;
966 cout << "\t--enable-panel: enable instrumetn panel" << endl;
967 cout << "\t--disable-sound: disable sound effects" << endl;
968 cout << "\t--enable-sound: enable sound effects" << endl;
969 cout << "\t--disable-anti-alias-hud: disable anti aliased hud" << endl;
970 cout << "\t--enable-anti-alias-hud: enable anti aliased hud" << endl;
973 cout << "Flight Model:" << endl;
974 cout << "\t--fdm=abcd: selects the core flight model code." << endl;
975 cout << "\t\tcan be one of jsb, larcsim, magic, or external" << endl;
976 cout << "\t--aircraft=abcd: aircraft model to load" << endl;
977 cout << "\t--model-hz=n: run the FDM this rate (iterations per second)"
979 cout << "\t--speed=n: run the FDM this much faster than real time" << endl;
980 cout << "\t--notrim: Do NOT attempt to trim the model when initializing JSBsim" << endl;
983 cout <<"Aircraft model directory" << endl;
984 cout <<"\t--aircraft-dir=<path> path is relative to the path of the executable" << endl;
987 cout << "Initial Position and Orientation:" << endl;
988 cout << "\t--airport-id=ABCD: specify starting postion by airport id"
990 cout << "\t--lon=degrees: starting longitude in degrees (west = -)"
992 cout << "\t--lat=degrees: starting latitude in degrees (south = -)"
994 cout << "\t--altitude=feet: starting altitude in feet" << endl;
995 cout << "\t\t(unless --units-meters specified" << endl;
996 cout << "\t--heading=degrees: heading (yaw) angle in degress (Psi)"
998 cout << "\t--roll=degrees: roll angle in degrees (Phi)" << endl;
999 cout << "\t--pitch=degrees: pitch angle in degrees (Theta)" << endl;
1000 cout << "\t--uBody=feet per second: velocity along the body X axis"
1002 cout << "\t--vBody=feet per second: velocity along the body Y axis"
1004 cout << "\t--wBody=feet per second: velocity along the body Z axis"
1006 cout << "\t\t(unless --units-meters specified" << endl;
1007 cout << "\t--vc= initial airspeed in knots (--fdm=jsb only)" << endl;
1008 cout << "\t--mach= initial mach number (--fdm=jsb only)" << endl;
1011 cout << "Rendering Options:" << endl;
1012 cout << "\t--fog-disable: disable fog/haze" << endl;
1013 cout << "\t--fog-fastest: enable fastest fog/haze" << endl;
1014 cout << "\t--fog-nicest: enable nicest fog/haze" << endl;
1015 cout << "\t--enable-clouds: enable demo cloud layer" << endl;
1016 cout << "\t--disable-clouds: disable demo cloud layer" << endl;
1017 cout << "\t--clouds-asl=xxx: specify altitude of cloud layer above sea level" << endl;
1018 cout << "\t--fov=xx.x: specify initial field of view angle in degrees"
1020 cout << "\t--disable-fullscreen: disable fullscreen mode" << endl;
1021 cout << "\t--enable-fullscreen: enable fullscreen mode" << endl;
1022 cout << "\t--shading-flat: enable flat shading" << endl;
1023 cout << "\t--shading-smooth: enable smooth shading" << endl;
1024 cout << "\t--disable-skyblend: disable sky blending" << endl;
1025 cout << "\t--enable-skyblend: enable sky blending" << endl;
1026 cout << "\t--disable-textures: disable textures" << endl;
1027 cout << "\t--enable-textures: enable textures" << endl;
1028 cout << "\t--disable-wireframe: disable wireframe drawing mode" << endl;
1029 cout << "\t--enable-wireframe: enable wireframe drawing mode" << endl;
1030 cout << "\t--geometry=WWWxHHH: window geometry: 640x480, 800x600, etc."
1034 cout << "Scenery Options:" << endl;
1035 cout << "\t--tile-radius=n: specify tile radius, must be 1 - 4" << endl;
1038 cout << "Hud Options:" << endl;
1039 cout << "\t--units-feet: Hud displays units in feet" << endl;
1040 cout << "\t--units-meters: Hud displays units in meters" << endl;
1041 cout << "\t--hud-tris: Hud displays number of triangles rendered" << endl;
1042 cout << "\t--hud-culled: Hud displays percentage of triangles culled"
1046 cout << "Time Options:" << endl;
1047 cout << "\t--time-offset=[+-]hh:mm:ss: add this time offset" << endl;
1048 cout << "\t--time-match-real: Synchronize real-world and FlightGear" << endl
1049 << "\t\ttime. Can be used in combination with --time-offset." << endl;
1050 cout << "\t--time-match-local:Synchronize local real-world and " << endl
1051 << "\t\tFlightGear time" << endl;
1052 cout << "\t--start-date-sys=yyyy:mm:dd:hh:mm:ss: specify a starting" << endl
1053 << "\t\tdate/time. Uses your system time " << endl;
1054 cout << "\t--start-date-gmt=yyyy:mm:dd:hh:mm:ss: specify a starting" << endl
1055 << "\t\tdate/time. Uses Greenwich Mean Time" << endl;
1056 cout << "\t--start-date-lat=yyyy:mm:dd:hh:mm:ss: specify a starting" << endl
1057 << "\t\tdate/time. Uses Local Aircraft Time" << endl;
1058 #ifdef FG_NETWORK_OLK
1061 cout << "Network Options:" << endl;
1062 cout << "\t--enable-network-olk: enable Multipilot mode" << endl;
1063 cout << "\t--disable-network-olk: disable Multipilot mode (default)" << endl;
1064 cout << "\t--net-hud: Hud displays network info" << endl;
1065 cout << "\t--net-id=name: specify your own callsign" << endl;
1071 fgOPTIONS::~fgOPTIONS( void ) {