// initialization routines. If you are adding a subsystem to flight
// gear, its initialization call should located in this routine.
// Returns non-zero if a problem encountered.
-bool fgInitSubsystems() {
+void fgCreateSubsystems() {
- SG_LOG( SG_GENERAL, SG_INFO, "Initialize Subsystems");
+ SG_LOG( SG_GENERAL, SG_INFO, "Creating Subsystems");
SG_LOG( SG_GENERAL, SG_INFO, "========== ==========");
////////////////////////////////////////////////////////////////////
globals->add_subsystem("tile-manager", globals->get_tile_mgr(),
SGSubsystemMgr::DISPLAY);
-
- ////////////////////////////////////////////////////////////////////
- // Bind and initialize subsystems.
- ////////////////////////////////////////////////////////////////////
-
- globals->get_subsystem_mgr()->bind();
- globals->get_subsystem_mgr()->init();
+}
+void fgPostInitSubsystems()
+{
+ SGTimeStamp st;
+ st.stamp();
+
////////////////////////////////////////////////////////////////////////
// Initialize the Nasal interpreter.
// Do this last, so that the loaded scripts see initialized state
FGNasalSys* nasal = new FGNasalSys();
globals->add_subsystem("nasal", nasal, SGSubsystemMgr::INIT);
nasal->init();
-
+ SG_LOG(SG_GENERAL, SG_INFO, "Nasal init took:" << st.elapsedMSec());
+
// initialize methods that depend on other subsystems.
+ st.stamp();
globals->get_subsystem_mgr()->postinit();
-
+ SG_LOG(SG_GENERAL, SG_INFO, "Subsystems postinit took:" << st.elapsedMSec());
+
////////////////////////////////////////////////////////////////////
// TODO FIXME! UGLY KLUDGE!
////////////////////////////////////////////////////////////////////
// Save the initial state for future
// reference.
globals->saveInitialState();
-
- return true;
}
// Reset: this is what the 'reset' command (and hence, GUI) is attached to
// forward decls
class SGPropertyNode;
-class SGTime;
class SGPath;
// Return the current base package version
bool fgInitGeneral ();
-// This is the top level init routine which calls all the other
-// initialization routines. If you are adding a subsystem to flight
-// gear, its initialization call should located in this routine.
-bool fgInitSubsystems();
+// Create all the subsystems needed by the sim
+void fgCreateSubsystems();
+// called after the subsystems have been bound and initialised,
+// to peform final init
+void fgPostInitSubsystems();
// Reset: this is what the 'reset' command (and hence, GUI) is attached to
void fgReInitSubsystems();
// our initializations out of the idle callback so that we can get a
// splash screen up and running right away.
static int idle_state = 0;
-
+ static int spin_count = 0;
+
static osg::ref_ptr<GeneralInitOperation> genOp;
if ( idle_state == 0 ) {
idle_state++;
} else if ( idle_state == 6 ) {
idle_state++;
- fgSplashProgress("initializing subsystems");
+ fgSplashProgress("creating subsystems");
} else if ( idle_state == 7 ) {
idle_state++;
- // Initialize audio support
-#ifdef ENABLE_AUDIO_SUPPORT
-
- // Start the intro music
- if ( fgGetBool("/sim/startup/intro-music") ) {
- SGPath mp3file( globals->get_fg_root() );
- mp3file.append( "Sounds/intro.mp3" );
-
- SG_LOG( SG_GENERAL, SG_INFO,
- "Starting intro music: " << mp3file.str() );
-
-# if defined( __CYGWIN__ )
- string command = "start /m `cygpath -w " + mp3file.str() + "`";
-# elif defined( _WIN32 )
- string command = "start /m " + mp3file.str();
-# else
- string command = "mpg123 " + mp3file.str() + "> /dev/null 2>&1";
-# endif
-
- if (0 != system ( command.c_str() ))
- {
- SG_LOG( SG_SOUND, SG_WARN,
- "Failed to play mp3 file " << mp3file.str() << ". Maybe mp3 player is not installed." );
- }
- }
-#endif
- // This is the top level init routine which calls all the
- // other subsystem initialization routines. If you are adding
- // a subsystem to flightgear, its initialization call should be
- // located in this routine.
- if( !fgInitSubsystems()) {
- SG_LOG( SG_GENERAL, SG_ALERT,
- "Subsystem initialization failed ..." );
- exit(-1);
+ SGTimeStamp st;
+ st.stamp();
+ fgCreateSubsystems();
+ SG_LOG(SG_GENERAL, SG_INFO, "Creating subsystems took:" << st.elapsedMSec());
+ fgSplashProgress("binding subsystems");
+
+ } else if ( idle_state == 8 ) {
+ idle_state++;
+ SGTimeStamp st;
+ st.stamp();
+ globals->get_subsystem_mgr()->bind();
+ SG_LOG(SG_GENERAL, SG_INFO, "Binding subsystems took:" << st.elapsedMSec());
+
+ fgSplashProgress("initing subsystems");
+ } else if ( idle_state == 9 ) {
+ SGSubsystem::InitStatus status = globals->get_subsystem_mgr()->incrementalInit();
+ if ( status == SGSubsystem::INIT_DONE) {
+ ++idle_state;
+ fgSplashProgress("finishing subsystem init");
+ } else {
+ const char* spinChars = "-\\|/";
+ string msg = string("initing subsystems ") + spinChars[spin_count++ % 4];
+ fgSplashProgress(msg.c_str());
}
-
- // Torsten Dreyer:
+
+ } else if ( idle_state == 10 ) {
+ idle_state = 900;
+ fgPostInitSubsystems();
+
+ // Torsten Dreyer:
// ugly hack for automatic runway selection on startup based on
// metar data. Makes startup.nas obsolete and guarantees the same
// runway selection as for AI traffic. However, this code belongs to
fgSplashProgress("initializing graphics engine");
- } else if ( idle_state == 8 ) {
+ } else if ( idle_state == 900 ) {
idle_state = 1000;
// setup OpenGL view parameters