using std::vector;
using std::cin;
-#define NEW_DEFAULT_MODEL_HZ 120
+using namespace flightgear;
-enum
-{
- FG_OPTIONS_OK = 0,
- FG_OPTIONS_HELP = 1,
- FG_OPTIONS_ERROR = 2,
- FG_OPTIONS_EXIT = 3,
- FG_OPTIONS_VERBOSE_HELP = 4,
- FG_OPTIONS_SHOW_AIRCRAFT = 5,
- FG_OPTIONS_SHOW_SOUND_DEVICES = 6,
- FG_OPTIONS_NO_DEFAULT_CONFIG = 7
-};
+#define NEW_DEFAULT_MODEL_HZ 120
static flightgear::Options* shared_instance = NULL;
fgSetBool("/sim/panel/visibility", true);
fgSetBool("/sim/sound/enabled", true);
fgSetBool("/sim/sound/working", true);
+ fgSetBool("/sim/fgcom/enabled", false);
// Flight Model options
fgSetString("/sim/flight-model", "jsb");
fgSetBool("/sim/rendering/distance-attenuation", false);
fgSetBool("/sim/rendering/specular-highlight", true);
fgSetString("/sim/rendering/materials-file", "materials.xml");
- fgSetInt("/sim/startup/xsize", 800);
- fgSetInt("/sim/startup/ysize", 600);
- fgSetInt("/sim/rendering/bits-per-pixel", 16);
+ fgSetInt("/sim/startup/xsize", 1024);
+ fgSetInt("/sim/startup/ysize", 768);
+ fgSetInt("/sim/rendering/bits-per-pixel", 32);
fgSetString("/sim/view-mode", "pilot");
fgSetDouble("/sim/current-view/heading-offset-deg", 0);
fgSetInt("/sim/multiplay/rxport", 0);
fgSetInt("/sim/multiplay/txport", 0);
- fgSetString("/sim/version/flightgear", FLIGHTGEAR_VERSION);
- fgSetString("/sim/version/simgear", SG_STRINGIZE(SIMGEAR_VERSION));
- fgSetString("/sim/version/openscenegraph", osgGetVersion());
- fgSetString("/sim/version/revision", REVISION);
- fgSetInt("/sim/version/build-number", HUDSON_BUILD_NUMBER);
- fgSetString("/sim/version/build-id", HUDSON_BUILD_ID);
-
- char* envp = ::getenv( "http_proxy" );
+ SGPropertyNode* v = globals->get_props()->getNode("/sim/version", true);
+ v->setValueReadOnly("flightgear", FLIGHTGEAR_VERSION);
+ v->setValueReadOnly("simgear", SG_STRINGIZE(SIMGEAR_VERSION));
+ v->setValueReadOnly("openscenegraph", osgGetVersion());
+ v->setValueReadOnly("openscenegraph-thread-safe-reference-counting",
+ osg::Referenced::getThreadSafeReferenceCounting());
+ v->setValueReadOnly("revision", REVISION);
+ v->setValueReadOnly("build-number", HUDSON_BUILD_NUMBER);
+ v->setValueReadOnly("build-id", HUDSON_BUILD_ID);
+ v->setValueReadOnly("hla-support", bool(FG_HAVE_HLA));
+
+ char* envp = ::getenv( "http_proxy" );
if( envp != NULL )
fgSetupProxy( envp );
}
{
string file = arg;
try {
- readProperties(file, globals->get_props());
+ readProperties(file, globals->get_props());
} catch (const sg_exception &e) {
- string message = "Error loading config file: ";
- message += e.getFormattedMessage() + e.getOrigin();
- SG_LOG(SG_INPUT, SG_ALERT, message);
- exit(2);
+ string message = "Error loading config file: ";
+ message += e.getFormattedMessage() + e.getOrigin();
+ SG_LOG(SG_INPUT, SG_ALERT, message);
+ return FG_OPTIONS_ERROR;
}
return FG_OPTIONS_OK;
}
return FG_OPTIONS_OK;
}
+static int
+fgOptIgnoreAutosave(const char* arg)
+{
+ fgSetBool("/sim/startup/ignore-autosave", true);
+ // don't overwrite autosave on exit
+ fgSetBool("/sim/startup/save-on-exit", false);
+ return FG_OPTIONS_OK;
+}
// Set a property for the --prop: option. Syntax: --prop:[<type>:]<name>=<value>
// <type> can be "double" etc. but also only the first letter "d".
} fgOptionArray[] = {
{"language", true, OPTION_IGNORE, "", false, "", 0 },
+ {"console", false, OPTION_IGNORE, "", false, "", 0 },
{"disable-rembrandt", false, OPTION_BOOL, "/sim/rendering/rembrandt/enabled", false, "", 0 },
{"enable-rembrandt", false, OPTION_BOOL, "/sim/rendering/rembrandt/enabled", true, "", 0 },
{"renderer", true, OPTION_STRING, "/sim/rendering/rembrandt/renderer", false, "", 0 },
{"enable-fullscreen", false, OPTION_BOOL, "/sim/startup/fullscreen", true, "", 0 },
{"disable-save-on-exit", false, OPTION_BOOL, "/sim/startup/save-on-exit", false, "", 0 },
{"enable-save-on-exit", false, OPTION_BOOL, "/sim/startup/save-on-exit", true, "", 0 },
+ {"ignore-autosave", false, OPTION_FUNC, "", false, "", fgOptIgnoreAutosave },
{"restore-defaults", false, OPTION_BOOL, "/sim/startup/restore-defaults", true, "", 0 },
{"shading-flat", false, OPTION_BOOL, "/sim/rendering/shading", false, "", 0 },
{"shading-smooth", false, OPTION_BOOL, "/sim/rendering/shading", true, "", 0 },
{"AV400WSimA", true, OPTION_CHANNEL | OPTION_MULTI, "", false, "", 0 },
{"AV400WSimB", true, OPTION_CHANNEL | OPTION_MULTI, "", false, "", 0 },
{"garmin", true, OPTION_CHANNEL | OPTION_MULTI, "", false, "", 0 },
+ {"igc", true, OPTION_CHANNEL | OPTION_MULTI, "", false, "", 0 },
{"nmea", true, OPTION_CHANNEL | OPTION_MULTI, "", false, "", 0 },
{"generic", true, OPTION_CHANNEL | OPTION_MULTI, "", false, "", 0 },
{"props", true, OPTION_CHANNEL | OPTION_MULTI, "", false, "", 0 },
{"proxy", true, OPTION_FUNC, "", false, "", fgSetupProxy },
{"callsign", true, OPTION_FUNC, "", false, "", fgOptCallSign},
{"multiplay", true, OPTION_CHANNEL | OPTION_MULTI, "", false, "", 0 },
-#ifdef FG_HAVE_HLA
+#if FG_HAVE_HLA
{"hla", true, OPTION_CHANNEL, "", false, "", 0 },
{"hla-local", true, OPTION_CHANNEL, "", false, "", 0 },
#endif
{"aircraft", true, OPTION_STRING, "/sim/aircraft", false, "", 0 },
{"vehicle", true, OPTION_STRING, "/sim/aircraft", false, "", 0 },
{"failure", true, OPTION_FUNC | OPTION_MULTI, "", false, "", fgOptFailure },
+#ifdef ENABLE_IAX
+ {"enable-fgcom", false, OPTION_BOOL, "/sim/fgcom/enabled", true, "", 0 },
+ {"disable-fgcom", false, OPTION_BOOL, "/sim/fgcom/enabled", false, "", 0 },
+#endif
{"com1", true, OPTION_DOUBLE, "/instrumentation/comm[0]/frequencies/selected-mhz", false, "", 0 },
{"com2", true, OPTION_DOUBLE, "/instrumentation/comm[1]/frequencies/selected-mhz", false, "", 0 },
{"nav1", true, OPTION_FUNC, "", false, "", fgOptNAV1 },
setupRoot();
// system.fgfsrc handling
- if( hostname.size() > 0 ) {
+ if( ! hostname.empty() ) {
config.set(globals->get_fg_root());
config.append( "system.fgfsrc" );
config.concat( "." );
} else if ( (s == "--verbose") || (s == "-v") ) {
// verbose help/usage request
return FG_OPTIONS_VERBOSE_HELP;
+ } else if ((s == "--console") || (s == "-c")) {
+ simgear::requestConsole();
+ return FG_OPTIONS_OK;
} else if (s.find("-psn") == 0) {
// on Mac, when launched from the GUI, we are passed the ProcessSerialNumber
// as an argument (and no others). Silently ignore the argument here.
return result;
}
-void Options::processOptions()
+OptionResult Options::processOptions()
{
// establish locale before showing help (this selects the default locale,
// when no explicit option was set)
// out quickly, but rely on aircraft / root settings
if (p->showHelp) {
showUsage();
- exit(0);
+ return FG_OPTIONS_EXIT;
}
// processing order is complicated. We must process groups LIFO, but the
{
case FG_OPTIONS_ERROR:
showUsage();
- exit(-1); // exit and return an error
+ return FG_OPTIONS_ERROR;
+
case FG_OPTIONS_EXIT:
- exit(0); // clean exit
+ return FG_OPTIONS_EXIT;
+
default:
break;
}
}
SGPath p(terrasyncDir);
- if (!p.exists()) {
- simgear::Dir dd(p);
- dd.create(0700);
+ // following is necessary to ensure NavDataCache sees stable scenery paths from
+ // terrasync. Ensure the Terrain and Objects subdirs exist immediately, rather
+ // than waiting for the first tiles to be scheduled.
+ simgear::Dir terrainDir(SGPath(p, "Terrain")),
+ objectsDir(SGPath(p, "Objects"));
+ if (!terrainDir.exists()) {
+ terrainDir.create(0755);
}
-
+
+ if (!objectsDir.exists()) {
+ objectsDir.create(0755);
+ }
+
const string_list& scenery_paths(globals->get_fg_scenery());
if (std::find(scenery_paths.begin(), scenery_paths.end(), terrasyncDir) == scenery_paths.end()) {
// terrasync dir is not in the scenery paths, add it
root.append("Scenery");
globals->append_fg_scenery(root.str());
}
+
+ return FG_OPTIONS_OK;
}
void Options::showUsage() const
FGLocale *locale = globals->get_locale();
SGPropertyNode options_root;
- SG_LOG( SG_GENERAL, SG_ALERT, "" ); // To popup the console on Windows
+ simgear::requestConsole(); // ensure console is shown on Windows
cout << endl;
try {
vector<SGPropertyNode_ptr> desc;
desc = option[k]->getChildren("description");
- if (desc.size() > 0) {
+ if (! desc.empty()) {
for ( unsigned int l = 0; l < desc.size(); l++) {
string t = desc[l]->getStringValue();
// look for a 'data' subdir
CFURLRef dataDir = CFURLCreateCopyAppendingPathComponent(NULL, resourcesUrl, CFSTR("data"), true);
+ CFURLRef absoluteDataUrl = CFURLCopyAbsoluteURL(dataDir);
+
// now convert down to a path, and the a c-string
- CFStringRef path = CFURLCopyFileSystemPath(dataDir, kCFURLPOSIXPathStyle);
+ CFStringRef path = CFURLCopyFileSystemPath(absoluteDataUrl, kCFURLPOSIXPathStyle);
string root = CFStringGetCStringPtr(path, CFStringGetSystemEncoding());
+ CFRelease(absoluteDataUrl);
CFRelease(resourcesUrl);
CFRelease(dataDir);
CFRelease(path);
if ( !(base_version == required_version) ) {
// tell the operator how to use this application
- SG_LOG( SG_GENERAL, SG_ALERT, "" ); // To popup the console on windows
+ simgear::requestConsole(); // ensure console is shown on Windows
+
cerr << endl << "Base package check failed:" << endl \
<< " Version " << base_version << " found at: " \
<< globals->get_fg_root() << endl \