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"
62 FG_USING_NAMESPACE(std);
65 extern void fgReshape( int width, int height );
68 atof( const string& str )
72 // -dw- if ::atof is called, then we get an infinite loop
73 return std::atof( str.c_str() );
75 return ::atof( str.c_str() );
80 atoi( const string& str )
83 // -dw- if ::atoi is called, then we get an infinite loop
84 return std::atoi( str.c_str() );
86 return ::atoi( str.c_str() );
91 // Defined the shared options class here
92 fgOPTIONS current_options;
96 fgOPTIONS::fgOPTIONS() :
97 // starting longitude in degrees (west = -)
98 // starting latitude in degrees (south = -)
100 // Default initial position is Globe, AZ (P13)
104 // North of the city of Globe
108 // North of the city of Globe
112 // Near where I used to live in Globe, AZ
116 // 10125 Jewell St. NE
120 // Near KHSP (Hot Springs, VA)
121 // lon(-79.8338964 + 0.01),
122 // lat( 37.9514564 + 0.008),
124 // (SEZ) SEDONA airport
125 // lon(-111.7884614 + 0.01),
126 // lat( 34.8486289 - 0.015),
128 // Jim Brennon's Kingmont Observatory
129 // lon(-121.1131667),
132 // Huaras, Peru (S09d 31.871' W077d 31.498')
136 // Eclipse Watching w73.5 n10 (approx) 18:00 UT
141 // lon(-90.1953055556),
142 // lat( 45.4511388889),
144 // starting altitude in meters (this will be reset to ground level
145 // if it is lower than the terrain
148 // Initial Orientation
149 heading(270.0), // heading (yaw) angle in degress (Psi)
150 roll(0.0), // roll angle in degrees (Phi)
151 pitch(0.424), // pitch angle in degrees (Theta)
153 // Initialize current options velocities to 0.0
154 uBody(0.0), vBody(0.0), wBody(0.0), vkcas(0.0), mach(0.0),
161 control_mode(FG_JOYSTICK),
162 auto_coordination(FG_AUTO_COORD_NOT_SPECIFIED),
170 // Flight Model options
171 flight_model( FGInterface::FG_LARCSIM ),
173 model_hz( NEW_DEFAULT_MODEL_HZ ),
178 fog(FG_FOG_NICEST), // nicest
180 clouds_asl(5000*FEET_TO_METER),
190 view_mode(FG_VIEW_PILOT),
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);
271 fgReshape( current_view.get_winWidth(), current_view.get_winHeight() );
274 globals->set_freeze( false );
278 fgOPTIONS::parse_time(const string& time_in) {
279 char *time_str, num[256];
280 double hours, minutes, seconds;
285 time_str = (char *)time_in.c_str();
287 // printf("parse_time(): %s\n", time_str);
290 if ( strlen(time_str) ) {
291 if ( time_str[0] == '+' ) {
294 } else if ( time_str[0] == '-' ) {
299 // printf("sign = %d\n", sign);
302 if ( strlen(time_str) ) {
304 while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
305 num[i] = time_str[0];
309 if ( time_str[0] == ':' ) {
314 // printf("hours = %.2lf\n", hours);
320 if ( strlen(time_str) ) {
322 while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
323 num[i] = time_str[0];
327 if ( time_str[0] == ':' ) {
332 // printf("minutes = %.2lf\n", minutes);
334 result += minutes / 60.0;
338 if ( strlen(time_str) ) {
340 while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
341 num[i] = time_str[0];
347 // printf("seconds = %.2lf\n", seconds);
349 result += seconds / 3600.0;
352 return(sign * result);
356 long int fgOPTIONS::parse_date( const string& date)
359 char * date_str, num[256];
361 // initialize to zero
368 gmt.tm_isdst = 0; // ignore daylight savings time for the moment
369 date_str = (char *)date.c_str();
371 if ( strlen(date_str) ) {
373 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
374 num[i] = date_str[0];
378 if ( date_str[0] == ':' ) {
382 gmt.tm_year = atoi(num) - 1900;
385 if ( strlen(date_str) ) {
387 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
388 num[i] = date_str[0];
392 if ( date_str[0] == ':' ) {
396 gmt.tm_mon = atoi(num) -1;
399 if ( strlen(date_str) ) {
401 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
402 num[i] = date_str[0];
406 if ( date_str[0] == ':' ) {
410 gmt.tm_mday = atoi(num);
413 if ( strlen(date_str) ) {
415 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
416 num[i] = date_str[0];
420 if ( date_str[0] == ':' ) {
424 gmt.tm_hour = atoi(num);
427 if ( strlen(date_str) ) {
429 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
430 num[i] = date_str[0];
434 if ( date_str[0] == ':' ) {
438 gmt.tm_min = atoi(num);
441 if ( strlen(date_str) ) {
443 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
444 num[i] = date_str[0];
448 if ( date_str[0] == ':' ) {
452 gmt.tm_sec = atoi(num);
454 time_t theTime = sgTimeGetGMT( gmt.tm_year, gmt.tm_mon, gmt.tm_mday,
455 gmt.tm_hour, gmt.tm_min, gmt.tm_sec );
456 //printf ("Date is %s\n", ctime(&theTime));
457 //printf ("in seconds that is %d\n", theTime);
463 // parse degree in the form of [+/-]hhh:mm:ss
464 void fgOPTIONS::parse_control( const string& mode ) {
465 if ( mode == "joystick" ) {
466 control_mode = FG_JOYSTICK;
467 } else if ( mode == "mouse" ) {
468 control_mode = FG_MOUSE;
470 control_mode = FG_KEYBOARD;
475 /// parse degree in the form of [+/-]hhh:mm:ss
477 fgOPTIONS::parse_degree( const string& degree_str) {
478 double result = parse_time( degree_str );
480 // printf("Degree = %.4f\n", result);
486 // parse time offset command line option
488 fgOPTIONS::parse_time_offset( const string& time_str) {
491 // printf("time offset = %s\n", time_str);
494 result = (int)rint(parse_time(time_str) * 3600.0);
496 result = (int)(parse_time(time_str) * 3600.0);
499 // printf("parse_time_offset(): %d\n", result);
505 // Parse --tile-diameter=n type option
508 fgOPTIONS::parse_tile_radius( const string& arg ) {
509 int radius = atoi( arg );
511 if ( radius < FG_RADIUS_MIN ) { radius = FG_RADIUS_MIN; }
512 if ( radius > FG_RADIUS_MAX ) { radius = FG_RADIUS_MAX; }
514 // printf("parse_tile_radius(): radius = %d\n", radius);
520 // Parse --fdm=abcdefg type option
522 fgOPTIONS::parse_fdm( const string& fm ) {
523 // cout << "fdm = " << fm << endl;
525 if ( fm == "balloon" ) {
526 return FGInterface::FG_BALLOONSIM;
527 } else if ( fm == "external" ) {
528 return FGInterface::FG_EXTERNAL;
529 } else if ( fm == "jsb" ) {
530 return FGInterface::FG_JSBSIM;
531 } else if ( (fm == "larcsim") || (fm == "LaRCsim") ) {
532 return FGInterface::FG_LARCSIM;
533 } else if ( fm == "magic" ) {
534 return FGInterface::FG_MAGICCARPET;
536 FG_LOG( FG_GENERAL, FG_ALERT, "Unknown fdm = " << fm );
540 // we'll never get here, but it makes the compiler happy.
545 // Parse --fov=x.xx type option
547 fgOPTIONS::parse_fov( const string& arg ) {
548 double fov = atof(arg);
550 if ( fov < FG_FOV_MIN ) { fov = FG_FOV_MIN; }
551 if ( fov > FG_FOV_MAX ) { fov = FG_FOV_MAX; }
553 // printf("parse_fov(): result = %.4f\n", fov);
559 // Parse I/O channel option
561 // Format is "--protocol=medium,direction,hz,medium_options,..."
563 // protocol = { native, nmea, garmin, fgfs, rul, pve, etc. }
564 // medium = { serial, socket, file, etc. }
565 // direction = { in, out, bi }
566 // hz = number of times to process channel per second (floating
567 // point values are ok.
569 // Serial example "--nmea=serial,dir,hz,device,baud" where
571 // device = OS device name of serial line to be open()'ed
572 // baud = {300, 1200, 2400, ..., 230400}
574 // Socket exacmple "--native=socket,dir,hz,machine,port,style" where
576 // machine = machine name or ip address if client (leave empty if server)
577 // port = port, leave empty to let system choose
578 // style = tcp or udp
580 // File example "--garmin=file,dir,hz,filename" where
582 // filename = file system file name
585 fgOPTIONS::parse_channel( const string& type, const string& channel_str ) {
586 // cout << "Channel string = " << channel_str << endl;
588 channel_options_list.push_back( type + "," + channel_str );
594 // Parse --wp=ID[,alt]
595 bool fgOPTIONS::parse_wp( const string& arg ) {
599 int pos = arg.find( "@" );
600 if ( pos != string::npos ) {
601 id = arg.substr( 0, pos );
602 alt_str = arg.substr( pos + 1 );
603 // cout << "id str = " << id << " alt str = " << alt_str << endl;
604 alt = atof( alt_str.c_str() );
605 if ( units == FG_UNITS_FEET ) {
606 alt *= FEET_TO_METER;
613 if ( fgFindAirportID( id, &a ) ) {
614 SGWayPoint wp( a.longitude, a.latitude, alt, SGWayPoint::WGS84, id );
615 globals->get_route()->add_waypoint( wp );
624 // Parse a single option
625 int fgOPTIONS::parse_option( const string& arg ) {
627 if ( (arg == "--help") || (arg == "-h") ) {
628 // help/usage request
629 return(FG_OPTIONS_HELP);
630 } else if ( arg == "--disable-game-mode") {
632 } else if ( arg == "--enable-game-mode" ) {
634 } else if ( arg == "--disable-splash-screen" ) {
635 splash_screen = false;
636 } else if ( arg == "--enable-splash-screen" ) {
637 splash_screen = true;
638 } else if ( arg == "--disable-intro-music" ) {
640 } else if ( arg == "--enable-intro-music" ) {
642 } else if ( arg == "--disable-mouse-pointer" ) {
644 } else if ( arg == "--enable-mouse-pointer" ) {
646 } else if ( arg == "--disable-freeze" ) {
647 globals->set_freeze( false );
648 } else if ( arg == "--enable-freeze" ) {
649 globals->set_freeze( true );
650 } else if ( arg == "--disable-anti-alias-hud" ) {
651 anti_alias_hud = false;
652 } else if ( arg == "--enable-anti-alias-hud" ) {
653 anti_alias_hud = true;
654 } else if ( arg.find( "--control=") != string::npos ) {
655 parse_control( arg.substr(10) );
656 } else if ( arg == "--disable-auto-coordination" ) {
657 auto_coordination = FG_AUTO_COORD_DISABLED;
658 } else if ( arg == "--enable-auto-coordination" ) {
659 auto_coordination = FG_AUTO_COORD_ENABLED;
660 } else if ( arg == "--disable-hud" ) {
662 } else if ( arg == "--enable-hud" ) {
664 } else if ( arg == "--disable-panel" ) {
665 panel_status = false;
666 if ( current_panel != NULL )
667 current_panel->setVisibility(false);
668 } else if ( arg == "--enable-panel" ) {
670 if ( current_panel != NULL )
671 current_panel->setVisibility(true);
672 // fov *= 0.4232; /* NO!!! */
673 } else if ( arg == "--disable-sound" ) {
675 } else if ( arg == "--enable-sound" ) {
677 } else if ( arg.find( "--airport-id=") != string::npos ) {
678 airport_id = arg.substr( 13 );
679 current_properties.setStringValue("/position/airport-id", airport_id);
680 } else if ( arg.find( "--lon=" ) != string::npos ) {
681 lon = parse_degree( arg.substr(6) );
683 current_properties.setDoubleValue("/position/longitude", lon);
684 current_properties.setStringValue("/position/airport-id", airport_id);
685 } else if ( arg.find( "--lat=" ) != string::npos ) {
686 lat = parse_degree( arg.substr(6) );
688 current_properties.setDoubleValue("/position/latitude", lat);
689 current_properties.setStringValue("/position/airport-id", airport_id);
690 } else if ( arg.find( "--altitude=" ) != string::npos ) {
691 if ( units == FG_UNITS_FEET ) {
692 altitude = atof( arg.substr(11) ) * FEET_TO_METER;
694 altitude = atof( arg.substr(11) );
696 current_properties.setDoubleValue("/position/altitude", altitude);
697 } else if ( arg.find( "--uBody=" ) != string::npos ) {
699 if ( units == FG_UNITS_FEET ) {
700 uBody = atof( arg.substr(8) );
702 uBody = atof( arg.substr(8) ) * FEET_TO_METER;
704 current_properties.setDoubleValue("/velocities/speed-north", uBody);
705 } else if ( arg.find( "--vBody=" ) != string::npos ) {
707 if ( units == FG_UNITS_FEET ) {
708 vBody = atof( arg.substr(8) );
710 vBody = atof( arg.substr(8) ) * FEET_TO_METER;
712 current_properties.setDoubleValue("/velocities/speed-east", vBody);
713 } else if ( arg.find( "--wBody=" ) != string::npos ) {
715 if ( units == FG_UNITS_FEET ) {
716 wBody = atof( arg.substr(8) );
718 wBody = atof( arg.substr(8) ) * FEET_TO_METER;
720 current_properties.setDoubleValue("/velocities/speed-down", wBody);
721 } else if ( arg.find( "--vc=" ) != string::npos) {
723 vkcas=atof( arg.substr(5) );
724 cout << "Got vc: " << vkcas << endl;
725 } else if ( arg.find( "--mach=" ) != string::npos) {
727 mach=atof( arg.substr(7) );
728 } else if ( arg.find( "--heading=" ) != string::npos ) {
729 heading = atof( arg.substr(10) );
730 current_properties.setDoubleValue("/orientation/heading", heading);
731 } else if ( arg.find( "--roll=" ) != string::npos ) {
732 roll = atof( arg.substr(7) );
733 current_properties.setDoubleValue("/orientation/roll", roll);
734 } else if ( arg.find( "--pitch=" ) != string::npos ) {
735 pitch = atof( arg.substr(8) );
736 current_properties.setDoubleValue("/orientation/pitch", pitch);
737 } else if ( arg.find( "--fg-root=" ) != string::npos ) {
738 fg_root = arg.substr( 10 );
739 } else if ( arg.find( "--fg-scenery=" ) != string::npos ) {
740 fg_scenery = arg.substr( 13 );
741 } else if ( arg.find( "--fdm=" ) != string::npos ) {
742 flight_model = parse_fdm( arg.substr(6) );
743 current_properties.setIntValue("/sim/flight-model", flight_model);
744 if((flight_model == FGInterface::FG_JSBSIM) && (get_trim_mode() == 0)) {
749 } else if ( arg.find( "--aircraft=" ) != string::npos ) {
750 aircraft = arg.substr(11);
751 current_properties.setStringValue("/sim/aircraft", aircraft);
752 } else if ( arg.find( "--aircraft-dir=" ) != string::npos ) {
753 aircraft_dir = arg.substr(15); // (UIUC)
754 } else if ( arg.find( "--model-hz=" ) != string::npos ) {
755 model_hz = atoi( arg.substr(11) );
756 } else if ( arg.find( "--speed=" ) != string::npos ) {
757 speed_up = atoi( arg.substr(8) );
758 } else if ( arg.find( "--notrim") != string::npos) {
760 } else if ( arg == "--fog-disable" ) {
761 fog = FG_FOG_DISABLED;
762 } else if ( arg == "--fog-fastest" ) {
763 fog = FG_FOG_FASTEST;
764 } else if ( arg == "--fog-nicest" ) {
766 } else if ( arg == "--disable-clouds" ) {
768 } else if ( arg == "--enable-clouds" ) {
770 } else if ( arg.find( "--clouds-asl=" ) != string::npos ) {
771 if ( units == FG_UNITS_FEET ) {
772 clouds_asl = atof( arg.substr(13) ) * FEET_TO_METER;
774 clouds_asl = atof( arg.substr(13) );
776 } else if ( arg.find( "--fov=" ) != string::npos ) {
777 fov = parse_fov( arg.substr(6) );
778 } else if ( arg == "--disable-fullscreen" ) {
780 } else if ( arg== "--enable-fullscreen") {
782 } else if ( arg == "--shading-flat") {
784 } else if ( arg == "--shading-smooth") {
786 } else if ( arg == "--disable-skyblend") {
788 } else if ( arg== "--enable-skyblend" ) {
790 } else if ( arg == "--disable-textures" ) {
792 } else if ( arg == "--enable-textures" ) {
794 } else if ( arg == "--disable-wireframe" ) {
796 } else if ( arg == "--enable-wireframe" ) {
798 } else if ( arg.find( "--geometry=" ) != string::npos ) {
799 bool geometry_ok = true;
800 string geometry = arg.substr( 11 );
801 string::size_type i = geometry.find('x');
803 if (i != string::npos) {
804 xsize = atoi(geometry.substr(0, i));
805 ysize = atoi(geometry.substr(i+1));
806 // cout << "Geometry is " << xsize << 'x' << ysize << '\n';
811 if ( xsize <= 0 || ysize <= 0 ) {
817 if ( !geometry_ok ) {
818 FG_LOG( FG_GENERAL, FG_ALERT, "Unknown geometry: " << geometry );
819 FG_LOG( FG_GENERAL, FG_ALERT,
820 "Setting geometry to " << xsize << 'x' << ysize << '\n');
822 } else if ( arg.find( "--bpp=" ) != string::npos ) {
823 string bits_per_pix = arg.substr( 6 );
824 if ( bits_per_pix == "16" ) {
826 } else if ( bits_per_pix == "24" ) {
828 } else if ( bits_per_pix == "32" ) {
831 } else if ( arg == "--units-feet" ) {
832 units = FG_UNITS_FEET;
833 } else if ( arg == "--units-meters" ) {
834 units = FG_UNITS_METERS;
835 } else if ( arg.find( "--tile-radius=" ) != string::npos ) {
836 tile_radius = parse_tile_radius( arg.substr(14) );
837 tile_diameter = tile_radius * 2 + 1;
838 } else if ( arg.find( "--time-offset" ) != string::npos ) {
839 time_offset = parse_time_offset( (arg.substr(14)) );
840 //time_offset_type = FG_TIME_SYS_OFFSET;
841 } else if ( arg.find( "--time-match-real") != string::npos ) {
842 //time_offset = parse_time_offset(arg.substr(18));
843 time_offset_type = FG_TIME_SYS_OFFSET;
844 } else if ( arg.find( "--time-match-local") != string::npos ) {
845 //time_offset = parse_time_offset(arg.substr(18));
846 time_offset_type = FG_TIME_LAT_OFFSET;
847 } else if ( arg.find( "--start-date-sys=") != string::npos ) {
848 time_offset = parse_date( (arg.substr(17)) );
849 time_offset_type = FG_TIME_SYS_ABSOLUTE;
850 } else if ( arg.find( "--start-date-lat=") != string::npos ) {
851 time_offset = parse_date( (arg.substr(17)) );
852 time_offset_type = FG_TIME_LAT_ABSOLUTE;
853 } else if ( arg.find( "--start-date-gmt=") != string::npos ) {
854 time_offset = parse_date( (arg.substr(17)) );
855 time_offset_type = FG_TIME_GMT_ABSOLUTE;
857 } else if ( arg == "--hud-tris" ) {
859 } else if ( arg == "--hud-culled" ) {
861 } else if ( arg.find( "--native=" ) != string::npos ) {
862 parse_channel( "native", arg.substr(9) );
863 } else if ( arg.find( "--garmin=" ) != string::npos ) {
864 parse_channel( "garmin", arg.substr(9) );
865 } else if ( arg.find( "--nmea=" ) != string::npos ) {
866 parse_channel( "nmea", arg.substr(7) );
867 } else if ( arg.find( "--props=" ) != string::npos ) {
868 parse_channel( "props", arg.substr(8) );
869 } else if ( arg.find( "--pve=" ) != string::npos ) {
870 parse_channel( "pve", arg.substr(6) );
871 } else if ( arg.find( "--ray=" ) != string::npos ) {
872 parse_channel( "ray", arg.substr(6) );
873 } else if ( arg.find( "--rul=" ) != string::npos ) {
874 parse_channel( "rul", arg.substr(6) );
875 } else if ( arg.find( "--joyclient=" ) != string::npos ) {
876 parse_channel( "joyclient", arg.substr(12) );
877 #ifdef FG_NETWORK_OLK
878 } else if ( arg == "--disable-network-olk" ) {
880 } else if ( arg== "--enable-network-olk") {
882 } else if ( arg == "--net-hud" ) {
884 } else if ( arg.find( "--net-id=") != string::npos ) {
885 net_id = arg.substr( 9 );
887 } else if ( arg.find( "--prop:" ) == 0 ) {
888 string assign = arg.substr(7);
889 int pos = assign.find('=');
890 if (pos == arg.npos || pos == 0) {
891 FG_LOG(FG_GENERAL, FG_ALERT, "Bad property assignment: " << arg);
892 return FG_OPTIONS_ERROR;
894 string name = assign.substr(0, pos);
895 string value = assign.substr(pos + 1);
896 current_properties.setStringValue(name.c_str(), value);
897 FG_LOG(FG_GENERAL, FG_INFO, "Setting default value of property "
898 << name << " to \"" << value << '"');
899 } else if ( arg.find( "--wp=" ) != string::npos ) {
900 parse_wp( arg.substr( 5 ) );
902 FG_LOG( FG_GENERAL, FG_ALERT, "Unknown option '" << arg << "'" );
903 return FG_OPTIONS_ERROR;
906 return FG_OPTIONS_OK;
910 // Scan the command line options for an fg_root definition and set
912 int fgOPTIONS::scan_command_line_for_root( int argc, char **argv ) {
916 FG_LOG(FG_GENERAL, FG_INFO, "Processing command line arguments");
919 FG_LOG( FG_GENERAL, FG_DEBUG, "argv[" << i << "] = " << argv[i] );
921 string arg = argv[i];
922 if ( arg.find( "--fg-root=" ) != string::npos ) {
923 fg_root = arg.substr( 10 );
929 return FG_OPTIONS_OK;
933 // Scan the config file for an fg_root definition and set just that.
934 int fgOPTIONS::scan_config_file_for_root( const string& path ) {
935 fg_gzifstream in( path );
937 return(FG_OPTIONS_ERROR);
939 FG_LOG( FG_GENERAL, FG_INFO, "Processing config file: " << path );
943 while ( ! in.eof() ) {
946 while ( in.get(c) && c != '\0' ) {
951 #ifdef GETLINE_NEEDS_TERMINATOR
952 getline( in, line, '\n' );
953 #elif defined( macintosh )
954 getline( in, line, '\r' );
959 if ( line.find( "--fg-root=" ) != string::npos ) {
960 fg_root = line.substr( 10 );
966 return FG_OPTIONS_OK;
970 // Parse the command line options
971 int fgOPTIONS::parse_command_line( int argc, char **argv ) {
975 FG_LOG(FG_GENERAL, FG_INFO, "Processing command line arguments");
978 FG_LOG( FG_GENERAL, FG_DEBUG, "argv[" << i << "] = " << argv[i] );
980 result = parse_option(argv[i]);
981 if ( (result == FG_OPTIONS_HELP) || (result == FG_OPTIONS_ERROR) ) {
988 return FG_OPTIONS_OK;
992 // Parse config file options
993 int fgOPTIONS::parse_config_file( const string& path ) {
994 fg_gzifstream in( path );
996 return(FG_OPTIONS_ERROR);
998 FG_LOG( FG_GENERAL, FG_INFO, "Processing config file: " << path );
1002 while ( ! in.eof() ) {
1005 while ( in.get(c) && c != '\0' ) {
1010 #ifdef GETLINE_NEEDS_TERMINATOR
1011 getline( in, line, '\n' );
1012 #elif defined( macintosh )
1013 getline( in, line, '\r' );
1015 getline( in, line );
1018 if ( parse_option( line ) == FG_OPTIONS_ERROR ) {
1019 FG_LOG( FG_GENERAL, FG_ALERT,
1020 "Config file parse error: " << path << " '"
1027 return FG_OPTIONS_OK;
1031 // Print usage message
1032 void fgOPTIONS::usage ( void ) {
1033 cout << "Usage: fg [ options ... ]" << endl;
1036 cout << "General Options:" << endl;
1037 cout << "\t--help -h: print usage" << endl;
1038 cout << "\t--fg-root=path: specify the root path for all the data files"
1040 cout << "\t--fg-scenery=path: specify the base path for all the scenery"
1042 << "\t\tdefaults to $FG_ROOT/Scenery" << endl;
1043 cout << "\t--disable-game-mode: disable full-screen game mode" << endl;
1044 cout << "\t--enable-game-mode: enable full-screen game mode" << endl;
1045 cout << "\t--disable-splash-screen: disable splash screen" << endl;
1046 cout << "\t--enable-splash-screen: enable splash screen" << endl;
1047 cout << "\t--disable-intro-music: disable introduction music" << endl;
1048 cout << "\t--enable-intro-music: enable introduction music" << endl;
1049 cout << "\t--disable-mouse-pointer: disable extra mouse pointer" << endl;
1050 cout << "\t--enable-mouse-pointer: enable extra mouse pointer (i.e. for"
1052 cout << "\t\tfull screen voodoo/voodoo-II based cards.)" << endl;
1053 cout << "\t--disable-freeze: start out in an running state" << endl;
1054 cout << "\t--enable-freeze: start out in a frozen state" << endl;
1055 cout << "\t--control=mode: primary control mode "
1056 << "(joystick, keyboard, mouse)" << endl;
1059 cout << "Features:" << endl;
1060 cout << "\t--disable-hud: disable heads up display" << endl;
1061 cout << "\t--enable-hud: enable heads up display" << endl;
1062 cout << "\t--disable-panel: disable instrument panel" << endl;
1063 cout << "\t--enable-panel: enable instrumetn panel" << endl;
1064 cout << "\t--disable-sound: disable sound effects" << endl;
1065 cout << "\t--enable-sound: enable sound effects" << endl;
1066 cout << "\t--disable-anti-alias-hud: disable anti aliased hud" << endl;
1067 cout << "\t--enable-anti-alias-hud: enable anti aliased hud" << endl;
1070 cout << "Flight Model:" << endl;
1071 cout << "\t--fdm=abcd: selects the core flight model code." << endl;
1072 cout << "\t\tcan be one of jsb, larcsim, magic, or external" << endl;
1073 cout << "\t--aircraft=abcd: aircraft model to load" << endl;
1074 cout << "\t--model-hz=n: run the FDM this rate (iterations per second)"
1076 cout << "\t--speed=n: run the FDM this much faster than real time" << endl;
1077 cout << "\t--notrim: Do NOT attempt to trim the model when initializing JSBsim" << endl;
1080 cout <<"Aircraft model directory:" << endl;
1081 cout <<"\t--aircraft-dir=<path> path is relative to the path of the executable" << endl;
1084 cout << "Initial Position and Orientation:" << endl;
1085 cout << "\t--airport-id=ABCD: specify starting postion by airport id"
1087 cout << "\t--lon=degrees: starting longitude in degrees (west = -)"
1089 cout << "\t--lat=degrees: starting latitude in degrees (south = -)"
1091 cout << "\t--altitude=feet: starting altitude in feet" << endl;
1092 cout << "\t\t(unless --units-meters specified" << endl;
1093 cout << "\t--heading=degrees: heading (yaw) angle in degress (Psi)"
1095 cout << "\t--roll=degrees: roll angle in degrees (Phi)" << endl;
1096 cout << "\t--pitch=degrees: pitch angle in degrees (Theta)" << endl;
1097 cout << "\t--uBody=feet per second: velocity along the body X axis"
1099 cout << "\t--vBody=feet per second: velocity along the body Y axis"
1101 cout << "\t--wBody=feet per second: velocity along the body Z axis"
1103 cout << "\t\t(unless --units-meters specified" << endl;
1104 cout << "\t--vc= initial airspeed in knots (--fdm=jsb only)" << endl;
1105 cout << "\t--mach= initial mach number (--fdm=jsb only)" << endl;
1108 cout << "Rendering Options:" << endl;
1109 cout << "\t--fog-disable: disable fog/haze" << endl;
1110 cout << "\t--fog-fastest: enable fastest fog/haze" << endl;
1111 cout << "\t--fog-nicest: enable nicest fog/haze" << endl;
1112 cout << "\t--enable-clouds: enable demo cloud layer" << endl;
1113 cout << "\t--disable-clouds: disable demo cloud layer" << endl;
1114 cout << "\t--clouds-asl=xxx: specify altitude of cloud layer above sea level" << endl;
1115 cout << "\t--fov=xx.x: specify initial field of view angle in degrees"
1117 cout << "\t--disable-fullscreen: disable fullscreen mode" << endl;
1118 cout << "\t--enable-fullscreen: enable fullscreen mode" << endl;
1119 cout << "\t--shading-flat: enable flat shading" << endl;
1120 cout << "\t--shading-smooth: enable smooth shading" << endl;
1121 cout << "\t--disable-skyblend: disable sky blending" << endl;
1122 cout << "\t--enable-skyblend: enable sky blending" << endl;
1123 cout << "\t--disable-textures: disable textures" << endl;
1124 cout << "\t--enable-textures: enable textures" << endl;
1125 cout << "\t--disable-wireframe: disable wireframe drawing mode" << endl;
1126 cout << "\t--enable-wireframe: enable wireframe drawing mode" << endl;
1127 cout << "\t--geometry=WWWxHHH: window geometry: 640x480, 800x600, etc."
1131 cout << "Scenery Options:" << endl;
1132 cout << "\t--tile-radius=n: specify tile radius, must be 1 - 4" << endl;
1135 cout << "Hud Options:" << endl;
1136 cout << "\t--units-feet: Hud displays units in feet" << endl;
1137 cout << "\t--units-meters: Hud displays units in meters" << endl;
1138 cout << "\t--hud-tris: Hud displays number of triangles rendered" << endl;
1139 cout << "\t--hud-culled: Hud displays percentage of triangles culled"
1143 cout << "Time Options:" << endl;
1144 cout << "\t--time-offset=[+-]hh:mm:ss: add this time offset" << endl;
1145 cout << "\t--time-match-real: Synchronize real-world and FlightGear" << endl
1146 << "\t\ttime. Can be used in combination with --time-offset." << endl;
1147 cout << "\t--time-match-local:Synchronize local real-world and " << endl
1148 << "\t\tFlightGear time" << endl;
1149 cout << "\t--start-date-sys=yyyy:mm:dd:hh:mm:ss: specify a starting" << endl
1150 << "\t\tdate/time. Uses your system time " << endl;
1151 cout << "\t--start-date-gmt=yyyy:mm:dd:hh:mm:ss: specify a starting" << endl
1152 << "\t\tdate/time. Uses Greenwich Mean Time" << endl;
1153 cout << "\t--start-date-lat=yyyy:mm:dd:hh:mm:ss: specify a starting" << endl
1154 << "\t\tdate/time. Uses Local Aircraft Time" << endl;
1155 #ifdef FG_NETWORK_OLK
1158 cout << "Network Options:" << endl;
1159 cout << "\t--enable-network-olk: enable Multipilot mode" << endl;
1160 cout << "\t--disable-network-olk: disable Multipilot mode (default)" << endl;
1161 cout << "\t--net-hud: Hud displays network info" << endl;
1162 cout << "\t--net-id=name: specify your own callsign" << endl;
1166 cout << "Route/Way Point Options:" << endl;
1167 cout << "\t--wp=ID[@alt]: specify a waypoint for the GC autopilot" << endl;
1168 cout << "\t\tYou can specify multiple waypoints (a route) with multiple"
1170 cout << "\t\tinstances of --wp=" << endl;
1175 fgOPTIONS::~fgOPTIONS( void ) {