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()
40 #include <simgear/math/sg_random.h>
41 #include <simgear/misc/sgstream.hxx>
42 #include <simgear/misc/sg_path.hxx>
43 #include <simgear/route/route.hxx>
44 #include <simgear/route/waypoint.hxx>
46 // #include <Include/general.hxx>
47 // #include <Airports/simple.hxx>
48 // #include <Cockpit/cockpit.hxx>
49 // #include <FDM/flight.hxx>
50 // #include <FDM/UIUCModel/uiuc_aircraftdir.h>
52 # include <NetworkOLK/network.h>
57 #include "globals.hxx"
58 #include "fg_init.hxx"
59 #include "fg_props.hxx"
60 #include "options.hxx"
61 #include "viewmgr.hxx"
65 SG_USING_NAMESPACE(std);
68 #define NEW_DEFAULT_MODEL_HZ 120
75 FG_OPTIONS_VERBOSE_HELP = 3,
76 FG_OPTIONS_SHOW_AIRCRAFT = 4
80 atof( const string& str )
84 // -dw- if ::atof is called, then we get an infinite loop
85 return std::atof( str.c_str() );
87 return ::atof( str.c_str() );
92 atoi( const string& str )
95 // -dw- if ::atoi is called, then we get an infinite loop
96 return std::atoi( str.c_str() );
98 return ::atoi( str.c_str() );
104 * Set a few fail-safe default property values.
106 * These should all be set in $FG_ROOT/preferences.xml, but just
107 * in case, we provide some initial sane values here. This method
108 * should be invoked *before* reading any init files.
113 // set a possibly independent location for scenery data
114 char *envp = ::getenv( "FG_SCENERY" );
116 if ( envp != NULL ) {
117 // fg_root could be anywhere, so default to environmental
118 // variable $FG_ROOT if it is set.
119 globals->set_fg_scenery(envp);
121 // Otherwise, default to Scenery being in $FG_ROOT/Scenery
122 globals->set_fg_scenery("");
124 // Position (deliberately out of range)
125 fgSetDouble("/position/longitude-deg", 9999.0);
126 fgSetDouble("/position/latitude-deg", 9999.0);
127 fgSetDouble("/position/altitude-ft", -9999.0);
130 fgSetDouble("/orientation/heading-deg", 270);
131 fgSetDouble("/orientation/roll-deg", 0);
132 fgSetDouble("/orientation/pitch-deg", 0.424);
135 fgSetDouble("/velocities/uBody-fps", 0.0);
136 fgSetDouble("/velocities/vBody-fps", 0.0);
137 fgSetDouble("/velocities/wBody-fps", 0.0);
138 fgSetDouble("/velocities/speed-north-fps", 0.0);
139 fgSetDouble("/velocities/speed-east-fps", 0.0);
140 fgSetDouble("/velocities/speed-down-fps", 0.0);
141 fgSetDouble("/velocities/airspeed-kt", 0.0);
142 fgSetDouble("/velocities/mach", 0.0);
145 fgSetDouble("/sim/presets/longitude-deg", 9999.0);
146 fgSetDouble("/sim/presets/latitude-deg", 9999.0);
147 fgSetDouble("/sim/presets/altitude-ft", -9999.0);
149 fgSetDouble("/sim/presets/heading-deg", 270);
150 fgSetDouble("/sim/presets/roll-deg", 0);
151 fgSetDouble("/sim/presets/pitch-deg", 0.424);
153 fgSetString("/sim/presets/speed-set", "knots");
154 fgSetDouble("/sim/presets/airspeed-kt", 0.0);
155 fgSetDouble("/sim/presets/mach", 0.0);
156 fgSetDouble("/sim/presets/uBody-fps", 0.0);
157 fgSetDouble("/sim/presets/vBody-fps", 0.0);
158 fgSetDouble("/sim/presets/wBody-fps", 0.0);
159 fgSetDouble("/sim/presets/speed-north-fps", 0.0);
160 fgSetDouble("/sim/presets/speed-east-fps", 0.0);
161 fgSetDouble("/sim/presets/speed-down-fps", 0.0);
163 fgSetBool("/sim/presets/onground", true);
164 fgSetBool("/sim/presets/trim", false);
167 fgSetBool("/sim/startup/game-mode", false);
168 fgSetBool("/sim/startup/splash-screen", true);
169 fgSetBool("/sim/startup/intro-music", true);
170 // we want mouse-pointer to have an undefined value if nothing is
171 // specified so we can do the right thing for voodoo-1/2 cards.
172 // fgSetString("/sim/startup/mouse-pointer", "disabled");
173 fgSetString("/sim/control-mode", "joystick");
174 fgSetBool("/sim/auto-coordination", false);
176 fgSetString("/sim/startup/browser-app", "netscape");
178 fgSetString("/sim/startup/browser-app", "webrun.bat");
181 fgSetBool("/sim/hud/visibility", false);
182 fgSetBool("/sim/panel/visibility", true);
183 fgSetBool("/sim/sound/audible", true);
184 fgSetBool("/sim/hud/antialiased", false);
186 // Flight Model options
187 fgSetString("/sim/flight-model", "jsb");
188 fgSetString("/sim/aero", "c172");
189 fgSetInt("/sim/model-hz", NEW_DEFAULT_MODEL_HZ);
190 fgSetInt("/sim/speed-up", 1);
193 fgSetString("/sim/rendering/fog", "nicest");
194 fgSetBool("/environment/clouds/status", true);
195 fgSetBool("/sim/startup/fullscreen", false);
196 fgSetBool("/sim/rendering/shading", true);
197 fgSetBool("/sim/rendering/skyblend", true);
198 fgSetBool("/sim/rendering/textures", true);
199 fgSetBool("/sim/rendering/wireframe", false);
200 fgSetBool("/sim/rendering/distance-attenuation", false);
201 fgSetInt("/sim/startup/xsize", 800);
202 fgSetInt("/sim/startup/ysize", 600);
203 fgSetInt("/sim/rendering/bits-per-pixel", 16);
204 fgSetString("/sim/view-mode", "pilot");
205 fgSetDouble("/sim/current-view/heading-offset-deg", 0);
206 fgSetDouble("/environment/visibility-m", 20000);
209 fgSetString("/sim/startup/units", "feet");
210 fgSetString("/sim/hud/frame-stat-type", "tris");
213 fgSetInt("/sim/startup/time-offset", 0);
214 fgSetString("/sim/startup/time-offset-type", "system-offset");
215 fgSetLong("/sim/time/cur-time-override", 0);
217 fgSetBool("/sim/networking/network-olk", false);
218 fgSetString("/sim/networking/call-sign", "Johnny");
221 fgSetBool("/sim/freeze/master", false);
222 fgSetBool("/sim/freeze/position", false);
223 fgSetBool("/sim/freeze/clock", false);
224 fgSetBool("/sim/freeze/fuel", false);
229 parse_wind (const string &wind, double * min_hdg, double * max_hdg,
230 double * speed, double * gust)
232 string::size_type pos = wind.find('@');
233 if (pos == string::npos)
235 string dir = wind.substr(0, pos);
236 string spd = wind.substr(pos+1);
238 if (pos == string::npos) {
239 *min_hdg = *max_hdg = atof(dir.c_str());
241 *min_hdg = atof(dir.substr(0,pos).c_str());
242 *max_hdg = atof(dir.substr(pos+1).c_str());
245 if (pos == string::npos) {
246 *speed = *gust = atof(spd.c_str());
248 *speed = atof(spd.substr(0,pos).c_str());
249 *gust = atof(spd.substr(pos+1).c_str());
254 // parse a time string ([+/-]%f[:%f[:%f]]) into hours
256 parse_time(const string& time_in) {
257 char *time_str, num[256];
258 double hours, minutes, seconds;
263 time_str = (char *)time_in.c_str();
265 // printf("parse_time(): %s\n", time_str);
268 if ( strlen(time_str) ) {
269 if ( time_str[0] == '+' ) {
272 } else if ( time_str[0] == '-' ) {
277 // printf("sign = %d\n", sign);
280 if ( strlen(time_str) ) {
282 while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
283 num[i] = time_str[0];
287 if ( time_str[0] == ':' ) {
292 // printf("hours = %.2lf\n", hours);
298 if ( strlen(time_str) ) {
300 while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
301 num[i] = time_str[0];
305 if ( time_str[0] == ':' ) {
310 // printf("minutes = %.2lf\n", minutes);
312 result += minutes / 60.0;
316 if ( strlen(time_str) ) {
318 while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
319 num[i] = time_str[0];
325 // printf("seconds = %.2lf\n", seconds);
327 result += seconds / 3600.0;
330 cout << " parse_time() = " << sign * result << endl;
332 return(sign * result);
336 // parse a date string (yyyy:mm:dd:hh:mm:ss) into a time_t (seconds)
338 parse_date( const string& date)
341 char * date_str, num[256];
343 // initialize to zero
350 gmt.tm_isdst = 0; // ignore daylight savings time for the moment
351 date_str = (char *)date.c_str();
353 if ( strlen(date_str) ) {
355 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
356 num[i] = date_str[0];
360 if ( date_str[0] == ':' ) {
364 gmt.tm_year = atoi(num) - 1900;
367 if ( strlen(date_str) ) {
369 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
370 num[i] = date_str[0];
374 if ( date_str[0] == ':' ) {
378 gmt.tm_mon = atoi(num) -1;
381 if ( strlen(date_str) ) {
383 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
384 num[i] = date_str[0];
388 if ( date_str[0] == ':' ) {
392 gmt.tm_mday = atoi(num);
395 if ( strlen(date_str) ) {
397 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
398 num[i] = date_str[0];
402 if ( date_str[0] == ':' ) {
406 gmt.tm_hour = atoi(num);
409 if ( strlen(date_str) ) {
411 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
412 num[i] = date_str[0];
416 if ( date_str[0] == ':' ) {
420 gmt.tm_min = atoi(num);
423 if ( strlen(date_str) ) {
425 while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
426 num[i] = date_str[0];
430 if ( date_str[0] == ':' ) {
434 gmt.tm_sec = atoi(num);
436 time_t theTime = sgTimeGetGMT( gmt.tm_year, gmt.tm_mon, gmt.tm_mday,
437 gmt.tm_hour, gmt.tm_min, gmt.tm_sec );
438 //printf ("Date is %s\n", ctime(&theTime));
439 //printf ("in seconds that is %d\n", theTime);
445 // parse angle in the form of [+/-]ddd:mm:ss into degrees
447 parse_degree( const string& degree_str) {
448 double result = parse_time( degree_str );
450 // printf("Degree = %.4f\n", result);
456 // parse time offset string into seconds
458 parse_time_offset( const string& time_str) {
461 // printf("time offset = %s\n", time_str);
464 result = (int)rint(parse_time(time_str) * 3600.0);
466 result = (int)(parse_time(time_str) * 3600.0);
469 // printf("parse_time_offset(): %d\n", result);
475 // Parse --fov=x.xx type option
477 parse_fov( const string& arg ) {
478 double fov = atof(arg);
480 if ( fov < FG_FOV_MIN ) { fov = FG_FOV_MIN; }
481 if ( fov > FG_FOV_MAX ) { fov = FG_FOV_MAX; }
483 fgSetDouble("/sim/current-view/field-of-view", fov);
485 // printf("parse_fov(): result = %.4f\n", fov);
491 // Parse I/O channel option
493 // Format is "--protocol=medium,direction,hz,medium_options,..."
495 // protocol = { native, nmea, garmin, fgfs, rul, pve, etc. }
496 // medium = { serial, socket, file, etc. }
497 // direction = { in, out, bi }
498 // hz = number of times to process channel per second (floating
499 // point values are ok.
501 // Serial example "--nmea=serial,dir,hz,device,baud" where
503 // device = OS device name of serial line to be open()'ed
504 // baud = {300, 1200, 2400, ..., 230400}
506 // Socket exacmple "--native=socket,dir,hz,machine,port,style" where
508 // machine = machine name or ip address if client (leave empty if server)
509 // port = port, leave empty to let system choose
510 // style = tcp or udp
512 // File example "--garmin=file,dir,hz,filename" where
514 // filename = file system file name
517 add_channel( const string& type, const string& channel_str ) {
518 // cout << "Channel string = " << channel_str << endl;
520 globals->get_channel_options_list()->push_back( type + "," + channel_str );
527 setup_wind (double min_hdg, double max_hdg, double speed, double gust)
529 fgSetDouble("/environment/wind-from-heading-deg", min_hdg);
530 fgSetDouble("/environment/params/min-wind-from-heading-deg", min_hdg);
531 fgSetDouble("/environment/params/max-wind-from-heading-deg", max_hdg);
532 fgSetDouble("/environment/wind-speed-kt", speed);
533 fgSetDouble("/environment/params/base-wind-speed-kt", speed);
534 fgSetDouble("/environment/params/gust-wind-speed-kt", gust);
536 SG_LOG(SG_GENERAL, SG_INFO, "WIND: " << min_hdg << '@' <<
537 speed << " knots" << endl);
541 speed *= SG_NM_TO_METER * SG_METER_TO_FEET * (1.0/3600);
542 while (min_hdg > 360)
546 min_hdg *= SGD_DEGREES_TO_RADIANS;
547 fgSetDouble("/environment/wind-from-north-fps", speed * cos(dir));
548 fgSetDouble("/environment/wind-from-east-fps", speed * sin(dir));
549 #endif // FG_WEATHERCM
553 // Parse --wp=ID[@alt]
555 parse_wp( const string& arg ) {
559 string::size_type pos = arg.find( "@" );
560 if ( pos != string::npos ) {
561 id = arg.substr( 0, pos );
562 alt_str = arg.substr( pos + 1 );
563 // cout << "id str = " << id << " alt str = " << alt_str << endl;
564 alt = atof( alt_str.c_str() );
565 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) {
566 alt *= SG_FEET_TO_METER;
573 if ( fgFindAirportID( id, &a ) ) {
574 SGWayPoint wp( a.longitude, a.latitude, alt, SGWayPoint::WGS84, id );
575 globals->get_route()->add_waypoint( wp );
584 // Parse --flight-plan=[file]
586 parse_flightplan(const string& arg)
588 sg_gzifstream in(arg.c_str());
589 if ( !in.is_open() ) {
595 #if defined( macintosh )
596 getline( in, line, '\r' );
598 getline( in, line, '\n' );
601 // catch extraneous (DOS) line ending character
602 if ( line[line.length() - 1] < 32 ) {
603 line = line.substr( 0, line.length()-1 );
615 #define NEW_OPTION_PARSING 1
616 #ifdef NEW_OPTION_PARSING
618 fgOptLanguage( const char *arg )
620 globals->set_locale( fgInitLocale( arg ) );
621 return FG_OPTIONS_OK;
625 fgOptLon( const char *arg )
627 fgSetDouble("/sim/presets/longitude-deg", parse_degree( arg ));
628 fgSetDouble("/position/longitude-deg", parse_degree( arg ));
629 fgSetString("/sim/presets/airport-id", "");
630 return FG_OPTIONS_OK;
634 fgOptLat( const char *arg )
636 fgSetDouble("/sim/presets/latitude-deg", parse_degree( arg ));
637 fgSetDouble("/position/latitude-deg", parse_degree( arg ));
638 fgSetString("/sim/presets/airport-id", "");
639 return FG_OPTIONS_OK;
643 fgOptAltitude( const char *arg )
645 fgSetBool("/sim/presets/onground", false);
646 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
647 fgSetDouble("/sim/presets/altitude-ft", atof( arg ));
649 fgSetDouble("/sim/presets/altitude-ft",
650 atof( arg ) * SG_METER_TO_FEET);
651 return FG_OPTIONS_OK;
655 fgOptUBody( const char *arg )
657 fgSetString("/sim/presets/speed-set", "UVW");
658 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
659 fgSetDouble("/sim/presets/uBody-fps", atof( arg ));
661 fgSetDouble("/sim/presets/uBody-fps",
662 atof( arg ) * SG_METER_TO_FEET);
663 return FG_OPTIONS_OK;
667 fgOptVBody( const char *arg )
669 fgSetString("/sim/presets/speed-set", "UVW");
670 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
671 fgSetDouble("/sim/presets/vBody-fps", atof( arg ));
673 fgSetDouble("/sim/presets/vBody-fps",
674 atof( arg ) * SG_METER_TO_FEET);
675 return FG_OPTIONS_OK;
679 fgOptWBody( const char *arg )
681 fgSetString("/sim/presets/speed-set", "UVW");
682 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
683 fgSetDouble("/sim/presets/wBody-fps", atof(arg));
685 fgSetDouble("/sim/presets/wBody-fps",
686 atof(arg) * SG_METER_TO_FEET);
687 return FG_OPTIONS_OK;
691 fgOptVNorth( const char *arg )
693 fgSetString("/sim/presets/speed-set", "NED");
694 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
695 fgSetDouble("/sim/presets/speed-north-fps", atof( arg ));
697 fgSetDouble("/sim/presets/speed-north-fps",
698 atof( arg ) * SG_METER_TO_FEET);
699 return FG_OPTIONS_OK;
703 fgOptVEast( const char *arg )
705 fgSetString("/sim/presets/speed-set", "NED");
706 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
707 fgSetDouble("/sim/presets/speed-east-fps", atof(arg));
709 fgSetDouble("/sim/presets/speed-east-fps",
710 atof(arg) * SG_METER_TO_FEET);
711 return FG_OPTIONS_OK;
715 fgOptVDown( const char *arg )
717 fgSetString("/sim/presets/speed-set", "NED");
718 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
719 fgSetDouble("/sim/presets/speed-down-fps", atof(arg));
721 fgSetDouble("/sim/presets/speed-down-fps",
722 atof(arg) * SG_METER_TO_FEET);
723 return FG_OPTIONS_OK;
727 fgOptVc( const char *arg )
729 // fgSetString("/sim/presets/speed-set", "knots");
730 // fgSetDouble("/velocities/airspeed-kt", atof(arg.substr(5)));
731 fgSetString("/sim/presets/speed-set", "knots");
732 fgSetDouble("/sim/presets/airspeed-kt", atof(arg));
733 return FG_OPTIONS_OK;
737 fgOptMach( const char *arg )
739 fgSetString("/sim/presets/speed-set", "mach");
740 fgSetDouble("/sim/presets/mach", atof(arg));
741 return FG_OPTIONS_OK;
745 fgOptRoc( const char *arg )
747 fgSetDouble("/velocities/vertical-speed-fps", atof(arg)/60);
748 return FG_OPTIONS_OK;
752 fgOptFgRoot( const char *arg )
754 globals->set_fg_root(arg);
755 return FG_OPTIONS_OK;
759 fgOptFgScenery( const char *arg )
761 globals->set_fg_scenery(arg);
762 return FG_OPTIONS_OK;
766 fgOptFov( const char *arg )
769 return FG_OPTIONS_OK;
773 fgOptGeometry( const char *arg )
775 bool geometry_ok = true;
776 int xsize = 0, ysize = 0;
777 string geometry = arg;
778 string::size_type i = geometry.find('x');
780 if (i != string::npos) {
781 xsize = atoi(geometry.substr(0, i));
782 ysize = atoi(geometry.substr(i+1));
787 if ( xsize <= 0 || ysize <= 0 ) {
793 if ( !geometry_ok ) {
794 SG_LOG( SG_GENERAL, SG_ALERT, "Unknown geometry: " << geometry );
795 SG_LOG( SG_GENERAL, SG_ALERT,
796 "Setting geometry to " << xsize << 'x' << ysize << '\n');
798 SG_LOG( SG_GENERAL, SG_INFO,
799 "Setting geometry to " << xsize << 'x' << ysize << '\n');
800 fgSetInt("/sim/startup/xsize", xsize);
801 fgSetInt("/sim/startup/ysize", ysize);
803 return FG_OPTIONS_OK;
807 fgOptBpp( const char *arg )
809 string bits_per_pix = arg;
810 if ( bits_per_pix == "16" ) {
811 fgSetInt("/sim/rendering/bits-per-pixel", 16);
812 } else if ( bits_per_pix == "24" ) {
813 fgSetInt("/sim/rendering/bits-per-pixel", 24);
814 } else if ( bits_per_pix == "32" ) {
815 fgSetInt("/sim/rendering/bits-per-pixel", 32);
817 SG_LOG(SG_GENERAL, SG_ALERT, "Unsupported bpp " << bits_per_pix);
819 return FG_OPTIONS_OK;
823 fgOptTimeOffset( const char *arg )
825 fgSetInt("/sim/startup/time-offset",
826 parse_time_offset( arg ));
827 fgSetString("/sim/startup/time-offset-type", "system-offset");
828 return FG_OPTIONS_OK;
832 fgOptStartDateSys( const char *arg )
834 fgSetInt("/sim/startup/time-offset", parse_date( arg ) );
835 fgSetString("/sim/startup/time-offset-type", "system");
836 return FG_OPTIONS_OK;
840 fgOptStartDateLat( const char *arg )
842 fgSetInt("/sim/startup/time-offset", parse_date( arg ) );
843 fgSetString("/sim/startup/time-offset-type", "latitude");
844 return FG_OPTIONS_OK;
848 fgOptStartDateGmt( const char *arg )
850 fgSetInt("/sim/startup/time-offset", parse_date( arg ) );
851 fgSetString("/sim/startup/time-offset-type", "gmt");
852 return FG_OPTIONS_OK;
855 #ifdef FG_NETWORK_OLK
857 fgOptNetHud( const char *arg )
859 fgSetBool("/sim/hud/net-display", true);
860 net_hud_display = 1; // FIXME
861 return FG_OPTIONS_OK;
866 fgOptTraceRead( const char *arg )
869 SG_LOG(SG_GENERAL, SG_INFO, "Tracing reads for property " << name);
870 fgGetNode(name.c_str(), true)
871 ->setAttribute(SGPropertyNode::TRACE_READ, true);
872 return FG_OPTIONS_OK;
876 fgOptTraceWrite( const char *arg )
879 SG_LOG(SG_GENERAL, SG_INFO, "Tracing writes for property " << name);
880 fgGetNode(name.c_str(), true)
881 ->setAttribute(SGPropertyNode::TRACE_WRITE, true);
882 return FG_OPTIONS_OK;
886 fgOptViewOffset( const char *arg )
888 // $$$ begin - added VS Renganathan, 14 Oct 2K
889 // for multi-window outside window imagery
890 string woffset = arg;
891 double default_view_offset = 0.0;
892 if ( woffset == "LEFT" ) {
893 default_view_offset = SGD_PI * 0.25;
894 } else if ( woffset == "RIGHT" ) {
895 default_view_offset = SGD_PI * 1.75;
896 } else if ( woffset == "CENTER" ) {
897 default_view_offset = 0.00;
899 default_view_offset = atof( woffset.c_str() ) * SGD_DEGREES_TO_RADIANS;
901 /* apparently not used (CLO, 11 Jun 2002)
902 FGViewer *pilot_view =
903 (FGViewer *)globals->get_viewmgr()->get_view( 0 ); */
904 // this will work without calls to the viewer...
905 fgSetDouble( "/sim/current-view/heading-offset-deg",
906 default_view_offset * SGD_RADIANS_TO_DEGREES );
907 // $$$ end - added VS Renganathan, 14 Oct 2K
908 return FG_OPTIONS_OK;
912 fgOptVisibilityMiles( const char *arg )
914 double visibility = atof( arg ) * 5280.0 * SG_FEET_TO_METER;
915 fgSetDouble("/environment/visibility-m", visibility);
916 return FG_OPTIONS_OK;
920 fgOptRandomWind( const char *arg )
922 double min_hdg = sg_random() * 360.0;
923 double max_hdg = min_hdg + (20 - sqrt(sg_random() * 400));
924 double speed = 40 - sqrt(sg_random() * 1600.0);
925 double gust = speed + (10 - sqrt(sg_random() * 100));
926 setup_wind(min_hdg, max_hdg, speed, gust);
927 return FG_OPTIONS_OK;
931 fgOptWind( const char *arg )
933 double min_hdg, max_hdg, speed, gust;
934 if (!parse_wind( arg, &min_hdg, &max_hdg, &speed, &gust)) {
935 SG_LOG( SG_GENERAL, SG_ALERT, "bad wind value " << arg );
936 return FG_OPTIONS_ERROR;
938 setup_wind(min_hdg, max_hdg, speed, gust);
939 return FG_OPTIONS_OK;
943 fgOptWp( const char *arg )
946 return FG_OPTIONS_OK;
950 fgOptFlightPlan( const char *arg )
952 parse_flightplan ( arg );
953 return FG_OPTIONS_OK;
957 fgOptConfig( const char *arg )
961 readProperties(file, globals->get_props());
962 } catch (const sg_exception &e) {
963 string message = "Error loading config file: ";
964 message += e.getFormattedMessage();
965 SG_LOG(SG_INPUT, SG_ALERT, message);
968 return FG_OPTIONS_OK;
971 static map<string,size_t> fgOptionMap;
973 enum OptionType { OPTION_BOOL, OPTION_STRING, OPTION_DOUBLE, OPTION_INT, OPTION_CHANNEL, OPTION_FUNC };
977 enum OptionType type;
981 int (*func)( const char * );
982 } fgOptionArray[] = {
984 {"language", true, OPTION_FUNC, "", false, "", fgOptLanguage },
985 {"disable-game-mode", false, OPTION_BOOL, "/sim/startup/game-mode", false, "", 0 },
986 {"enable-game-mode", false, OPTION_BOOL, "/sim/startup/game-mode", true, "", 0 },
987 {"disable-splash-screen", false, OPTION_BOOL, "/sim/startup/splash-screen", false, "", 0 },
988 {"enable-splash-screen", false, OPTION_BOOL, "/sim/startup/splash-screen", true, "", 0 },
989 {"disable-intro-music", false, OPTION_BOOL, "/sim/startup/intro-music", false, "", 0 },
990 {"enable-intro-music", false, OPTION_BOOL, "/sim/startup/intro-music", true, "", 0 },
991 {"disable-mouse-pointer", false, OPTION_STRING, "/sim/startup/mouse-pointer", false, "disabled", 0 },
992 {"enable-mouse-pointer", false, OPTION_STRING, "/sim/startup/mouse-pointer", false, "enabled", 0 },
993 {"disable-random-objects", false, OPTION_BOOL, "/sim/rendering/random-objects", false, "", 0 },
994 {"enable-random-objects", false, OPTION_BOOL, "/sim/rendering/random-objects", true, "", 0 },
995 {"disable-freeze", false, OPTION_BOOL, "/sim/freeze/master", false, "", 0 },
996 {"enable-freeze", false, OPTION_BOOL, "/sim/freeze/master", true, "", 0 },
997 {"disable-fuel-freeze", false, OPTION_BOOL, "/sim/freeze/fuel", false, "", 0 },
998 {"enable-fuel-freeze", false, OPTION_BOOL, "/sim/freeze/fuel", true, "", 0 },
999 {"disable-clock-freeze", false, OPTION_BOOL, "/sim/freeze/clock", false, "", 0 },
1000 {"enable-clock-freeze", false, OPTION_BOOL, "/sim/freeze/clock", true, "", 0 },
1001 {"disable-anti-alias-hud", false, OPTION_BOOL, "/sim/hud/antialiased", false, "", 0 },
1002 {"enable-anti-alias-hud", false, OPTION_BOOL, "/sim/hud/antialiased", true, "", 0 },
1003 {"control", true, OPTION_STRING, "/sim/control-mode", false, "", 0 },
1004 {"disable-auto-coordination", false, OPTION_BOOL, "/sim/auto-coordination", false, "", 0 },
1005 {"enable-auto-coordination", false, OPTION_BOOL, "/sim/auto-coordination", true, "", 0 },
1006 {"browser-app", true, OPTION_STRING, "/sim/startup/browser-app", false, "", 0 },
1007 {"disable-hud", false, OPTION_BOOL, "/sim/hud/visibility", false, "", 0 },
1008 {"enable-hud", false, OPTION_BOOL, "/sim/hud/visibility", true, "", 0 },
1009 {"disable-panel", false, OPTION_BOOL, "/sim/panel/visibility", false, "", 0 },
1010 {"enable-panel", false, OPTION_BOOL, "/sim/panel/visibility", true, "", 0 },
1011 {"disable-sound", false, OPTION_BOOL, "/sim/sound/audible", false, "", 0 },
1012 {"enable-sound", false, OPTION_BOOL, "/sim/sound/audible", true, "", 0 },
1013 {"airport", true, OPTION_STRING, "/sim/presets/airport-id", false, "", 0 },
1014 {"airport-id", true, OPTION_STRING, "/sim/presets/airport-id", false, "", 0 },
1015 {"runway", true, OPTION_STRING, "/sim/presets/runway", false, "", 0 },
1016 {"offset-distance", true, OPTION_DOUBLE, "/sim/presets/offset-distance", false, "", 0 },
1017 {"offset-azimuth", true, OPTION_DOUBLE, "/sim/presets/offset-azimuth", false, "", 0 },
1018 {"lon", true, OPTION_FUNC, "", false, "", fgOptLon },
1019 {"lat", true, OPTION_FUNC, "", false, "", fgOptLat },
1020 {"altitude", true, OPTION_FUNC, "", false, "", fgOptAltitude },
1021 {"uBody", true, OPTION_FUNC, "", false, "", fgOptUBody },
1022 {"vBody", true, OPTION_FUNC, "", false, "", fgOptVBody },
1023 {"wBody", true, OPTION_FUNC, "", false, "", fgOptWBody },
1024 {"vNorth", true, OPTION_FUNC, "", false, "", fgOptVNorth },
1025 {"vEast", true, OPTION_FUNC, "", false, "", fgOptVEast },
1026 {"vDown", true, OPTION_FUNC, "", false, "", fgOptVDown },
1027 {"vc", true, OPTION_FUNC, "", false, "", fgOptVc },
1028 {"mach", true, OPTION_FUNC, "", false, "", fgOptMach },
1029 {"heading", true, OPTION_DOUBLE, "/sim/presets/heading-deg", false, "", 0 },
1030 {"roll", true, OPTION_DOUBLE, "/sim/presets/roll-deg", false, "", 0 },
1031 {"pitch", true, OPTION_DOUBLE, "/sim/presets/pitch-deg", false, "", 0 },
1032 {"glideslope", true, OPTION_DOUBLE, "/sim/presets/glideslope-deg", false, "", 0 },
1033 {"roc", true, OPTION_FUNC, "", false, "", fgOptRoc },
1034 {"fg-root", true, OPTION_FUNC, "", false, "", fgOptFgRoot },
1035 {"fg-scenery", true, OPTION_FUNC, "", false, "", fgOptFgScenery },
1036 {"fdm", true, OPTION_STRING, "/sim/flight-model", false, "", 0 },
1037 {"aero", true, OPTION_STRING, "/sim/aero", false, "", 0 },
1038 {"aircraft-dir", true, OPTION_STRING, "/sim/aircraft-dir", false, "", 0 },
1039 {"model-hz", true, OPTION_INT, "/sim/model-hz", false, "", 0 },
1040 {"speed", true, OPTION_INT, "/sim/speed-up", false, "", 0 },
1041 {"trim", false, OPTION_BOOL, "/sim/presets/trim", true, "", 0 },
1042 {"notrim", false, OPTION_BOOL, "/sim/presets/trim", false, "", 0 },
1043 {"on-ground", false, OPTION_BOOL, "/sim/presets/onground", true, "", 0 },
1044 {"in-air", false, OPTION_BOOL, "/sim/presets/onground", false, "", 0 },
1045 {"fog-disable", false, OPTION_STRING, "/sim/rendering/fog", false, "disabled", 0 },
1046 {"fog-fastest", false, OPTION_STRING, "/sim/rendering/fog", false, "fastest", 0 },
1047 {"fog-nicest", false, OPTION_STRING, "/sim/fog", false, "nicest", 0 },
1048 {"disable-distance-attenuation", false, OPTION_BOOL, "/environment/distance-attenuation", false, "", 0 },
1049 {"enable-distance-attenuation", false, OPTION_BOOL, "/environment/distance-attenuation", true, "", 0 },
1050 {"disable-clouds", false, OPTION_BOOL, "/environment/clouds/status", false, "", 0 },
1051 {"enable-clouds", false, OPTION_BOOL, "/environment/clouds/status", true, "", 0 },
1052 #ifdef FG_USE_CLOUDS_3D
1053 {"disable-clouds3d", false, OPTION_BOOL, "/sim/rendering/clouds3d", false, "", 0 },
1054 {"enable-clouds3d", false, OPTION_BOOL, "/sim/rendering/clouds3d", true, "", 0 },
1056 {"fov", true, OPTION_FUNC, "", false, "", fgOptFov },
1057 {"disable-fullscreen", false, OPTION_BOOL, "/sim/startup/fullscreen", false, "", 0 },
1058 {"enable-fullscreen", false, OPTION_BOOL, "/sim/startup/fullscreen", true, "", 0 },
1059 {"shading-flat", false, OPTION_BOOL, "/sim/rendering/shading", false, "", 0 },
1060 {"shading-smooth", false, OPTION_BOOL, "/sim/rendering/shading", true, "", 0 },
1061 {"disable-skyblend", false, OPTION_BOOL, "/sim/rendering/skyblend", false, "", 0 },
1062 {"enable-skyblend", false, OPTION_BOOL, "/sim/rendering/skyblend", true, "", 0 },
1063 {"disable-textures", false, OPTION_BOOL, "/sim/rendering/textures", false, "", 0 },
1064 {"enable-textures", false, OPTION_BOOL, "/sim/rendering/textures", true, "", 0 },
1065 {"disable-wireframe", false, OPTION_BOOL, "/sim/rendering/wireframe", false, "", 0 },
1066 {"enable-wireframe", false, OPTION_BOOL, "/sim/rendering/wireframe", true, "", 0 },
1067 {"geometry", true, OPTION_FUNC, "", false, "", fgOptGeometry },
1068 {"bpp", true, OPTION_FUNC, "", false, "", fgOptBpp },
1069 {"units-feet", false, OPTION_STRING, "/sim/startup/units", false, "feet", 0 },
1070 {"units-meters", false, OPTION_STRING, "/sim/startup/units", false, "meters", 0 },
1071 {"time-offset", true, OPTION_FUNC, "", false, "", fgOptTimeOffset },
1072 {"time-match-real", false, OPTION_STRING, "/sim/startup/time-offset-type", false, "system-offset", 0 },
1073 {"time-match-local", false, OPTION_STRING, "/sim/startup/time-offset-type", false, "latitude-offset", 0 },
1074 {"start-date-sys", true, OPTION_FUNC, "", false, "", fgOptStartDateSys },
1075 {"start-date-lat", true, OPTION_FUNC, "", false, "", fgOptStartDateLat },
1076 {"start-date-gmt", true, OPTION_FUNC, "", false, "", fgOptStartDateGmt },
1077 {"hud-tris", false, OPTION_STRING, "/sim/hud/frame-stat-type", false, "tris", 0 },
1078 {"hud-culled", false, OPTION_STRING, "/sim/hud/frame-stat-type", false, "culled", 0 },
1079 {"atc610x", false, OPTION_CHANNEL, "", false, "dummy", 0 },
1080 {"atlas", true, OPTION_CHANNEL, "", false, "", 0 },
1081 {"httpd", true, OPTION_CHANNEL, "", false, "", 0 },
1082 #ifdef FG_JPEG_SERVER
1083 {"jpg-httpd", true, OPTION_CHANNEL, "", false, "", 0 },
1085 {"native", true, OPTION_CHANNEL, "", false, "", 0 },
1086 {"native-ctrls", true, OPTION_CHANNEL, "", false, "", 0 },
1087 {"native-fdm", true, OPTION_CHANNEL, "", false, "", 0 },
1088 {"native-gui", true, OPTION_CHANNEL, "", false, "", 0 },
1089 {"opengc", true, OPTION_CHANNEL, "", false, "", 0 },
1090 {"garmin", true, OPTION_CHANNEL, "", false, "", 0 },
1091 {"nmea", true, OPTION_CHANNEL, "", false, "", 0 },
1092 {"props", true, OPTION_CHANNEL, "", false, "", 0 },
1093 {"telnet", true, OPTION_CHANNEL, "", false, "", 0 },
1094 {"pve", true, OPTION_CHANNEL, "", false, "", 0 },
1095 {"ray", true, OPTION_CHANNEL, "", false, "", 0 },
1096 {"rul", true, OPTION_CHANNEL, "", false, "", 0 },
1097 {"joyclient", true, OPTION_CHANNEL, "", false, "", 0 },
1098 #ifdef FG_NETWORK_OLK
1099 {"disable-network-olk", false, OPTION_BOOL, "/sim/networking/olk", false, "", 0 },
1100 {"enable-network-olk", false, OPTION_BOOL, "/sim/networking/olk", true, "", 0 },
1101 {"net-hud", false, OPTION_FUNC, "", false, "", fgOptNetHud },
1102 {"net-id", true, OPTION_STRING, "sim/networking/call-sign", false, "", 0 },
1104 {"trace-read", true, OPTION_FUNC, "", false, "", fgOptTraceRead },
1105 {"trace-write", true, OPTION_FUNC, "", false, "", fgOptTraceWrite },
1106 {"view-offset", true, OPTION_FUNC, "", false, "", fgOptViewOffset },
1107 {"visibility", true, OPTION_DOUBLE, "/environment/visibility-m", false, "", 0 },
1108 {"visibility-miles", true, OPTION_FUNC, "", false, "", fgOptVisibilityMiles },
1109 {"random-wind", false, OPTION_FUNC, "", false, "", fgOptRandomWind },
1110 {"wind", true, OPTION_FUNC, "", false, "", fgOptWind },
1111 {"wp", true, OPTION_FUNC, "", false, "", fgOptWp },
1112 {"flight-plan", true, OPTION_FUNC, "", false, "", fgOptFlightPlan },
1113 {"config", true, OPTION_FUNC, "", false, "", fgOptConfig },
1114 {"aircraft", true, OPTION_STRING, "/sim/aircraft", false, "", 0 },
1119 // Parse a single option
1121 parse_option (const string& arg)
1123 #ifdef NEW_OPTION_PARSING
1124 if ( fgOptionMap.size() == 0 ) {
1126 OptionDesc *pt = &fgOptionArray[ 0 ];
1127 while ( pt->option != 0 ) {
1128 fgOptionMap[ pt->option ] = i;
1135 if ( (arg == "--help") || (arg == "-h") ) {
1136 // help/usage request
1137 return(FG_OPTIONS_HELP);
1138 } else if ( (arg == "--verbose") || (arg == "-v") ) {
1139 // verbose help/usage request
1140 return(FG_OPTIONS_VERBOSE_HELP);
1141 } else if ( arg.find( "--show-aircraft") == 0) {
1142 return(FG_OPTIONS_SHOW_AIRCRAFT);
1143 } else if ( arg.find( "--prop:" ) == 0 ) {
1144 string assign = arg.substr(7);
1145 string::size_type pos = assign.find('=');
1146 if ( pos == arg.npos || pos == 0 ) {
1147 SG_LOG( SG_GENERAL, SG_ALERT, "Bad property assignment: " << arg );
1148 return FG_OPTIONS_ERROR;
1150 string name = assign.substr(0, pos);
1151 string value = assign.substr(pos + 1);
1152 fgSetString(name.c_str(), value.c_str());
1153 // SG_LOG(SG_GENERAL, SG_INFO, "Setting default value of property "
1154 // << name << " to \"" << value << '"');
1155 } else if ( arg.find( "--" ) == 0 ) {
1156 size_t pos = arg.find( '=' );
1158 if ( pos == string::npos ) {
1159 arg_name = arg.substr( 2 );
1161 arg_name = arg.substr( 2, pos - 2 );
1163 map<string,size_t>::iterator it = fgOptionMap.find( arg_name );
1164 if ( it != fgOptionMap.end() ) {
1165 OptionDesc *pt = &fgOptionArray[ it->second ];
1166 switch ( pt->type ) {
1168 fgSetBool( pt->property, pt->b_param );
1171 if ( pt->has_param && pos != string::npos ) {
1172 fgSetString( pt->property, arg.substr( pos + 1 ).c_str() );
1173 } else if ( !pt->has_param && pos == string::npos ) {
1174 fgSetString( pt->property, pt->s_param );
1175 } else if ( pt->has_param ) {
1176 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' needs a parameter" );
1177 return FG_OPTIONS_ERROR;
1179 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' does not have a parameter" );
1180 return FG_OPTIONS_ERROR;
1184 if ( pos != string::npos ) {
1185 fgSetDouble( pt->property, atof( arg.substr( pos + 1 ) ) );
1187 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' needs a parameter" );
1188 return FG_OPTIONS_ERROR;
1192 if ( pos != string::npos ) {
1193 fgSetInt( pt->property, atoi( arg.substr( pos + 1 ) ) );
1195 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' needs a parameter" );
1196 return FG_OPTIONS_ERROR;
1199 case OPTION_CHANNEL:
1200 if ( pt->has_param && pos != string::npos ) {
1201 add_channel( pt->option, arg.substr( pos + 1 ) );
1202 } else if ( !pt->has_param && pos == string::npos ) {
1203 add_channel( pt->option, pt->s_param );
1204 } else if ( pt->has_param ) {
1205 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' needs a parameter" );
1206 return FG_OPTIONS_ERROR;
1208 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' does not have a parameter" );
1209 return FG_OPTIONS_ERROR;
1213 if ( pt->has_param && pos != string::npos ) {
1214 pt->func( arg.substr( pos + 1 ).c_str() );
1215 } else if ( !pt->has_param && pos == string::npos ) {
1217 } else if ( pt->has_param ) {
1218 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' needs a parameter" );
1219 return FG_OPTIONS_ERROR;
1221 SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' does not have a parameter" );
1222 return FG_OPTIONS_ERROR;
1227 SG_LOG( SG_GENERAL, SG_ALERT, "Unknown option '" << arg << "'" );
1228 return FG_OPTIONS_ERROR;
1231 SG_LOG( SG_GENERAL, SG_ALERT, "Unknown option '" << arg << "'" );
1232 return FG_OPTIONS_ERROR;
1238 if ( (arg == "--help") || (arg == "-h") ) {
1239 // help/usage request
1240 return(FG_OPTIONS_HELP);
1241 } else if ( (arg == "--verbose") || (arg == "-v") ) {
1242 // verbose help/usage request
1243 return(FG_OPTIONS_VERBOSE_HELP);
1244 } else if ( arg.find( "--language=") == 0 ) {
1245 globals->set_locale( fgInitLocale( arg.substr( 11 ).c_str() ) );
1246 } else if ( arg == "--disable-game-mode") {
1247 fgSetBool("/sim/startup/game-mode", false);
1248 } else if ( arg == "--enable-game-mode" ) {
1249 fgSetBool("/sim/startup/game-mode", true);
1250 } else if ( arg == "--disable-splash-screen" ) {
1251 fgSetBool("/sim/startup/splash-screen", false);
1252 } else if ( arg == "--enable-splash-screen" ) {
1253 fgSetBool("/sim/startup/splash-screen", true);
1254 } else if ( arg == "--disable-intro-music" ) {
1255 fgSetBool("/sim/startup/intro-music", false);
1256 } else if ( arg == "--enable-intro-music" ) {
1257 fgSetBool("/sim/startup/intro-music", true);
1258 } else if ( arg == "--disable-mouse-pointer" ) {
1259 fgSetString("/sim/startup/mouse-pointer", "disabled");
1260 } else if ( arg == "--enable-mouse-pointer" ) {
1261 fgSetString("/sim/startup/mouse-pointer", "enabled");
1262 } else if ( arg == "--disable-random-objects" ) {
1263 fgSetBool("/sim/rendering/random-objects", false);
1264 } else if ( arg == "--enable-random-objects" ) {
1265 fgSetBool("/sim/rendering/random-objects", true);
1266 } else if ( arg == "--disable-freeze" ) {
1267 fgSetBool("/sim/freeze/master", false);
1268 } else if ( arg == "--enable-freeze" ) {
1269 fgSetBool("/sim/freeze/master", true);
1270 } else if ( arg == "--disable-fuel-freeze" ) {
1271 fgSetBool("/sim/freeze/fuel", false);
1272 } else if ( arg == "--enable-fuel-freeze" ) {
1273 fgSetBool("/sim/freeze/fuel", true);
1274 } else if ( arg == "--disable-clock-freeze" ) {
1275 fgSetBool("/sim/freeze/clock", false);
1276 } else if ( arg == "--enable-clock-freeze" ) {
1277 fgSetBool("/sim/freeze/clock", true);
1278 } else if ( arg == "--disable-anti-alias-hud" ) {
1279 fgSetBool("/sim/hud/antialiased", false);
1280 } else if ( arg == "--enable-anti-alias-hud" ) {
1281 fgSetBool("/sim/hud/antialiased", true);
1282 } else if ( arg.find( "--control=") == 0 ) {
1283 fgSetString("/sim/control-mode", arg.substr(10).c_str());
1284 } else if ( arg == "--disable-auto-coordination" ) {
1285 fgSetBool("/sim/auto-coordination", false);
1286 } else if ( arg == "--enable-auto-coordination" ) {
1287 fgSetBool("/sim/auto-coordination", true);
1288 } else if ( arg.find( "--browser-app=") == 0 ) {
1289 fgSetString("/sim/startup/browser-app", arg.substr(14).c_str());
1290 } else if ( arg == "--disable-hud" ) {
1291 fgSetBool("/sim/hud/visibility", false);
1292 } else if ( arg == "--enable-hud" ) {
1293 fgSetBool("/sim/hud/visibility", true);
1294 } else if ( arg == "--disable-panel" ) {
1295 fgSetBool("/sim/panel/visibility", false);
1296 } else if ( arg == "--enable-panel" ) {
1297 fgSetBool("/sim/panel/visibility", true);
1298 } else if ( arg == "--disable-sound" ) {
1299 fgSetBool("/sim/sound/audible", false);
1300 } else if ( arg == "--enable-sound" ) {
1301 fgSetBool("/sim/sound/audible", true);
1302 } else if ( arg.find( "--airport=") == 0 ) {
1303 fgSetString("/sim/presets/airport-id", arg.substr(10).c_str());
1304 } else if ( arg.find( "--airport-id=") == 0 ) {
1305 fgSetString("/sim/presets/airport-id", arg.substr(13).c_str());
1306 } else if ( arg.find( "--runway=") == 0 ) {
1307 fgSetString("/sim/presets/runway", arg.substr(9).c_str());
1308 } else if ( arg.find( "--offset-distance=") == 0 ) {
1309 fgSetDouble("/sim/presets/offset-distance", atof(arg.substr(18)));
1310 } else if ( arg.find( "--offset-azimuth=") == 0 ) {
1311 fgSetDouble("/sim/presets/offset-azimuth", atof(arg.substr(17)));
1312 } else if ( arg.find( "--lon=" ) == 0 ) {
1313 fgSetDouble("/sim/presets/longitude-deg", parse_degree(arg.substr(6)));
1314 fgSetDouble("/position/longitude-deg", parse_degree(arg.substr(6)));
1315 fgSetString("/sim/presets/airport-id", "");
1316 } else if ( arg.find( "--lat=" ) == 0 ) {
1317 fgSetDouble("/sim/presets/latitude-deg", parse_degree(arg.substr(6)));
1318 fgSetDouble("/position/latitude-deg", parse_degree(arg.substr(6)));
1319 fgSetString("/sim/presets/airport-id", "");
1320 } else if ( arg.find( "--altitude=" ) == 0 ) {
1321 fgSetBool("/sim/presets/onground", false);
1322 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1323 fgSetDouble("/sim/presets/altitude-ft", atof(arg.substr(11)));
1325 fgSetDouble("/sim/presets/altitude-ft",
1326 atof(arg.substr(11)) * SG_METER_TO_FEET);
1327 } else if ( arg.find( "--uBody=" ) == 0 ) {
1328 fgSetString("/sim/presets/speed-set", "UVW");
1329 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1330 fgSetDouble("/sim/presets/uBody-fps", atof(arg.substr(8)));
1332 fgSetDouble("/sim/presets/uBody-fps",
1333 atof(arg.substr(8)) * SG_METER_TO_FEET);
1334 } else if ( arg.find( "--vBody=" ) == 0 ) {
1335 fgSetString("/sim/presets/speed-set", "UVW");
1336 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1337 fgSetDouble("/sim/presets/vBody-fps", atof(arg.substr(8)));
1339 fgSetDouble("/sim/presets/vBody-fps",
1340 atof(arg.substr(8)) * SG_METER_TO_FEET);
1341 } else if ( arg.find( "--wBody=" ) == 0 ) {
1342 fgSetString("/sim/presets/speed-set", "UVW");
1343 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1344 fgSetDouble("/sim/presets/wBody-fps", atof(arg.substr(8)));
1346 fgSetDouble("/sim/presets/wBody-fps",
1347 atof(arg.substr(8)) * SG_METER_TO_FEET);
1348 } else if ( arg.find( "--vNorth=" ) == 0 ) {
1349 fgSetString("/sim/presets/speed-set", "NED");
1350 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1351 fgSetDouble("/sim/presets/speed-north-fps", atof(arg.substr(9)));
1353 fgSetDouble("/sim/presets/speed-north-fps",
1354 atof(arg.substr(9)) * SG_METER_TO_FEET);
1355 } else if ( arg.find( "--vEast=" ) == 0 ) {
1356 fgSetString("/sim/presets/speed-set", "NED");
1357 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1358 fgSetDouble("/sim/presets/speed-east-fps", atof(arg.substr(8)));
1360 fgSetDouble("/sim/presets/speed-east-fps",
1361 atof(arg.substr(8)) * SG_METER_TO_FEET);
1362 } else if ( arg.find( "--vDown=" ) == 0 ) {
1363 fgSetString("/sim/presets/speed-set", "NED");
1364 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
1365 fgSetDouble("/sim/presets/speed-down-fps", atof(arg.substr(8)));
1367 fgSetDouble("/sim/presets/speed-down-fps",
1368 atof(arg.substr(8)) * SG_METER_TO_FEET);
1369 } else if ( arg.find( "--vc=" ) == 0) {
1370 // fgSetString("/sim/presets/speed-set", "knots");
1371 // fgSetDouble("/velocities/airspeed-kt", atof(arg.substr(5)));
1372 fgSetString("/sim/presets/speed-set", "knots");
1373 fgSetDouble("/sim/presets/airspeed-kt", atof(arg.substr(5)));
1374 } else if ( arg.find( "--mach=" ) == 0) {
1375 fgSetString("/sim/presets/speed-set", "mach");
1376 fgSetDouble("/sim/presets/mach", atof(arg.substr(7)));
1377 } else if ( arg.find( "--heading=" ) == 0 ) {
1378 fgSetDouble("/sim/presets/heading-deg", atof(arg.substr(10)));
1379 } else if ( arg.find( "--roll=" ) == 0 ) {
1380 fgSetDouble("/sim/presets/roll-deg", atof(arg.substr(7)));
1381 } else if ( arg.find( "--pitch=" ) == 0 ) {
1382 fgSetDouble("/sim/presets/pitch-deg", atof(arg.substr(8)));
1383 } else if ( arg.find( "--glideslope=" ) == 0 ) {
1384 fgSetDouble("/sim/presets/glideslope-deg",
1385 atof(arg.substr(13)));
1386 } else if ( arg.find( "--roc=" ) == 0 ) {
1387 fgSetDouble("/velocities/vertical-speed-fps", atof(arg.substr(6))/60);
1388 } else if ( arg.find( "--fg-root=" ) == 0 ) {
1389 globals->set_fg_root(arg.substr( 10 ));
1390 } else if ( arg.find( "--fg-scenery=" ) == 0 ) {
1391 globals->set_fg_scenery(arg.substr( 13 ));
1392 } else if ( arg.find( "--fdm=" ) == 0 ) {
1393 fgSetString("/sim/flight-model", arg.substr(6).c_str());
1394 } else if ( arg.find( "--aero=" ) == 0 ) {
1395 fgSetString("/sim/aero", arg.substr(7).c_str());
1396 } else if ( arg.find( "--aircraft-dir=" ) == 0 ) {
1397 fgSetString("/sim/aircraft-dir", arg.substr(15).c_str());
1398 } else if ( arg.find( "--show-aircraft") == 0) {
1399 return(FG_OPTIONS_SHOW_AIRCRAFT);
1400 } else if ( arg.find( "--model-hz=" ) == 0 ) {
1401 fgSetInt("/sim/model-hz", atoi(arg.substr(11)));
1402 } else if ( arg.find( "--speed=" ) == 0 ) {
1403 fgSetInt("/sim/speed-up", atoi(arg.substr(8)));
1404 } else if ( arg.find( "--trim") == 0) {
1405 fgSetBool("/sim/presets/trim", true);
1406 } else if ( arg.find( "--notrim") == 0) {
1407 fgSetBool("/sim/presets/trim", false);
1408 } else if ( arg.find( "--on-ground") == 0) {
1409 fgSetBool("/sim/presets/onground", true);
1410 } else if ( arg.find( "--in-air") == 0) {
1411 fgSetBool("/sim/presets/onground", false);
1412 } else if ( arg == "--fog-disable" ) {
1413 fgSetString("/sim/rendering/fog", "disabled");
1414 } else if ( arg == "--fog-fastest" ) {
1415 fgSetString("/sim/rendering/fog", "fastest");
1416 } else if ( arg == "--fog-nicest" ) {
1417 fgSetString("/sim/fog", "nicest");
1418 } else if ( arg == "--disable-distance-attenuation" ) {
1419 fgSetBool("/environment/distance-attenuation", false);
1420 } else if ( arg == "--enable-distance-attenuation" ) {
1421 fgSetBool("/environment/distance-attenuation", true);
1422 } else if ( arg == "--disable-clouds" ) {
1423 fgSetBool("/environment/clouds/status", false);
1424 } else if ( arg == "--enable-clouds" ) {
1425 fgSetBool("/environment/clouds/status", true);
1426 #ifdef FG_USE_CLOUDS_3D
1427 } else if ( arg == "--disable-clouds3d" ) {
1428 fgSetBool("/sim/rendering/clouds3d", false);
1429 } else if ( arg == "--enable-clouds3d" ) {
1430 fgSetBool("/sim/rendering/clouds3d", true);
1432 } else if ( arg.find( "--fov=" ) == 0 ) {
1433 parse_fov( arg.substr(6) );
1434 } else if ( arg == "--disable-fullscreen" ) {
1435 fgSetBool("/sim/startup/fullscreen", false);
1436 } else if ( arg== "--enable-fullscreen") {
1437 fgSetBool("/sim/startup/fullscreen", true);
1438 } else if ( arg == "--shading-flat") {
1439 fgSetBool("/sim/rendering/shading", false);
1440 } else if ( arg == "--shading-smooth") {
1441 fgSetBool("/sim/rendering/shading", true);
1442 } else if ( arg == "--disable-skyblend") {
1443 fgSetBool("/sim/rendering/skyblend", false);
1444 } else if ( arg== "--enable-skyblend" ) {
1445 fgSetBool("/sim/rendering/skyblend", true);
1446 } else if ( arg == "--disable-textures" ) {
1447 fgSetBool("/sim/rendering/textures", false);
1448 } else if ( arg == "--enable-textures" ) {
1449 fgSetBool("/sim/rendering/textures", true);
1450 } else if ( arg == "--disable-wireframe" ) {
1451 fgSetBool("/sim/rendering/wireframe", false);
1452 } else if ( arg == "--enable-wireframe" ) {
1453 fgSetBool("/sim/rendering/wireframe", true);
1454 } else if ( arg.find( "--geometry=" ) == 0 ) {
1455 bool geometry_ok = true;
1456 int xsize = 0, ysize = 0;
1457 string geometry = arg.substr( 11 );
1458 string::size_type i = geometry.find('x');
1460 if (i != string::npos) {
1461 xsize = atoi(geometry.substr(0, i));
1462 ysize = atoi(geometry.substr(i+1));
1464 geometry_ok = false;
1467 if ( xsize <= 0 || ysize <= 0 ) {
1470 geometry_ok = false;
1473 if ( !geometry_ok ) {
1474 SG_LOG( SG_GENERAL, SG_ALERT, "Unknown geometry: " << geometry );
1475 SG_LOG( SG_GENERAL, SG_ALERT,
1476 "Setting geometry to " << xsize << 'x' << ysize << '\n');
1478 SG_LOG( SG_GENERAL, SG_INFO,
1479 "Setting geometry to " << xsize << 'x' << ysize << '\n');
1480 fgSetInt("/sim/startup/xsize", xsize);
1481 fgSetInt("/sim/startup/ysize", ysize);
1483 } else if ( arg.find( "--bpp=" ) == 0 ) {
1484 string bits_per_pix = arg.substr( 6 );
1485 if ( bits_per_pix == "16" ) {
1486 fgSetInt("/sim/rendering/bits-per-pixel", 16);
1487 } else if ( bits_per_pix == "24" ) {
1488 fgSetInt("/sim/rendering/bits-per-pixel", 24);
1489 } else if ( bits_per_pix == "32" ) {
1490 fgSetInt("/sim/rendering/bits-per-pixel", 32);
1492 SG_LOG(SG_GENERAL, SG_ALERT, "Unsupported bpp " << bits_per_pix);
1494 } else if ( arg == "--units-feet" ) {
1495 fgSetString("/sim/startup/units", "feet");
1496 } else if ( arg == "--units-meters" ) {
1497 fgSetString("/sim/startup/units", "meters");
1498 } else if ( arg.find( "--time-offset" ) == 0 ) {
1499 fgSetInt("/sim/startup/time-offset",
1500 parse_time_offset( (arg.substr(14)) ));
1501 fgSetString("/sim/startup/time-offset-type", "system-offset");
1502 } else if ( arg.find( "--time-match-real") == 0 ) {
1503 fgSetString("/sim/startup/time-offset-type", "system-offset");
1504 } else if ( arg.find( "--time-match-local") == 0 ) {
1505 fgSetString("/sim/startup/time-offset-type", "latitude-offset");
1506 } else if ( arg.find( "--start-date-sys=") == 0 ) {
1507 fgSetInt("/sim/startup/time-offset", parse_date((arg.substr(17))));
1508 fgSetString("/sim/startup/time-offset-type", "system");
1509 } else if ( arg.find( "--start-date-lat=") == 0 ) {
1510 fgSetInt("/sim/startup/time-offset", parse_date((arg.substr(17))));
1511 fgSetString("/sim/startup/time-offset-type", "latitude");
1512 } else if ( arg.find( "--start-date-gmt=") == 0 ) {
1513 fgSetInt("/sim/startup/time-offset", parse_date((arg.substr(17))));
1514 fgSetString("/sim/startup/time-offset-type", "gmt");
1515 } else if ( arg == "--hud-tris" ) {
1516 fgSetString("/sim/hud/frame-stat-type", "tris");
1517 } else if ( arg == "--hud-culled" ) {
1518 fgSetString("/sim/hud/frame-stat-type", "culled");
1519 } else if ( arg.find( "--atc610x" ) == 0 ) {
1520 add_channel( "atc610x", "dummy" );
1521 } else if ( arg.find( "--atlas=" ) == 0 ) {
1522 add_channel( "atlas", arg.substr(8) );
1523 } else if ( arg.find( "--httpd=" ) == 0 ) {
1524 add_channel( "httpd", arg.substr(8) );
1525 #ifdef FG_JPEG_SERVER
1526 } else if ( arg.find( "--jpg-httpd=" ) == 0 ) {
1527 add_channel( "jpg-httpd", arg.substr(12) );
1529 } else if ( arg.find( "--native=" ) == 0 ) {
1530 add_channel( "native", arg.substr(9) );
1531 } else if ( arg.find( "--native-ctrls=" ) == 0 ) {
1532 add_channel( "native_ctrls", arg.substr(15) );
1533 } else if ( arg.find( "--native-fdm=" ) == 0 ) {
1534 add_channel( "native_fdm", arg.substr(13) );
1535 } else if ( arg.find( "--native-gui=" ) == 0 ) {
1536 add_channel( "native_gui", arg.substr(13) );
1537 } else if ( arg.find( "--opengc=" ) == 0 ) {
1539 // cout << "Adding channel for OpenGC Display" << endl; cin >> stop;
1540 add_channel( "opengc", arg.substr(9) );
1541 } else if ( arg.find( "--garmin=" ) == 0 ) {
1542 add_channel( "garmin", arg.substr(9) );
1543 } else if ( arg.find( "--nmea=" ) == 0 ) {
1544 add_channel( "nmea", arg.substr(7) );
1545 } else if ( arg.find( "--props=" ) == 0 ) {
1546 add_channel( "props", arg.substr(8) );
1547 } else if ( arg.find( "--telnet=" ) == 0 ) {
1548 add_channel( "telnet", arg.substr(9) );
1549 } else if ( arg.find( "--pve=" ) == 0 ) {
1550 add_channel( "pve", arg.substr(6) );
1551 } else if ( arg.find( "--ray=" ) == 0 ) {
1552 add_channel( "ray", arg.substr(6) );
1553 } else if ( arg.find( "--rul=" ) == 0 ) {
1554 add_channel( "rul", arg.substr(6) );
1555 } else if ( arg.find( "--joyclient=" ) == 0 ) {
1556 add_channel( "joyclient", arg.substr(12) );
1557 #ifdef FG_NETWORK_OLK
1558 } else if ( arg == "--disable-network-olk" ) {
1559 fgSetBool("/sim/networking/olk", false);
1560 } else if ( arg== "--enable-network-olk") {
1561 fgSetBool("/sim/networking/olk", true);
1562 } else if ( arg == "--net-hud" ) {
1563 fgSetBool("/sim/hud/net-display", true);
1564 net_hud_display = 1; // FIXME
1565 } else if ( arg.find( "--net-id=") == 0 ) {
1566 fgSetString("sim/networking/call-sign", arg.substr(9).c_str());
1568 } else if ( arg.find( "--prop:" ) == 0 ) {
1569 string assign = arg.substr(7);
1570 string::size_type pos = assign.find('=');
1571 if ( pos == arg.npos || pos == 0 ) {
1572 SG_LOG( SG_GENERAL, SG_ALERT, "Bad property assignment: " << arg );
1573 return FG_OPTIONS_ERROR;
1575 string name = assign.substr(0, pos);
1576 string value = assign.substr(pos + 1);
1577 fgSetString(name.c_str(), value.c_str());
1578 // SG_LOG(SG_GENERAL, SG_INFO, "Setting default value of property "
1579 // << name << " to \"" << value << '"');
1580 } else if ( arg.find("--trace-read=") == 0) {
1581 string name = arg.substr(13);
1582 SG_LOG(SG_GENERAL, SG_INFO, "Tracing reads for property " << name);
1583 fgGetNode(name.c_str(), true)
1584 ->setAttribute(SGPropertyNode::TRACE_READ, true);
1585 } else if ( arg.find("--trace-write=") == 0) {
1586 string name = arg.substr(14);
1587 SG_LOG(SG_GENERAL, SG_INFO, "Tracing writes for property " << name);
1588 fgGetNode(name.c_str(), true)
1589 ->setAttribute(SGPropertyNode::TRACE_WRITE, true);
1590 } else if ( arg.find( "--view-offset=" ) == 0 ) {
1591 // $$$ begin - added VS Renganathan, 14 Oct 2K
1592 // for multi-window outside window imagery
1593 string woffset = arg.substr( 14 );
1594 double default_view_offset = 0.0;
1595 if ( woffset == "LEFT" ) {
1596 default_view_offset = SGD_PI * 0.25;
1597 } else if ( woffset == "RIGHT" ) {
1598 default_view_offset = SGD_PI * 1.75;
1599 } else if ( woffset == "CENTER" ) {
1600 default_view_offset = 0.00;
1602 default_view_offset = atof( woffset.c_str() ) * SGD_DEGREES_TO_RADIANS;
1604 /* apparently not used (CLO, 11 Jun 2002)
1605 FGViewer *pilot_view =
1606 (FGViewer *)globals->get_viewmgr()->get_view( 0 ); */
1607 // this will work without calls to the viewer...
1608 fgSetDouble( "/sim/current-view/heading-offset-deg",
1609 default_view_offset * SGD_RADIANS_TO_DEGREES );
1610 // $$$ end - added VS Renganathan, 14 Oct 2K
1611 } else if ( arg.find( "--visibility=" ) == 0 ) {
1612 fgSetDouble("/environment/visibility-m", atof(arg.substr(13)));
1613 } else if ( arg.find( "--visibility-miles=" ) == 0 ) {
1614 double visibility = atof(arg.substr(19)) * 5280.0 * SG_FEET_TO_METER;
1615 fgSetDouble("/environment/visibility-m", visibility);
1616 } else if ( arg.find( "--random-wind" ) == 0 ) {
1617 double min_hdg = sg_random() * 360.0;
1618 double max_hdg = min_hdg + (20 - sqrt(sg_random() * 400));
1619 double speed = 40 - sqrt(sg_random() * 1600.0);
1620 double gust = speed + (10 - sqrt(sg_random() * 100));
1621 setup_wind(min_hdg, max_hdg, speed, gust);
1622 } else if ( arg.find( "--wind=" ) == 0 ) {
1623 double min_hdg, max_hdg, speed, gust;
1624 if (!parse_wind(arg.substr(7), &min_hdg, &max_hdg, &speed, &gust)) {
1625 SG_LOG( SG_GENERAL, SG_ALERT, "bad wind value " << arg.substr(7) );
1626 return FG_OPTIONS_ERROR;
1628 setup_wind(min_hdg, max_hdg, speed, gust);
1629 } else if ( arg.find( "--wp=" ) == 0 ) {
1630 parse_wp( arg.substr( 5 ) );
1631 } else if ( arg.find( "--flight-plan=") == 0) {
1632 parse_flightplan ( arg.substr (14) );
1633 } else if ( arg.find( "--config=" ) == 0 ) {
1634 string file = arg.substr(9);
1636 readProperties(file, globals->get_props());
1637 } catch (const sg_exception &e) {
1638 string message = "Error loading config file: ";
1639 message += e.getFormattedMessage();
1640 SG_LOG(SG_INPUT, SG_ALERT, message);
1643 } else if ( arg.find( "--aircraft=" ) == 0 ) {
1644 fgSetString("/sim/aircraft", arg.substr(11).c_str());
1646 SG_LOG( SG_GENERAL, SG_ALERT, "Unknown option '" << arg << "'" );
1647 return FG_OPTIONS_ERROR;
1651 return FG_OPTIONS_OK;
1655 // Parse the command line options
1657 fgParseArgs (int argc, char **argv)
1659 bool in_options = true;
1660 bool verbose = false;
1663 SG_LOG(SG_GENERAL, SG_INFO, "Processing command line arguments");
1665 for (int i = 1; i < argc; i++) {
1666 string arg = argv[i];
1668 if (in_options && (arg.find('-') == 0)) {
1672 int result = parse_option(arg);
1673 if ((result == FG_OPTIONS_HELP) || (result == FG_OPTIONS_ERROR))
1676 else if (result == FG_OPTIONS_VERBOSE_HELP)
1679 else if (result == FG_OPTIONS_SHOW_AIRCRAFT) {
1686 SG_LOG(SG_GENERAL, SG_INFO,
1687 "Reading command-line property file " << arg);
1688 readProperties(arg, globals->get_props());
1697 SG_LOG(SG_GENERAL, SG_INFO, "Finished command line arguments");
1701 // Parse config file options
1703 fgParseOptions (const string& path) {
1704 sg_gzifstream in( path );
1705 if ( !in.is_open() ) {
1709 SG_LOG( SG_GENERAL, SG_INFO, "Processing config file: " << path );
1713 while ( ! in.eof() ) {
1716 while ( in.get(c) && c != '\0' ) {
1721 #if defined( macintosh )
1722 getline( in, line, '\r' );
1724 getline( in, line, '\n' );
1727 // catch extraneous (DOS) line ending character
1728 if ( line[line.length() - 1] < 32 ) {
1729 line = line.substr( 0, line.length()-1 );
1732 if ( parse_option( line ) == FG_OPTIONS_ERROR ) {
1733 cerr << endl << "Config file parse error: " << path << " '"
1734 << line << "'" << endl;
1743 // Print usage message
1745 fgUsage (bool verbose)
1747 SGPropertyNode *locale = globals->get_locale();
1749 SGPropertyNode options_root;
1754 fgLoadProps("options.xml", &options_root);
1755 } catch (const sg_exception &ex) {
1756 cout << "Unable to read the help file." << endl;
1757 cout << "Make sure the file options.xml is located in the FlightGear base directory," << endl;
1758 cout << "and the location of the base directory is specified by setting $FG_ROOT or" << endl;
1759 cout << "by adding --fg-root=path as a program argument." << endl;
1764 SGPropertyNode *options = options_root.getNode("options");
1766 SG_LOG( SG_GENERAL, SG_ALERT,
1767 "Error reading options.xml: <options> directive not found." );
1771 SGPropertyNode *usage = locale->getNode(options->getStringValue("usage"));
1773 cout << "Usage: " << usage->getStringValue() << endl;
1776 vector<SGPropertyNode_ptr>section = options->getChildren("section");
1777 for (unsigned int j = 0; j < section.size(); j++) {
1780 vector<SGPropertyNode_ptr>option = section[j]->getChildren("option");
1781 for (unsigned int k = 0; k < option.size(); k++) {
1783 SGPropertyNode *name = option[k]->getNode("name");
1784 SGPropertyNode *short_name = option[k]->getNode("short");
1785 SGPropertyNode *key = option[k]->getNode("key");
1786 SGPropertyNode *arg = option[k]->getNode("arg");
1787 bool brief = option[k]->getNode("brief");
1789 if ((brief || verbose) && name) {
1790 string tmp = name->getStringValue();
1794 tmp.append(key->getStringValue());
1798 tmp.append(arg->getStringValue());
1802 tmp.append(short_name->getStringValue());
1806 if (tmp.size() <= 25) {
1807 snprintf(cstr, 96, " --%-27s", tmp.c_str());
1809 snprintf(cstr, 96, "\n --%s\n%32c", tmp.c_str(), ' ');
1812 // There may be more than one <description> tag assosiated
1816 vector<SGPropertyNode_ptr>desc =
1817 option[k]->getChildren("description");
1819 if (desc.size() > 0) {
1820 for ( unsigned int l = 0; l < desc.size(); l++) {
1822 // There may be more than one translation line.
1824 string t = desc[l]->getStringValue();
1825 SGPropertyNode *n = locale->getNode("strings");
1826 vector<SGPropertyNode_ptr>trans_desc =
1827 n->getChildren(t.substr(8).c_str());
1829 for ( unsigned int m = 0; m < trans_desc.size(); m++ ) {
1830 string t_str = trans_desc[m]->getStringValue();
1832 if ((m > 0) || ((l > 0) && m == 0)) {
1833 snprintf(cstr, 96, "%32c", ' ');
1838 // If the string is too large to fit on the screen,
1839 // then split it up in several pieces.
1841 while ( t_str.size() > 47 ) {
1843 unsigned int m = t_str.rfind(' ', 47);
1844 msg += t_str.substr(0, m);
1845 snprintf(cstr, 96, "\n%32c", ' ');
1848 t_str.erase(t_str.begin(), t_str.begin() + m + 1);
1850 msg += t_str + '\n';
1857 SGPropertyNode *name =
1858 locale->getNode(section[j]->getStringValue("name"));
1860 if (!msg.empty() && name) {
1861 cout << endl << name->getStringValue() << ":" << endl;
1869 cout << "For a complete list of options use --help --verbose" << endl;
1873 // Show available aircraft types
1874 void fgShowAircraft(void) {
1875 SGPath path( globals->get_fg_root() );
1876 path.append("Aircraft");
1881 dirp = ulOpenDir(path.c_str());
1883 cerr << "Unable to open aircraft directory." << endl;
1887 cout << "Available aircraft:" << endl;
1888 while ((dire = ulReadDir(dirp)) != NULL) {
1891 if ((ptr = strstr(dire->d_name, "-set.xml")) && ptr[8] == '\0' ) {
1892 SGPath afile = path;
1893 afile.append(dire->d_name);
1897 SGPropertyNode root;
1899 readProperties(afile.str(), &root);
1904 SGPropertyNode *desc = NULL;
1905 SGPropertyNode *node = root.getNode("sim");
1907 desc = node->getNode("description");
1911 if (strlen(dire->d_name) <= 27)
1912 snprintf(cstr, 96, " %-27s %s", dire->d_name,
1913 (desc) ? desc->getStringValue() : "" );
1916 snprintf(cstr, 96, " %-27s\n%32c%s", dire->d_name, ' ',
1917 (desc) ? desc->getStringValue() : "" );
1919 cout << cstr << endl;