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 #include <simgear/compiler.h>
29 #include <simgear/misc/exception.hxx>
31 #include <math.h> // rint()
33 #include <stdlib.h> // atof(), atoi()
34 #include <string.h> // strcmp()
41 #include <simgear/math/sg_random.h>
42 #include <simgear/misc/sgstream.hxx>
43 #include <simgear/misc/sg_path.hxx>
44 #include <simgear/route/route.hxx>
45 #include <simgear/route/waypoint.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>
58 #include "globals.hxx"
59 #include "fg_init.hxx"
60 #include "fg_props.hxx"
61 #include "options.hxx"
62 #include "viewmgr.hxx"
67 SG_USING_NAMESPACE(std);
70 #define NEW_DEFAULT_MODEL_HZ 120
77 FG_OPTIONS_VERBOSE_HELP = 3,
78 FG_OPTIONS_SHOW_AIRCRAFT = 4
82 atof( const string& str )
86 // -dw- if ::atof is called, then we get an infinite loop
87 return std::atof( str.c_str() );
89 return ::atof( str.c_str() );
94 atoi( const string& str )
97 // -dw- if ::atoi is called, then we get an infinite loop
98 return std::atoi( str.c_str() );
100 return ::atoi( str.c_str() );
106 * Set a few fail-safe default property values.
108 * These should all be set in $FG_ROOT/preferences.xml, but just
109 * in case, we provide some initial sane values here. This method
110 * should be invoked *before* reading any init files.
115 // set a possibly independent location for scenery data
116 char *envp = ::getenv( "FG_SCENERY" );
118 if ( envp != NULL ) {
119 // fg_root could be anywhere, so default to environmental
120 // variable $FG_ROOT if it is set.
121 globals->set_fg_scenery(envp);
123 // Otherwise, default to Scenery being in $FG_ROOT/Scenery
124 globals->set_fg_scenery("");
126 // Position (deliberately out of range)
127 fgSetDouble("/position/longitude-deg", 9999.0);
128 fgSetDouble("/position/latitude-deg", 9999.0);
129 fgSetDouble("/position/altitude-ft", -9999.0);
132 fgSetDouble("/orientation/heading-deg", 270);
133 fgSetDouble("/orientation/roll-deg", 0);
134 fgSetDouble("/orientation/pitch-deg", 0.424);
137 fgSetDouble("/velocities/uBody-fps", 0.0);
138 fgSetDouble("/velocities/vBody-fps", 0.0);
139 fgSetDouble("/velocities/wBody-fps", 0.0);
140 fgSetDouble("/velocities/speed-north-fps", 0.0);
141 fgSetDouble("/velocities/speed-east-fps", 0.0);
142 fgSetDouble("/velocities/speed-down-fps", 0.0);
143 fgSetDouble("/velocities/airspeed-kt", 0.0);
144 fgSetDouble("/velocities/mach", 0.0);
147 fgSetDouble("/sim/presets/longitude-deg", 9999.0);
148 fgSetDouble("/sim/presets/latitude-deg", 9999.0);
149 fgSetDouble("/sim/presets/altitude-ft", -9999.0);
151 fgSetDouble("/sim/presets/heading-deg", 270);
152 fgSetDouble("/sim/presets/roll-deg", 0);
153 fgSetDouble("/sim/presets/pitch-deg", 0.424);
155 fgSetString("/sim/presets/speed-set", "knots");
156 fgSetDouble("/sim/presets/airspeed-kt", 0.0);
157 fgSetDouble("/sim/presets/mach", 0.0);
158 fgSetDouble("/sim/presets/uBody-fps", 0.0);
159 fgSetDouble("/sim/presets/vBody-fps", 0.0);
160 fgSetDouble("/sim/presets/wBody-fps", 0.0);
161 fgSetDouble("/sim/presets/speed-north-fps", 0.0);
162 fgSetDouble("/sim/presets/speed-east-fps", 0.0);
163 fgSetDouble("/sim/presets/speed-down-fps", 0.0);
165 fgSetBool("/sim/presets/onground", true);
166 fgSetBool("/sim/presets/trim", false);
169 fgSetBool("/sim/startup/game-mode", false);
170 fgSetBool("/sim/startup/splash-screen", true);
171 fgSetBool("/sim/startup/intro-music", true);
172 // we want mouse-pointer to have an undefined value if nothing is
173 // specified so we can do the right thing for voodoo-1/2 cards.
174 // fgSetString("/sim/startup/mouse-pointer", "disabled");
175 fgSetString("/sim/control-mode", "joystick");
176 fgSetBool("/sim/auto-coordination", false);
178 fgSetString("/sim/startup/browser-app", "netscape");
180 fgSetString("/sim/startup/browser-app", "webrun.bat");
183 fgSetBool("/sim/hud/visibility", false);
184 fgSetBool("/sim/panel/visibility", true);
185 fgSetBool("/sim/sound/audible", true);
186 fgSetBool("/sim/hud/antialiased", false);
188 // Flight Model options
189 fgSetString("/sim/flight-model", "jsb");
190 fgSetString("/sim/aero", "c172");
191 fgSetInt("/sim/model-hz", NEW_DEFAULT_MODEL_HZ);
192 fgSetInt("/sim/speed-up", 1);
195 fgSetString("/sim/rendering/fog", "nicest");
196 fgSetBool("/environment/clouds/status", true);
197 fgSetBool("/sim/startup/fullscreen", false);
198 fgSetBool("/sim/rendering/shading", true);
199 fgSetBool("/sim/rendering/skyblend", true);
200 fgSetBool("/sim/rendering/textures", true);
201 fgSetBool("/sim/rendering/wireframe", false);
202 fgSetBool("/sim/rendering/distance-attenuation", false);
203 fgSetInt("/sim/startup/xsize", 800);
204 fgSetInt("/sim/startup/ysize", 600);
205 fgSetInt("/sim/rendering/bits-per-pixel", 16);
206 fgSetString("/sim/view-mode", "pilot");
207 fgSetDouble("/sim/current-view/heading-offset-deg", 0);
208 fgSetDouble("/environment/visibility-m", 20000);
211 fgSetString("/sim/startup/units", "feet");
212 fgSetString("/sim/hud/frame-stat-type", "tris");
215 fgSetInt("/sim/startup/time-offset", 0);
216 fgSetString("/sim/startup/time-offset-type", "system-offset");
217 fgSetLong("/sim/time/cur-time-override", 0);
219 fgSetBool("/sim/networking/network-olk", false);
220 fgSetString("/sim/networking/call-sign", "Johnny");
223 fgSetBool("/sim/freeze/master", false);
224 fgSetBool("/sim/freeze/position", false);
225 fgSetBool("/sim/freeze/clock", false);
226 fgSetBool("/sim/freeze/fuel", false);
231 parse_wind (const string &wind, double * min_hdg, double * max_hdg,
232 double * speed, double * gust)
234 string::size_type pos = wind.find('@');
235 if (pos == string::npos)
237 string dir = wind.substr(0, pos);
238 string spd = wind.substr(pos+1);
240 if (pos == string::npos) {
241 *min_hdg = *max_hdg = atof(dir.c_str());
243 *min_hdg = atof(dir.substr(0,pos).c_str());
244 *max_hdg = atof(dir.substr(pos+1).c_str());
247 if (pos == string::npos) {
248 *speed = *gust = atof(spd.c_str());
250 *speed = atof(spd.substr(0,pos).c_str());
251 *gust = atof(spd.substr(pos+1).c_str());
256 // parse a time string ([+/-]%f[:%f[:%f]]) into hours
258 parse_time(const string& time_in) {
259 char *time_str, num[256];
260 double hours, minutes, seconds;
265 time_str = (char *)time_in.c_str();
267 // printf("parse_time(): %s\n", time_str);
270 if ( strlen(time_str) ) {
271 if ( time_str[0] == '+' ) {
274 } else if ( time_str[0] == '-' ) {
279 // printf("sign = %d\n", sign);
282 if ( strlen(time_str) ) {
284 while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
285 num[i] = time_str[0];
289 if ( time_str[0] == ':' ) {
294 // printf("hours = %.2lf\n", hours);
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("minutes = %.2lf\n", minutes);
314 result += minutes / 60.0;
318 if ( strlen(time_str) ) {
320 while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
321 num[i] = time_str[0];
327 // printf("seconds = %.2lf\n", seconds);
329 result += seconds / 3600.0;
332 cout << " parse_time() = " << sign * result << endl;
334 return(sign * result);
338 // parse a date string (yyyy:mm:dd:hh:mm:ss) into a time_t (seconds)
340 parse_date( const string& date)
343 char * date_str, num[256];
345 // initialize to zero
352 gmt.tm_isdst = 0; // ignore daylight savings time for the moment
353 date_str = (char *)date.c_str();
355 if ( strlen(date_str) ) {
357 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
358 num[i] = date_str[0];
362 if ( date_str[0] == ':' ) {
366 gmt.tm_year = atoi(num) - 1900;
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_mon = atoi(num) -1;
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_mday = atoi(num);
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_hour = 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_min = 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_sec = atoi(num);
438 time_t theTime = sgTimeGetGMT( gmt.tm_year, gmt.tm_mon, gmt.tm_mday,
439 gmt.tm_hour, gmt.tm_min, gmt.tm_sec );
440 //printf ("Date is %s\n", ctime(&theTime));
441 //printf ("in seconds that is %d\n", theTime);
447 // parse angle in the form of [+/-]ddd:mm:ss into degrees
449 parse_degree( const string& degree_str) {
450 double result = parse_time( degree_str );
452 // printf("Degree = %.4f\n", result);
458 // parse time offset string into seconds
460 parse_time_offset( const string& time_str) {
463 // printf("time offset = %s\n", time_str);
466 result = (int)rint(parse_time(time_str) * 3600.0);
468 result = (int)(parse_time(time_str) * 3600.0);
471 // printf("parse_time_offset(): %d\n", result);
477 // Parse --fov=x.xx type option
479 parse_fov( const string& arg ) {
480 double fov = atof(arg);
482 if ( fov < FG_FOV_MIN ) { fov = FG_FOV_MIN; }
483 if ( fov > FG_FOV_MAX ) { fov = FG_FOV_MAX; }
485 fgSetDouble("/sim/current-view/field-of-view", fov);
487 // printf("parse_fov(): result = %.4f\n", fov);
493 // Parse I/O channel option
495 // Format is "--protocol=medium,direction,hz,medium_options,..."
497 // protocol = { native, nmea, garmin, fgfs, rul, pve, etc. }
498 // medium = { serial, socket, file, etc. }
499 // direction = { in, out, bi }
500 // hz = number of times to process channel per second (floating
501 // point values are ok.
503 // Serial example "--nmea=serial,dir,hz,device,baud" where
505 // device = OS device name of serial line to be open()'ed
506 // baud = {300, 1200, 2400, ..., 230400}
508 // Socket exacmple "--native=socket,dir,hz,machine,port,style" where
510 // machine = machine name or ip address if client (leave empty if server)
511 // port = port, leave empty to let system choose
512 // style = tcp or udp
514 // File example "--garmin=file,dir,hz,filename" where
516 // filename = file system file name
519 add_channel( const string& type, const string& channel_str ) {
520 // cout << "Channel string = " << channel_str << endl;
522 globals->get_channel_options_list()->push_back( type + "," + channel_str );
529 setup_wind (double min_hdg, double max_hdg, double speed, double gust)
531 fgSetDouble("/environment/wind-from-heading-deg", min_hdg);
532 fgSetDouble("/environment/params/min-wind-from-heading-deg", min_hdg);
533 fgSetDouble("/environment/params/max-wind-from-heading-deg", max_hdg);
534 fgSetDouble("/environment/wind-speed-kt", speed);
535 fgSetDouble("/environment/params/base-wind-speed-kt", speed);
536 fgSetDouble("/environment/params/gust-wind-speed-kt", gust);
538 SG_LOG(SG_GENERAL, SG_INFO, "WIND: " << min_hdg << '@' <<
539 speed << " knots" << endl);
543 speed *= SG_NM_TO_METER * SG_METER_TO_FEET * (1.0/3600);
544 while (min_hdg > 360)
548 min_hdg *= SGD_DEGREES_TO_RADIANS;
549 fgSetDouble("/environment/wind-from-north-fps", speed * cos(dir));
550 fgSetDouble("/environment/wind-from-east-fps", speed * sin(dir));
551 #endif // FG_WEATHERCM
555 // Parse --wp=ID[@alt]
557 parse_wp( const string& arg ) {
561 string::size_type pos = arg.find( "@" );
562 if ( pos != string::npos ) {
563 id = arg.substr( 0, pos );
564 alt_str = arg.substr( pos + 1 );
565 // cout << "id str = " << id << " alt str = " << alt_str << endl;
566 alt = atof( alt_str.c_str() );
567 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) {
568 alt *= SG_FEET_TO_METER;
575 if ( fgFindAirportID( id, &a ) ) {
576 SGWayPoint wp( a.longitude, a.latitude, alt, SGWayPoint::WGS84, id );
577 globals->get_route()->add_waypoint( wp );
586 // Parse --flight-plan=[file]
588 parse_flightplan(const string& arg)
590 sg_gzifstream in(arg.c_str());
591 if ( !in.is_open() ) {
597 #if defined( macintosh )
598 getline( in, line, '\r' );
600 getline( in, line, '\n' );
603 // catch extraneous (DOS) line ending character
604 if ( line[line.length() - 1] < 32 ) {
605 line = line.substr( 0, line.length()-1 );
617 #define NEW_OPTION_PARSING 1
618 #ifdef NEW_OPTION_PARSING
620 fgOptLanguage( const char *arg )
622 globals->set_locale( fgInitLocale( arg ) );
623 return FG_OPTIONS_OK;
629 fgSetString("/sim/presets/airport-id", "");
630 fgSetString("/sim/presets/vor-id", "");
631 fgSetString("/sim/presets/ndb-id", "");
632 fgSetString("/sim/presets/fix", "");
636 fgOptVOR( const char * arg )
639 fgSetString("/sim/presets/vor-id", arg);
640 return FG_OPTIONS_OK;
644 fgOptNDB( const char * arg )
647 fgSetString("/sim/presets/ndb-id", arg);
648 return FG_OPTIONS_OK;
652 fgOptFIX( const char * arg )
655 fgSetString("/sim/presets/fix", arg);
656 return FG_OPTIONS_OK;
660 fgOptLon( const char *arg )
663 fgSetDouble("/sim/presets/longitude-deg", parse_degree( arg ));
664 fgSetDouble("/position/longitude-deg", parse_degree( arg ));
665 return FG_OPTIONS_OK;
669 fgOptLat( const char *arg )
672 fgSetDouble("/sim/presets/latitude-deg", parse_degree( arg ));
673 fgSetDouble("/position/latitude-deg", parse_degree( arg ));
674 return FG_OPTIONS_OK;
678 fgOptAltitude( const char *arg )
680 fgSetBool("/sim/presets/onground", false);
681 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
682 fgSetDouble("/sim/presets/altitude-ft", atof( arg ));
684 fgSetDouble("/sim/presets/altitude-ft",
685 atof( arg ) * SG_METER_TO_FEET);
686 return FG_OPTIONS_OK;
690 fgOptUBody( const char *arg )
692 fgSetString("/sim/presets/speed-set", "UVW");
693 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
694 fgSetDouble("/sim/presets/uBody-fps", atof( arg ));
696 fgSetDouble("/sim/presets/uBody-fps",
697 atof( arg ) * SG_METER_TO_FEET);
698 return FG_OPTIONS_OK;
702 fgOptVBody( const char *arg )
704 fgSetString("/sim/presets/speed-set", "UVW");
705 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
706 fgSetDouble("/sim/presets/vBody-fps", atof( arg ));
708 fgSetDouble("/sim/presets/vBody-fps",
709 atof( arg ) * SG_METER_TO_FEET);
710 return FG_OPTIONS_OK;
714 fgOptWBody( const char *arg )
716 fgSetString("/sim/presets/speed-set", "UVW");
717 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
718 fgSetDouble("/sim/presets/wBody-fps", atof(arg));
720 fgSetDouble("/sim/presets/wBody-fps",
721 atof(arg) * SG_METER_TO_FEET);
722 return FG_OPTIONS_OK;
726 fgOptVNorth( const char *arg )
728 fgSetString("/sim/presets/speed-set", "NED");
729 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
730 fgSetDouble("/sim/presets/speed-north-fps", atof( arg ));
732 fgSetDouble("/sim/presets/speed-north-fps",
733 atof( arg ) * SG_METER_TO_FEET);
734 return FG_OPTIONS_OK;
738 fgOptVEast( const char *arg )
740 fgSetString("/sim/presets/speed-set", "NED");
741 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
742 fgSetDouble("/sim/presets/speed-east-fps", atof(arg));
744 fgSetDouble("/sim/presets/speed-east-fps",
745 atof(arg) * SG_METER_TO_FEET);
746 return FG_OPTIONS_OK;
750 fgOptVDown( const char *arg )
752 fgSetString("/sim/presets/speed-set", "NED");
753 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
754 fgSetDouble("/sim/presets/speed-down-fps", atof(arg));
756 fgSetDouble("/sim/presets/speed-down-fps",
757 atof(arg) * SG_METER_TO_FEET);
758 return FG_OPTIONS_OK;
762 fgOptVc( const char *arg )
764 // fgSetString("/sim/presets/speed-set", "knots");
765 // fgSetDouble("/velocities/airspeed-kt", atof(arg.substr(5)));
766 fgSetString("/sim/presets/speed-set", "knots");
767 fgSetDouble("/sim/presets/airspeed-kt", atof(arg));
768 return FG_OPTIONS_OK;
772 fgOptMach( const char *arg )
774 fgSetString("/sim/presets/speed-set", "mach");
775 fgSetDouble("/sim/presets/mach", atof(arg));
776 return FG_OPTIONS_OK;
780 fgOptRoc( const char *arg )
782 fgSetDouble("/velocities/vertical-speed-fps", atof(arg)/60);
783 return FG_OPTIONS_OK;
787 fgOptFgRoot( const char *arg )
789 globals->set_fg_root(arg);
790 return FG_OPTIONS_OK;
794 fgOptFgScenery( const char *arg )
796 globals->set_fg_scenery(arg);
797 return FG_OPTIONS_OK;
801 fgOptFov( const char *arg )
804 return FG_OPTIONS_OK;
808 fgOptGeometry( const char *arg )
810 bool geometry_ok = true;
811 int xsize = 0, ysize = 0;
812 string geometry = arg;
813 string::size_type i = geometry.find('x');
815 if (i != string::npos) {
816 xsize = atoi(geometry.substr(0, i));
817 ysize = atoi(geometry.substr(i+1));
822 if ( xsize <= 0 || ysize <= 0 ) {
828 if ( !geometry_ok ) {
829 SG_LOG( SG_GENERAL, SG_ALERT, "Unknown geometry: " << geometry );
830 SG_LOG( SG_GENERAL, SG_ALERT,
831 "Setting geometry to " << xsize << 'x' << ysize << '\n');
833 SG_LOG( SG_GENERAL, SG_INFO,
834 "Setting geometry to " << xsize << 'x' << ysize << '\n');
835 fgSetInt("/sim/startup/xsize", xsize);
836 fgSetInt("/sim/startup/ysize", ysize);
838 return FG_OPTIONS_OK;
842 fgOptBpp( const char *arg )
844 string bits_per_pix = arg;
845 if ( bits_per_pix == "16" ) {
846 fgSetInt("/sim/rendering/bits-per-pixel", 16);
847 } else if ( bits_per_pix == "24" ) {
848 fgSetInt("/sim/rendering/bits-per-pixel", 24);
849 } else if ( bits_per_pix == "32" ) {
850 fgSetInt("/sim/rendering/bits-per-pixel", 32);
852 SG_LOG(SG_GENERAL, SG_ALERT, "Unsupported bpp " << bits_per_pix);
854 return FG_OPTIONS_OK;
858 fgOptTimeOffset( const char *arg )
860 fgSetInt("/sim/startup/time-offset",
861 parse_time_offset( arg ));
862 fgSetString("/sim/startup/time-offset-type", "system-offset");
863 return FG_OPTIONS_OK;
867 fgOptStartDateSys( const char *arg )
869 fgSetInt("/sim/startup/time-offset", parse_date( arg ) );
870 fgSetString("/sim/startup/time-offset-type", "system");
871 return FG_OPTIONS_OK;
875 fgOptStartDateLat( const char *arg )
877 fgSetInt("/sim/startup/time-offset", parse_date( arg ) );
878 fgSetString("/sim/startup/time-offset-type", "latitude");
879 return FG_OPTIONS_OK;
883 fgOptStartDateGmt( const char *arg )
885 fgSetInt("/sim/startup/time-offset", parse_date( arg ) );
886 fgSetString("/sim/startup/time-offset-type", "gmt");
887 return FG_OPTIONS_OK;
890 #ifdef FG_NETWORK_OLK
892 fgOptNetHud( const char *arg )
894 fgSetBool("/sim/hud/net-display", true);
895 net_hud_display = 1; // FIXME
896 return FG_OPTIONS_OK;
901 fgOptTraceRead( const char *arg )
904 SG_LOG(SG_GENERAL, SG_INFO, "Tracing reads for property " << name);
905 fgGetNode(name.c_str(), true)
906 ->setAttribute(SGPropertyNode::TRACE_READ, true);
907 return FG_OPTIONS_OK;
911 fgOptTraceWrite( const char *arg )
914 SG_LOG(SG_GENERAL, SG_INFO, "Tracing writes for property " << name);
915 fgGetNode(name.c_str(), true)
916 ->setAttribute(SGPropertyNode::TRACE_WRITE, true);
917 return FG_OPTIONS_OK;
921 fgOptViewOffset( const char *arg )
923 // $$$ begin - added VS Renganathan, 14 Oct 2K
924 // for multi-window outside window imagery
925 string woffset = arg;
926 double default_view_offset = 0.0;
927 if ( woffset == "LEFT" ) {
928 default_view_offset = SGD_PI * 0.25;
929 } else if ( woffset == "RIGHT" ) {
930 default_view_offset = SGD_PI * 1.75;
931 } else if ( woffset == "CENTER" ) {
932 default_view_offset = 0.00;
934 default_view_offset = atof( woffset.c_str() ) * SGD_DEGREES_TO_RADIANS;
936 /* apparently not used (CLO, 11 Jun 2002)
937 FGViewer *pilot_view =
938 (FGViewer *)globals->get_viewmgr()->get_view( 0 ); */
939 // this will work without calls to the viewer...
940 fgSetDouble( "/sim/current-view/heading-offset-deg",
941 default_view_offset * SGD_RADIANS_TO_DEGREES );
942 // $$$ end - added VS Renganathan, 14 Oct 2K
943 return FG_OPTIONS_OK;
947 fgOptVisibilityMiles( const char *arg )
949 double visibility = atof( arg ) * 5280.0 * SG_FEET_TO_METER;
950 fgSetDouble("/environment/visibility-m", visibility);
951 return FG_OPTIONS_OK;
955 fgOptRandomWind( const char *arg )
957 double min_hdg = sg_random() * 360.0;
958 double max_hdg = min_hdg + (20 - sqrt(sg_random() * 400));
959 double speed = 40 - sqrt(sg_random() * 1600.0);
960 double gust = speed + (10 - sqrt(sg_random() * 100));
961 setup_wind(min_hdg, max_hdg, speed, gust);
962 return FG_OPTIONS_OK;
966 fgOptWind( const char *arg )
968 double min_hdg, max_hdg, speed, gust;
969 if (!parse_wind( arg, &min_hdg, &max_hdg, &speed, &gust)) {
970 SG_LOG( SG_GENERAL, SG_ALERT, "bad wind value " << arg );
971 return FG_OPTIONS_ERROR;
973 setup_wind(min_hdg, max_hdg, speed, gust);
974 return FG_OPTIONS_OK;
978 fgOptWp( const char *arg )
981 return FG_OPTIONS_OK;
985 fgOptFlightPlan( const char *arg )
987 parse_flightplan ( arg );
988 return FG_OPTIONS_OK;
992 fgOptConfig( const char *arg )
996 readProperties(file, globals->get_props());
997 } catch (const sg_exception &e) {
998 string message = "Error loading config file: ";
999 message += e.getFormattedMessage();
1000 SG_LOG(SG_INPUT, SG_ALERT, message);
1003 return FG_OPTIONS_OK;
1006 static map<string,size_t> fgOptionMap;
1008 enum OptionType { OPTION_BOOL, OPTION_STRING, OPTION_DOUBLE, OPTION_INT, OPTION_CHANNEL, OPTION_FUNC };
1012 enum OptionType type;
1016 int (*func)( const char * );
1017 } fgOptionArray[] = {
1019 {"language", true, OPTION_FUNC, "", false, "", fgOptLanguage },
1020 {"disable-game-mode", false, OPTION_BOOL, "/sim/startup/game-mode", false, "", 0 },
1021 {"enable-game-mode", false, OPTION_BOOL, "/sim/startup/game-mode", true, "", 0 },
1022 {"disable-splash-screen", false, OPTION_BOOL, "/sim/startup/splash-screen", false, "", 0 },
1023 {"enable-splash-screen", false, OPTION_BOOL, "/sim/startup/splash-screen", true, "", 0 },
1024 {"disable-intro-music", false, OPTION_BOOL, "/sim/startup/intro-music", false, "", 0 },
1025 {"enable-intro-music", false, OPTION_BOOL, "/sim/startup/intro-music", true, "", 0 },
1026 {"disable-mouse-pointer", false, OPTION_STRING, "/sim/startup/mouse-pointer", false, "disabled", 0 },
1027 {"enable-mouse-pointer", false, OPTION_STRING, "/sim/startup/mouse-pointer", false, "enabled", 0 },
1028 {"disable-random-objects", false, OPTION_BOOL, "/sim/rendering/random-objects", false, "", 0 },
1029 {"enable-random-objects", false, OPTION_BOOL, "/sim/rendering/random-objects", true, "", 0 },
1030 {"disable-freeze", false, OPTION_BOOL, "/sim/freeze/master", false, "", 0 },
1031 {"enable-freeze", false, OPTION_BOOL, "/sim/freeze/master", true, "", 0 },
1032 {"disable-fuel-freeze", false, OPTION_BOOL, "/sim/freeze/fuel", false, "", 0 },
1033 {"enable-fuel-freeze", false, OPTION_BOOL, "/sim/freeze/fuel", true, "", 0 },
1034 {"disable-clock-freeze", false, OPTION_BOOL, "/sim/freeze/clock", false, "", 0 },
1035 {"enable-clock-freeze", false, OPTION_BOOL, "/sim/freeze/clock", true, "", 0 },
1036 {"disable-anti-alias-hud", false, OPTION_BOOL, "/sim/hud/antialiased", false, "", 0 },
1037 {"enable-anti-alias-hud", false, OPTION_BOOL, "/sim/hud/antialiased", true, "", 0 },
1038 {"control", true, OPTION_STRING, "/sim/control-mode", false, "", 0 },
1039 {"disable-auto-coordination", false, OPTION_BOOL, "/sim/auto-coordination", false, "", 0 },
1040 {"enable-auto-coordination", false, OPTION_BOOL, "/sim/auto-coordination", true, "", 0 },
1041 {"browser-app", true, OPTION_STRING, "/sim/startup/browser-app", false, "", 0 },
1042 {"disable-hud", false, OPTION_BOOL, "/sim/hud/visibility", false, "", 0 },
1043 {"enable-hud", false, OPTION_BOOL, "/sim/hud/visibility", true, "", 0 },
1044 {"disable-panel", false, OPTION_BOOL, "/sim/panel/visibility", false, "", 0 },
1045 {"enable-panel", false, OPTION_BOOL, "/sim/panel/visibility", true, "", 0 },
1046 {"disable-sound", false, OPTION_BOOL, "/sim/sound/audible", false, "", 0 },
1047 {"enable-sound", false, OPTION_BOOL, "/sim/sound/audible", true, "", 0 },
1048 {"airport", true, OPTION_STRING, "/sim/presets/airport-id", false, "", 0 },
1049 {"airport-id", true, OPTION_STRING, "/sim/presets/airport-id", false, "", 0 },
1050 {"runway", true, OPTION_STRING, "/sim/presets/runway", false, "", 0 },
1051 {"vor", true, OPTION_FUNC, "", false, "", fgOptVOR },
1052 {"ndb", true, OPTION_FUNC, "", false, "", fgOptNDB },
1053 {"fix", true, OPTION_FUNC, "", false, "", fgOptFIX },
1054 {"offset-distance", true, OPTION_DOUBLE, "/sim/presets/offset-distance", false, "", 0 },
1055 {"offset-azimuth", true, OPTION_DOUBLE, "/sim/presets/offset-azimuth", false, "", 0 },
1056 {"lon", true, OPTION_FUNC, "", false, "", fgOptLon },
1057 {"lat", true, OPTION_FUNC, "", false, "", fgOptLat },
1058 {"altitude", true, OPTION_FUNC, "", false, "", fgOptAltitude },
1059 {"uBody", true, OPTION_FUNC, "", false, "", fgOptUBody },
1060 {"vBody", true, OPTION_FUNC, "", false, "", fgOptVBody },
1061 {"wBody", true, OPTION_FUNC, "", false, "", fgOptWBody },
1062 {"vNorth", true, OPTION_FUNC, "", false, "", fgOptVNorth },
1063 {"vEast", true, OPTION_FUNC, "", false, "", fgOptVEast },
1064 {"vDown", true, OPTION_FUNC, "", false, "", fgOptVDown },
1065 {"vc", true, OPTION_FUNC, "", false, "", fgOptVc },
1066 {"mach", true, OPTION_FUNC, "", false, "", fgOptMach },
1067 {"heading", true, OPTION_DOUBLE, "/sim/presets/heading-deg", false, "", 0 },
1068 {"roll", true, OPTION_DOUBLE, "/sim/presets/roll-deg", false, "", 0 },
1069 {"pitch", true, OPTION_DOUBLE, "/sim/presets/pitch-deg", false, "", 0 },
1070 {"glideslope", true, OPTION_DOUBLE, "/sim/presets/glideslope-deg", false, "", 0 },
1071 {"roc", true, OPTION_FUNC, "", false, "", fgOptRoc },
1072 {"fg-root", true, OPTION_FUNC, "", false, "", fgOptFgRoot },
1073 {"fg-scenery", true, OPTION_FUNC, "", false, "", fgOptFgScenery },
1074 {"fdm", true, OPTION_STRING, "/sim/flight-model", false, "", 0 },
1075 {"aero", true, OPTION_STRING, "/sim/aero", false, "", 0 },
1076 {"aircraft-dir", true, OPTION_STRING, "/sim/aircraft-dir", false, "", 0 },
1077 {"model-hz", true, OPTION_INT, "/sim/model-hz", false, "", 0 },
1078 {"speed", true, OPTION_INT, "/sim/speed-up", false, "", 0 },
1079 {"trim", false, OPTION_BOOL, "/sim/presets/trim", true, "", 0 },
1080 {"notrim", false, OPTION_BOOL, "/sim/presets/trim", false, "", 0 },
1081 {"on-ground", false, OPTION_BOOL, "/sim/presets/onground", true, "", 0 },
1082 {"in-air", false, OPTION_BOOL, "/sim/presets/onground", false, "", 0 },
1083 {"fog-disable", false, OPTION_STRING, "/sim/rendering/fog", false, "disabled", 0 },
1084 {"fog-fastest", false, OPTION_STRING, "/sim/rendering/fog", false, "fastest", 0 },
1085 {"fog-nicest", false, OPTION_STRING, "/sim/fog", false, "nicest", 0 },
1086 {"disable-distance-attenuation", false, OPTION_BOOL, "/environment/distance-attenuation", false, "", 0 },
1087 {"enable-distance-attenuation", false, OPTION_BOOL, "/environment/distance-attenuation", true, "", 0 },
1088 {"disable-clouds", false, OPTION_BOOL, "/environment/clouds/status", false, "", 0 },
1089 {"enable-clouds", false, OPTION_BOOL, "/environment/clouds/status", true, "", 0 },
1090 #ifdef FG_USE_CLOUDS_3D
1091 {"disable-clouds3d", false, OPTION_BOOL, "/sim/rendering/clouds3d", false, "", 0 },
1092 {"enable-clouds3d", false, OPTION_BOOL, "/sim/rendering/clouds3d", true, "", 0 },
1094 {"fov", true, OPTION_FUNC, "", false, "", fgOptFov },
1095 {"disable-fullscreen", false, OPTION_BOOL, "/sim/startup/fullscreen", false, "", 0 },
1096 {"enable-fullscreen", false, OPTION_BOOL, "/sim/startup/fullscreen", true, "", 0 },
1097 {"shading-flat", false, OPTION_BOOL, "/sim/rendering/shading", false, "", 0 },
1098 {"shading-smooth", false, OPTION_BOOL, "/sim/rendering/shading", true, "", 0 },
1099 {"disable-skyblend", false, OPTION_BOOL, "/sim/rendering/skyblend", false, "", 0 },
1100 {"enable-skyblend", false, OPTION_BOOL, "/sim/rendering/skyblend", true, "", 0 },
1101 {"disable-textures", false, OPTION_BOOL, "/sim/rendering/textures", false, "", 0 },
1102 {"enable-textures", false, OPTION_BOOL, "/sim/rendering/textures", true, "", 0 },
1103 {"disable-wireframe", false, OPTION_BOOL, "/sim/rendering/wireframe", false, "", 0 },
1104 {"enable-wireframe", false, OPTION_BOOL, "/sim/rendering/wireframe", true, "", 0 },
1105 {"geometry", true, OPTION_FUNC, "", false, "", fgOptGeometry },
1106 {"bpp", true, OPTION_FUNC, "", false, "", fgOptBpp },
1107 {"units-feet", false, OPTION_STRING, "/sim/startup/units", false, "feet", 0 },
1108 {"units-meters", false, OPTION_STRING, "/sim/startup/units", false, "meters", 0 },
1109 {"time-offset", true, OPTION_FUNC, "", false, "", fgOptTimeOffset },
1110 {"time-match-real", false, OPTION_STRING, "/sim/startup/time-offset-type", false, "system-offset", 0 },
1111 {"time-match-local", false, OPTION_STRING, "/sim/startup/time-offset-type", false, "latitude-offset", 0 },
1112 {"start-date-sys", true, OPTION_FUNC, "", false, "", fgOptStartDateSys },
1113 {"start-date-lat", true, OPTION_FUNC, "", false, "", fgOptStartDateLat },
1114 {"start-date-gmt", true, OPTION_FUNC, "", false, "", fgOptStartDateGmt },
1115 {"hud-tris", false, OPTION_STRING, "/sim/hud/frame-stat-type", false, "tris", 0 },
1116 {"hud-culled", false, OPTION_STRING, "/sim/hud/frame-stat-type", false, "culled", 0 },
1117 {"atc610x", false, OPTION_CHANNEL, "", false, "dummy", 0 },
1118 {"atlas", true, OPTION_CHANNEL, "", false, "", 0 },
1119 {"httpd", true, OPTION_CHANNEL, "", false, "", 0 },
1120 #ifdef FG_JPEG_SERVER
1121 {"jpg-httpd", true, OPTION_CHANNEL, "", false, "", 0 },
1123 {"native", true, OPTION_CHANNEL, "", false, "", 0 },
1124 {"native-ctrls", true, OPTION_CHANNEL, "", false, "", 0 },
1125 {"native-fdm", true, OPTION_CHANNEL, "", false, "", 0 },
1126 {"native-gui", true, OPTION_CHANNEL, "", false, "", 0 },
1127 {"opengc", true, OPTION_CHANNEL, "", false, "", 0 },
1128 {"garmin", true, OPTION_CHANNEL, "", false, "", 0 },
1129 {"nmea", true, OPTION_CHANNEL, "", false, "", 0 },
1130 {"props", true, OPTION_CHANNEL, "", false, "", 0 },
1131 {"telnet", true, OPTION_CHANNEL, "", false, "", 0 },
1132 {"pve", true, OPTION_CHANNEL, "", false, "", 0 },
1133 {"ray", true, OPTION_CHANNEL, "", false, "", 0 },
1134 {"rul", true, OPTION_CHANNEL, "", false, "", 0 },
1135 {"joyclient", true, OPTION_CHANNEL, "", false, "", 0 },
1136 #ifdef FG_NETWORK_OLK
1137 {"disable-network-olk", false, OPTION_BOOL, "/sim/networking/olk", false, "", 0 },
1138 {"enable-network-olk", false, OPTION_BOOL, "/sim/networking/olk", true, "", 0 },
1139 {"net-hud", false, OPTION_FUNC, "", false, "", fgOptNetHud },
1140 {"net-id", true, OPTION_STRING, "sim/networking/call-sign", false, "", 0 },
1142 {"trace-read", true, OPTION_FUNC, "", false, "", fgOptTraceRead },
1143 {"trace-write", true, OPTION_FUNC, "", false, "", fgOptTraceWrite },
1144 {"view-offset", true, OPTION_FUNC, "", false, "", fgOptViewOffset },
1145 {"visibility", true, OPTION_DOUBLE, "/environment/visibility-m", false, "", 0 },
1146 {"visibility-miles", true, OPTION_FUNC, "", false, "", fgOptVisibilityMiles },
1147 {"random-wind", false, OPTION_FUNC, "", false, "", fgOptRandomWind },
1148 {"wind", true, OPTION_FUNC, "", false, "", fgOptWind },
1149 {"turbulence", true, OPTION_DOUBLE, "/environment/turbulence-norm", false, "", 0 },
1150 {"wp", true, OPTION_FUNC, "", false, "", fgOptWp },
1151 {"flight-plan", true, OPTION_FUNC, "", false, "", fgOptFlightPlan },
1152 {"config", true, OPTION_FUNC, "", false, "", fgOptConfig },
1153 {"aircraft", true, OPTION_STRING, "/sim/aircraft", false, "", 0 },
1158 // Parse a single option
1160 parse_option (const string& arg)
1162 #ifdef NEW_OPTION_PARSING
1163 if ( fgOptionMap.size() == 0 ) {
1165 OptionDesc *pt = &fgOptionArray[ 0 ];
1166 while ( pt->option != 0 ) {
1167 fgOptionMap[ pt->option ] = i;
1174 if ( (arg == "--help") || (arg == "-h") ) {
1175 // help/usage request
1176 return(FG_OPTIONS_HELP);
1177 } else if ( (arg == "--verbose") || (arg == "-v") ) {
1178 // verbose help/usage request
1179 return(FG_OPTIONS_VERBOSE_HELP);
1180 } else if ( arg.find( "--show-aircraft") == 0) {
1181 return(FG_OPTIONS_SHOW_AIRCRAFT);
1182 } else if ( arg.find( "--prop:" ) == 0 ) {
1183 string assign = arg.substr(7);
1184 string::size_type pos = assign.find('=');
1185 if ( pos == arg.npos || pos == 0 ) {
1186 SG_LOG( SG_GENERAL, SG_ALERT, "Bad property assignment: " << arg );
1187 return FG_OPTIONS_ERROR;
1189 string name = assign.substr(0, pos);
1190 string value = assign.substr(pos + 1);
1191 fgSetString(name.c_str(), value.c_str());
1192 // SG_LOG(SG_GENERAL, SG_INFO, "Setting default value of property "
1193 // << name << " to \"" << value << '"');
1194 } else if ( arg.find( "--" ) == 0 ) {
1195 size_t pos = arg.find( '=' );
1197 if ( pos == string::npos ) {
1198 arg_name = arg.substr( 2 );
1200 arg_name = arg.substr( 2, pos - 2 );
1202 map<string,size_t>::iterator it = fgOptionMap.find( arg_name );
1203 if ( it != fgOptionMap.end() ) {
1204 OptionDesc *pt = &fgOptionArray[ it->second ];
1205 switch ( pt->type ) {
1207 fgSetBool( pt->property, pt->b_param );
1210 if ( pt->has_param && pos != string::npos ) {
1211 fgSetString( pt->property, arg.substr( pos + 1 ).c_str() );
1212 } else if ( !pt->has_param && pos == string::npos ) {
1213 fgSetString( pt->property, pt->s_param );
1214 } else if ( pt->has_param ) {
1215 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' needs a parameter" );
1216 return FG_OPTIONS_ERROR;
1218 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' does not have a parameter" );
1219 return FG_OPTIONS_ERROR;
1223 if ( pos != string::npos ) {
1224 fgSetDouble( pt->property, atof( arg.substr( pos + 1 ) ) );
1226 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' needs a parameter" );
1227 return FG_OPTIONS_ERROR;
1231 if ( pos != string::npos ) {
1232 fgSetInt( pt->property, atoi( arg.substr( pos + 1 ) ) );
1234 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' needs a parameter" );
1235 return FG_OPTIONS_ERROR;
1238 case OPTION_CHANNEL:
1239 if ( pt->has_param && pos != string::npos ) {
1240 add_channel( pt->option, arg.substr( pos + 1 ) );
1241 } else if ( !pt->has_param && pos == string::npos ) {
1242 add_channel( pt->option, pt->s_param );
1243 } else if ( pt->has_param ) {
1244 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' needs a parameter" );
1245 return FG_OPTIONS_ERROR;
1247 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' does not have a parameter" );
1248 return FG_OPTIONS_ERROR;
1252 if ( pt->has_param && pos != string::npos ) {
1253 pt->func( arg.substr( pos + 1 ).c_str() );
1254 } else if ( !pt->has_param && pos == string::npos ) {
1256 } else if ( pt->has_param ) {
1257 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' needs a parameter" );
1258 return FG_OPTIONS_ERROR;
1260 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' does not have a parameter" );
1261 return FG_OPTIONS_ERROR;
1266 SG_LOG( SG_GENERAL, SG_ALERT, "Unknown option '" << arg << "'" );
1267 return FG_OPTIONS_ERROR;
1270 SG_LOG( SG_GENERAL, SG_ALERT, "Unknown option '" << arg << "'" );
1271 return FG_OPTIONS_ERROR;
1277 if ( (arg == "--help") || (arg == "-h") ) {
1278 // help/usage request
1279 return(FG_OPTIONS_HELP);
1280 } else if ( (arg == "--verbose") || (arg == "-v") ) {
1281 // verbose help/usage request
1282 return(FG_OPTIONS_VERBOSE_HELP);
1283 } else if ( arg.find( "--language=") == 0 ) {
1284 globals->set_locale( fgInitLocale( arg.substr( 11 ).c_str() ) );
1285 } else if ( arg == "--disable-game-mode") {
1286 fgSetBool("/sim/startup/game-mode", false);
1287 } else if ( arg == "--enable-game-mode" ) {
1288 fgSetBool("/sim/startup/game-mode", true);
1289 } else if ( arg == "--disable-splash-screen" ) {
1290 fgSetBool("/sim/startup/splash-screen", false);
1291 } else if ( arg == "--enable-splash-screen" ) {
1292 fgSetBool("/sim/startup/splash-screen", true);
1293 } else if ( arg == "--disable-intro-music" ) {
1294 fgSetBool("/sim/startup/intro-music", false);
1295 } else if ( arg == "--enable-intro-music" ) {
1296 fgSetBool("/sim/startup/intro-music", true);
1297 } else if ( arg == "--disable-mouse-pointer" ) {
1298 fgSetString("/sim/startup/mouse-pointer", "disabled");
1299 } else if ( arg == "--enable-mouse-pointer" ) {
1300 fgSetString("/sim/startup/mouse-pointer", "enabled");
1301 } else if ( arg == "--disable-random-objects" ) {
1302 fgSetBool("/sim/rendering/random-objects", false);
1303 } else if ( arg == "--enable-random-objects" ) {
1304 fgSetBool("/sim/rendering/random-objects", true);
1305 } else if ( arg == "--disable-freeze" ) {
1306 fgSetBool("/sim/freeze/master", false);
1307 } else if ( arg == "--enable-freeze" ) {
1308 fgSetBool("/sim/freeze/master", true);
1309 } else if ( arg == "--disable-fuel-freeze" ) {
1310 fgSetBool("/sim/freeze/fuel", false);
1311 } else if ( arg == "--enable-fuel-freeze" ) {
1312 fgSetBool("/sim/freeze/fuel", true);
1313 } else if ( arg == "--disable-clock-freeze" ) {
1314 fgSetBool("/sim/freeze/clock", false);
1315 } else if ( arg == "--enable-clock-freeze" ) {
1316 fgSetBool("/sim/freeze/clock", true);
1317 } else if ( arg == "--disable-anti-alias-hud" ) {
1318 fgSetBool("/sim/hud/antialiased", false);
1319 } else if ( arg == "--enable-anti-alias-hud" ) {
1320 fgSetBool("/sim/hud/antialiased", true);
1321 } else if ( arg.find( "--control=") == 0 ) {
1322 fgSetString("/sim/control-mode", arg.substr(10).c_str());
1323 } else if ( arg == "--disable-auto-coordination" ) {
1324 fgSetBool("/sim/auto-coordination", false);
1325 } else if ( arg == "--enable-auto-coordination" ) {
1326 fgSetBool("/sim/auto-coordination", true);
1327 } else if ( arg.find( "--browser-app=") == 0 ) {
1328 fgSetString("/sim/startup/browser-app", arg.substr(14).c_str());
1329 } else if ( arg == "--disable-hud" ) {
1330 fgSetBool("/sim/hud/visibility", false);
1331 } else if ( arg == "--enable-hud" ) {
1332 fgSetBool("/sim/hud/visibility", true);
1333 } else if ( arg == "--disable-panel" ) {
1334 fgSetBool("/sim/panel/visibility", false);
1335 } else if ( arg == "--enable-panel" ) {
1336 fgSetBool("/sim/panel/visibility", true);
1337 } else if ( arg == "--disable-sound" ) {
1338 fgSetBool("/sim/sound/audible", false);
1339 } else if ( arg == "--enable-sound" ) {
1340 fgSetBool("/sim/sound/audible", true);
1341 } else if ( arg.find( "--airport=") == 0 ) {
1342 fgSetString("/sim/presets/airport-id", arg.substr(10).c_str());
1343 } else if ( arg.find( "--airport-id=") == 0 ) {
1344 fgSetString("/sim/presets/airport-id", arg.substr(13).c_str());
1345 } else if ( arg.find( "--runway=") == 0 ) {
1346 fgSetString("/sim/presets/runway", arg.substr(9).c_str());
1347 } else if ( arg.find( "--offset-distance=") == 0 ) {
1348 fgSetDouble("/sim/presets/offset-distance", atof(arg.substr(18)));
1349 } else if ( arg.find( "--offset-azimuth=") == 0 ) {
1350 fgSetDouble("/sim/presets/offset-azimuth", atof(arg.substr(17)));
1351 } else if ( arg.find( "--lon=" ) == 0 ) {
1352 fgSetDouble("/sim/presets/longitude-deg", parse_degree(arg.substr(6)));
1353 fgSetDouble("/position/longitude-deg", parse_degree(arg.substr(6)));
1354 fgSetString("/sim/presets/airport-id", "");
1355 } else if ( arg.find( "--lat=" ) == 0 ) {
1356 fgSetDouble("/sim/presets/latitude-deg", parse_degree(arg.substr(6)));
1357 fgSetDouble("/position/latitude-deg", parse_degree(arg.substr(6)));
1358 fgSetString("/sim/presets/airport-id", "");
1359 } else if ( arg.find( "--altitude=" ) == 0 ) {
1360 fgSetBool("/sim/presets/onground", false);
1361 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1362 fgSetDouble("/sim/presets/altitude-ft", atof(arg.substr(11)));
1364 fgSetDouble("/sim/presets/altitude-ft",
1365 atof(arg.substr(11)) * SG_METER_TO_FEET);
1366 } else if ( arg.find( "--uBody=" ) == 0 ) {
1367 fgSetString("/sim/presets/speed-set", "UVW");
1368 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1369 fgSetDouble("/sim/presets/uBody-fps", atof(arg.substr(8)));
1371 fgSetDouble("/sim/presets/uBody-fps",
1372 atof(arg.substr(8)) * SG_METER_TO_FEET);
1373 } else if ( arg.find( "--vBody=" ) == 0 ) {
1374 fgSetString("/sim/presets/speed-set", "UVW");
1375 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1376 fgSetDouble("/sim/presets/vBody-fps", atof(arg.substr(8)));
1378 fgSetDouble("/sim/presets/vBody-fps",
1379 atof(arg.substr(8)) * SG_METER_TO_FEET);
1380 } else if ( arg.find( "--wBody=" ) == 0 ) {
1381 fgSetString("/sim/presets/speed-set", "UVW");
1382 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1383 fgSetDouble("/sim/presets/wBody-fps", atof(arg.substr(8)));
1385 fgSetDouble("/sim/presets/wBody-fps",
1386 atof(arg.substr(8)) * SG_METER_TO_FEET);
1387 } else if ( arg.find( "--vNorth=" ) == 0 ) {
1388 fgSetString("/sim/presets/speed-set", "NED");
1389 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1390 fgSetDouble("/sim/presets/speed-north-fps", atof(arg.substr(9)));
1392 fgSetDouble("/sim/presets/speed-north-fps",
1393 atof(arg.substr(9)) * SG_METER_TO_FEET);
1394 } else if ( arg.find( "--vEast=" ) == 0 ) {
1395 fgSetString("/sim/presets/speed-set", "NED");
1396 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1397 fgSetDouble("/sim/presets/speed-east-fps", atof(arg.substr(8)));
1399 fgSetDouble("/sim/presets/speed-east-fps",
1400 atof(arg.substr(8)) * SG_METER_TO_FEET);
1401 } else if ( arg.find( "--vDown=" ) == 0 ) {
1402 fgSetString("/sim/presets/speed-set", "NED");
1403 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1404 fgSetDouble("/sim/presets/speed-down-fps", atof(arg.substr(8)));
1406 fgSetDouble("/sim/presets/speed-down-fps",
1407 atof(arg.substr(8)) * SG_METER_TO_FEET);
1408 } else if ( arg.find( "--vc=" ) == 0) {
1409 // fgSetString("/sim/presets/speed-set", "knots");
1410 // fgSetDouble("/velocities/airspeed-kt", atof(arg.substr(5)));
1411 fgSetString("/sim/presets/speed-set", "knots");
1412 fgSetDouble("/sim/presets/airspeed-kt", atof(arg.substr(5)));
1413 } else if ( arg.find( "--mach=" ) == 0) {
1414 fgSetString("/sim/presets/speed-set", "mach");
1415 fgSetDouble("/sim/presets/mach", atof(arg.substr(7)));
1416 } else if ( arg.find( "--heading=" ) == 0 ) {
1417 fgSetDouble("/sim/presets/heading-deg", atof(arg.substr(10)));
1418 } else if ( arg.find( "--roll=" ) == 0 ) {
1419 fgSetDouble("/sim/presets/roll-deg", atof(arg.substr(7)));
1420 } else if ( arg.find( "--pitch=" ) == 0 ) {
1421 fgSetDouble("/sim/presets/pitch-deg", atof(arg.substr(8)));
1422 } else if ( arg.find( "--glideslope=" ) == 0 ) {
1423 fgSetDouble("/sim/presets/glideslope-deg",
1424 atof(arg.substr(13)));
1425 } else if ( arg.find( "--roc=" ) == 0 ) {
1426 fgSetDouble("/velocities/vertical-speed-fps", atof(arg.substr(6))/60);
1427 } else if ( arg.find( "--fg-root=" ) == 0 ) {
1428 globals->set_fg_root(arg.substr( 10 ));
1429 } else if ( arg.find( "--fg-scenery=" ) == 0 ) {
1430 globals->set_fg_scenery(arg.substr( 13 ));
1431 } else if ( arg.find( "--fdm=" ) == 0 ) {
1432 fgSetString("/sim/flight-model", arg.substr(6).c_str());
1433 } else if ( arg.find( "--aero=" ) == 0 ) {
1434 fgSetString("/sim/aero", arg.substr(7).c_str());
1435 } else if ( arg.find( "--aircraft-dir=" ) == 0 ) {
1436 fgSetString("/sim/aircraft-dir", arg.substr(15).c_str());
1437 } else if ( arg.find( "--show-aircraft") == 0) {
1438 return(FG_OPTIONS_SHOW_AIRCRAFT);
1439 } else if ( arg.find( "--model-hz=" ) == 0 ) {
1440 fgSetInt("/sim/model-hz", atoi(arg.substr(11)));
1441 } else if ( arg.find( "--speed=" ) == 0 ) {
1442 fgSetInt("/sim/speed-up", atoi(arg.substr(8)));
1443 } else if ( arg.find( "--trim") == 0) {
1444 fgSetBool("/sim/presets/trim", true);
1445 } else if ( arg.find( "--notrim") == 0) {
1446 fgSetBool("/sim/presets/trim", false);
1447 } else if ( arg.find( "--on-ground") == 0) {
1448 fgSetBool("/sim/presets/onground", true);
1449 } else if ( arg.find( "--in-air") == 0) {
1450 fgSetBool("/sim/presets/onground", false);
1451 } else if ( arg == "--fog-disable" ) {
1452 fgSetString("/sim/rendering/fog", "disabled");
1453 } else if ( arg == "--fog-fastest" ) {
1454 fgSetString("/sim/rendering/fog", "fastest");
1455 } else if ( arg == "--fog-nicest" ) {
1456 fgSetString("/sim/fog", "nicest");
1457 } else if ( arg == "--disable-distance-attenuation" ) {
1458 fgSetBool("/environment/distance-attenuation", false);
1459 } else if ( arg == "--enable-distance-attenuation" ) {
1460 fgSetBool("/environment/distance-attenuation", true);
1461 } else if ( arg == "--disable-clouds" ) {
1462 fgSetBool("/environment/clouds/status", false);
1463 } else if ( arg == "--enable-clouds" ) {
1464 fgSetBool("/environment/clouds/status", true);
1465 #ifdef FG_USE_CLOUDS_3D
1466 } else if ( arg == "--disable-clouds3d" ) {
1467 fgSetBool("/sim/rendering/clouds3d", false);
1468 } else if ( arg == "--enable-clouds3d" ) {
1469 fgSetBool("/sim/rendering/clouds3d", true);
1471 } else if ( arg.find( "--fov=" ) == 0 ) {
1472 parse_fov( arg.substr(6) );
1473 } else if ( arg == "--disable-fullscreen" ) {
1474 fgSetBool("/sim/startup/fullscreen", false);
1475 } else if ( arg== "--enable-fullscreen") {
1476 fgSetBool("/sim/startup/fullscreen", true);
1477 } else if ( arg == "--shading-flat") {
1478 fgSetBool("/sim/rendering/shading", false);
1479 } else if ( arg == "--shading-smooth") {
1480 fgSetBool("/sim/rendering/shading", true);
1481 } else if ( arg == "--disable-skyblend") {
1482 fgSetBool("/sim/rendering/skyblend", false);
1483 } else if ( arg== "--enable-skyblend" ) {
1484 fgSetBool("/sim/rendering/skyblend", true);
1485 } else if ( arg == "--disable-textures" ) {
1486 fgSetBool("/sim/rendering/textures", false);
1487 } else if ( arg == "--enable-textures" ) {
1488 fgSetBool("/sim/rendering/textures", true);
1489 } else if ( arg == "--disable-wireframe" ) {
1490 fgSetBool("/sim/rendering/wireframe", false);
1491 } else if ( arg == "--enable-wireframe" ) {
1492 fgSetBool("/sim/rendering/wireframe", true);
1493 } else if ( arg.find( "--geometry=" ) == 0 ) {
1494 bool geometry_ok = true;
1495 int xsize = 0, ysize = 0;
1496 string geometry = arg.substr( 11 );
1497 string::size_type i = geometry.find('x');
1499 if (i != string::npos) {
1500 xsize = atoi(geometry.substr(0, i));
1501 ysize = atoi(geometry.substr(i+1));
1503 geometry_ok = false;
1506 if ( xsize <= 0 || ysize <= 0 ) {
1509 geometry_ok = false;
1512 if ( !geometry_ok ) {
1513 SG_LOG( SG_GENERAL, SG_ALERT, "Unknown geometry: " << geometry );
1514 SG_LOG( SG_GENERAL, SG_ALERT,
1515 "Setting geometry to " << xsize << 'x' << ysize << '\n');
1517 SG_LOG( SG_GENERAL, SG_INFO,
1518 "Setting geometry to " << xsize << 'x' << ysize << '\n');
1519 fgSetInt("/sim/startup/xsize", xsize);
1520 fgSetInt("/sim/startup/ysize", ysize);
1522 } else if ( arg.find( "--bpp=" ) == 0 ) {
1523 string bits_per_pix = arg.substr( 6 );
1524 if ( bits_per_pix == "16" ) {
1525 fgSetInt("/sim/rendering/bits-per-pixel", 16);
1526 } else if ( bits_per_pix == "24" ) {
1527 fgSetInt("/sim/rendering/bits-per-pixel", 24);
1528 } else if ( bits_per_pix == "32" ) {
1529 fgSetInt("/sim/rendering/bits-per-pixel", 32);
1531 SG_LOG(SG_GENERAL, SG_ALERT, "Unsupported bpp " << bits_per_pix);
1533 } else if ( arg == "--units-feet" ) {
1534 fgSetString("/sim/startup/units", "feet");
1535 } else if ( arg == "--units-meters" ) {
1536 fgSetString("/sim/startup/units", "meters");
1537 } else if ( arg.find( "--time-offset" ) == 0 ) {
1538 fgSetInt("/sim/startup/time-offset",
1539 parse_time_offset( (arg.substr(14)) ));
1540 fgSetString("/sim/startup/time-offset-type", "system-offset");
1541 } else if ( arg.find( "--time-match-real") == 0 ) {
1542 fgSetString("/sim/startup/time-offset-type", "system-offset");
1543 } else if ( arg.find( "--time-match-local") == 0 ) {
1544 fgSetString("/sim/startup/time-offset-type", "latitude-offset");
1545 } else if ( arg.find( "--start-date-sys=") == 0 ) {
1546 fgSetInt("/sim/startup/time-offset", parse_date((arg.substr(17))));
1547 fgSetString("/sim/startup/time-offset-type", "system");
1548 } else if ( arg.find( "--start-date-lat=") == 0 ) {
1549 fgSetInt("/sim/startup/time-offset", parse_date((arg.substr(17))));
1550 fgSetString("/sim/startup/time-offset-type", "latitude");
1551 } else if ( arg.find( "--start-date-gmt=") == 0 ) {
1552 fgSetInt("/sim/startup/time-offset", parse_date((arg.substr(17))));
1553 fgSetString("/sim/startup/time-offset-type", "gmt");
1554 } else if ( arg == "--hud-tris" ) {
1555 fgSetString("/sim/hud/frame-stat-type", "tris");
1556 } else if ( arg == "--hud-culled" ) {
1557 fgSetString("/sim/hud/frame-stat-type", "culled");
1558 } else if ( arg.find( "--atc610x" ) == 0 ) {
1559 add_channel( "atc610x", "dummy" );
1560 } else if ( arg.find( "--atlas=" ) == 0 ) {
1561 add_channel( "atlas", arg.substr(8) );
1562 } else if ( arg.find( "--httpd=" ) == 0 ) {
1563 add_channel( "httpd", arg.substr(8) );
1564 #ifdef FG_JPEG_SERVER
1565 } else if ( arg.find( "--jpg-httpd=" ) == 0 ) {
1566 add_channel( "jpg-httpd", arg.substr(12) );
1568 } else if ( arg.find( "--native=" ) == 0 ) {
1569 add_channel( "native", arg.substr(9) );
1570 } else if ( arg.find( "--native-ctrls=" ) == 0 ) {
1571 add_channel( "native_ctrls", arg.substr(15) );
1572 } else if ( arg.find( "--native-fdm=" ) == 0 ) {
1573 add_channel( "native_fdm", arg.substr(13) );
1574 } else if ( arg.find( "--native-gui=" ) == 0 ) {
1575 add_channel( "native_gui", arg.substr(13) );
1576 } else if ( arg.find( "--opengc=" ) == 0 ) {
1578 // cout << "Adding channel for OpenGC Display" << endl; cin >> stop;
1579 add_channel( "opengc", arg.substr(9) );
1580 } else if ( arg.find( "--garmin=" ) == 0 ) {
1581 add_channel( "garmin", arg.substr(9) );
1582 } else if ( arg.find( "--nmea=" ) == 0 ) {
1583 add_channel( "nmea", arg.substr(7) );
1584 } else if ( arg.find( "--props=" ) == 0 ) {
1585 add_channel( "props", arg.substr(8) );
1586 } else if ( arg.find( "--telnet=" ) == 0 ) {
1587 add_channel( "telnet", arg.substr(9) );
1588 } else if ( arg.find( "--pve=" ) == 0 ) {
1589 add_channel( "pve", arg.substr(6) );
1590 } else if ( arg.find( "--ray=" ) == 0 ) {
1591 add_channel( "ray", arg.substr(6) );
1592 } else if ( arg.find( "--rul=" ) == 0 ) {
1593 add_channel( "rul", arg.substr(6) );
1594 } else if ( arg.find( "--joyclient=" ) == 0 ) {
1595 add_channel( "joyclient", arg.substr(12) );
1596 #ifdef FG_NETWORK_OLK
1597 } else if ( arg == "--disable-network-olk" ) {
1598 fgSetBool("/sim/networking/olk", false);
1599 } else if ( arg== "--enable-network-olk") {
1600 fgSetBool("/sim/networking/olk", true);
1601 } else if ( arg == "--net-hud" ) {
1602 fgSetBool("/sim/hud/net-display", true);
1603 net_hud_display = 1; // FIXME
1604 } else if ( arg.find( "--net-id=") == 0 ) {
1605 fgSetString("sim/networking/call-sign", arg.substr(9).c_str());
1607 } else if ( arg.find( "--prop:" ) == 0 ) {
1608 string assign = arg.substr(7);
1609 string::size_type pos = assign.find('=');
1610 if ( pos == arg.npos || pos == 0 ) {
1611 SG_LOG( SG_GENERAL, SG_ALERT, "Bad property assignment: " << arg );
1612 return FG_OPTIONS_ERROR;
1614 string name = assign.substr(0, pos);
1615 string value = assign.substr(pos + 1);
1616 fgSetString(name.c_str(), value.c_str());
1617 // SG_LOG(SG_GENERAL, SG_INFO, "Setting default value of property "
1618 // << name << " to \"" << value << '"');
1619 } else if ( arg.find("--trace-read=") == 0) {
1620 string name = arg.substr(13);
1621 SG_LOG(SG_GENERAL, SG_INFO, "Tracing reads for property " << name);
1622 fgGetNode(name.c_str(), true)
1623 ->setAttribute(SGPropertyNode::TRACE_READ, true);
1624 } else if ( arg.find("--trace-write=") == 0) {
1625 string name = arg.substr(14);
1626 SG_LOG(SG_GENERAL, SG_INFO, "Tracing writes for property " << name);
1627 fgGetNode(name.c_str(), true)
1628 ->setAttribute(SGPropertyNode::TRACE_WRITE, true);
1629 } else if ( arg.find( "--view-offset=" ) == 0 ) {
1630 // $$$ begin - added VS Renganathan, 14 Oct 2K
1631 // for multi-window outside window imagery
1632 string woffset = arg.substr( 14 );
1633 double default_view_offset = 0.0;
1634 if ( woffset == "LEFT" ) {
1635 default_view_offset = SGD_PI * 0.25;
1636 } else if ( woffset == "RIGHT" ) {
1637 default_view_offset = SGD_PI * 1.75;
1638 } else if ( woffset == "CENTER" ) {
1639 default_view_offset = 0.00;
1641 default_view_offset = atof( woffset.c_str() ) * SGD_DEGREES_TO_RADIANS;
1643 /* apparently not used (CLO, 11 Jun 2002)
1644 FGViewer *pilot_view =
1645 (FGViewer *)globals->get_viewmgr()->get_view( 0 ); */
1646 // this will work without calls to the viewer...
1647 fgSetDouble( "/sim/current-view/heading-offset-deg",
1648 default_view_offset * SGD_RADIANS_TO_DEGREES );
1649 // $$$ end - added VS Renganathan, 14 Oct 2K
1650 } else if ( arg.find( "--visibility=" ) == 0 ) {
1651 fgSetDouble("/environment/visibility-m", atof(arg.substr(13)));
1652 } else if ( arg.find( "--visibility-miles=" ) == 0 ) {
1653 double visibility = atof(arg.substr(19)) * 5280.0 * SG_FEET_TO_METER;
1654 fgSetDouble("/environment/visibility-m", visibility);
1655 } else if ( arg.find( "--random-wind" ) == 0 ) {
1656 double min_hdg = sg_random() * 360.0;
1657 double max_hdg = min_hdg + (20 - sqrt(sg_random() * 400));
1658 double speed = 40 - sqrt(sg_random() * 1600.0);
1659 double gust = speed + (10 - sqrt(sg_random() * 100));
1660 setup_wind(min_hdg, max_hdg, speed, gust);
1661 } else if ( arg.find( "--wind=" ) == 0 ) {
1662 double min_hdg, max_hdg, speed, gust;
1663 if (!parse_wind(arg.substr(7), &min_hdg, &max_hdg, &speed, &gust)) {
1664 SG_LOG( SG_GENERAL, SG_ALERT, "bad wind value " << arg.substr(7) );
1665 return FG_OPTIONS_ERROR;
1667 setup_wind(min_hdg, max_hdg, speed, gust);
1668 } else if ( arg.find( "--wp=" ) == 0 ) {
1669 parse_wp( arg.substr( 5 ) );
1670 } else if ( arg.find( "--flight-plan=") == 0) {
1671 parse_flightplan ( arg.substr (14) );
1672 } else if ( arg.find( "--config=" ) == 0 ) {
1673 string file = arg.substr(9);
1675 readProperties(file, globals->get_props());
1676 } catch (const sg_exception &e) {
1677 string message = "Error loading config file: ";
1678 message += e.getFormattedMessage();
1679 SG_LOG(SG_INPUT, SG_ALERT, message);
1682 } else if ( arg.find( "--aircraft=" ) == 0 ) {
1683 fgSetString("/sim/aircraft", arg.substr(11).c_str());
1685 SG_LOG( SG_GENERAL, SG_ALERT, "Unknown option '" << arg << "'" );
1686 return FG_OPTIONS_ERROR;
1690 return FG_OPTIONS_OK;
1694 // Parse the command line options
1696 fgParseArgs (int argc, char **argv)
1698 bool in_options = true;
1699 bool verbose = false;
1702 SG_LOG(SG_GENERAL, SG_INFO, "Processing command line arguments");
1704 for (int i = 1; i < argc; i++) {
1705 string arg = argv[i];
1707 if (in_options && (arg.find('-') == 0)) {
1711 int result = parse_option(arg);
1712 if ((result == FG_OPTIONS_HELP) || (result == FG_OPTIONS_ERROR))
1715 else if (result == FG_OPTIONS_VERBOSE_HELP)
1718 else if (result == FG_OPTIONS_SHOW_AIRCRAFT) {
1725 SG_LOG(SG_GENERAL, SG_INFO,
1726 "Reading command-line property file " << arg);
1727 readProperties(arg, globals->get_props());
1736 SG_LOG(SG_GENERAL, SG_INFO, "Finished command line arguments");
1740 // Parse config file options
1742 fgParseOptions (const string& path) {
1743 sg_gzifstream in( path );
1744 if ( !in.is_open() ) {
1748 SG_LOG( SG_GENERAL, SG_INFO, "Processing config file: " << path );
1752 while ( ! in.eof() ) {
1755 while ( in.get(c) && c != '\0' ) {
1760 #if defined( macintosh )
1761 getline( in, line, '\r' );
1763 getline( in, line, '\n' );
1766 // catch extraneous (DOS) line ending character
1767 if ( line[line.length() - 1] < 32 ) {
1768 line = line.substr( 0, line.length()-1 );
1771 if ( parse_option( line ) == FG_OPTIONS_ERROR ) {
1772 cerr << endl << "Config file parse error: " << path << " '"
1773 << line << "'" << endl;
1782 // Print usage message
1784 fgUsage (bool verbose)
1786 SGPropertyNode *locale = globals->get_locale();
1788 SGPropertyNode options_root;
1793 fgLoadProps("options.xml", &options_root);
1794 } catch (const sg_exception &ex) {
1795 cout << "Unable to read the help file." << endl;
1796 cout << "Make sure the file options.xml is located in the FlightGear base directory," << endl;
1797 cout << "and the location of the base directory is specified by setting $FG_ROOT or" << endl;
1798 cout << "by adding --fg-root=path as a program argument." << endl;
1803 SGPropertyNode *options = options_root.getNode("options");
1805 SG_LOG( SG_GENERAL, SG_ALERT,
1806 "Error reading options.xml: <options> directive not found." );
1810 SGPropertyNode *usage = locale->getNode(options->getStringValue("usage"));
1812 cout << "Usage: " << usage->getStringValue() << endl;
1815 vector<SGPropertyNode_ptr>section = options->getChildren("section");
1816 for (unsigned int j = 0; j < section.size(); j++) {
1819 vector<SGPropertyNode_ptr>option = section[j]->getChildren("option");
1820 for (unsigned int k = 0; k < option.size(); k++) {
1822 SGPropertyNode *name = option[k]->getNode("name");
1823 SGPropertyNode *short_name = option[k]->getNode("short");
1824 SGPropertyNode *key = option[k]->getNode("key");
1825 SGPropertyNode *arg = option[k]->getNode("arg");
1826 bool brief = option[k]->getNode("brief");
1828 if ((brief || verbose) && name) {
1829 string tmp = name->getStringValue();
1833 tmp.append(key->getStringValue());
1837 tmp.append(arg->getStringValue());
1841 tmp.append(short_name->getStringValue());
1845 if (tmp.size() <= 25) {
1846 snprintf(cstr, 96, " --%-27s", tmp.c_str());
1848 snprintf(cstr, 96, "\n --%s\n%32c", tmp.c_str(), ' ');
1851 // There may be more than one <description> tag assosiated
1855 vector<SGPropertyNode_ptr>desc =
1856 option[k]->getChildren("description");
1858 if (desc.size() > 0) {
1859 for ( unsigned int l = 0; l < desc.size(); l++) {
1861 // There may be more than one translation line.
1863 string t = desc[l]->getStringValue();
1864 SGPropertyNode *n = locale->getNode("strings");
1865 vector<SGPropertyNode_ptr>trans_desc =
1866 n->getChildren(t.substr(8).c_str());
1868 for ( unsigned int m = 0; m < trans_desc.size(); m++ ) {
1869 string t_str = trans_desc[m]->getStringValue();
1871 if ((m > 0) || ((l > 0) && m == 0)) {
1872 snprintf(cstr, 96, "%32c", ' ');
1877 // If the string is too large to fit on the screen,
1878 // then split it up in several pieces.
1880 while ( t_str.size() > 47 ) {
1882 unsigned int m = t_str.rfind(' ', 47);
1883 msg += t_str.substr(0, m);
1884 snprintf(cstr, 96, "\n%32c", ' ');
1887 t_str.erase(t_str.begin(), t_str.begin() + m + 1);
1889 msg += t_str + '\n';
1896 SGPropertyNode *name =
1897 locale->getNode(section[j]->getStringValue("name"));
1899 if (!msg.empty() && name) {
1900 cout << endl << name->getStringValue() << ":" << endl;
1908 cout << "For a complete list of options use --help --verbose" << endl;
1912 // Show available aircraft types
1913 void fgShowAircraft(void) {
1914 vector<string> aircraft;
1916 SGPath path( globals->get_fg_root() );
1917 path.append("Aircraft");
1922 dirp = ulOpenDir(path.c_str());
1924 cerr << "Unable to open aircraft directory." << endl;
1928 while ((dire = ulReadDir(dirp)) != NULL) {
1931 if ((ptr = strstr(dire->d_name, "-set.xml")) && ptr[8] == '\0' ) {
1932 SGPath afile = path;
1933 afile.append(dire->d_name);
1937 SGPropertyNode root;
1939 readProperties(afile.str(), &root);
1944 SGPropertyNode *desc = NULL;
1945 SGPropertyNode *node = root.getNode("sim");
1947 desc = node->getNode("description");
1951 if (strlen(dire->d_name) <= 27)
1952 snprintf(cstr, 96, " %-27s %s", dire->d_name,
1953 (desc) ? desc->getStringValue() : "" );
1956 snprintf(cstr, 96, " %-27s\n%32c%s", dire->d_name, ' ',
1957 (desc) ? desc->getStringValue() : "" );
1959 aircraft.push_back(cstr);
1963 sort(aircraft.begin(), aircraft.end());
1964 cout << "Available aircraft:" << endl;
1965 for ( unsigned int i = 0; i < aircraft.size(); i++ ) {
1966 cout << aircraft[i] << endl;