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;
627 fgOptLon( const char *arg )
629 fgSetDouble("/sim/presets/longitude-deg", parse_degree( arg ));
630 fgSetDouble("/position/longitude-deg", parse_degree( arg ));
631 fgSetString("/sim/presets/airport-id", "");
632 return FG_OPTIONS_OK;
636 fgOptLat( const char *arg )
638 fgSetDouble("/sim/presets/latitude-deg", parse_degree( arg ));
639 fgSetDouble("/position/latitude-deg", parse_degree( arg ));
640 fgSetString("/sim/presets/airport-id", "");
641 return FG_OPTIONS_OK;
645 fgOptAltitude( const char *arg )
647 fgSetBool("/sim/presets/onground", false);
648 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
649 fgSetDouble("/sim/presets/altitude-ft", atof( arg ));
651 fgSetDouble("/sim/presets/altitude-ft",
652 atof( arg ) * SG_METER_TO_FEET);
653 return FG_OPTIONS_OK;
657 fgOptUBody( const char *arg )
659 fgSetString("/sim/presets/speed-set", "UVW");
660 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
661 fgSetDouble("/sim/presets/uBody-fps", atof( arg ));
663 fgSetDouble("/sim/presets/uBody-fps",
664 atof( arg ) * SG_METER_TO_FEET);
665 return FG_OPTIONS_OK;
669 fgOptVBody( const char *arg )
671 fgSetString("/sim/presets/speed-set", "UVW");
672 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
673 fgSetDouble("/sim/presets/vBody-fps", atof( arg ));
675 fgSetDouble("/sim/presets/vBody-fps",
676 atof( arg ) * SG_METER_TO_FEET);
677 return FG_OPTIONS_OK;
681 fgOptWBody( const char *arg )
683 fgSetString("/sim/presets/speed-set", "UVW");
684 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
685 fgSetDouble("/sim/presets/wBody-fps", atof(arg));
687 fgSetDouble("/sim/presets/wBody-fps",
688 atof(arg) * SG_METER_TO_FEET);
689 return FG_OPTIONS_OK;
693 fgOptVNorth( const char *arg )
695 fgSetString("/sim/presets/speed-set", "NED");
696 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
697 fgSetDouble("/sim/presets/speed-north-fps", atof( arg ));
699 fgSetDouble("/sim/presets/speed-north-fps",
700 atof( arg ) * SG_METER_TO_FEET);
701 return FG_OPTIONS_OK;
705 fgOptVEast( const char *arg )
707 fgSetString("/sim/presets/speed-set", "NED");
708 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
709 fgSetDouble("/sim/presets/speed-east-fps", atof(arg));
711 fgSetDouble("/sim/presets/speed-east-fps",
712 atof(arg) * SG_METER_TO_FEET);
713 return FG_OPTIONS_OK;
717 fgOptVDown( const char *arg )
719 fgSetString("/sim/presets/speed-set", "NED");
720 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
721 fgSetDouble("/sim/presets/speed-down-fps", atof(arg));
723 fgSetDouble("/sim/presets/speed-down-fps",
724 atof(arg) * SG_METER_TO_FEET);
725 return FG_OPTIONS_OK;
729 fgOptVc( const char *arg )
731 // fgSetString("/sim/presets/speed-set", "knots");
732 // fgSetDouble("/velocities/airspeed-kt", atof(arg.substr(5)));
733 fgSetString("/sim/presets/speed-set", "knots");
734 fgSetDouble("/sim/presets/airspeed-kt", atof(arg));
735 return FG_OPTIONS_OK;
739 fgOptMach( const char *arg )
741 fgSetString("/sim/presets/speed-set", "mach");
742 fgSetDouble("/sim/presets/mach", atof(arg));
743 return FG_OPTIONS_OK;
747 fgOptRoc( const char *arg )
749 fgSetDouble("/velocities/vertical-speed-fps", atof(arg)/60);
750 return FG_OPTIONS_OK;
754 fgOptFgRoot( const char *arg )
756 globals->set_fg_root(arg);
757 return FG_OPTIONS_OK;
761 fgOptFgScenery( const char *arg )
763 globals->set_fg_scenery(arg);
764 return FG_OPTIONS_OK;
768 fgOptFov( const char *arg )
771 return FG_OPTIONS_OK;
775 fgOptGeometry( const char *arg )
777 bool geometry_ok = true;
778 int xsize = 0, ysize = 0;
779 string geometry = arg;
780 string::size_type i = geometry.find('x');
782 if (i != string::npos) {
783 xsize = atoi(geometry.substr(0, i));
784 ysize = atoi(geometry.substr(i+1));
789 if ( xsize <= 0 || ysize <= 0 ) {
795 if ( !geometry_ok ) {
796 SG_LOG( SG_GENERAL, SG_ALERT, "Unknown geometry: " << geometry );
797 SG_LOG( SG_GENERAL, SG_ALERT,
798 "Setting geometry to " << xsize << 'x' << ysize << '\n');
800 SG_LOG( SG_GENERAL, SG_INFO,
801 "Setting geometry to " << xsize << 'x' << ysize << '\n');
802 fgSetInt("/sim/startup/xsize", xsize);
803 fgSetInt("/sim/startup/ysize", ysize);
805 return FG_OPTIONS_OK;
809 fgOptBpp( const char *arg )
811 string bits_per_pix = arg;
812 if ( bits_per_pix == "16" ) {
813 fgSetInt("/sim/rendering/bits-per-pixel", 16);
814 } else if ( bits_per_pix == "24" ) {
815 fgSetInt("/sim/rendering/bits-per-pixel", 24);
816 } else if ( bits_per_pix == "32" ) {
817 fgSetInt("/sim/rendering/bits-per-pixel", 32);
819 SG_LOG(SG_GENERAL, SG_ALERT, "Unsupported bpp " << bits_per_pix);
821 return FG_OPTIONS_OK;
825 fgOptTimeOffset( const char *arg )
827 fgSetInt("/sim/startup/time-offset",
828 parse_time_offset( arg ));
829 fgSetString("/sim/startup/time-offset-type", "system-offset");
830 return FG_OPTIONS_OK;
834 fgOptStartDateSys( const char *arg )
836 fgSetInt("/sim/startup/time-offset", parse_date( arg ) );
837 fgSetString("/sim/startup/time-offset-type", "system");
838 return FG_OPTIONS_OK;
842 fgOptStartDateLat( const char *arg )
844 fgSetInt("/sim/startup/time-offset", parse_date( arg ) );
845 fgSetString("/sim/startup/time-offset-type", "latitude");
846 return FG_OPTIONS_OK;
850 fgOptStartDateGmt( const char *arg )
852 fgSetInt("/sim/startup/time-offset", parse_date( arg ) );
853 fgSetString("/sim/startup/time-offset-type", "gmt");
854 return FG_OPTIONS_OK;
857 #ifdef FG_NETWORK_OLK
859 fgOptNetHud( const char *arg )
861 fgSetBool("/sim/hud/net-display", true);
862 net_hud_display = 1; // FIXME
863 return FG_OPTIONS_OK;
868 fgOptTraceRead( const char *arg )
871 SG_LOG(SG_GENERAL, SG_INFO, "Tracing reads for property " << name);
872 fgGetNode(name.c_str(), true)
873 ->setAttribute(SGPropertyNode::TRACE_READ, true);
874 return FG_OPTIONS_OK;
878 fgOptTraceWrite( const char *arg )
881 SG_LOG(SG_GENERAL, SG_INFO, "Tracing writes for property " << name);
882 fgGetNode(name.c_str(), true)
883 ->setAttribute(SGPropertyNode::TRACE_WRITE, true);
884 return FG_OPTIONS_OK;
888 fgOptViewOffset( const char *arg )
890 // $$$ begin - added VS Renganathan, 14 Oct 2K
891 // for multi-window outside window imagery
892 string woffset = arg;
893 double default_view_offset = 0.0;
894 if ( woffset == "LEFT" ) {
895 default_view_offset = SGD_PI * 0.25;
896 } else if ( woffset == "RIGHT" ) {
897 default_view_offset = SGD_PI * 1.75;
898 } else if ( woffset == "CENTER" ) {
899 default_view_offset = 0.00;
901 default_view_offset = atof( woffset.c_str() ) * SGD_DEGREES_TO_RADIANS;
903 /* apparently not used (CLO, 11 Jun 2002)
904 FGViewer *pilot_view =
905 (FGViewer *)globals->get_viewmgr()->get_view( 0 ); */
906 // this will work without calls to the viewer...
907 fgSetDouble( "/sim/current-view/heading-offset-deg",
908 default_view_offset * SGD_RADIANS_TO_DEGREES );
909 // $$$ end - added VS Renganathan, 14 Oct 2K
910 return FG_OPTIONS_OK;
914 fgOptVisibilityMiles( const char *arg )
916 double visibility = atof( arg ) * 5280.0 * SG_FEET_TO_METER;
917 fgSetDouble("/environment/visibility-m", visibility);
918 return FG_OPTIONS_OK;
922 fgOptRandomWind( const char *arg )
924 double min_hdg = sg_random() * 360.0;
925 double max_hdg = min_hdg + (20 - sqrt(sg_random() * 400));
926 double speed = 40 - sqrt(sg_random() * 1600.0);
927 double gust = speed + (10 - sqrt(sg_random() * 100));
928 setup_wind(min_hdg, max_hdg, speed, gust);
929 return FG_OPTIONS_OK;
933 fgOptWind( const char *arg )
935 double min_hdg, max_hdg, speed, gust;
936 if (!parse_wind( arg, &min_hdg, &max_hdg, &speed, &gust)) {
937 SG_LOG( SG_GENERAL, SG_ALERT, "bad wind value " << arg );
938 return FG_OPTIONS_ERROR;
940 setup_wind(min_hdg, max_hdg, speed, gust);
941 return FG_OPTIONS_OK;
945 fgOptWp( const char *arg )
948 return FG_OPTIONS_OK;
952 fgOptFlightPlan( const char *arg )
954 parse_flightplan ( arg );
955 return FG_OPTIONS_OK;
959 fgOptConfig( const char *arg )
963 readProperties(file, globals->get_props());
964 } catch (const sg_exception &e) {
965 string message = "Error loading config file: ";
966 message += e.getFormattedMessage();
967 SG_LOG(SG_INPUT, SG_ALERT, message);
970 return FG_OPTIONS_OK;
973 static map<string,size_t> fgOptionMap;
975 enum OptionType { OPTION_BOOL, OPTION_STRING, OPTION_DOUBLE, OPTION_INT, OPTION_CHANNEL, OPTION_FUNC };
979 enum OptionType type;
983 int (*func)( const char * );
984 } fgOptionArray[] = {
986 {"language", true, OPTION_FUNC, "", false, "", fgOptLanguage },
987 {"disable-game-mode", false, OPTION_BOOL, "/sim/startup/game-mode", false, "", 0 },
988 {"enable-game-mode", false, OPTION_BOOL, "/sim/startup/game-mode", true, "", 0 },
989 {"disable-splash-screen", false, OPTION_BOOL, "/sim/startup/splash-screen", false, "", 0 },
990 {"enable-splash-screen", false, OPTION_BOOL, "/sim/startup/splash-screen", true, "", 0 },
991 {"disable-intro-music", false, OPTION_BOOL, "/sim/startup/intro-music", false, "", 0 },
992 {"enable-intro-music", false, OPTION_BOOL, "/sim/startup/intro-music", true, "", 0 },
993 {"disable-mouse-pointer", false, OPTION_STRING, "/sim/startup/mouse-pointer", false, "disabled", 0 },
994 {"enable-mouse-pointer", false, OPTION_STRING, "/sim/startup/mouse-pointer", false, "enabled", 0 },
995 {"disable-random-objects", false, OPTION_BOOL, "/sim/rendering/random-objects", false, "", 0 },
996 {"enable-random-objects", false, OPTION_BOOL, "/sim/rendering/random-objects", true, "", 0 },
997 {"disable-freeze", false, OPTION_BOOL, "/sim/freeze/master", false, "", 0 },
998 {"enable-freeze", false, OPTION_BOOL, "/sim/freeze/master", true, "", 0 },
999 {"disable-fuel-freeze", false, OPTION_BOOL, "/sim/freeze/fuel", false, "", 0 },
1000 {"enable-fuel-freeze", false, OPTION_BOOL, "/sim/freeze/fuel", true, "", 0 },
1001 {"disable-clock-freeze", false, OPTION_BOOL, "/sim/freeze/clock", false, "", 0 },
1002 {"enable-clock-freeze", false, OPTION_BOOL, "/sim/freeze/clock", true, "", 0 },
1003 {"disable-anti-alias-hud", false, OPTION_BOOL, "/sim/hud/antialiased", false, "", 0 },
1004 {"enable-anti-alias-hud", false, OPTION_BOOL, "/sim/hud/antialiased", true, "", 0 },
1005 {"control", true, OPTION_STRING, "/sim/control-mode", false, "", 0 },
1006 {"disable-auto-coordination", false, OPTION_BOOL, "/sim/auto-coordination", false, "", 0 },
1007 {"enable-auto-coordination", false, OPTION_BOOL, "/sim/auto-coordination", true, "", 0 },
1008 {"browser-app", true, OPTION_STRING, "/sim/startup/browser-app", false, "", 0 },
1009 {"disable-hud", false, OPTION_BOOL, "/sim/hud/visibility", false, "", 0 },
1010 {"enable-hud", false, OPTION_BOOL, "/sim/hud/visibility", true, "", 0 },
1011 {"disable-panel", false, OPTION_BOOL, "/sim/panel/visibility", false, "", 0 },
1012 {"enable-panel", false, OPTION_BOOL, "/sim/panel/visibility", true, "", 0 },
1013 {"disable-sound", false, OPTION_BOOL, "/sim/sound/audible", false, "", 0 },
1014 {"enable-sound", false, OPTION_BOOL, "/sim/sound/audible", true, "", 0 },
1015 {"airport", true, OPTION_STRING, "/sim/presets/airport-id", false, "", 0 },
1016 {"airport-id", true, OPTION_STRING, "/sim/presets/airport-id", false, "", 0 },
1017 {"runway", true, OPTION_STRING, "/sim/presets/runway", false, "", 0 },
1018 {"offset-distance", true, OPTION_DOUBLE, "/sim/presets/offset-distance", false, "", 0 },
1019 {"offset-azimuth", true, OPTION_DOUBLE, "/sim/presets/offset-azimuth", false, "", 0 },
1020 {"lon", true, OPTION_FUNC, "", false, "", fgOptLon },
1021 {"lat", true, OPTION_FUNC, "", false, "", fgOptLat },
1022 {"altitude", true, OPTION_FUNC, "", false, "", fgOptAltitude },
1023 {"uBody", true, OPTION_FUNC, "", false, "", fgOptUBody },
1024 {"vBody", true, OPTION_FUNC, "", false, "", fgOptVBody },
1025 {"wBody", true, OPTION_FUNC, "", false, "", fgOptWBody },
1026 {"vNorth", true, OPTION_FUNC, "", false, "", fgOptVNorth },
1027 {"vEast", true, OPTION_FUNC, "", false, "", fgOptVEast },
1028 {"vDown", true, OPTION_FUNC, "", false, "", fgOptVDown },
1029 {"vc", true, OPTION_FUNC, "", false, "", fgOptVc },
1030 {"mach", true, OPTION_FUNC, "", false, "", fgOptMach },
1031 {"heading", true, OPTION_DOUBLE, "/sim/presets/heading-deg", false, "", 0 },
1032 {"roll", true, OPTION_DOUBLE, "/sim/presets/roll-deg", false, "", 0 },
1033 {"pitch", true, OPTION_DOUBLE, "/sim/presets/pitch-deg", false, "", 0 },
1034 {"glideslope", true, OPTION_DOUBLE, "/sim/presets/glideslope-deg", false, "", 0 },
1035 {"roc", true, OPTION_FUNC, "", false, "", fgOptRoc },
1036 {"fg-root", true, OPTION_FUNC, "", false, "", fgOptFgRoot },
1037 {"fg-scenery", true, OPTION_FUNC, "", false, "", fgOptFgScenery },
1038 {"fdm", true, OPTION_STRING, "/sim/flight-model", false, "", 0 },
1039 {"aero", true, OPTION_STRING, "/sim/aero", false, "", 0 },
1040 {"aircraft-dir", true, OPTION_STRING, "/sim/aircraft-dir", false, "", 0 },
1041 {"model-hz", true, OPTION_INT, "/sim/model-hz", false, "", 0 },
1042 {"speed", true, OPTION_INT, "/sim/speed-up", false, "", 0 },
1043 {"trim", false, OPTION_BOOL, "/sim/presets/trim", true, "", 0 },
1044 {"notrim", false, OPTION_BOOL, "/sim/presets/trim", false, "", 0 },
1045 {"on-ground", false, OPTION_BOOL, "/sim/presets/onground", true, "", 0 },
1046 {"in-air", false, OPTION_BOOL, "/sim/presets/onground", false, "", 0 },
1047 {"fog-disable", false, OPTION_STRING, "/sim/rendering/fog", false, "disabled", 0 },
1048 {"fog-fastest", false, OPTION_STRING, "/sim/rendering/fog", false, "fastest", 0 },
1049 {"fog-nicest", false, OPTION_STRING, "/sim/fog", false, "nicest", 0 },
1050 {"disable-distance-attenuation", false, OPTION_BOOL, "/environment/distance-attenuation", false, "", 0 },
1051 {"enable-distance-attenuation", false, OPTION_BOOL, "/environment/distance-attenuation", true, "", 0 },
1052 {"disable-clouds", false, OPTION_BOOL, "/environment/clouds/status", false, "", 0 },
1053 {"enable-clouds", false, OPTION_BOOL, "/environment/clouds/status", true, "", 0 },
1054 #ifdef FG_USE_CLOUDS_3D
1055 {"disable-clouds3d", false, OPTION_BOOL, "/sim/rendering/clouds3d", false, "", 0 },
1056 {"enable-clouds3d", false, OPTION_BOOL, "/sim/rendering/clouds3d", true, "", 0 },
1058 {"fov", true, OPTION_FUNC, "", false, "", fgOptFov },
1059 {"disable-fullscreen", false, OPTION_BOOL, "/sim/startup/fullscreen", false, "", 0 },
1060 {"enable-fullscreen", false, OPTION_BOOL, "/sim/startup/fullscreen", true, "", 0 },
1061 {"shading-flat", false, OPTION_BOOL, "/sim/rendering/shading", false, "", 0 },
1062 {"shading-smooth", false, OPTION_BOOL, "/sim/rendering/shading", true, "", 0 },
1063 {"disable-skyblend", false, OPTION_BOOL, "/sim/rendering/skyblend", false, "", 0 },
1064 {"enable-skyblend", false, OPTION_BOOL, "/sim/rendering/skyblend", true, "", 0 },
1065 {"disable-textures", false, OPTION_BOOL, "/sim/rendering/textures", false, "", 0 },
1066 {"enable-textures", false, OPTION_BOOL, "/sim/rendering/textures", true, "", 0 },
1067 {"disable-wireframe", false, OPTION_BOOL, "/sim/rendering/wireframe", false, "", 0 },
1068 {"enable-wireframe", false, OPTION_BOOL, "/sim/rendering/wireframe", true, "", 0 },
1069 {"geometry", true, OPTION_FUNC, "", false, "", fgOptGeometry },
1070 {"bpp", true, OPTION_FUNC, "", false, "", fgOptBpp },
1071 {"units-feet", false, OPTION_STRING, "/sim/startup/units", false, "feet", 0 },
1072 {"units-meters", false, OPTION_STRING, "/sim/startup/units", false, "meters", 0 },
1073 {"time-offset", true, OPTION_FUNC, "", false, "", fgOptTimeOffset },
1074 {"time-match-real", false, OPTION_STRING, "/sim/startup/time-offset-type", false, "system-offset", 0 },
1075 {"time-match-local", false, OPTION_STRING, "/sim/startup/time-offset-type", false, "latitude-offset", 0 },
1076 {"start-date-sys", true, OPTION_FUNC, "", false, "", fgOptStartDateSys },
1077 {"start-date-lat", true, OPTION_FUNC, "", false, "", fgOptStartDateLat },
1078 {"start-date-gmt", true, OPTION_FUNC, "", false, "", fgOptStartDateGmt },
1079 {"hud-tris", false, OPTION_STRING, "/sim/hud/frame-stat-type", false, "tris", 0 },
1080 {"hud-culled", false, OPTION_STRING, "/sim/hud/frame-stat-type", false, "culled", 0 },
1081 {"atc610x", false, OPTION_CHANNEL, "", false, "dummy", 0 },
1082 {"atlas", true, OPTION_CHANNEL, "", false, "", 0 },
1083 {"httpd", true, OPTION_CHANNEL, "", false, "", 0 },
1084 #ifdef FG_JPEG_SERVER
1085 {"jpg-httpd", true, OPTION_CHANNEL, "", false, "", 0 },
1087 {"native", true, OPTION_CHANNEL, "", false, "", 0 },
1088 {"native-ctrls", true, OPTION_CHANNEL, "", false, "", 0 },
1089 {"native-fdm", true, OPTION_CHANNEL, "", false, "", 0 },
1090 {"native-gui", true, OPTION_CHANNEL, "", false, "", 0 },
1091 {"opengc", true, OPTION_CHANNEL, "", false, "", 0 },
1092 {"garmin", true, OPTION_CHANNEL, "", false, "", 0 },
1093 {"nmea", true, OPTION_CHANNEL, "", false, "", 0 },
1094 {"props", true, OPTION_CHANNEL, "", false, "", 0 },
1095 {"telnet", true, OPTION_CHANNEL, "", false, "", 0 },
1096 {"pve", true, OPTION_CHANNEL, "", false, "", 0 },
1097 {"ray", true, OPTION_CHANNEL, "", false, "", 0 },
1098 {"rul", true, OPTION_CHANNEL, "", false, "", 0 },
1099 {"joyclient", true, OPTION_CHANNEL, "", false, "", 0 },
1100 #ifdef FG_NETWORK_OLK
1101 {"disable-network-olk", false, OPTION_BOOL, "/sim/networking/olk", false, "", 0 },
1102 {"enable-network-olk", false, OPTION_BOOL, "/sim/networking/olk", true, "", 0 },
1103 {"net-hud", false, OPTION_FUNC, "", false, "", fgOptNetHud },
1104 {"net-id", true, OPTION_STRING, "sim/networking/call-sign", false, "", 0 },
1106 {"trace-read", true, OPTION_FUNC, "", false, "", fgOptTraceRead },
1107 {"trace-write", true, OPTION_FUNC, "", false, "", fgOptTraceWrite },
1108 {"view-offset", true, OPTION_FUNC, "", false, "", fgOptViewOffset },
1109 {"visibility", true, OPTION_DOUBLE, "/environment/visibility-m", false, "", 0 },
1110 {"visibility-miles", true, OPTION_FUNC, "", false, "", fgOptVisibilityMiles },
1111 {"random-wind", false, OPTION_FUNC, "", false, "", fgOptRandomWind },
1112 {"wind", true, OPTION_FUNC, "", false, "", fgOptWind },
1113 {"wp", true, OPTION_FUNC, "", false, "", fgOptWp },
1114 {"flight-plan", true, OPTION_FUNC, "", false, "", fgOptFlightPlan },
1115 {"config", true, OPTION_FUNC, "", false, "", fgOptConfig },
1116 {"aircraft", true, OPTION_STRING, "/sim/aircraft", false, "", 0 },
1121 // Parse a single option
1123 parse_option (const string& arg)
1125 #ifdef NEW_OPTION_PARSING
1126 if ( fgOptionMap.size() == 0 ) {
1128 OptionDesc *pt = &fgOptionArray[ 0 ];
1129 while ( pt->option != 0 ) {
1130 fgOptionMap[ pt->option ] = i;
1137 if ( (arg == "--help") || (arg == "-h") ) {
1138 // help/usage request
1139 return(FG_OPTIONS_HELP);
1140 } else if ( (arg == "--verbose") || (arg == "-v") ) {
1141 // verbose help/usage request
1142 return(FG_OPTIONS_VERBOSE_HELP);
1143 } else if ( arg.find( "--show-aircraft") == 0) {
1144 return(FG_OPTIONS_SHOW_AIRCRAFT);
1145 } else if ( arg.find( "--prop:" ) == 0 ) {
1146 string assign = arg.substr(7);
1147 string::size_type pos = assign.find('=');
1148 if ( pos == arg.npos || pos == 0 ) {
1149 SG_LOG( SG_GENERAL, SG_ALERT, "Bad property assignment: " << arg );
1150 return FG_OPTIONS_ERROR;
1152 string name = assign.substr(0, pos);
1153 string value = assign.substr(pos + 1);
1154 fgSetString(name.c_str(), value.c_str());
1155 // SG_LOG(SG_GENERAL, SG_INFO, "Setting default value of property "
1156 // << name << " to \"" << value << '"');
1157 } else if ( arg.find( "--" ) == 0 ) {
1158 size_t pos = arg.find( '=' );
1160 if ( pos == string::npos ) {
1161 arg_name = arg.substr( 2 );
1163 arg_name = arg.substr( 2, pos - 2 );
1165 map<string,size_t>::iterator it = fgOptionMap.find( arg_name );
1166 if ( it != fgOptionMap.end() ) {
1167 OptionDesc *pt = &fgOptionArray[ it->second ];
1168 switch ( pt->type ) {
1170 fgSetBool( pt->property, pt->b_param );
1173 if ( pt->has_param && pos != string::npos ) {
1174 fgSetString( pt->property, arg.substr( pos + 1 ).c_str() );
1175 } else if ( !pt->has_param && pos == string::npos ) {
1176 fgSetString( pt->property, pt->s_param );
1177 } else if ( pt->has_param ) {
1178 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' needs a parameter" );
1179 return FG_OPTIONS_ERROR;
1181 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' does not have a parameter" );
1182 return FG_OPTIONS_ERROR;
1186 if ( pos != string::npos ) {
1187 fgSetDouble( pt->property, atof( arg.substr( pos + 1 ) ) );
1189 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' needs a parameter" );
1190 return FG_OPTIONS_ERROR;
1194 if ( pos != string::npos ) {
1195 fgSetInt( pt->property, atoi( arg.substr( pos + 1 ) ) );
1197 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' needs a parameter" );
1198 return FG_OPTIONS_ERROR;
1201 case OPTION_CHANNEL:
1202 if ( pt->has_param && pos != string::npos ) {
1203 add_channel( pt->option, arg.substr( pos + 1 ) );
1204 } else if ( !pt->has_param && pos == string::npos ) {
1205 add_channel( pt->option, pt->s_param );
1206 } else if ( pt->has_param ) {
1207 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' needs a parameter" );
1208 return FG_OPTIONS_ERROR;
1210 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' does not have a parameter" );
1211 return FG_OPTIONS_ERROR;
1215 if ( pt->has_param && pos != string::npos ) {
1216 pt->func( arg.substr( pos + 1 ).c_str() );
1217 } else if ( !pt->has_param && pos == string::npos ) {
1219 } else if ( pt->has_param ) {
1220 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' needs a parameter" );
1221 return FG_OPTIONS_ERROR;
1223 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' does not have a parameter" );
1224 return FG_OPTIONS_ERROR;
1229 SG_LOG( SG_GENERAL, SG_ALERT, "Unknown option '" << arg << "'" );
1230 return FG_OPTIONS_ERROR;
1233 SG_LOG( SG_GENERAL, SG_ALERT, "Unknown option '" << arg << "'" );
1234 return FG_OPTIONS_ERROR;
1240 if ( (arg == "--help") || (arg == "-h") ) {
1241 // help/usage request
1242 return(FG_OPTIONS_HELP);
1243 } else if ( (arg == "--verbose") || (arg == "-v") ) {
1244 // verbose help/usage request
1245 return(FG_OPTIONS_VERBOSE_HELP);
1246 } else if ( arg.find( "--language=") == 0 ) {
1247 globals->set_locale( fgInitLocale( arg.substr( 11 ).c_str() ) );
1248 } else if ( arg == "--disable-game-mode") {
1249 fgSetBool("/sim/startup/game-mode", false);
1250 } else if ( arg == "--enable-game-mode" ) {
1251 fgSetBool("/sim/startup/game-mode", true);
1252 } else if ( arg == "--disable-splash-screen" ) {
1253 fgSetBool("/sim/startup/splash-screen", false);
1254 } else if ( arg == "--enable-splash-screen" ) {
1255 fgSetBool("/sim/startup/splash-screen", true);
1256 } else if ( arg == "--disable-intro-music" ) {
1257 fgSetBool("/sim/startup/intro-music", false);
1258 } else if ( arg == "--enable-intro-music" ) {
1259 fgSetBool("/sim/startup/intro-music", true);
1260 } else if ( arg == "--disable-mouse-pointer" ) {
1261 fgSetString("/sim/startup/mouse-pointer", "disabled");
1262 } else if ( arg == "--enable-mouse-pointer" ) {
1263 fgSetString("/sim/startup/mouse-pointer", "enabled");
1264 } else if ( arg == "--disable-random-objects" ) {
1265 fgSetBool("/sim/rendering/random-objects", false);
1266 } else if ( arg == "--enable-random-objects" ) {
1267 fgSetBool("/sim/rendering/random-objects", true);
1268 } else if ( arg == "--disable-freeze" ) {
1269 fgSetBool("/sim/freeze/master", false);
1270 } else if ( arg == "--enable-freeze" ) {
1271 fgSetBool("/sim/freeze/master", true);
1272 } else if ( arg == "--disable-fuel-freeze" ) {
1273 fgSetBool("/sim/freeze/fuel", false);
1274 } else if ( arg == "--enable-fuel-freeze" ) {
1275 fgSetBool("/sim/freeze/fuel", true);
1276 } else if ( arg == "--disable-clock-freeze" ) {
1277 fgSetBool("/sim/freeze/clock", false);
1278 } else if ( arg == "--enable-clock-freeze" ) {
1279 fgSetBool("/sim/freeze/clock", true);
1280 } else if ( arg == "--disable-anti-alias-hud" ) {
1281 fgSetBool("/sim/hud/antialiased", false);
1282 } else if ( arg == "--enable-anti-alias-hud" ) {
1283 fgSetBool("/sim/hud/antialiased", true);
1284 } else if ( arg.find( "--control=") == 0 ) {
1285 fgSetString("/sim/control-mode", arg.substr(10).c_str());
1286 } else if ( arg == "--disable-auto-coordination" ) {
1287 fgSetBool("/sim/auto-coordination", false);
1288 } else if ( arg == "--enable-auto-coordination" ) {
1289 fgSetBool("/sim/auto-coordination", true);
1290 } else if ( arg.find( "--browser-app=") == 0 ) {
1291 fgSetString("/sim/startup/browser-app", arg.substr(14).c_str());
1292 } else if ( arg == "--disable-hud" ) {
1293 fgSetBool("/sim/hud/visibility", false);
1294 } else if ( arg == "--enable-hud" ) {
1295 fgSetBool("/sim/hud/visibility", true);
1296 } else if ( arg == "--disable-panel" ) {
1297 fgSetBool("/sim/panel/visibility", false);
1298 } else if ( arg == "--enable-panel" ) {
1299 fgSetBool("/sim/panel/visibility", true);
1300 } else if ( arg == "--disable-sound" ) {
1301 fgSetBool("/sim/sound/audible", false);
1302 } else if ( arg == "--enable-sound" ) {
1303 fgSetBool("/sim/sound/audible", true);
1304 } else if ( arg.find( "--airport=") == 0 ) {
1305 fgSetString("/sim/presets/airport-id", arg.substr(10).c_str());
1306 } else if ( arg.find( "--airport-id=") == 0 ) {
1307 fgSetString("/sim/presets/airport-id", arg.substr(13).c_str());
1308 } else if ( arg.find( "--runway=") == 0 ) {
1309 fgSetString("/sim/presets/runway", arg.substr(9).c_str());
1310 } else if ( arg.find( "--offset-distance=") == 0 ) {
1311 fgSetDouble("/sim/presets/offset-distance", atof(arg.substr(18)));
1312 } else if ( arg.find( "--offset-azimuth=") == 0 ) {
1313 fgSetDouble("/sim/presets/offset-azimuth", atof(arg.substr(17)));
1314 } else if ( arg.find( "--lon=" ) == 0 ) {
1315 fgSetDouble("/sim/presets/longitude-deg", parse_degree(arg.substr(6)));
1316 fgSetDouble("/position/longitude-deg", parse_degree(arg.substr(6)));
1317 fgSetString("/sim/presets/airport-id", "");
1318 } else if ( arg.find( "--lat=" ) == 0 ) {
1319 fgSetDouble("/sim/presets/latitude-deg", parse_degree(arg.substr(6)));
1320 fgSetDouble("/position/latitude-deg", parse_degree(arg.substr(6)));
1321 fgSetString("/sim/presets/airport-id", "");
1322 } else if ( arg.find( "--altitude=" ) == 0 ) {
1323 fgSetBool("/sim/presets/onground", false);
1324 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1325 fgSetDouble("/sim/presets/altitude-ft", atof(arg.substr(11)));
1327 fgSetDouble("/sim/presets/altitude-ft",
1328 atof(arg.substr(11)) * SG_METER_TO_FEET);
1329 } else if ( arg.find( "--uBody=" ) == 0 ) {
1330 fgSetString("/sim/presets/speed-set", "UVW");
1331 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1332 fgSetDouble("/sim/presets/uBody-fps", atof(arg.substr(8)));
1334 fgSetDouble("/sim/presets/uBody-fps",
1335 atof(arg.substr(8)) * SG_METER_TO_FEET);
1336 } else if ( arg.find( "--vBody=" ) == 0 ) {
1337 fgSetString("/sim/presets/speed-set", "UVW");
1338 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1339 fgSetDouble("/sim/presets/vBody-fps", atof(arg.substr(8)));
1341 fgSetDouble("/sim/presets/vBody-fps",
1342 atof(arg.substr(8)) * SG_METER_TO_FEET);
1343 } else if ( arg.find( "--wBody=" ) == 0 ) {
1344 fgSetString("/sim/presets/speed-set", "UVW");
1345 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1346 fgSetDouble("/sim/presets/wBody-fps", atof(arg.substr(8)));
1348 fgSetDouble("/sim/presets/wBody-fps",
1349 atof(arg.substr(8)) * SG_METER_TO_FEET);
1350 } else if ( arg.find( "--vNorth=" ) == 0 ) {
1351 fgSetString("/sim/presets/speed-set", "NED");
1352 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1353 fgSetDouble("/sim/presets/speed-north-fps", atof(arg.substr(9)));
1355 fgSetDouble("/sim/presets/speed-north-fps",
1356 atof(arg.substr(9)) * SG_METER_TO_FEET);
1357 } else if ( arg.find( "--vEast=" ) == 0 ) {
1358 fgSetString("/sim/presets/speed-set", "NED");
1359 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1360 fgSetDouble("/sim/presets/speed-east-fps", atof(arg.substr(8)));
1362 fgSetDouble("/sim/presets/speed-east-fps",
1363 atof(arg.substr(8)) * SG_METER_TO_FEET);
1364 } else if ( arg.find( "--vDown=" ) == 0 ) {
1365 fgSetString("/sim/presets/speed-set", "NED");
1366 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1367 fgSetDouble("/sim/presets/speed-down-fps", atof(arg.substr(8)));
1369 fgSetDouble("/sim/presets/speed-down-fps",
1370 atof(arg.substr(8)) * SG_METER_TO_FEET);
1371 } else if ( arg.find( "--vc=" ) == 0) {
1372 // fgSetString("/sim/presets/speed-set", "knots");
1373 // fgSetDouble("/velocities/airspeed-kt", atof(arg.substr(5)));
1374 fgSetString("/sim/presets/speed-set", "knots");
1375 fgSetDouble("/sim/presets/airspeed-kt", atof(arg.substr(5)));
1376 } else if ( arg.find( "--mach=" ) == 0) {
1377 fgSetString("/sim/presets/speed-set", "mach");
1378 fgSetDouble("/sim/presets/mach", atof(arg.substr(7)));
1379 } else if ( arg.find( "--heading=" ) == 0 ) {
1380 fgSetDouble("/sim/presets/heading-deg", atof(arg.substr(10)));
1381 } else if ( arg.find( "--roll=" ) == 0 ) {
1382 fgSetDouble("/sim/presets/roll-deg", atof(arg.substr(7)));
1383 } else if ( arg.find( "--pitch=" ) == 0 ) {
1384 fgSetDouble("/sim/presets/pitch-deg", atof(arg.substr(8)));
1385 } else if ( arg.find( "--glideslope=" ) == 0 ) {
1386 fgSetDouble("/sim/presets/glideslope-deg",
1387 atof(arg.substr(13)));
1388 } else if ( arg.find( "--roc=" ) == 0 ) {
1389 fgSetDouble("/velocities/vertical-speed-fps", atof(arg.substr(6))/60);
1390 } else if ( arg.find( "--fg-root=" ) == 0 ) {
1391 globals->set_fg_root(arg.substr( 10 ));
1392 } else if ( arg.find( "--fg-scenery=" ) == 0 ) {
1393 globals->set_fg_scenery(arg.substr( 13 ));
1394 } else if ( arg.find( "--fdm=" ) == 0 ) {
1395 fgSetString("/sim/flight-model", arg.substr(6).c_str());
1396 } else if ( arg.find( "--aero=" ) == 0 ) {
1397 fgSetString("/sim/aero", arg.substr(7).c_str());
1398 } else if ( arg.find( "--aircraft-dir=" ) == 0 ) {
1399 fgSetString("/sim/aircraft-dir", arg.substr(15).c_str());
1400 } else if ( arg.find( "--show-aircraft") == 0) {
1401 return(FG_OPTIONS_SHOW_AIRCRAFT);
1402 } else if ( arg.find( "--model-hz=" ) == 0 ) {
1403 fgSetInt("/sim/model-hz", atoi(arg.substr(11)));
1404 } else if ( arg.find( "--speed=" ) == 0 ) {
1405 fgSetInt("/sim/speed-up", atoi(arg.substr(8)));
1406 } else if ( arg.find( "--trim") == 0) {
1407 fgSetBool("/sim/presets/trim", true);
1408 } else if ( arg.find( "--notrim") == 0) {
1409 fgSetBool("/sim/presets/trim", false);
1410 } else if ( arg.find( "--on-ground") == 0) {
1411 fgSetBool("/sim/presets/onground", true);
1412 } else if ( arg.find( "--in-air") == 0) {
1413 fgSetBool("/sim/presets/onground", false);
1414 } else if ( arg == "--fog-disable" ) {
1415 fgSetString("/sim/rendering/fog", "disabled");
1416 } else if ( arg == "--fog-fastest" ) {
1417 fgSetString("/sim/rendering/fog", "fastest");
1418 } else if ( arg == "--fog-nicest" ) {
1419 fgSetString("/sim/fog", "nicest");
1420 } else if ( arg == "--disable-distance-attenuation" ) {
1421 fgSetBool("/environment/distance-attenuation", false);
1422 } else if ( arg == "--enable-distance-attenuation" ) {
1423 fgSetBool("/environment/distance-attenuation", true);
1424 } else if ( arg == "--disable-clouds" ) {
1425 fgSetBool("/environment/clouds/status", false);
1426 } else if ( arg == "--enable-clouds" ) {
1427 fgSetBool("/environment/clouds/status", true);
1428 #ifdef FG_USE_CLOUDS_3D
1429 } else if ( arg == "--disable-clouds3d" ) {
1430 fgSetBool("/sim/rendering/clouds3d", false);
1431 } else if ( arg == "--enable-clouds3d" ) {
1432 fgSetBool("/sim/rendering/clouds3d", true);
1434 } else if ( arg.find( "--fov=" ) == 0 ) {
1435 parse_fov( arg.substr(6) );
1436 } else if ( arg == "--disable-fullscreen" ) {
1437 fgSetBool("/sim/startup/fullscreen", false);
1438 } else if ( arg== "--enable-fullscreen") {
1439 fgSetBool("/sim/startup/fullscreen", true);
1440 } else if ( arg == "--shading-flat") {
1441 fgSetBool("/sim/rendering/shading", false);
1442 } else if ( arg == "--shading-smooth") {
1443 fgSetBool("/sim/rendering/shading", true);
1444 } else if ( arg == "--disable-skyblend") {
1445 fgSetBool("/sim/rendering/skyblend", false);
1446 } else if ( arg== "--enable-skyblend" ) {
1447 fgSetBool("/sim/rendering/skyblend", true);
1448 } else if ( arg == "--disable-textures" ) {
1449 fgSetBool("/sim/rendering/textures", false);
1450 } else if ( arg == "--enable-textures" ) {
1451 fgSetBool("/sim/rendering/textures", true);
1452 } else if ( arg == "--disable-wireframe" ) {
1453 fgSetBool("/sim/rendering/wireframe", false);
1454 } else if ( arg == "--enable-wireframe" ) {
1455 fgSetBool("/sim/rendering/wireframe", true);
1456 } else if ( arg.find( "--geometry=" ) == 0 ) {
1457 bool geometry_ok = true;
1458 int xsize = 0, ysize = 0;
1459 string geometry = arg.substr( 11 );
1460 string::size_type i = geometry.find('x');
1462 if (i != string::npos) {
1463 xsize = atoi(geometry.substr(0, i));
1464 ysize = atoi(geometry.substr(i+1));
1466 geometry_ok = false;
1469 if ( xsize <= 0 || ysize <= 0 ) {
1472 geometry_ok = false;
1475 if ( !geometry_ok ) {
1476 SG_LOG( SG_GENERAL, SG_ALERT, "Unknown geometry: " << geometry );
1477 SG_LOG( SG_GENERAL, SG_ALERT,
1478 "Setting geometry to " << xsize << 'x' << ysize << '\n');
1480 SG_LOG( SG_GENERAL, SG_INFO,
1481 "Setting geometry to " << xsize << 'x' << ysize << '\n');
1482 fgSetInt("/sim/startup/xsize", xsize);
1483 fgSetInt("/sim/startup/ysize", ysize);
1485 } else if ( arg.find( "--bpp=" ) == 0 ) {
1486 string bits_per_pix = arg.substr( 6 );
1487 if ( bits_per_pix == "16" ) {
1488 fgSetInt("/sim/rendering/bits-per-pixel", 16);
1489 } else if ( bits_per_pix == "24" ) {
1490 fgSetInt("/sim/rendering/bits-per-pixel", 24);
1491 } else if ( bits_per_pix == "32" ) {
1492 fgSetInt("/sim/rendering/bits-per-pixel", 32);
1494 SG_LOG(SG_GENERAL, SG_ALERT, "Unsupported bpp " << bits_per_pix);
1496 } else if ( arg == "--units-feet" ) {
1497 fgSetString("/sim/startup/units", "feet");
1498 } else if ( arg == "--units-meters" ) {
1499 fgSetString("/sim/startup/units", "meters");
1500 } else if ( arg.find( "--time-offset" ) == 0 ) {
1501 fgSetInt("/sim/startup/time-offset",
1502 parse_time_offset( (arg.substr(14)) ));
1503 fgSetString("/sim/startup/time-offset-type", "system-offset");
1504 } else if ( arg.find( "--time-match-real") == 0 ) {
1505 fgSetString("/sim/startup/time-offset-type", "system-offset");
1506 } else if ( arg.find( "--time-match-local") == 0 ) {
1507 fgSetString("/sim/startup/time-offset-type", "latitude-offset");
1508 } else if ( arg.find( "--start-date-sys=") == 0 ) {
1509 fgSetInt("/sim/startup/time-offset", parse_date((arg.substr(17))));
1510 fgSetString("/sim/startup/time-offset-type", "system");
1511 } else if ( arg.find( "--start-date-lat=") == 0 ) {
1512 fgSetInt("/sim/startup/time-offset", parse_date((arg.substr(17))));
1513 fgSetString("/sim/startup/time-offset-type", "latitude");
1514 } else if ( arg.find( "--start-date-gmt=") == 0 ) {
1515 fgSetInt("/sim/startup/time-offset", parse_date((arg.substr(17))));
1516 fgSetString("/sim/startup/time-offset-type", "gmt");
1517 } else if ( arg == "--hud-tris" ) {
1518 fgSetString("/sim/hud/frame-stat-type", "tris");
1519 } else if ( arg == "--hud-culled" ) {
1520 fgSetString("/sim/hud/frame-stat-type", "culled");
1521 } else if ( arg.find( "--atc610x" ) == 0 ) {
1522 add_channel( "atc610x", "dummy" );
1523 } else if ( arg.find( "--atlas=" ) == 0 ) {
1524 add_channel( "atlas", arg.substr(8) );
1525 } else if ( arg.find( "--httpd=" ) == 0 ) {
1526 add_channel( "httpd", arg.substr(8) );
1527 #ifdef FG_JPEG_SERVER
1528 } else if ( arg.find( "--jpg-httpd=" ) == 0 ) {
1529 add_channel( "jpg-httpd", arg.substr(12) );
1531 } else if ( arg.find( "--native=" ) == 0 ) {
1532 add_channel( "native", arg.substr(9) );
1533 } else if ( arg.find( "--native-ctrls=" ) == 0 ) {
1534 add_channel( "native_ctrls", arg.substr(15) );
1535 } else if ( arg.find( "--native-fdm=" ) == 0 ) {
1536 add_channel( "native_fdm", arg.substr(13) );
1537 } else if ( arg.find( "--native-gui=" ) == 0 ) {
1538 add_channel( "native_gui", arg.substr(13) );
1539 } else if ( arg.find( "--opengc=" ) == 0 ) {
1541 // cout << "Adding channel for OpenGC Display" << endl; cin >> stop;
1542 add_channel( "opengc", arg.substr(9) );
1543 } else if ( arg.find( "--garmin=" ) == 0 ) {
1544 add_channel( "garmin", arg.substr(9) );
1545 } else if ( arg.find( "--nmea=" ) == 0 ) {
1546 add_channel( "nmea", arg.substr(7) );
1547 } else if ( arg.find( "--props=" ) == 0 ) {
1548 add_channel( "props", arg.substr(8) );
1549 } else if ( arg.find( "--telnet=" ) == 0 ) {
1550 add_channel( "telnet", arg.substr(9) );
1551 } else if ( arg.find( "--pve=" ) == 0 ) {
1552 add_channel( "pve", arg.substr(6) );
1553 } else if ( arg.find( "--ray=" ) == 0 ) {
1554 add_channel( "ray", arg.substr(6) );
1555 } else if ( arg.find( "--rul=" ) == 0 ) {
1556 add_channel( "rul", arg.substr(6) );
1557 } else if ( arg.find( "--joyclient=" ) == 0 ) {
1558 add_channel( "joyclient", arg.substr(12) );
1559 #ifdef FG_NETWORK_OLK
1560 } else if ( arg == "--disable-network-olk" ) {
1561 fgSetBool("/sim/networking/olk", false);
1562 } else if ( arg== "--enable-network-olk") {
1563 fgSetBool("/sim/networking/olk", true);
1564 } else if ( arg == "--net-hud" ) {
1565 fgSetBool("/sim/hud/net-display", true);
1566 net_hud_display = 1; // FIXME
1567 } else if ( arg.find( "--net-id=") == 0 ) {
1568 fgSetString("sim/networking/call-sign", arg.substr(9).c_str());
1570 } else if ( arg.find( "--prop:" ) == 0 ) {
1571 string assign = arg.substr(7);
1572 string::size_type pos = assign.find('=');
1573 if ( pos == arg.npos || pos == 0 ) {
1574 SG_LOG( SG_GENERAL, SG_ALERT, "Bad property assignment: " << arg );
1575 return FG_OPTIONS_ERROR;
1577 string name = assign.substr(0, pos);
1578 string value = assign.substr(pos + 1);
1579 fgSetString(name.c_str(), value.c_str());
1580 // SG_LOG(SG_GENERAL, SG_INFO, "Setting default value of property "
1581 // << name << " to \"" << value << '"');
1582 } else if ( arg.find("--trace-read=") == 0) {
1583 string name = arg.substr(13);
1584 SG_LOG(SG_GENERAL, SG_INFO, "Tracing reads for property " << name);
1585 fgGetNode(name.c_str(), true)
1586 ->setAttribute(SGPropertyNode::TRACE_READ, true);
1587 } else if ( arg.find("--trace-write=") == 0) {
1588 string name = arg.substr(14);
1589 SG_LOG(SG_GENERAL, SG_INFO, "Tracing writes for property " << name);
1590 fgGetNode(name.c_str(), true)
1591 ->setAttribute(SGPropertyNode::TRACE_WRITE, true);
1592 } else if ( arg.find( "--view-offset=" ) == 0 ) {
1593 // $$$ begin - added VS Renganathan, 14 Oct 2K
1594 // for multi-window outside window imagery
1595 string woffset = arg.substr( 14 );
1596 double default_view_offset = 0.0;
1597 if ( woffset == "LEFT" ) {
1598 default_view_offset = SGD_PI * 0.25;
1599 } else if ( woffset == "RIGHT" ) {
1600 default_view_offset = SGD_PI * 1.75;
1601 } else if ( woffset == "CENTER" ) {
1602 default_view_offset = 0.00;
1604 default_view_offset = atof( woffset.c_str() ) * SGD_DEGREES_TO_RADIANS;
1606 /* apparently not used (CLO, 11 Jun 2002)
1607 FGViewer *pilot_view =
1608 (FGViewer *)globals->get_viewmgr()->get_view( 0 ); */
1609 // this will work without calls to the viewer...
1610 fgSetDouble( "/sim/current-view/heading-offset-deg",
1611 default_view_offset * SGD_RADIANS_TO_DEGREES );
1612 // $$$ end - added VS Renganathan, 14 Oct 2K
1613 } else if ( arg.find( "--visibility=" ) == 0 ) {
1614 fgSetDouble("/environment/visibility-m", atof(arg.substr(13)));
1615 } else if ( arg.find( "--visibility-miles=" ) == 0 ) {
1616 double visibility = atof(arg.substr(19)) * 5280.0 * SG_FEET_TO_METER;
1617 fgSetDouble("/environment/visibility-m", visibility);
1618 } else if ( arg.find( "--random-wind" ) == 0 ) {
1619 double min_hdg = sg_random() * 360.0;
1620 double max_hdg = min_hdg + (20 - sqrt(sg_random() * 400));
1621 double speed = 40 - sqrt(sg_random() * 1600.0);
1622 double gust = speed + (10 - sqrt(sg_random() * 100));
1623 setup_wind(min_hdg, max_hdg, speed, gust);
1624 } else if ( arg.find( "--wind=" ) == 0 ) {
1625 double min_hdg, max_hdg, speed, gust;
1626 if (!parse_wind(arg.substr(7), &min_hdg, &max_hdg, &speed, &gust)) {
1627 SG_LOG( SG_GENERAL, SG_ALERT, "bad wind value " << arg.substr(7) );
1628 return FG_OPTIONS_ERROR;
1630 setup_wind(min_hdg, max_hdg, speed, gust);
1631 } else if ( arg.find( "--wp=" ) == 0 ) {
1632 parse_wp( arg.substr( 5 ) );
1633 } else if ( arg.find( "--flight-plan=") == 0) {
1634 parse_flightplan ( arg.substr (14) );
1635 } else if ( arg.find( "--config=" ) == 0 ) {
1636 string file = arg.substr(9);
1638 readProperties(file, globals->get_props());
1639 } catch (const sg_exception &e) {
1640 string message = "Error loading config file: ";
1641 message += e.getFormattedMessage();
1642 SG_LOG(SG_INPUT, SG_ALERT, message);
1645 } else if ( arg.find( "--aircraft=" ) == 0 ) {
1646 fgSetString("/sim/aircraft", arg.substr(11).c_str());
1648 SG_LOG( SG_GENERAL, SG_ALERT, "Unknown option '" << arg << "'" );
1649 return FG_OPTIONS_ERROR;
1653 return FG_OPTIONS_OK;
1657 // Parse the command line options
1659 fgParseArgs (int argc, char **argv)
1661 bool in_options = true;
1662 bool verbose = false;
1665 SG_LOG(SG_GENERAL, SG_INFO, "Processing command line arguments");
1667 for (int i = 1; i < argc; i++) {
1668 string arg = argv[i];
1670 if (in_options && (arg.find('-') == 0)) {
1674 int result = parse_option(arg);
1675 if ((result == FG_OPTIONS_HELP) || (result == FG_OPTIONS_ERROR))
1678 else if (result == FG_OPTIONS_VERBOSE_HELP)
1681 else if (result == FG_OPTIONS_SHOW_AIRCRAFT) {
1688 SG_LOG(SG_GENERAL, SG_INFO,
1689 "Reading command-line property file " << arg);
1690 readProperties(arg, globals->get_props());
1699 SG_LOG(SG_GENERAL, SG_INFO, "Finished command line arguments");
1703 // Parse config file options
1705 fgParseOptions (const string& path) {
1706 sg_gzifstream in( path );
1707 if ( !in.is_open() ) {
1711 SG_LOG( SG_GENERAL, SG_INFO, "Processing config file: " << path );
1715 while ( ! in.eof() ) {
1718 while ( in.get(c) && c != '\0' ) {
1723 #if defined( macintosh )
1724 getline( in, line, '\r' );
1726 getline( in, line, '\n' );
1729 // catch extraneous (DOS) line ending character
1730 if ( line[line.length() - 1] < 32 ) {
1731 line = line.substr( 0, line.length()-1 );
1734 if ( parse_option( line ) == FG_OPTIONS_ERROR ) {
1735 cerr << endl << "Config file parse error: " << path << " '"
1736 << line << "'" << endl;
1745 // Print usage message
1747 fgUsage (bool verbose)
1749 SGPropertyNode *locale = globals->get_locale();
1751 SGPropertyNode options_root;
1756 fgLoadProps("options.xml", &options_root);
1757 } catch (const sg_exception &ex) {
1758 cout << "Unable to read the help file." << endl;
1759 cout << "Make sure the file options.xml is located in the FlightGear base directory," << endl;
1760 cout << "and the location of the base directory is specified by setting $FG_ROOT or" << endl;
1761 cout << "by adding --fg-root=path as a program argument." << endl;
1766 SGPropertyNode *options = options_root.getNode("options");
1768 SG_LOG( SG_GENERAL, SG_ALERT,
1769 "Error reading options.xml: <options> directive not found." );
1773 SGPropertyNode *usage = locale->getNode(options->getStringValue("usage"));
1775 cout << "Usage: " << usage->getStringValue() << endl;
1778 vector<SGPropertyNode_ptr>section = options->getChildren("section");
1779 for (unsigned int j = 0; j < section.size(); j++) {
1782 vector<SGPropertyNode_ptr>option = section[j]->getChildren("option");
1783 for (unsigned int k = 0; k < option.size(); k++) {
1785 SGPropertyNode *name = option[k]->getNode("name");
1786 SGPropertyNode *short_name = option[k]->getNode("short");
1787 SGPropertyNode *key = option[k]->getNode("key");
1788 SGPropertyNode *arg = option[k]->getNode("arg");
1789 bool brief = option[k]->getNode("brief");
1791 if ((brief || verbose) && name) {
1792 string tmp = name->getStringValue();
1796 tmp.append(key->getStringValue());
1800 tmp.append(arg->getStringValue());
1804 tmp.append(short_name->getStringValue());
1808 if (tmp.size() <= 25) {
1809 snprintf(cstr, 96, " --%-27s", tmp.c_str());
1811 snprintf(cstr, 96, "\n --%s\n%32c", tmp.c_str(), ' ');
1814 // There may be more than one <description> tag assosiated
1818 vector<SGPropertyNode_ptr>desc =
1819 option[k]->getChildren("description");
1821 if (desc.size() > 0) {
1822 for ( unsigned int l = 0; l < desc.size(); l++) {
1824 // There may be more than one translation line.
1826 string t = desc[l]->getStringValue();
1827 SGPropertyNode *n = locale->getNode("strings");
1828 vector<SGPropertyNode_ptr>trans_desc =
1829 n->getChildren(t.substr(8).c_str());
1831 for ( unsigned int m = 0; m < trans_desc.size(); m++ ) {
1832 string t_str = trans_desc[m]->getStringValue();
1834 if ((m > 0) || ((l > 0) && m == 0)) {
1835 snprintf(cstr, 96, "%32c", ' ');
1840 // If the string is too large to fit on the screen,
1841 // then split it up in several pieces.
1843 while ( t_str.size() > 47 ) {
1845 unsigned int m = t_str.rfind(' ', 47);
1846 msg += t_str.substr(0, m);
1847 snprintf(cstr, 96, "\n%32c", ' ');
1850 t_str.erase(t_str.begin(), t_str.begin() + m + 1);
1852 msg += t_str + '\n';
1859 SGPropertyNode *name =
1860 locale->getNode(section[j]->getStringValue("name"));
1862 if (!msg.empty() && name) {
1863 cout << endl << name->getStringValue() << ":" << endl;
1871 cout << "For a complete list of options use --help --verbose" << endl;
1875 // Show available aircraft types
1876 void fgShowAircraft(void) {
1877 vector<string> aircraft;
1879 SGPath path( globals->get_fg_root() );
1880 path.append("Aircraft");
1885 dirp = ulOpenDir(path.c_str());
1887 cerr << "Unable to open aircraft directory." << endl;
1891 while ((dire = ulReadDir(dirp)) != NULL) {
1894 if ((ptr = strstr(dire->d_name, "-set.xml")) && ptr[8] == '\0' ) {
1895 SGPath afile = path;
1896 afile.append(dire->d_name);
1900 SGPropertyNode root;
1902 readProperties(afile.str(), &root);
1907 SGPropertyNode *desc = NULL;
1908 SGPropertyNode *node = root.getNode("sim");
1910 desc = node->getNode("description");
1914 if (strlen(dire->d_name) <= 27)
1915 snprintf(cstr, 96, " %-27s %s", dire->d_name,
1916 (desc) ? desc->getStringValue() : "" );
1919 snprintf(cstr, 96, " %-27s\n%32c%s", dire->d_name, ' ',
1920 (desc) ? desc->getStringValue() : "" );
1922 aircraft.push_back(cstr);
1926 sort(aircraft.begin(), aircraft.end());
1927 cout << "Available aircraft:" << endl;
1928 for (int i = 0; i < aircraft.size(); i++)
1929 cout << aircraft[i] << endl;