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 <Airports/simple.hxx>
49 #include <Cockpit/cockpit.hxx>
50 #include <FDM/flight.hxx>
51 #include <FDM/UIUCModel/uiuc_aircraftdir.h>
53 # include <NetworkOLK/network.h>
56 #include "fg_init.hxx"
57 #include "globals.hxx"
58 #include "options.hxx"
61 FG_USING_NAMESPACE(std);
64 extern void fgReshape( int width, int height );
67 atof( const string& str )
71 // -dw- if ::atof is called, then we get an infinite loop
72 return std::atof( str.c_str() );
74 return ::atof( str.c_str() );
79 atoi( const string& str )
82 // -dw- if ::atoi is called, then we get an infinite loop
83 return std::atoi( str.c_str() );
85 return ::atoi( str.c_str() );
90 // Defined the shared options class here
91 // FGOptions current_options;
95 FGOptions::FGOptions() :
96 // starting longitude in degrees (west = -)
97 // starting latitude in degrees (south = -)
99 // Default initial position is Globe, AZ (P13)
103 // North of the city of Globe
107 // North of the city of Globe
111 // Near where I used to live in Globe, AZ
115 // 10125 Jewell St. NE
119 // Near KHSP (Hot Springs, VA)
120 // lon(-79.8338964 + 0.01),
121 // lat( 37.9514564 + 0.008),
123 // (SEZ) SEDONA airport
124 // lon(-111.7884614 + 0.01),
125 // lat( 34.8486289 - 0.015),
127 // Jim Brennon's Kingmont Observatory
128 // lon(-121.1131667),
131 // Huaras, Peru (S09d 31.871' W077d 31.498')
135 // Eclipse Watching w73.5 n10 (approx) 18:00 UT
140 // lon(-90.1953055556),
141 // lat( 45.4511388889),
143 // starting altitude in meters (this will be reset to ground level
144 // if it is lower than the terrain
147 // Initial Orientation
148 heading(270.0), // heading (yaw) angle in degress (Psi)
149 roll(0.0), // roll angle in degrees (Phi)
150 pitch(0.424), // pitch angle in degrees (Theta)
152 // Initialize current options velocities to 0.0
153 uBody(0.0), vBody(0.0), wBody(0.0), vkcas(0.0), mach(0.0),
160 control_mode(FG_JOYSTICK),
161 auto_coordination(FG_AUTO_COORD_NOT_SPECIFIED),
169 // Flight Model options
170 flight_model( FGInterface::FG_LARCSIM ),
172 model_hz( NEW_DEFAULT_MODEL_HZ ),
177 fog(FG_FOG_NICEST), // nicest
179 clouds_asl(5000*FEET_TO_METER),
189 view_mode(FG_VIEW_PILOT),
190 default_view_offset(0),
196 units(FG_UNITS_FEET),
204 // set initial values/defaults
205 time_offset_type = FG_TIME_SYS_OFFSET;
206 char* envp = ::getenv( "FG_ROOT" );
208 if ( envp != NULL ) {
209 // fg_root could be anywhere, so default to environmental
210 // variable $FG_ROOT if it is set.
213 // Otherwise, default to a random compiled-in location if
214 // $FG_ROOT is not set. This can still be overridden from the
215 // command line or a config file.
218 fg_root = "\\FlightGear";
219 #elif defined( macintosh )
226 // set a possibly independent location for scenery data
227 envp = ::getenv( "FG_SCENERY" );
229 if ( envp != NULL ) {
230 // fg_root could be anywhere, so default to environmental
231 // variable $FG_ROOT if it is set.
234 // Otherwise, default to Scenery being in $FG_ROOT/Scenery
238 airport_id = "KPAO"; // default airport id
239 net_id = "Johnney"; // default pilot's name
241 // initialize port config string list
242 channel_options_list.clear();
246 FGOptions::toggle_panel() {
248 bool freeze = globals->get_freeze();
251 globals->set_freeze(true);
254 panel_status = false;
255 if ( current_panel != NULL )
256 current_panel->setVisibility(false);
259 if ( current_panel != NULL )
260 current_panel->setVisibility(true);
263 // new rule .. "fov" shouldn't get messed with like this.
264 /* if ( panel_status ) {
267 fov *= (1.0 / 0.4232);
270 fgReshape( xsize, ysize);
273 globals->set_freeze( false );
277 FGOptions::parse_time(const string& time_in) {
278 char *time_str, num[256];
279 double hours, minutes, seconds;
284 time_str = (char *)time_in.c_str();
286 // printf("parse_time(): %s\n", time_str);
289 if ( strlen(time_str) ) {
290 if ( time_str[0] == '+' ) {
293 } else if ( time_str[0] == '-' ) {
298 // printf("sign = %d\n", sign);
301 if ( strlen(time_str) ) {
303 while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
304 num[i] = time_str[0];
308 if ( time_str[0] == ':' ) {
313 // printf("hours = %.2lf\n", hours);
319 if ( strlen(time_str) ) {
321 while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
322 num[i] = time_str[0];
326 if ( time_str[0] == ':' ) {
331 // printf("minutes = %.2lf\n", minutes);
333 result += minutes / 60.0;
337 if ( strlen(time_str) ) {
339 while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
340 num[i] = time_str[0];
346 // printf("seconds = %.2lf\n", seconds);
348 result += seconds / 3600.0;
351 return(sign * result);
355 long int FGOptions::parse_date( const string& date)
358 char * date_str, num[256];
360 // initialize to zero
367 gmt.tm_isdst = 0; // ignore daylight savings time for the moment
368 date_str = (char *)date.c_str();
370 if ( strlen(date_str) ) {
372 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
373 num[i] = date_str[0];
377 if ( date_str[0] == ':' ) {
381 gmt.tm_year = atoi(num) - 1900;
384 if ( strlen(date_str) ) {
386 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
387 num[i] = date_str[0];
391 if ( date_str[0] == ':' ) {
395 gmt.tm_mon = atoi(num) -1;
398 if ( strlen(date_str) ) {
400 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
401 num[i] = date_str[0];
405 if ( date_str[0] == ':' ) {
409 gmt.tm_mday = atoi(num);
412 if ( strlen(date_str) ) {
414 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
415 num[i] = date_str[0];
419 if ( date_str[0] == ':' ) {
423 gmt.tm_hour = atoi(num);
426 if ( strlen(date_str) ) {
428 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
429 num[i] = date_str[0];
433 if ( date_str[0] == ':' ) {
437 gmt.tm_min = atoi(num);
440 if ( strlen(date_str) ) {
442 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
443 num[i] = date_str[0];
447 if ( date_str[0] == ':' ) {
451 gmt.tm_sec = atoi(num);
453 time_t theTime = sgTimeGetGMT( gmt.tm_year, gmt.tm_mon, gmt.tm_mday,
454 gmt.tm_hour, gmt.tm_min, gmt.tm_sec );
455 //printf ("Date is %s\n", ctime(&theTime));
456 //printf ("in seconds that is %d\n", theTime);
462 // parse degree in the form of [+/-]hhh:mm:ss
463 void FGOptions::parse_control( const string& mode ) {
464 if ( mode == "joystick" ) {
465 control_mode = FG_JOYSTICK;
466 } else if ( mode == "mouse" ) {
467 control_mode = FG_MOUSE;
469 control_mode = FG_KEYBOARD;
474 /// parse degree in the form of [+/-]hhh:mm:ss
476 FGOptions::parse_degree( const string& degree_str) {
477 double result = parse_time( degree_str );
479 // printf("Degree = %.4f\n", result);
485 // parse time offset command line option
487 FGOptions::parse_time_offset( const string& time_str) {
490 // printf("time offset = %s\n", time_str);
493 result = (int)rint(parse_time(time_str) * 3600.0);
495 result = (int)(parse_time(time_str) * 3600.0);
498 // printf("parse_time_offset(): %d\n", result);
504 // Parse --tile-diameter=n type option
507 FGOptions::parse_tile_radius( const string& arg ) {
508 int radius = atoi( arg );
510 if ( radius < FG_RADIUS_MIN ) { radius = FG_RADIUS_MIN; }
511 if ( radius > FG_RADIUS_MAX ) { radius = FG_RADIUS_MAX; }
513 // printf("parse_tile_radius(): radius = %d\n", radius);
519 // Parse --fdm=abcdefg type option
521 FGOptions::parse_fdm( const string& fm ) {
522 // cout << "fdm = " << fm << endl;
525 return FGInterface::FG_ADA;
526 } else if ( fm == "balloon" ) {
527 return FGInterface::FG_BALLOONSIM;
528 } else if ( fm == "external" ) {
529 return FGInterface::FG_EXTERNAL;
530 } else if ( fm == "jsb" ) {
531 return FGInterface::FG_JSBSIM;
532 } else if ( (fm == "larcsim") || (fm == "LaRCsim") ) {
533 return FGInterface::FG_LARCSIM;
534 } else if ( fm == "magic" ) {
535 return FGInterface::FG_MAGICCARPET;
537 FG_LOG( FG_GENERAL, FG_ALERT, "Unknown fdm = " << fm );
541 // we'll never get here, but it makes the compiler happy.
546 // Parse --fov=x.xx type option
548 FGOptions::parse_fov( const string& arg ) {
549 double fov = atof(arg);
551 if ( fov < FG_FOV_MIN ) { fov = FG_FOV_MIN; }
552 if ( fov > FG_FOV_MAX ) { fov = FG_FOV_MAX; }
554 // printf("parse_fov(): result = %.4f\n", fov);
560 // Parse I/O channel option
562 // Format is "--protocol=medium,direction,hz,medium_options,..."
564 // protocol = { native, nmea, garmin, fgfs, rul, pve, etc. }
565 // medium = { serial, socket, file, etc. }
566 // direction = { in, out, bi }
567 // hz = number of times to process channel per second (floating
568 // point values are ok.
570 // Serial example "--nmea=serial,dir,hz,device,baud" where
572 // device = OS device name of serial line to be open()'ed
573 // baud = {300, 1200, 2400, ..., 230400}
575 // Socket exacmple "--native=socket,dir,hz,machine,port,style" where
577 // machine = machine name or ip address if client (leave empty if server)
578 // port = port, leave empty to let system choose
579 // style = tcp or udp
581 // File example "--garmin=file,dir,hz,filename" where
583 // filename = file system file name
586 FGOptions::parse_channel( const string& type, const string& channel_str ) {
587 // cout << "Channel string = " << channel_str << endl;
589 channel_options_list.push_back( type + "," + channel_str );
595 // Parse --wp=ID[,alt]
596 bool FGOptions::parse_wp( const string& arg ) {
600 int pos = arg.find( "@" );
601 if ( pos != string::npos ) {
602 id = arg.substr( 0, pos );
603 alt_str = arg.substr( pos + 1 );
604 // cout << "id str = " << id << " alt str = " << alt_str << endl;
605 alt = atof( alt_str.c_str() );
606 if ( units == FG_UNITS_FEET ) {
607 alt *= FEET_TO_METER;
614 if ( fgFindAirportID( id, &a ) ) {
615 SGWayPoint wp( a.longitude, a.latitude, alt, SGWayPoint::WGS84, id );
616 globals->get_route()->add_waypoint( wp );
625 // Parse a single option
626 int FGOptions::parse_option( const string& arg ) {
628 if ( (arg == "--help") || (arg == "-h") ) {
629 // help/usage request
630 return(FG_OPTIONS_HELP);
631 } else if ( arg == "--disable-game-mode") {
633 } else if ( arg == "--enable-game-mode" ) {
635 } else if ( arg == "--disable-splash-screen" ) {
636 splash_screen = false;
637 } else if ( arg == "--enable-splash-screen" ) {
638 splash_screen = true;
639 } else if ( arg == "--disable-intro-music" ) {
641 } else if ( arg == "--enable-intro-music" ) {
643 } else if ( arg == "--disable-mouse-pointer" ) {
645 } else if ( arg == "--enable-mouse-pointer" ) {
647 } else if ( arg == "--disable-freeze" ) {
648 globals->set_freeze( false );
649 } else if ( arg == "--enable-freeze" ) {
650 globals->set_freeze( true );
651 } else if ( arg == "--disable-anti-alias-hud" ) {
652 anti_alias_hud = false;
653 } else if ( arg == "--enable-anti-alias-hud" ) {
654 anti_alias_hud = true;
655 } else if ( arg.find( "--control=") != string::npos ) {
656 parse_control( arg.substr(10) );
657 } else if ( arg == "--disable-auto-coordination" ) {
658 auto_coordination = FG_AUTO_COORD_DISABLED;
659 } else if ( arg == "--enable-auto-coordination" ) {
660 auto_coordination = FG_AUTO_COORD_ENABLED;
661 } else if ( arg == "--disable-hud" ) {
663 } else if ( arg == "--enable-hud" ) {
665 } else if ( arg == "--disable-panel" ) {
666 panel_status = false;
667 if ( current_panel != NULL )
668 current_panel->setVisibility(false);
669 } else if ( arg == "--enable-panel" ) {
671 if ( current_panel != NULL )
672 current_panel->setVisibility(true);
673 // fov *= 0.4232; /* NO!!! */
674 } else if ( arg == "--disable-sound" ) {
676 } else if ( arg == "--enable-sound" ) {
678 } else if ( arg.find( "--airport-id=") != string::npos ) {
679 airport_id = arg.substr( 13 );
680 current_properties.setStringValue("/position/airport-id", airport_id);
681 } else if ( arg.find( "--lon=" ) != string::npos ) {
682 lon = parse_degree( arg.substr(6) );
684 current_properties.setDoubleValue("/position/longitude", lon);
685 current_properties.setStringValue("/position/airport-id", airport_id);
686 } else if ( arg.find( "--lat=" ) != string::npos ) {
687 lat = parse_degree( arg.substr(6) );
689 current_properties.setDoubleValue("/position/latitude", lat);
690 current_properties.setStringValue("/position/airport-id", airport_id);
691 } else if ( arg.find( "--altitude=" ) != string::npos ) {
692 if ( units == FG_UNITS_FEET ) {
693 altitude = atof( arg.substr(11) ) * FEET_TO_METER;
695 altitude = atof( arg.substr(11) );
697 current_properties.setDoubleValue("/position/altitude", altitude);
698 } else if ( arg.find( "--uBody=" ) != string::npos ) {
700 if ( units == FG_UNITS_FEET ) {
701 uBody = atof( arg.substr(8) );
703 uBody = atof( arg.substr(8) ) * FEET_TO_METER;
705 current_properties.setDoubleValue("/velocities/speed-north", uBody);
706 } else if ( arg.find( "--vBody=" ) != string::npos ) {
708 if ( units == FG_UNITS_FEET ) {
709 vBody = atof( arg.substr(8) );
711 vBody = atof( arg.substr(8) ) * FEET_TO_METER;
713 current_properties.setDoubleValue("/velocities/speed-east", vBody);
714 } else if ( arg.find( "--wBody=" ) != string::npos ) {
716 if ( units == FG_UNITS_FEET ) {
717 wBody = atof( arg.substr(8) );
719 wBody = atof( arg.substr(8) ) * FEET_TO_METER;
721 current_properties.setDoubleValue("/velocities/speed-down", wBody);
722 } else if ( arg.find( "--vc=" ) != string::npos) {
724 vkcas=atof( arg.substr(5) );
725 cout << "Got vc: " << vkcas << endl;
726 } else if ( arg.find( "--mach=" ) != string::npos) {
728 mach=atof( arg.substr(7) );
729 } else if ( arg.find( "--heading=" ) != string::npos ) {
730 heading = atof( arg.substr(10) );
731 current_properties.setDoubleValue("/orientation/heading", heading);
732 } else if ( arg.find( "--roll=" ) != string::npos ) {
733 roll = atof( arg.substr(7) );
734 current_properties.setDoubleValue("/orientation/roll", roll);
735 } else if ( arg.find( "--pitch=" ) != string::npos ) {
736 pitch = atof( arg.substr(8) );
737 current_properties.setDoubleValue("/orientation/pitch", pitch);
738 } else if ( arg.find( "--fg-root=" ) != string::npos ) {
739 fg_root = arg.substr( 10 );
740 } else if ( arg.find( "--fg-scenery=" ) != string::npos ) {
741 fg_scenery = arg.substr( 13 );
742 } else if ( arg.find( "--fdm=" ) != string::npos ) {
743 flight_model = parse_fdm( arg.substr(6) );
744 current_properties.setIntValue("/sim/flight-model", flight_model);
745 if((flight_model == FGInterface::FG_JSBSIM) && (get_trim_mode() == 0)) {
750 } else if ( arg.find( "--aircraft=" ) != string::npos ) {
751 aircraft = arg.substr(11);
752 current_properties.setStringValue("/sim/aircraft", aircraft);
753 } else if ( arg.find( "--aircraft-dir=" ) != string::npos ) {
754 aircraft_dir = arg.substr(15); // (UIUC)
755 } else if ( arg.find( "--model-hz=" ) != string::npos ) {
756 model_hz = atoi( arg.substr(11) );
757 } else if ( arg.find( "--speed=" ) != string::npos ) {
758 speed_up = atoi( arg.substr(8) );
759 } else if ( arg.find( "--notrim") != string::npos) {
761 } else if ( arg == "--fog-disable" ) {
762 fog = FG_FOG_DISABLED;
763 } else if ( arg == "--fog-fastest" ) {
764 fog = FG_FOG_FASTEST;
765 } else if ( arg == "--fog-nicest" ) {
767 } else if ( arg == "--disable-clouds" ) {
769 } else if ( arg == "--enable-clouds" ) {
771 } else if ( arg.find( "--clouds-asl=" ) != string::npos ) {
772 if ( units == FG_UNITS_FEET ) {
773 clouds_asl = atof( arg.substr(13) ) * FEET_TO_METER;
775 clouds_asl = atof( arg.substr(13) );
777 } else if ( arg.find( "--fov=" ) != string::npos ) {
778 fov = parse_fov( arg.substr(6) );
779 } else if ( arg == "--disable-fullscreen" ) {
781 } else if ( arg== "--enable-fullscreen") {
783 } else if ( arg == "--shading-flat") {
785 } else if ( arg == "--shading-smooth") {
787 } else if ( arg == "--disable-skyblend") {
789 } else if ( arg== "--enable-skyblend" ) {
791 } else if ( arg == "--disable-textures" ) {
793 } else if ( arg == "--enable-textures" ) {
795 } else if ( arg == "--disable-wireframe" ) {
797 } else if ( arg == "--enable-wireframe" ) {
799 } else if ( arg.find( "--geometry=" ) != string::npos ) {
800 bool geometry_ok = true;
801 string geometry = arg.substr( 11 );
802 string::size_type i = geometry.find('x');
804 if (i != string::npos) {
805 xsize = atoi(geometry.substr(0, i));
806 ysize = atoi(geometry.substr(i+1));
807 // cout << "Geometry is " << xsize << 'x' << ysize << '\n';
812 if ( xsize <= 0 || ysize <= 0 ) {
818 if ( !geometry_ok ) {
819 FG_LOG( FG_GENERAL, FG_ALERT, "Unknown geometry: " << geometry );
820 FG_LOG( FG_GENERAL, FG_ALERT,
821 "Setting geometry to " << xsize << 'x' << ysize << '\n');
823 } else if ( arg.find( "--bpp=" ) != string::npos ) {
824 string bits_per_pix = arg.substr( 6 );
825 if ( bits_per_pix == "16" ) {
827 } else if ( bits_per_pix == "24" ) {
829 } else if ( bits_per_pix == "32" ) {
832 } else if ( arg == "--units-feet" ) {
833 units = FG_UNITS_FEET;
834 } else if ( arg == "--units-meters" ) {
835 units = FG_UNITS_METERS;
836 } else if ( arg.find( "--tile-radius=" ) != string::npos ) {
837 tile_radius = parse_tile_radius( arg.substr(14) );
838 tile_diameter = tile_radius * 2 + 1;
839 } else if ( arg.find( "--time-offset" ) != string::npos ) {
840 time_offset = parse_time_offset( (arg.substr(14)) );
841 //time_offset_type = FG_TIME_SYS_OFFSET;
842 } else if ( arg.find( "--time-match-real") != string::npos ) {
843 //time_offset = parse_time_offset(arg.substr(18));
844 time_offset_type = FG_TIME_SYS_OFFSET;
845 } else if ( arg.find( "--time-match-local") != string::npos ) {
846 //time_offset = parse_time_offset(arg.substr(18));
847 time_offset_type = FG_TIME_LAT_OFFSET;
848 } else if ( arg.find( "--start-date-sys=") != string::npos ) {
849 time_offset = parse_date( (arg.substr(17)) );
850 time_offset_type = FG_TIME_SYS_ABSOLUTE;
851 } else if ( arg.find( "--start-date-lat=") != string::npos ) {
852 time_offset = parse_date( (arg.substr(17)) );
853 time_offset_type = FG_TIME_LAT_ABSOLUTE;
854 } else if ( arg.find( "--start-date-gmt=") != string::npos ) {
855 time_offset = parse_date( (arg.substr(17)) );
856 time_offset_type = FG_TIME_GMT_ABSOLUTE;
858 } else if ( arg == "--hud-tris" ) {
860 } else if ( arg == "--hud-culled" ) {
862 } else if ( arg.find( "--native=" ) != string::npos ) {
863 parse_channel( "native", arg.substr(9) );
864 } else if ( arg.find( "--garmin=" ) != string::npos ) {
865 parse_channel( "garmin", arg.substr(9) );
866 } else if ( arg.find( "--nmea=" ) != string::npos ) {
867 parse_channel( "nmea", arg.substr(7) );
868 } else if ( arg.find( "--props=" ) != string::npos ) {
869 parse_channel( "props", arg.substr(8) );
870 } else if ( arg.find( "--pve=" ) != string::npos ) {
871 parse_channel( "pve", arg.substr(6) );
872 } else if ( arg.find( "--ray=" ) != string::npos ) {
873 parse_channel( "ray", arg.substr(6) );
874 } else if ( arg.find( "--rul=" ) != string::npos ) {
875 parse_channel( "rul", arg.substr(6) );
876 } else if ( arg.find( "--joyclient=" ) != string::npos ) {
877 parse_channel( "joyclient", arg.substr(12) );
878 #ifdef FG_NETWORK_OLK
879 } else if ( arg == "--disable-network-olk" ) {
881 } else if ( arg== "--enable-network-olk") {
883 } else if ( arg == "--net-hud" ) {
885 } else if ( arg.find( "--net-id=") != string::npos ) {
886 net_id = arg.substr( 9 );
888 } else if ( arg.find( "--prop:" ) == 0 ) {
889 string assign = arg.substr(7);
890 int pos = assign.find('=');
891 if (pos == arg.npos || pos == 0) {
892 FG_LOG(FG_GENERAL, FG_ALERT, "Bad property assignment: " << arg);
893 return FG_OPTIONS_ERROR;
895 string name = assign.substr(0, pos);
896 string value = assign.substr(pos + 1);
897 current_properties.setStringValue(name.c_str(), value);
898 FG_LOG(FG_GENERAL, FG_INFO, "Setting default value of property "
899 << name << " to \"" << value << '"');
900 // $$$ begin - added VS Renganathan, 14 Oct 2K
901 // for multi-window outside window imagery
902 } else if ( arg.find( "--view-offset=" ) != string::npos ) {
903 string woffset = arg.substr( 14 );
904 if ( woffset == "LEFT" ) {
905 default_view_offset = M_PI * 0.25;
906 } else if ( woffset == "RIGHT" ) {
907 default_view_offset = M_PI * 1.75;
908 } else if ( woffset == "CENTER" ) {
909 default_view_offset = 0.00;
911 default_view_offset = atof( woffset.c_str() ) * DEG_TO_RAD;
913 // $$$ end - added VS Renganathan, 14 Oct 2K
914 } else if ( arg.find( "--wp=" ) != string::npos ) {
915 parse_wp( arg.substr( 5 ) );
917 FG_LOG( FG_GENERAL, FG_ALERT, "Unknown option '" << arg << "'" );
918 return FG_OPTIONS_ERROR;
921 return FG_OPTIONS_OK;
925 // Scan the command line options for an fg_root definition and set
927 int FGOptions::scan_command_line_for_root( int argc, char **argv ) {
931 FG_LOG(FG_GENERAL, FG_INFO, "Processing command line arguments");
934 FG_LOG( FG_GENERAL, FG_DEBUG, "argv[" << i << "] = " << argv[i] );
936 string arg = argv[i];
937 if ( arg.find( "--fg-root=" ) != string::npos ) {
938 fg_root = arg.substr( 10 );
944 return FG_OPTIONS_OK;
948 // Scan the config file for an fg_root definition and set just that.
949 int FGOptions::scan_config_file_for_root( const string& path ) {
950 fg_gzifstream in( path );
952 return(FG_OPTIONS_ERROR);
954 FG_LOG( FG_GENERAL, FG_INFO, "Processing config file: " << path );
958 while ( ! in.eof() ) {
961 while ( in.get(c) && c != '\0' ) {
966 #ifdef GETLINE_NEEDS_TERMINATOR
967 getline( in, line, '\n' );
968 #elif defined( macintosh )
969 getline( in, line, '\r' );
974 if ( line.find( "--fg-root=" ) != string::npos ) {
975 fg_root = line.substr( 10 );
981 return FG_OPTIONS_OK;
985 // Parse the command line options
986 int FGOptions::parse_command_line( int argc, char **argv ) {
990 FG_LOG(FG_GENERAL, FG_INFO, "Processing command line arguments");
993 FG_LOG( FG_GENERAL, FG_DEBUG, "argv[" << i << "] = " << argv[i] );
995 result = parse_option(argv[i]);
996 if ( (result == FG_OPTIONS_HELP) || (result == FG_OPTIONS_ERROR) ) {
1003 return FG_OPTIONS_OK;
1007 // Parse config file options
1008 int FGOptions::parse_config_file( const string& path ) {
1009 fg_gzifstream in( path );
1010 if ( !in.is_open() )
1011 return(FG_OPTIONS_ERROR);
1013 FG_LOG( FG_GENERAL, FG_INFO, "Processing config file: " << path );
1017 while ( ! in.eof() ) {
1020 while ( in.get(c) && c != '\0' ) {
1025 #ifdef GETLINE_NEEDS_TERMINATOR
1026 getline( in, line, '\n' );
1027 #elif defined( macintosh )
1028 getline( in, line, '\r' );
1030 getline( in, line );
1033 if ( parse_option( line ) == FG_OPTIONS_ERROR ) {
1034 FG_LOG( FG_GENERAL, FG_ALERT,
1035 "Config file parse error: " << path << " '"
1042 return FG_OPTIONS_OK;
1046 // Print usage message
1047 void FGOptions::usage ( void ) {
1048 cout << "Usage: fg [ options ... ]" << endl;
1051 cout << "General Options:" << endl;
1052 cout << "\t--help -h: print usage" << endl;
1053 cout << "\t--fg-root=path: specify the root path for all the data files"
1055 cout << "\t--fg-scenery=path: specify the base path for all the scenery"
1057 << "\t\tdefaults to $FG_ROOT/Scenery" << endl;
1058 cout << "\t--disable-game-mode: disable full-screen game mode" << endl;
1059 cout << "\t--enable-game-mode: enable full-screen game mode" << endl;
1060 cout << "\t--disable-splash-screen: disable splash screen" << endl;
1061 cout << "\t--enable-splash-screen: enable splash screen" << endl;
1062 cout << "\t--disable-intro-music: disable introduction music" << endl;
1063 cout << "\t--enable-intro-music: enable introduction music" << endl;
1064 cout << "\t--disable-mouse-pointer: disable extra mouse pointer" << endl;
1065 cout << "\t--enable-mouse-pointer: enable extra mouse pointer (i.e. for"
1067 cout << "\t\tfull screen voodoo/voodoo-II based cards.)" << endl;
1068 cout << "\t--disable-freeze: start out in an running state" << endl;
1069 cout << "\t--enable-freeze: start out in a frozen state" << endl;
1070 cout << "\t--control=mode: primary control mode "
1071 << "(joystick, keyboard, mouse)" << endl;
1074 cout << "Features:" << endl;
1075 cout << "\t--disable-hud: disable heads up display" << endl;
1076 cout << "\t--enable-hud: enable heads up display" << endl;
1077 cout << "\t--disable-panel: disable instrument panel" << endl;
1078 cout << "\t--enable-panel: enable instrumetn panel" << endl;
1079 cout << "\t--disable-sound: disable sound effects" << endl;
1080 cout << "\t--enable-sound: enable sound effects" << endl;
1081 cout << "\t--disable-anti-alias-hud: disable anti aliased hud" << endl;
1082 cout << "\t--enable-anti-alias-hud: enable anti aliased hud" << endl;
1085 cout << "Flight Model:" << endl;
1086 cout << "\t--fdm=abcd: selects the core flight model code." << endl;
1087 cout << "\t\tcan be one of jsb, larcsim, magic, external, balloon, or ada"
1089 cout << "\t--aircraft=abcd: aircraft model to load" << endl;
1090 cout << "\t--model-hz=n: run the FDM this rate (iterations per second)"
1092 cout << "\t--speed=n: run the FDM this much faster than real time" << endl;
1093 cout << "\t--notrim: Do NOT attempt to trim the model when initializing JSBsim" << endl;
1096 cout <<"Aircraft model directory:" << endl;
1097 cout <<"\t--aircraft-dir=<path> path is relative to the path of the executable" << endl;
1100 cout << "Initial Position and Orientation:" << endl;
1101 cout << "\t--airport-id=ABCD: specify starting postion by airport id"
1103 cout << "\t--lon=degrees: starting longitude in degrees (west = -)"
1105 cout << "\t--lat=degrees: starting latitude in degrees (south = -)"
1107 cout << "\t--altitude=feet: starting altitude in feet" << endl;
1108 cout << "\t\t(unless --units-meters specified" << endl;
1109 cout << "\t--heading=degrees: heading (yaw) angle in degress (Psi)"
1111 cout << "\t--roll=degrees: roll angle in degrees (Phi)" << endl;
1112 cout << "\t--pitch=degrees: pitch angle in degrees (Theta)" << endl;
1113 cout << "\t--uBody=feet per second: velocity along the body X axis"
1115 cout << "\t--vBody=feet per second: velocity along the body Y axis"
1117 cout << "\t--wBody=feet per second: velocity along the body Z axis"
1119 cout << "\t\t(unless --units-meters specified" << endl;
1120 cout << "\t--vc= initial airspeed in knots (--fdm=jsb only)" << endl;
1121 cout << "\t--mach= initial mach number (--fdm=jsb only)" << endl;
1124 cout << "Rendering Options:" << endl;
1125 cout << "\t--fog-disable: disable fog/haze" << endl;
1126 cout << "\t--fog-fastest: enable fastest fog/haze" << endl;
1127 cout << "\t--fog-nicest: enable nicest fog/haze" << endl;
1128 cout << "\t--enable-clouds: enable demo cloud layer" << endl;
1129 cout << "\t--disable-clouds: disable demo cloud layer" << endl;
1130 cout << "\t--clouds-asl=xxx: specify altitude of cloud layer above sea level" << endl;
1131 cout << "\t--fov=xx.x: specify initial field of view angle in degrees"
1133 cout << "\t--disable-fullscreen: disable fullscreen mode" << endl;
1134 cout << "\t--enable-fullscreen: enable fullscreen mode" << endl;
1135 cout << "\t--shading-flat: enable flat shading" << endl;
1136 cout << "\t--shading-smooth: enable smooth shading" << endl;
1137 cout << "\t--disable-skyblend: disable sky blending" << endl;
1138 cout << "\t--enable-skyblend: enable sky blending" << endl;
1139 cout << "\t--disable-textures: disable textures" << endl;
1140 cout << "\t--enable-textures: enable textures" << endl;
1141 cout << "\t--disable-wireframe: disable wireframe drawing mode" << endl;
1142 cout << "\t--enable-wireframe: enable wireframe drawing mode" << endl;
1143 cout << "\t--geometry=WWWxHHH: window geometry: 640x480, 800x600, etc."
1145 cout << "\t--view-offset=xxx: set the default forward view direction"
1147 cout << "\t\tas an offset from straight ahead. Allowable values are"
1149 cout << "\t\tLEFT, RIGHT, CENTER, or a specific number of degrees" << endl;
1152 cout << "Scenery Options:" << endl;
1153 cout << "\t--tile-radius=n: specify tile radius, must be 1 - 4" << endl;
1156 cout << "Hud Options:" << endl;
1157 cout << "\t--units-feet: Hud displays units in feet" << endl;
1158 cout << "\t--units-meters: Hud displays units in meters" << endl;
1159 cout << "\t--hud-tris: Hud displays number of triangles rendered" << endl;
1160 cout << "\t--hud-culled: Hud displays percentage of triangles culled"
1164 cout << "Time Options:" << endl;
1165 cout << "\t--time-offset=[+-]hh:mm:ss: add this time offset" << endl;
1166 cout << "\t--time-match-real: Synchronize real-world and FlightGear" << endl
1167 << "\t\ttime. Can be used in combination with --time-offset." << endl;
1168 cout << "\t--time-match-local:Synchronize local real-world and " << endl
1169 << "\t\tFlightGear time" << endl;
1170 cout << "\t--start-date-sys=yyyy:mm:dd:hh:mm:ss: specify a starting" << endl
1171 << "\t\tdate/time. Uses your system time " << endl;
1172 cout << "\t--start-date-gmt=yyyy:mm:dd:hh:mm:ss: specify a starting" << endl
1173 << "\t\tdate/time. Uses Greenwich Mean Time" << endl;
1174 cout << "\t--start-date-lat=yyyy:mm:dd:hh:mm:ss: specify a starting" << endl
1175 << "\t\tdate/time. Uses Local Aircraft Time" << endl;
1176 #ifdef FG_NETWORK_OLK
1179 cout << "Network Options:" << endl;
1180 cout << "\t--enable-network-olk: enable Multipilot mode" << endl;
1181 cout << "\t--disable-network-olk: disable Multipilot mode (default)" << endl;
1182 cout << "\t--net-hud: Hud displays network info" << endl;
1183 cout << "\t--net-id=name: specify your own callsign" << endl;
1187 cout << "Route/Way Point Options:" << endl;
1188 cout << "\t--wp=ID[@alt]: specify a waypoint for the GC autopilot" << endl;
1189 cout << "\t\tYou can specify multiple waypoints (a route) with multiple"
1191 cout << "\t\tinstances of --wp=" << endl;
1196 FGOptions::~FGOptions( void ) {