# include <config.h>
#endif
-// For BC 5.01 this must be included before OpenGL includes.
-#ifdef SG_MATH_EXCEPTION_CLASH
-# include <math.h>
-#endif
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h> // strcmp()
#include <simgear/compiler.h>
-#include STL_STRING
+#include <string>
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/timing/lowleveltime.h>
#include <Aircraft/aircraft.hxx>
+#include <Aircraft/controls.hxx>
#include <Aircraft/replay.hxx>
#include <Airports/apt_loader.hxx>
#include <Airports/runways.hxx>
#include <Airports/simple.hxx>
#include <AIModel/AIManager.hxx>
-#include <ATC/ATCmgr.hxx>
-#include <ATC/AIMgr.hxx>
+#include <ATCDCL/ATCmgr.hxx>
+#include <ATCDCL/AIMgr.hxx>
#include <Autopilot/route_mgr.hxx>
#include <Autopilot/xmlauto.hxx>
#include <Cockpit/cockpit.hxx>
#ifdef ENABLE_SP_FDM
#include <FDM/SP/ADA.hxx>
#include <FDM/SP/ACMS.hxx>
+#include <FDM/SP/MagicCarpet.hxx>
+#include <FDM/SP/Balloon.h>
#endif
-#include <FDM/Balloon.h>
#include <FDM/ExternalNet/ExternalNet.hxx>
#include <FDM/ExternalPipe/ExternalPipe.hxx>
#include <FDM/JSBSim/JSBSim.hxx>
#include <FDM/LaRCsim/LaRCsim.hxx>
-#include <FDM/MagicCarpet.hxx>
#include <FDM/UFO.hxx>
#include <FDM/NullFDM.hxx>
#include <FDM/YASim/YASim.hxx>
#include "options.hxx"
#include "globals.hxx"
#include "logger.hxx"
+#include "renderer.hxx"
#include "viewmgr.hxx"
#include "main.hxx"
-#if defined(FX) && defined(XMESA)
-#include <GL/xmesa.h>
+#ifdef __APPLE__
+# include <CoreFoundation/CoreFoundation.h>
#endif
-SG_USING_STD(string);
-
+using std::string;
class Sound;
extern const char *default_root;
int len = option.length();
in >> skipcomment;
-#ifndef __MWERKS__
while ( ! in.eof() ) {
-#else
- char c = '\0';
- while ( in.get(c) && c != '\0' ) {
- in.putback(c);
-#endif
string line;
-
-#if defined( macintosh )
- getline( in, line, '\r' );
-#else
getline( in, line, '\n' );
-#endif
// catch extraneous (DOS) line ending character
if ( line[line.length() - 1] < 32 ) {
root = "/FlightGear";
#elif defined( WIN32 )
root = "\\FlightGear";
-#elif defined(OSX_BUNDLE)
- /* the following code looks for the base package directly inside
- the application bundle. This can be changed fairly easily by
- fiddling with the code below. And yes, I know it's ugly and verbose.
+#elif defined(__APPLE__)
+ /*
+ The following code looks for the base package inside the application
+ bundle, in the standard Contents/Resources location.
*/
- CFBundleRef appBundle = CFBundleGetMainBundle();
- CFURLRef appUrl = CFBundleCopyBundleURL(appBundle);
- CFRelease(appBundle);
+ CFURLRef resourcesUrl = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle());
- // look for a 'data' subdir directly inside the bundle : is there
- // a better place? maybe in Resources? I don't know ...
- CFURLRef dataDir = CFURLCreateCopyAppendingPathComponent(NULL, appUrl, CFSTR("data"), true);
+ // look for a 'data' subdir
+ CFURLRef dataDir = CFURLCreateCopyAppendingPathComponent(NULL, resourcesUrl, CFSTR("data"), true);
// now convert down to a path, and the a c-string
CFStringRef path = CFURLCopyFileSystemPath(dataDir, kCFURLPOSIXPathStyle);
root = CFStringGetCStringPtr(path, CFStringGetSystemEncoding());
- // tidy up.
- CFRelease(appBundle);
+ CFRelease(resourcesUrl);
CFRelease(dataDir);
CFRelease(path);
#else
SGPropertyNode *strings = c_node->getNode("strings");
try {
readProperties(d_path.str(), strings);
- } catch (const sg_exception &e) {
+ } catch (const sg_exception &) {
SG_LOG(SG_GENERAL, SG_ALERT, "Unable to read the localized strings");
return NULL;
}
try {
readProperties(c_path.str(), strings);
- } catch (const sg_exception &e) {
+ } catch (const sg_exception &) {
SG_LOG(SG_GENERAL, SG_ALERT,
"Unable to read the localized strings from " << c_path.str());
return NULL;
// Initialize the localization routines
bool fgDetectLanguage() {
- char *language = ::getenv("LANG");
+ const char *language = ::getenv("LANG");
if (language == NULL) {
SG_LOG(SG_GENERAL, SG_INFO, "Unable to detect the language" );
SGPath config( homedir );
config.append( ".fgfs" );
#endif
- fgSetString("/sim/fg-home", config.c_str());
+ const char *fg_home = getenv("FG_HOME");
+ if (fg_home)
+ config = fg_home;
+
+ // Set /sim/fg-home and don't allow malign code to override it until
+ // Nasal security is set up. Use FG_HOME if necessary.
+ SGPropertyNode *home = fgGetNode("/sim", true);
+ home->removeChild("fg-home", 0, false);
+ home = home->getChild("fg-home", 0, true);
+ home->setStringValue(config.c_str());
+ home->setAttribute(SGPropertyNode::WRITE, false);
+
config.append( "autosave.xml" );
SG_LOG(SG_INPUT, SG_INFO, "Reading user settings from " << config.str());
try {
bool fgInitGeneral() {
string root;
-#if defined(FX) && defined(XMESA)
- char *mesa_win_state;
-#endif
-
SG_LOG( SG_GENERAL, SG_INFO, "General Initialization" );
SG_LOG( SG_GENERAL, SG_INFO, "======= ==============" );
}
SG_LOG( SG_GENERAL, SG_INFO, "FG_ROOT = " << '"' << root << '"' << endl );
-#if defined(FX) && defined(XMESA)
- // initialize full screen flag
- globals->set_fullscreen(false);
- if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
- // Test for the MESA_GLX_FX env variable
- if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
- // test if we are fullscreen mesa/glide
- if ( (mesa_win_state[0] == 'f') ||
- (mesa_win_state[0] == 'F') ) {
- globals->set_fullscreen(true);
- }
- }
- }
-#endif
+ globals->set_browser(fgGetString("/sim/startup/browser-app", "firefox %u"));
- char buf[512], *cwd = getcwd(buf, 512);
- fgSetString("/sim/fg-current", cwd ? cwd : "");
+ char buf[512], *cwd = getcwd(buf, 511);
+ buf[511] = '\0';
+ SGPropertyNode *curr = fgGetNode("/sim", true);
+ curr->removeChild("fg-current", 0, false);
+ curr = curr->getChild("fg-current", 0, true);
+ curr->setStringValue(cwd ? cwd : "");
+ curr->setAttribute(SGPropertyNode::WRITE, false);
return true;
}
cur_fdm_state = new FGADA( dt );
} else if ( model == "acms" ) {
cur_fdm_state = new FGACMS( dt );
-#endif
} else if ( model == "balloon" ) {
cur_fdm_state = new FGBalloonSim( dt );
} else if ( model == "magic" ) {
cur_fdm_state = new FGMagicCarpet( dt );
+#endif
} else if ( model == "ufo" ) {
cur_fdm_state = new FGUFO( dt );
} else if ( model == "external" ) {
fgSetBool("/sim/sceneryloaded",false);
}
+
+void reInit(void) // from gui_local.cxx -- TODO merge with fgReInitSubsystems()
+{
+ static SGPropertyNode_ptr master_freeze = fgGetNode("/sim/freeze/master", true);
+
+ bool freeze = master_freeze->getBoolValue();
+ if (!freeze)
+ master_freeze->setBoolValue(true);
+
+ fgSetBool("/sim/signals/reinit", true);
+ cur_fdm_state->unbind();
+
+ // in case user has changed window size as
+ // restoreInitialState() overwrites these
+ int xsize = fgGetInt("/sim/startup/xsize");
+ int ysize = fgGetInt("/sim/startup/ysize");
+
+ globals->restoreInitialState();
+
+ // update our position based on current presets
+ fgInitPosition();
+
+ // We don't know how to resize the window, so keep the last values
+ // for xsize and ysize, and don't use the one set initially
+ fgSetInt("/sim/startup/xsize", xsize);
+ fgSetInt("/sim/startup/ysize", ysize);
+
+ SGTime *t = globals->get_time_params();
+ delete t;
+ t = fgInitTime();
+ globals->set_time_params(t);
+
+ fgReInitSubsystems();
+
+ globals->get_tile_mgr()->update(fgGetDouble("/environment/visibility-m"));
+ globals->get_renderer()->resize(xsize, ysize);
+ fgSetBool("/sim/signals/reinit", false);
+
+ if (!freeze)
+ master_freeze->setBoolValue(false);
+}
+