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