]> git.mxchange.org Git - flightgear.git/blob - src/Main/options.cxx
Corrected wind, so that properties give the FROM direction for all
[flightgear.git] / src / Main / options.cxx
1 // options.cxx -- class to handle command line options
2 //
3 // Written by Curtis Olson, started April 1998.
4 //
5 // Copyright (C) 1998  Curtis L. Olson  - curt@me.umn.edu
6 //
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.
11 //
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.
16 //
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.
20 //
21 // $Id$
22
23
24 #ifdef HAVE_CONFIG_H
25 #  include <config.h>
26 #endif
27
28 #include <simgear/compiler.h>
29 #include <simgear/misc/exception.hxx>
30
31 #include <math.h>            // rint()
32 #include <stdio.h>
33 #include <stdlib.h>          // atof(), atoi()
34 #include <string.h>
35
36 #include STL_STRING
37
38 #include <simgear/misc/sgstream.hxx>
39
40 // #include <Include/general.hxx>
41 // #include <Airports/simple.hxx>
42 // #include <Cockpit/cockpit.hxx>
43 // #include <FDM/flight.hxx>
44 // #include <FDM/UIUCModel/uiuc_aircraftdir.h>
45 #ifdef FG_NETWORK_OLK
46 #  include <NetworkOLK/network.h>
47 #endif
48
49 #include <GUI/gui.h>
50
51 #include "globals.hxx"
52 #include "fg_init.hxx"
53 #include "fg_props.hxx"
54 #include "options.hxx"
55 #include "viewmgr.hxx"
56
57 SG_USING_STD(string);
58 SG_USING_NAMESPACE(std);
59
60
61 #define NEW_DEFAULT_MODEL_HZ 120
62
63 enum
64 {
65     FG_OPTIONS_OK = 0,
66     FG_OPTIONS_HELP = 1,
67     FG_OPTIONS_ERROR = 2
68 };
69
70 static double
71 atof( const string& str )
72 {
73
74 #ifdef __MWERKS__ 
75     // -dw- if ::atof is called, then we get an infinite loop
76     return std::atof( str.c_str() );
77 #else
78     return ::atof( str.c_str() );
79 #endif
80 }
81
82 static int
83 atoi( const string& str )
84 {
85 #ifdef __MWERKS__ 
86     // -dw- if ::atoi is called, then we get an infinite loop
87     return std::atoi( str.c_str() );
88 #else
89     return ::atoi( str.c_str() );
90 #endif
91 }
92
93
94 /**
95  * Set a few fail-safe default property values.
96  *
97  * These should all be set in $FG_ROOT/preferences.xml, but just
98  * in case, we provide some initial sane values here. This method 
99  * should be invoked *before* reading any init files.
100  */
101 void
102 fgSetDefaults ()
103 {
104     // set a possibly independent location for scenery data
105     char *envp = ::getenv( "FG_SCENERY" );
106
107     if ( envp != NULL ) {
108         // fg_root could be anywhere, so default to environmental
109         // variable $FG_ROOT if it is set.
110         globals->set_fg_scenery(envp);
111     } else {
112         // Otherwise, default to Scenery being in $FG_ROOT/Scenery
113         globals->set_fg_scenery("");
114     }
115                                 // Position (Globe, AZ)
116     fgSetDouble("/position/longitude-deg", -110.6642444);
117     fgSetDouble("/position/latitude-deg", 33.3528917);
118     fgSetDouble("/position/altitude-ft", -9999.0);
119
120                                 // Orientation
121     fgSetDouble("/orientation/heading-deg", 270);
122     fgSetDouble("/orientation/roll-deg", 0);
123     fgSetDouble("/orientation/pitch-deg", 0.424);
124
125                                 // Velocities
126     fgSetString("/sim/startup/speed-set", "knots");
127     fgSetDouble("/velocities/uBody-fps", 0.0);
128     fgSetDouble("/velocities/vBody-fps", 0.0);
129     fgSetDouble("/velocities/wBody-fps", 0.0);
130     fgSetDouble("/velocities/speed-north-fps", 0.0);
131     fgSetDouble("/velocities/speed-east-fps", 0.0);
132     fgSetDouble("/velocities/speed-down-fps", 0.0);
133     fgSetDouble("/velocities/airspeed-kt", 0.0);
134     fgSetDouble("/velocities/mach", 0.0);
135
136                                 // Miscellaneous
137     fgSetBool("/sim/startup/game-mode", false);
138     fgSetBool("/sim/startup/splash-screen", true);
139     fgSetBool("/sim/startup/intro-music", true);
140     // we want mouse-pointer to have an undefined value if nothing is
141     // specified so we can do the right thing for voodoo-1/2 cards.
142     // fgSetString("/sim/startup/mouse-pointer", "disabled");
143     fgSetString("/sim/control-mode", "joystick");
144     fgSetBool("/sim/auto-coordination", false);
145 #if !defined(WIN32)
146     fgSetString("/sim/startup/browser-app", "netscape");
147 #else
148     fgSetString("/sim/startup/browser-app", "webrun.bat");
149 #endif
150                                 // Features
151     fgSetBool("/sim/hud/visibility", false);
152     fgSetBool("/sim/panel/visibility", true);
153     fgSetBool("/sim/sound", true);
154     fgSetBool("/sim/hud/antialiased", false);
155
156                                 // Flight Model options
157     fgSetString("/sim/flight-model", "jsb");
158     fgSetString("/sim/aero", "c172");
159     fgSetInt("/sim/model-hz", NEW_DEFAULT_MODEL_HZ);
160     fgSetInt("/sim/speed-up", 1);
161     fgSetBool("/sim/startup/trim", false);
162     fgSetBool("/sim/startup/onground", true);
163
164                                 // Rendering options
165     fgSetString("/sim/rendering/fog", "nicest");
166     fgSetBool("/environment/clouds/status", true);
167     fgSetDouble("/environment/clouds/altitude-ft", 5000);
168     fgSetBool("/sim/startup/fullscreen", false);
169     fgSetBool("/sim/rendering/shading", true);
170     fgSetBool("/sim/rendering/skyblend", true);
171     fgSetBool("/sim/rendering/textures", true);
172     fgSetBool("/sim/rendering/wireframe", false);
173     fgSetInt("/sim/startup/xsize", 800);
174     fgSetInt("/sim/startup/ysize", 600);
175     fgSetInt("/sim/rendering/bits-per-pixel", 16);
176     fgSetString("/sim/view-mode", "pilot");
177     fgSetDouble("/sim/view/offset-deg", 0);
178     fgSetDouble("/environment/visibility-m", 20000);
179
180                                 // HUD options
181     fgSetString("/sim/startup/units", "feet");
182     fgSetString("/sim/hud/frame-stat-type", "tris");
183         
184                                 // Time options
185     fgSetInt("/sim/startup/time-offset", 0);
186     fgSetString("/sim/startup/time-offset-type", "system-offset");
187     fgSetLong("/sim/time/cur-time-override", 0);
188
189     fgSetBool("/sim/networking/network-olk", false);
190     fgSetString("/sim/networking/call-sign", "Johnny");
191
192                                 // Freeze options
193     fgSetBool("/sim/freeze/master", false);
194     fgSetBool("/sim/freeze/position", false);
195     fgSetBool("/sim/freeze/clock", false);
196     fgSetBool("/sim/freeze/fuel", false);
197 }
198
199
200 // parse a time string ([+/-]%f[:%f[:%f]]) into hours
201 static double
202 parse_time(const string& time_in) {
203     char *time_str, num[256];
204     double hours, minutes, seconds;
205     double result = 0.0;
206     int sign = 1;
207     int i;
208
209     time_str = (char *)time_in.c_str();
210
211     // printf("parse_time(): %s\n", time_str);
212
213     // check for sign
214     if ( strlen(time_str) ) {
215         if ( time_str[0] == '+' ) {
216             sign = 1;
217             time_str++;
218         } else if ( time_str[0] == '-' ) {
219             sign = -1;
220             time_str++;
221         }
222     }
223     // printf("sign = %d\n", sign);
224
225     // get hours
226     if ( strlen(time_str) ) {
227         i = 0;
228         while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
229             num[i] = time_str[0];
230             time_str++;
231             i++;
232         }
233         if ( time_str[0] == ':' ) {
234             time_str++;
235         }
236         num[i] = '\0';
237         hours = atof(num);
238         // printf("hours = %.2lf\n", hours);
239
240         result += hours;
241     }
242
243     // get minutes
244     if ( strlen(time_str) ) {
245         i = 0;
246         while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
247             num[i] = time_str[0];
248             time_str++;
249             i++;
250         }
251         if ( time_str[0] == ':' ) {
252             time_str++;
253         }
254         num[i] = '\0';
255         minutes = atof(num);
256         // printf("minutes = %.2lf\n", minutes);
257
258         result += minutes / 60.0;
259     }
260
261     // get seconds
262     if ( strlen(time_str) ) {
263         i = 0;
264         while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
265             num[i] = time_str[0];
266             time_str++;
267             i++;
268         }
269         num[i] = '\0';
270         seconds = atof(num);
271         // printf("seconds = %.2lf\n", seconds);
272
273         result += seconds / 3600.0;
274     }
275
276     return(sign * result);
277 }
278
279
280 // parse a date string (yyyy:mm:dd:hh:mm:ss) into a time_t (seconds)
281 static long int 
282 parse_date( const string& date)
283 {
284     struct tm gmt;
285     char * date_str, num[256];
286     int i;
287     // initialize to zero
288     gmt.tm_sec = 0;
289     gmt.tm_min = 0;
290     gmt.tm_hour = 0;
291     gmt.tm_mday = 0;
292     gmt.tm_mon = 0;
293     gmt.tm_year = 0;
294     gmt.tm_isdst = 0; // ignore daylight savings time for the moment
295     date_str = (char *)date.c_str();
296     // get year
297     if ( strlen(date_str) ) {
298         i = 0;
299         while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
300             num[i] = date_str[0];
301             date_str++;
302             i++;
303         }
304         if ( date_str[0] == ':' ) {
305             date_str++;
306         }
307         num[i] = '\0';
308         gmt.tm_year = atoi(num) - 1900;
309     }
310     // get month
311     if ( strlen(date_str) ) {
312         i = 0;
313         while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
314             num[i] = date_str[0];
315             date_str++;
316             i++;
317         }
318         if ( date_str[0] == ':' ) {
319             date_str++;
320         }
321         num[i] = '\0';
322         gmt.tm_mon = atoi(num) -1;
323     }
324     // get day
325     if ( strlen(date_str) ) {
326         i = 0;
327         while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
328             num[i] = date_str[0];
329             date_str++;
330             i++;
331         }
332         if ( date_str[0] == ':' ) {
333             date_str++;
334         }
335         num[i] = '\0';
336         gmt.tm_mday = atoi(num);
337     }
338     // get hour
339     if ( strlen(date_str) ) {
340         i = 0;
341         while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
342             num[i] = date_str[0];
343             date_str++;
344             i++;
345         }
346         if ( date_str[0] == ':' ) {
347             date_str++;
348         }
349         num[i] = '\0';
350         gmt.tm_hour = atoi(num);
351     }
352     // get minute
353     if ( strlen(date_str) ) {
354         i = 0;
355         while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
356             num[i] = date_str[0];
357             date_str++;
358             i++;
359         }
360         if ( date_str[0] == ':' ) {
361             date_str++;
362         }
363         num[i] = '\0';
364         gmt.tm_min = atoi(num);
365     }
366     // get second
367     if ( strlen(date_str) ) {
368         i = 0;
369         while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
370             num[i] = date_str[0];
371             date_str++;
372             i++;
373         }
374         if ( date_str[0] == ':' ) {
375             date_str++;
376         }
377         num[i] = '\0';
378         gmt.tm_sec = atoi(num);
379     }
380     time_t theTime = sgTimeGetGMT( gmt.tm_year, gmt.tm_mon, gmt.tm_mday,
381                                    gmt.tm_hour, gmt.tm_min, gmt.tm_sec );
382     //printf ("Date is %s\n", ctime(&theTime));
383     //printf ("in seconds that is %d\n", theTime);
384     //exit(1);
385     return (theTime);
386 }
387
388
389 // parse angle in the form of [+/-]ddd:mm:ss into degrees
390 static double
391 parse_degree( const string& degree_str) {
392     double result = parse_time( degree_str );
393
394     // printf("Degree = %.4f\n", result);
395
396     return(result);
397 }
398
399
400 // parse time offset string into seconds
401 static int
402 parse_time_offset( const string& time_str) {
403     int result;
404
405     // printf("time offset = %s\n", time_str);
406
407 #ifdef HAVE_RINT
408     result = (int)rint(parse_time(time_str) * 3600.0);
409 #else
410     result = (int)(parse_time(time_str) * 3600.0);
411 #endif
412
413     // printf("parse_time_offset(): %d\n", result);
414
415     return( result );
416 }
417
418
419 // Parse --fov=x.xx type option 
420 static double
421 parse_fov( const string& arg ) {
422     double fov = atof(arg);
423
424     if ( fov < FG_FOV_MIN ) { fov = FG_FOV_MIN; }
425     if ( fov > FG_FOV_MAX ) { fov = FG_FOV_MAX; }
426
427     fgSetDouble("/sim/field-of-view", fov);
428
429     // printf("parse_fov(): result = %.4f\n", fov);
430
431     return fov;
432 }
433
434
435 // Parse I/O channel option
436 //
437 // Format is "--protocol=medium,direction,hz,medium_options,..."
438 //
439 //   protocol = { native, nmea, garmin, fgfs, rul, pve, etc. }
440 //   medium = { serial, socket, file, etc. }
441 //   direction = { in, out, bi }
442 //   hz = number of times to process channel per second (floating
443 //        point values are ok.
444 //
445 // Serial example "--nmea=serial,dir,hz,device,baud" where
446 // 
447 //  device = OS device name of serial line to be open()'ed
448 //  baud = {300, 1200, 2400, ..., 230400}
449 //
450 // Socket exacmple "--native=socket,dir,hz,machine,port,style" where
451 // 
452 //  machine = machine name or ip address if client (leave empty if server)
453 //  port = port, leave empty to let system choose
454 //  style = tcp or udp
455 //
456 // File example "--garmin=file,dir,hz,filename" where
457 // 
458 //  filename = file system file name
459
460 static bool 
461 add_channel( const string& type, const string& channel_str ) {
462     // cout << "Channel string = " << channel_str << endl;
463
464     globals->get_channel_options_list()->push_back( type + "," + channel_str );
465
466     return true;
467 }
468
469
470 // Parse --wp=ID[@alt]
471 static bool 
472 parse_wp( const string& arg ) {
473     string id, alt_str;
474     double alt = 0.0;
475
476     unsigned int pos = arg.find( "@" );
477     if ( pos != string::npos ) {
478         id = arg.substr( 0, pos );
479         alt_str = arg.substr( pos + 1 );
480         // cout << "id str = " << id << "  alt str = " << alt_str << endl;
481         alt = atof( alt_str.c_str() );
482         if ( fgGetString("/sim/startup/units") == "feet" ) {
483             alt *= SG_FEET_TO_METER;
484         }
485     } else {
486         id = arg;
487     }
488
489     FGAirport a;
490     if ( fgFindAirportID( id, &a ) ) {
491         SGWayPoint wp( a.longitude, a.latitude, alt, SGWayPoint::WGS84, id );
492         globals->get_route()->add_waypoint( wp );
493
494         return true;
495     } else {
496         return false;
497     }
498 }
499
500
501 // Parse --flight-plan=[file]
502 static bool 
503 parse_flightplan(const string& arg)
504 {
505     sg_gzifstream in(arg.c_str());
506     if ( !in.is_open() ) {
507         return false;
508     }
509     while ( true ) {
510         string line;
511
512 #if defined( macintosh )
513         getline( in, line, '\r' );
514 #else
515         getline( in, line, '\n' );
516 #endif
517
518         // catch extraneous (DOS) line ending character
519         if ( line[line.length() - 1] < 32 ) {
520             line = line.substr( 0, line.length()-1 );
521         }
522
523         if ( in.eof() ) {
524             break;
525         }
526         parse_wp(line);
527     }
528
529     return true;
530 }
531
532
533 // Parse a single option
534 static int 
535 parse_option (const string& arg) 
536 {
537     // General Options
538     if ( (arg == "--help") || (arg == "-h") ) {
539         // help/usage request
540         return(FG_OPTIONS_HELP);
541     } else if ( arg == "--disable-game-mode") {
542         fgSetBool("/sim/startup/game-mode", false);
543     } else if ( arg == "--enable-game-mode" ) {
544         fgSetBool("/sim/startup/game-mode", true);
545     } else if ( arg == "--disable-splash-screen" ) {
546         fgSetBool("/sim/startup/splash-screen", false); 
547     } else if ( arg == "--enable-splash-screen" ) {
548         fgSetBool("/sim/startup/splash-screen", true);
549     } else if ( arg == "--disable-intro-music" ) {
550         fgSetBool("/sim/startup/intro-music", false);
551     } else if ( arg == "--enable-intro-music" ) {
552         fgSetBool("/sim/startup/intro-music", true);
553     } else if ( arg == "--disable-mouse-pointer" ) {
554         fgSetString("/sim/startup/mouse-pointer", "disabled");
555     } else if ( arg == "--enable-mouse-pointer" ) {
556         fgSetString("/sim/startup/mouse-pointer", "enabled");
557     } else if ( arg == "--disable-freeze" ) {
558         fgSetBool("/sim/freeze/master", false);
559     } else if ( arg == "--enable-freeze" ) {
560         fgSetBool("/sim/freeze/master", true);
561     } else if ( arg == "--disable-fuel-freeze" ) {
562         fgSetBool("/sim/freeze/fuel", false);
563     } else if ( arg == "--enable-fuel-freeze" ) {
564         fgSetBool("/sim/freeze/fuel", true);
565     } else if ( arg == "--disable-clock-freeze" ) {
566         fgSetBool("/sim/freeze/clock", false);
567     } else if ( arg == "--enable-clock-freeze" ) {
568         fgSetBool("/sim/freeze/clock", true);
569     } else if ( arg == "--disable-anti-alias-hud" ) {
570         fgSetBool("/sim/hud/antialiased", false);
571     } else if ( arg == "--enable-anti-alias-hud" ) {
572         fgSetBool("/sim/hud/antialiased", true);
573     } else if ( arg.find( "--control=") == 0 ) {
574         fgSetString("/sim/control-mode", arg.substr(10));
575     } else if ( arg == "--disable-auto-coordination" ) {
576         fgSetBool("/sim/auto-coordination", false);
577     } else if ( arg == "--enable-auto-coordination" ) {
578         fgSetBool("/sim/auto-coordination", true);
579     } else if ( arg.find( "--browser-app=") == 0 ) {
580         fgSetString("/sim/startup/browser-app", arg.substr(14));
581     } else if ( arg == "--disable-hud" ) {
582         fgSetBool("/sim/hud/visibility", false);
583     } else if ( arg == "--enable-hud" ) {
584         fgSetBool("/sim/hud/visibility", true);
585     } else if ( arg == "--disable-panel" ) {
586         fgSetBool("/sim/panel/visibility", false);
587     } else if ( arg == "--enable-panel" ) {
588         fgSetBool("/sim/panel/visibility", true);
589     } else if ( arg == "--disable-sound" ) {
590         fgSetBool("/sim/sound", false);
591     } else if ( arg == "--enable-sound" ) {
592         fgSetBool("/sim/sound", true);
593     } else if ( arg.find( "--airport-id=") == 0 ) {
594                                 // NB: changed property name!!!
595         fgSetString("/sim/startup/airport-id", arg.substr(13));
596     } else if ( arg.find( "--offset-distance=") == 0 ) {
597         fgSetDouble("/sim/startup/offset-distance", atof(arg.substr(18)));
598     } else if ( arg.find( "--offset-azimuth=") == 0 ) {
599         fgSetDouble("/sim/startup/offset-azimuth", atof(arg.substr(17))); 
600     } else if ( arg.find( "--lon=" ) == 0 ) {
601         fgSetDouble("/position/longitude-deg",
602                               parse_degree(arg.substr(6)));
603         fgSetString("/sim/startup/airport-id", "");
604     } else if ( arg.find( "--lat=" ) == 0 ) {
605         fgSetDouble("/position/latitude-deg",
606                               parse_degree(arg.substr(6)));
607         fgSetString("/sim/startup/airport-id", "");
608     } else if ( arg.find( "--altitude=" ) == 0 ) {
609         fgSetBool("/sim/startup/onground", false);
610         if ( fgGetString("/sim/startup/units") == "feet" )
611             fgSetDouble("/position/altitude-ft", atof(arg.substr(11)));
612         else
613             fgSetDouble("/position/altitude-ft",
614                         atof(arg.substr(11)) * SG_METER_TO_FEET);
615     } else if ( arg.find( "--uBody=" ) == 0 ) {
616         fgSetString("/sim/startup/speed-set", "UVW");
617         if ( fgGetString("/sim/startup/units") == "feet" )
618           fgSetDouble("/velocities/uBody-fps", atof(arg.substr(8)));
619         else
620           fgSetDouble("/velocities/uBody-fps",
621                                atof(arg.substr(8)) * SG_METER_TO_FEET);
622     } else if ( arg.find( "--vBody=" ) == 0 ) {
623         fgSetString("/sim/startup/speed-set", "UVW");
624         if ( fgGetString("/sim/startup/units") == "feet" )
625           fgSetDouble("/velocities/vBody-fps", atof(arg.substr(8)));
626         else
627           fgSetDouble("/velocities/vBody-fps",
628                                atof(arg.substr(8)) * SG_METER_TO_FEET);
629     } else if ( arg.find( "--wBody=" ) == 0 ) {
630         fgSetString("/sim/startup/speed-set", "UVW");
631         if ( fgGetString("/sim/startup/units") == "feet" )
632           fgSetDouble("/velocities/wBody-fps", atof(arg.substr(8)));
633         else
634           fgSetDouble("/velocities/wBody-fps",
635                                atof(arg.substr(8)) * SG_METER_TO_FEET);
636     } else if ( arg.find( "--vNorth=" ) == 0 ) {
637         fgSetString("/sim/startup/speed-set", "NED");
638         if ( fgGetString("/sim/startup/units") == "feet" )
639           fgSetDouble("/velocities/speed-north-fps", atof(arg.substr(9)));
640         else
641           fgSetDouble("/velocities/speed-north-fps",
642                                atof(arg.substr(9)) * SG_METER_TO_FEET);
643     } else if ( arg.find( "--vEast=" ) == 0 ) {
644         fgSetString("/sim/startup/speed-set", "NED");
645         if ( fgGetString("/sim/startup/units") == "feet" )
646           fgSetDouble("/velocities/speed-east-fps", atof(arg.substr(8)));
647         else
648           fgSetDouble("/velocities/speed-east-fps",
649                       atof(arg.substr(8)) * SG_METER_TO_FEET);
650     } else if ( arg.find( "--vDown=" ) == 0 ) {
651         fgSetString("/sim/startup/speed-set", "NED");
652         if ( fgGetString("/sim/startup/units") == "feet" )
653           fgSetDouble("/velocities/speed-down-fps", atof(arg.substr(8)));
654         else
655           fgSetDouble("/velocities/speed-down-fps",
656                                atof(arg.substr(8)) * SG_METER_TO_FEET);
657     } else if ( arg.find( "--vc=" ) == 0) {
658         fgSetString("/sim/startup/speed-set", "knots");
659         fgSetDouble("/velocities/airspeed-kt", atof(arg.substr(5)));
660     } else if ( arg.find( "--mach=" ) == 0) {
661         fgSetString("/sim/startup/speed-set", "mach");
662         fgSetDouble("/velocities/mach", atof(arg.substr(7)));
663     } else if ( arg.find( "--heading=" ) == 0 ) {
664         fgSetDouble("/orientation/heading-deg", atof(arg.substr(10)));
665     } else if ( arg.find( "--roll=" ) == 0 ) {
666         fgSetDouble("/orientation/roll-deg", atof(arg.substr(7)));
667     } else if ( arg.find( "--pitch=" ) == 0 ) {
668         fgSetDouble("/orientation/pitch-deg", atof(arg.substr(8)));
669     } else if ( arg.find( "--glideslope=" ) == 0 ) {
670         fgSetDouble("/velocities/glideslope", atof(arg.substr(13))
671                                           *SG_DEGREES_TO_RADIANS);
672     }  else if ( arg.find( "--roc=" ) == 0 ) {
673         fgSetDouble("/velocities/vertical-speed-fps", atof(arg.substr(6))/60);
674     } else if ( arg.find( "--fg-root=" ) == 0 ) {
675         globals->set_fg_root(arg.substr( 10 ));
676     } else if ( arg.find( "--fg-scenery=" ) == 0 ) {
677         globals->set_fg_scenery(arg.substr( 13 ));
678     } else if ( arg.find( "--fdm=" ) == 0 ) {
679         fgSetString("/sim/flight-model", arg.substr(6));
680     } else if ( arg.find( "--aero=" ) == 0 ) {
681         fgSetString("/sim/aero", arg.substr(7));
682     } else if ( arg.find( "--aircraft-dir=" ) == 0 ) {
683         fgSetString("/sim/aircraft-dir", arg.substr(15));
684     } else if ( arg.find( "--model-hz=" ) == 0 ) {
685         fgSetInt("/sim/model-hz", atoi(arg.substr(11)));
686     } else if ( arg.find( "--speed=" ) == 0 ) {
687         fgSetInt("/sim/speed-up", atoi(arg.substr(8)));
688     } else if ( arg.find( "--trim") == 0) {
689         fgSetBool("/sim/startup/trim", true);
690     } else if ( arg.find( "--notrim") == 0) {
691         fgSetBool("/sim/startup/trim", false);
692     } else if ( arg.find( "--on-ground") == 0) {
693         fgSetBool("/sim/startup/onground", true);
694     } else if ( arg.find( "--in-air") == 0) {
695         fgSetBool("/sim/startup/onground", false);
696     } else if ( arg == "--fog-disable" ) {
697         fgSetString("/sim/rendering/fog", "disabled");
698     } else if ( arg == "--fog-fastest" ) {
699         fgSetString("/sim/rendering/fog", "fastest");
700     } else if ( arg == "--fog-nicest" ) {
701         fgSetString("/sim/fog", "nicest");
702     } else if ( arg == "--disable-clouds" ) {
703         fgSetBool("/environment/clouds/status", false);
704     } else if ( arg == "--enable-clouds" ) {
705         fgSetBool("/environment/clouds/status", true);
706     } else if ( arg.find( "--clouds-asl=" ) == 0 ) {
707                                 // FIXME: check units
708         if ( fgGetString("/sim/startup/units") == "feet" )
709           fgSetDouble("/environment/clouds/altitude-ft",
710                                 atof(arg.substr(13)));
711         else
712           fgSetDouble("/environment/clouds/altitude-ft",
713                                 atof(arg.substr(13)) * SG_METER_TO_FEET);
714     } else if ( arg.find( "--fov=" ) == 0 ) {
715         parse_fov( arg.substr(6) );
716     } else if ( arg == "--disable-fullscreen" ) {
717         fgSetBool("/sim/startup/fullscreen", false);
718     } else if ( arg== "--enable-fullscreen") {
719         fgSetBool("/sim/startup/fullscreen", true);
720     } else if ( arg == "--shading-flat") {
721         fgSetBool("/sim/rendering/shading", false);
722     } else if ( arg == "--shading-smooth") {
723         fgSetBool("/sim/rendering/shading", true);
724     } else if ( arg == "--disable-skyblend") {
725         fgSetBool("/sim/rendering/skyblend", false);
726     } else if ( arg== "--enable-skyblend" ) {
727         fgSetBool("/sim/rendering/skyblend", true);
728     } else if ( arg == "--disable-textures" ) {
729         fgSetBool("/sim/rendering/textures", false);
730     } else if ( arg == "--enable-textures" ) {
731         fgSetBool("/sim/rendering/textures", true);
732     } else if ( arg == "--disable-wireframe" ) {
733         fgSetBool("/sim/rendering/wireframe", false);
734     } else if ( arg == "--enable-wireframe" ) {
735         fgSetBool("/sim/rendering/wireframe", true);
736     } else if ( arg.find( "--geometry=" ) == 0 ) {
737         bool geometry_ok = true;
738         int xsize = 0, ysize = 0;
739         string geometry = arg.substr( 11 );
740         string::size_type i = geometry.find('x');
741
742         if (i != string::npos) {
743             xsize = atoi(geometry.substr(0, i));
744             ysize = atoi(geometry.substr(i+1));
745         } else {
746             geometry_ok = false;
747         }
748
749         if ( xsize <= 0 || ysize <= 0 ) {
750             xsize = 640;
751             ysize = 480;
752             geometry_ok = false;
753         }
754
755         if ( !geometry_ok ) {
756             SG_LOG( SG_GENERAL, SG_ALERT, "Unknown geometry: " << geometry );
757             SG_LOG( SG_GENERAL, SG_ALERT,
758                     "Setting geometry to " << xsize << 'x' << ysize << '\n');
759         } else {
760           SG_LOG( SG_GENERAL, SG_INFO,
761                   "Setting geometry to " << xsize << 'x' << ysize << '\n');
762           fgSetInt("/sim/startup/xsize", xsize);
763           fgSetInt("/sim/startup/ysize", ysize);
764         }
765     } else if ( arg.find( "--bpp=" ) == 0 ) {
766         string bits_per_pix = arg.substr( 6 );
767         if ( bits_per_pix == "16" ) {
768             fgSetInt("/sim/rendering/bits-per-pixel", 16);
769         } else if ( bits_per_pix == "24" ) {
770             fgSetInt("/sim/rendering/bits-per-pixel", 24);
771         } else if ( bits_per_pix == "32" ) {
772             fgSetInt("/sim/rendering/bits-per-pixel", 32);
773         } else {
774           SG_LOG(SG_GENERAL, SG_ALERT, "Unsupported bpp " << bits_per_pix);
775         }
776     } else if ( arg == "--units-feet" ) {
777         fgSetString("/sim/startup/units", "feet");
778     } else if ( arg == "--units-meters" ) {
779         fgSetString("/sim/startup/units", "meters");
780     } else if ( arg.find( "--time-offset" ) == 0 ) {
781         fgSetInt("/sim/startup/time-offset",
782                  parse_time_offset( (arg.substr(14)) ));
783         fgSetString("/sim/startup/time-offset-type", "system-offset");
784     } else if ( arg.find( "--time-match-real") == 0 ) {
785         fgSetString("/sim/startup/time-offset-type", "system-offset");
786     } else if ( arg.find( "--time-match-local") == 0 ) {
787         fgSetString("/sim/startup/time-offset-type", "latitude-offset");
788     } else if ( arg.find( "--start-date-sys=") == 0 ) {
789         fgSetInt("/sim/startup/time-offset", parse_date((arg.substr(17))));
790         fgSetString("/sim/startup/time-offset-type", "system");
791     } else if ( arg.find( "--start-date-lat=") == 0 ) {
792         fgSetInt("/sim/startup/time-offset", parse_date((arg.substr(17))));
793         fgSetString("/sim/startup/time-offset-type", "latitude");
794     } else if ( arg.find( "--start-date-gmt=") == 0 ) {
795         fgSetInt("/sim/startup/time-offset", parse_date((arg.substr(17))));
796         fgSetString("/sim/startup/time-offset-type", "gmt");
797     } else if ( arg == "--hud-tris" ) {
798         fgSetString("/sim/hud/frame-stat-type", "tris");
799     } else if ( arg == "--hud-culled" ) {
800         fgSetString("/sim/hud/frame-stat-type", "culled");
801     } else if ( arg.find( "--atc610x" ) == 0 ) {
802         add_channel( "atc610x", "dummy" );
803     } else if ( arg.find( "--atlas=" ) == 0 ) {
804         add_channel( "atlas", arg.substr(8) );
805     } else if ( arg.find( "--httpd=" ) == 0 ) {
806         add_channel( "httpd", arg.substr(8) );
807 #ifdef FG_JPEG_SERVER
808     } else if ( arg.find( "--jpg-httpd=" ) == 0 ) {
809         add_channel( "jpg-httpd", arg.substr(12) );
810 #endif
811     } else if ( arg.find( "--native=" ) == 0 ) {
812         add_channel( "native", arg.substr(9) );
813     } else if ( arg.find( "--native-ctrls=" ) == 0 ) {
814         add_channel( "native_ctrls", arg.substr(15) );
815     } else if ( arg.find( "--native-fdm=" ) == 0 ) {
816         add_channel( "native_fdm", arg.substr(13) );
817     } else if ( arg.find( "--opengc=" ) == 0 ) {
818         // char stop;
819         // cout << "Adding channel for OpenGC Display" << endl; cin >> stop;
820         add_channel( "opengc", arg.substr(9) );
821     } else if ( arg.find( "--garmin=" ) == 0 ) {
822         add_channel( "garmin", arg.substr(9) );
823     } else if ( arg.find( "--nmea=" ) == 0 ) {
824         add_channel( "nmea", arg.substr(7) );
825     } else if ( arg.find( "--props=" ) == 0 ) {
826         add_channel( "props", arg.substr(8) );
827     } else if ( arg.find( "--pve=" ) == 0 ) {
828         add_channel( "pve", arg.substr(6) );
829     } else if ( arg.find( "--ray=" ) == 0 ) {
830         add_channel( "ray", arg.substr(6) );
831     } else if ( arg.find( "--rul=" ) == 0 ) {
832         add_channel( "rul", arg.substr(6) );
833     } else if ( arg.find( "--joyclient=" ) == 0 ) {
834         add_channel( "joyclient", arg.substr(12) );
835 #ifdef FG_NETWORK_OLK
836     } else if ( arg == "--disable-network-olk" ) {
837         fgSetBool("/sim/networking/olk", false);
838     } else if ( arg== "--enable-network-olk") {
839         fgSetBool("/sim/networking/olk", true);
840     } else if ( arg == "--net-hud" ) {
841         fgSetBool("/sim/hud/net-display", true);
842         net_hud_display = 1;    // FIXME
843     } else if ( arg.find( "--net-id=") == 0 ) {
844         fgSetString("sim/networking/call-sign", arg.substr(9));
845 #endif
846     } else if ( arg.find( "--prop:" ) == 0 ) {
847         string assign = arg.substr(7);
848         unsigned int pos = assign.find('=');
849         if ( pos == arg.npos || pos == 0 ) {
850             SG_LOG( SG_GENERAL, SG_ALERT, "Bad property assignment: " << arg );
851             return FG_OPTIONS_ERROR;
852         }
853         string name = assign.substr(0, pos);
854         string value = assign.substr(pos + 1);
855         fgSetString(name.c_str(), value);
856         // SG_LOG(SG_GENERAL, SG_INFO, "Setting default value of property "
857         //        << name << " to \"" << value << '"');
858     } else if ( arg.find("--trace-read=") == 0) {
859         string name = arg.substr(13);
860         SG_LOG(SG_GENERAL, SG_INFO, "Tracing reads for property " << name);
861         fgGetNode(name, true)->setAttribute(SGPropertyNode::TRACE_READ, true);
862     } else if ( arg.find("--trace-write=") == 0) {
863         string name = arg.substr(14);
864         SG_LOG(SG_GENERAL, SG_INFO, "Tracing writes for property " << name);
865         fgGetNode(name, true)->setAttribute(SGPropertyNode::TRACE_WRITE, true);
866     } else if ( arg.find( "--view-offset=" ) == 0 ) {
867         // $$$ begin - added VS Renganathan, 14 Oct 2K
868         // for multi-window outside window imagery
869         string woffset = arg.substr( 14 );
870         double default_view_offset = 0.0;
871         if ( woffset == "LEFT" ) {
872                default_view_offset = SGD_PI * 0.25;
873         } else if ( woffset == "RIGHT" ) {
874             default_view_offset = SGD_PI * 1.75;
875         } else if ( woffset == "CENTER" ) {
876             default_view_offset = 0.00;
877         } else {
878             default_view_offset = atof( woffset.c_str() ) * SGD_DEGREES_TO_RADIANS;
879         }
880         FGViewerRPH *pilot_view =
881             (FGViewerRPH *)globals->get_viewmgr()->get_view( 0 );
882         pilot_view->set_view_offset( default_view_offset );
883         pilot_view->set_goal_view_offset( default_view_offset );
884         fgSetDouble("/sim/view/offset-deg", default_view_offset);
885     // $$$ end - added VS Renganathan, 14 Oct 2K
886     } else if ( arg.find( "--visibility=" ) == 0 ) {
887         fgSetDouble("/environment/visibility-m", atof(arg.substr(13)));
888     } else if ( arg.find( "--visibility-miles=" ) == 0 ) {
889         double visibility = atof(arg.substr(19)) * 5280.0 * SG_FEET_TO_METER;
890         fgSetDouble("/environment/visibility-m", visibility);
891     } else if ( arg.find( "--wind=" ) == 0 ) {
892         string val = arg.substr(7);
893         unsigned int pos = val.find('@');
894         if ( pos == string::npos ) {
895           SG_LOG( SG_GENERAL, SG_ALERT, "bad wind value " << val );
896           return FG_OPTIONS_ERROR;
897         }
898         double dir = atof(val.substr(0,pos).c_str());
899         double speed = atof(val.substr(pos+1).c_str());
900         SG_LOG(SG_GENERAL, SG_INFO, "WIND: " << dir << '@' << 
901                speed << " knots" << endl);
902         fgSetDouble("/environment/wind-from-heading-deg", dir);
903         fgSetDouble("/environment/wind-speed-knots", speed);
904
905         // convert to fps
906         speed *= SG_NM_TO_METER * SG_METER_TO_FEET * (1.0/3600);
907         dir += 180;
908         if (dir >= 360)
909           dir -= 360;
910         dir *= SGD_DEGREES_TO_RADIANS;
911         fgSetDouble("/environment/wind-north-fps",
912                     speed * cos(dir));
913         fgSetDouble("/environment/wind-east-fps",
914                     speed * sin(dir));
915     } else if ( arg.find( "--wp=" ) == 0 ) {
916         parse_wp( arg.substr( 5 ) );
917     } else if ( arg.find( "--flight-plan=") == 0) {
918         parse_flightplan ( arg.substr (14) );
919     } else if ( arg.find( "--config=" ) == 0 ) {
920         string file = arg.substr(9);
921         try {
922           readProperties(file, globals->get_props());
923         } catch (const sg_exception &e) {
924           string message = "Error loading config file: ";
925           message += e.getFormattedMessage();
926           SG_LOG(SG_INPUT, SG_ALERT, message);
927           exit(2);
928         }
929     } else if ( arg.find( "--aircraft=" ) == 0 ) {
930         // read in the top level aircraft definition file
931         SGPath apath( globals->get_fg_root() );
932         apath.append( "Aircraft" );
933         apath.append( arg.substr(11) );
934         apath.concat( "-set.xml" );
935         try {
936             readProperties( apath.str(), globals->get_props() );
937         } catch (const sg_exception &e) {
938             string message = "Error loading aircraft file: ";
939             message += e.getFormattedMessage();
940             SG_LOG(SG_INPUT, SG_ALERT, message);
941             exit(2);
942         }
943     } else {
944         SG_LOG( SG_GENERAL, SG_ALERT, "Unknown option '" << arg << "'" );
945         return FG_OPTIONS_ERROR;
946     }
947     
948     return FG_OPTIONS_OK;
949 }
950
951
952 // Scan the command line options for an fg_root definition and set
953 // just that.
954 string
955 fgScanForRoot (int argc, char **argv) 
956 {
957     int i = 1;
958
959     SG_LOG(SG_GENERAL, SG_INFO, "Scanning for root: command line");
960
961     while ( i < argc ) {
962         SG_LOG( SG_GENERAL, SG_DEBUG, "argv[" << i << "] = " << argv[i] );
963
964         string arg = argv[i];
965         if ( arg.find( "--fg-root=" ) == 0 ) {
966             return arg.substr( 10 );
967         }
968
969         i++;
970     }
971
972     return "";
973 }
974
975
976 // Scan the config file for an fg_root definition and set just that.
977 string
978 fgScanForRoot (const string& path)
979 {
980     sg_gzifstream in( path );
981     if ( !in.is_open() )
982       return "";
983
984     SG_LOG( SG_GENERAL, SG_INFO, "Scanning for root: " << path );
985
986     in >> skipcomment;
987 #ifndef __MWERKS__
988     while ( ! in.eof() ) {
989 #else
990     char c = '\0';
991     while ( in.get(c) && c != '\0' ) {
992         in.putback(c);
993 #endif
994         string line;
995
996 #if defined( macintosh )
997         getline( in, line, '\r' );
998 #else
999         getline( in, line, '\n' );
1000 #endif
1001
1002         // catch extraneous (DOS) line ending character
1003         if ( line[line.length() - 1] < 32 ) {
1004             line = line.substr( 0, line.length()-1 );
1005         }
1006
1007         if ( line.find( "--fg-root=" ) == 0 ) {
1008             return line.substr( 10 );
1009         }
1010
1011         in >> skipcomment;
1012     }
1013
1014     return "";
1015 }
1016
1017
1018 // Parse the command line options
1019 void
1020 fgParseArgs (int argc, char **argv)
1021 {
1022     bool in_options = true;
1023
1024     SG_LOG(SG_GENERAL, SG_INFO, "Processing command line arguments");
1025
1026     for (int i = 1; i < argc; i++) {
1027         string arg = argv[i];
1028
1029         if (in_options && (arg.find('-') == 0)) {
1030           if (arg == "--") {
1031             in_options = false;
1032           } else {
1033             int result = parse_option(arg);
1034             if ( (result == FG_OPTIONS_HELP) ||
1035                  (result == FG_OPTIONS_ERROR) ) {
1036               fgUsage();
1037               exit(-1);
1038             }
1039           }
1040         } else {
1041           in_options = false;
1042           SG_LOG(SG_GENERAL, SG_INFO,
1043                  "Reading command-line property file " << arg);
1044           readProperties(arg, globals->get_props());
1045         }
1046     }
1047
1048     SG_LOG(SG_GENERAL, SG_INFO, "Finished command line arguments");
1049 }
1050
1051
1052 // Parse config file options
1053 void
1054 fgParseOptions (const string& path) {
1055     sg_gzifstream in( path );
1056     if ( !in.is_open() ) {
1057         return;
1058     }
1059
1060     SG_LOG( SG_GENERAL, SG_INFO, "Processing config file: " << path );
1061
1062     in >> skipcomment;
1063 #ifndef __MWERKS__
1064     while ( ! in.eof() ) {
1065 #else
1066     char c = '\0';
1067     while ( in.get(c) && c != '\0' ) {
1068         in.putback(c);
1069 #endif
1070         string line;
1071
1072 #if defined( macintosh )
1073         getline( in, line, '\r' );
1074 #else
1075         getline( in, line, '\n' );
1076 #endif
1077
1078         // catch extraneous (DOS) line ending character
1079         if ( line[line.length() - 1] < 32 ) {
1080             line = line.substr( 0, line.length()-1 );
1081         }
1082
1083         if ( parse_option( line ) == FG_OPTIONS_ERROR ) {
1084             SG_LOG( SG_GENERAL, SG_ALERT, 
1085                     "Config file parse error: " << path << " '" 
1086                     << line << "'" );
1087             fgUsage();
1088             exit(-1);
1089         }
1090         in >> skipcomment;
1091     }
1092 }
1093
1094
1095 // Print usage message
1096 void 
1097 fgUsage ()
1098 {
1099     cout << "Usage: fgfs [ option ... ]" << endl
1100          << endl
1101
1102          << "General Options:" << endl
1103          << "    --help, -h                    Print usage" << endl
1104          << "    --fg-root=path                Specify the root data path" << endl
1105          << "    --fg-scenery=path             Specify the base scenery path;" << endl
1106          << "                                  Defaults to $FG_ROOT/Scenery" << endl
1107          << "    --disable-game-mode           Disable full-screen game mode" << endl
1108          << "    --enable-game-mode            Enable full-screen game mode" << endl
1109          << "    --disable-splash-screen       Disable splash screen" << endl
1110          << "    --enable-splash-screen        Enable splash screen" << endl
1111          << "    --disable-intro-music         Disable introduction music" << endl
1112          << "    --enable-intro-music          Enable introduction music" << endl
1113          << "    --disable-mouse-pointer       Disable extra mouse pointer" << endl
1114          << "    --enable-mouse-pointer        Enable extra mouse pointer (i.e. for full-" << endl
1115          << "                                  screen Voodoo based cards)" << endl
1116          << "    --disable-freeze              Start in a running state" << endl
1117          << "    --enable-freeze               Start in a frozen state" << endl
1118          << "    --disable-fuel-freeze         Fuel is consumed normally" << endl
1119          << "    --enable-fuel-freeze          Fuel tank quantity forced to remain constant" << endl
1120          << "    --disable-clock-freeze        Clock advances normally" << endl
1121          << "    --enable-clock-freeze         Do not advance clock" << endl
1122          << "    --control=mode                Primary control mode (joystick, keyboard," << endl
1123          << "                                  mouse)" << endl
1124          << "    --enable-auto-coordination    Enable auto coordination" << endl
1125          << "    --disable-auto-coordination   Disable auto coordination" << endl
1126          << "    --browser-app=path            Specify path to your web browser" << endl
1127          << "    --prop:name=value             Set property <name> to <value>" << endl
1128          << "    --config=path                 Load additional properties from path" << endl
1129          << "    --units-feet                  Use feet for distances" << endl
1130          << "    --units-meters                Use meters for distances" << endl
1131          << endl
1132
1133          << "Features:" << endl
1134          << "    --disable-hud                 Disable Heads Up Display (HUD)" << endl
1135          << "    --enable-hud                  Enable Heads Up Display (HUD)" << endl
1136          << "    --disable-panel               Disable instrument panel" << endl
1137          << "    --enable-panel                Enable instrument panel" << endl
1138          << "    --disable-sound               Disable sound effects" << endl
1139          << "    --enable-sound                Enable sound effects" << endl
1140          << "    --disable-anti-alias-hud      Disable anti-aliased HUD" << endl
1141          << "    --enable-anti-alias-hud       Enable anti-aliased HUD" << endl
1142          << endl
1143
1144          << "Aircraft:" <<endl
1145          << "    --aircraft=name               Select an aircraft profile as defined by a" << endl
1146          << "                                  top level <name>-set.xml" << endl
1147          << endl
1148
1149          << "Flight Model:" << endl
1150          << "    --fdm=name                    Select the core flight dynamics model" << endl
1151          << "                                  Can be one of jsb, larcsim, yasim, magic," << endl
1152          << "                                  balloon, ada, external, or null" << endl
1153          << "    --aero=name                   Select aircraft aerodynamics model to load" << endl
1154          << "    --model-hz=n                  Run the FDM this rate (iterations per" << endl
1155          << "                                  second)" << endl
1156          << "    --speed=n                     Run the FDM 'n' times faster than real time" << endl
1157          << "    --notrim                      Do NOT attempt to trim the model (only with" << endl
1158          << "                                  fdm=jsbsim)" << endl
1159          << "    --on-ground                   Start at ground level (default)" << endl
1160          << "    --in-air                      Start in air (implied when using --altitude)" << endl
1161          << "    --wind=DIR@SPEED              Specify wind coming from DIR (degrees) at" << endl
1162          << "                                  SPEED (knots)" << endl
1163          << endl
1164
1165          << "Aircraft model directory (UIUC FDM ONLY):" << endl
1166          << "    --aircraft-dir=path           Aircraft directory relative to the path of" << endl
1167          << "                                  the executable" << endl
1168          << endl
1169
1170          << "Initial Position and Orientation:" << endl
1171          << "    --airport-id=ID               Specify starting position by airport ID" << endl
1172          << "    --offset-distance=nm          Specify distance to threshold" << endl 
1173          << "    --offset-azimuth=degrees      Specify heading to threshold" << endl    
1174          << "    --lon=degrees                 Starting longitude (west = -)" << endl
1175          << "    --lat=degrees                 Starting latitude (south = -)" << endl
1176          << "    --altitude=value              Starting altitude (in feet unless" << endl
1177          << "                                  --units-meters specified)" << endl
1178          << "    --heading=degrees             Specify heading (yaw) angle (Psi)" << endl
1179          << "    --roll=degrees                Specify roll angle (Phi)" << endl
1180          << "    --pitch=degrees               Specify pitch angle (Theta)" << endl
1181          << "    --uBody=units_per_sec         Specify velocity along the body X axis" << endl
1182          << "                                  (in feet unless --units-meters specified)" << endl
1183          << "    --vBody=units_per_sec         Specify velocity along the body Y axis" << endl
1184          << "                                  (in feet unless --units-meters specified)" << endl
1185          << "    --wBody=units_per_sec         Specify velocity along the body Z axis" << endl
1186          << "                                  (in feet unless --units-meters specified)" << endl
1187          << "    --vc=knots                    Specify initial airspeed" << endl
1188          << "    --mach=num                    Specify initial mach number" << endl
1189          << "    --glideslope=degreees         Specify flight path angle (can be positive)" << endl
1190          << "    --roc=fpm                     Specify initial climb rate (can be negative)" << endl
1191          << endl
1192
1193          << "Rendering Options:" << endl
1194          << "    --bpp=depth                   Specify the bits per pixel" << endl
1195          << "    --fog-disable                 Disable fog/haze" << endl
1196          << "    --fog-fastest                 Enable fastest fog/haze" << endl
1197          << "    --fog-nicest                  Enable nicest fog/haze" << endl
1198          << "    --enable-clouds               Enable cloud layers" << endl
1199          << "    --disable-clouds              Disable cloud layers" << endl
1200          << "    --clouds-asl=altitude         Specify altitude of cloud layer above sea" << endl
1201          << "                                  level" << endl
1202          << "    --fov=degrees                 Specify field of view angle" << endl
1203          << "    --disable-fullscreen          Disable fullscreen mode" << endl
1204          << "    --enable-fullscreen           Enable fullscreen mode" << endl
1205          << "    --shading-flat                Enable flat shading" << endl
1206          << "    --shading-smooth              Enable smooth shading" << endl
1207          << "    --disable-skyblend            Disable sky blending" << endl
1208          << "    --enable-skyblend             Enable sky blending" << endl
1209          << "    --disable-textures            Disable textures" << endl
1210          << "    --enable-textures             Enable textures" << endl
1211          << "    --disable-wireframe           Disable wireframe drawing mode" << endl
1212          << "    --enable-wireframe            Enable wireframe drawing mode" << endl
1213          << "    --geometry=WxH                Specify window geometry (640x480, etc)" << endl
1214          << "    --view-offset=value           Specify the default forward view direction" << endl
1215          << "                                  as an offset from straight ahead.  Allowable" << endl
1216          << "                                  values are LEFT, RIGHT, CENTER, or a specific" << endl
1217          << "                                  number in degrees" << endl
1218          << "    --visibility=meters           Specify initial visibility" << endl
1219          << "    --visibility-miles=miles      Specify initial visibility in miles" << endl
1220          << endl
1221
1222          << "Hud Options:" << endl
1223          << "    --hud-tris                    Hud displays number of triangles rendered" << endl
1224          << "    --hud-culled                  Hud displays percentage of triangles culled" << endl
1225          << endl
1226         
1227          << "Time Options:" << endl
1228          << "    --time-offset=[+-]hh:mm:ss    Add this time offset" << endl
1229          << "    --time-match-real             Synchronize time with real-world time" << endl
1230          << "    --time-match-local            Synchronize time with local real-world time" << endl
1231          << "    --start-date-sys=yyyy:mm:dd:hh:mm:ss" << endl
1232          << "                                  Specify a starting date/time with respect to" << endl
1233          << "                                  system time" << endl
1234          << "    --start-date-gmt=yyyy:mm:dd:hh:mm:ss" << endl
1235          << "                                  Specify a starting date/time with respect to" << endl
1236          << "                                  Greenwich Mean Time" << endl
1237          << "    --start-date-lat=yyyy:mm:dd:hh:mm:ss" << endl
1238          << "                                  Specify a starting date/time with respect to" << endl
1239          << "                                  Local Aircraft Time" << endl
1240          << endl
1241
1242          << "Network Options:" << endl
1243          << "    --httpd=port                  Enable http server on the specified port" << endl
1244 #ifdef FG_JPEG_SERVER
1245          << "    --jpg-httpd=port              Enable screen shot http server on the" << endl
1246          << "                                  specified port" << endl
1247 #endif
1248 #ifdef FG_NETWORK_OLK
1249          << "    --disable-network-olk         Disable Multipilot mode (default)" << endl
1250          << "    --enable-network-olk          Enable Multipilot mode" << endl
1251          << "    --net-hud                     Hud displays network info" << endl
1252          << "    --net-id=name                 Specify your own callsign" << endl
1253 #endif
1254          << endl
1255
1256          << "Route/Way Point Options:" << endl
1257          << "    --wp=ID[@alt]                 Specify a waypoint for the GC autopilot;" << endl
1258          << "                                  multiple instances can be used to create a" << endl
1259          << "                                  route" << endl
1260          << "    --flight-plan=file            Read all waypoints from a file" << endl
1261          << endl
1262
1263          << "IO Options:" << endl
1264          << "    --gamin=params                Open connection using the Garmin GPS protocol" << endl
1265          << "    --joyclient=params            Open connection to an Agwagon joystick" << endl
1266          << "    --native-ctrls=params         Open connection using the FG Native Controls" << endl
1267          << "                                  protocol" << endl
1268          << "    --native-fdm=params           Open connection using the FG Native FDM" << endl
1269          << "                                  protocol" << endl
1270          << "    --native=params               Open connection using the FG Native protocol" << endl
1271          << "    --nmea=params                 Open connection using the NMEA protocol" << endl
1272          << "    --opengc=params               Open connection using the OpenGC protocol" << endl
1273          << "    --props=params                Open connection using the interactive" << endl
1274          << "                                  property manager" << endl
1275          << "    --pve=params                  Open connection using the PVE protocol" << endl
1276          << "    --ray=params                  Open connection using the RayWoodworth" << endl
1277          << "                                  motion chair protocol" << endl
1278          << "    --rul=params                  Open connection using the RUL protocol" << endl
1279          << endl
1280          << "    --atc610x                     Enable atc610x interface." << endl
1281          << endl
1282
1283          << "Debugging Options:" << endl
1284          << "    --trace-read=property         Trace the reads for a property; multiple" << endl
1285          << "                                  instances allowed." << endl
1286          << "    --trace-write=property        Trace the writes for a property; multiple" << endl
1287          << "                                  instances allowed." << endl
1288          << endl;
1289 }