From 01376eec31323df1242ddafc63a8b7242492210b Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Mon, 17 Sep 2012 13:41:42 +0200 Subject: [PATCH] Minor main loop/init clean-up --- src/Main/main.cxx | 23 ++++++++--------------- src/Main/main.hxx | 24 +++++++++++++++++++----- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/Main/main.cxx b/src/Main/main.cxx index a16f77f1c..8d65c1b69 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -75,11 +75,6 @@ using namespace flightgear; using std::cerr; using std::vector; -// Specify our current idle function state. This is used to run all -// our initializations out of the idle callback so that we can get a -// splash screen up and running right away. -int idle_state = 0; - // The atexit() function handler should know when the graphical subsystem // is initialized. extern int _bootstrap_OSInit; @@ -124,7 +119,7 @@ static void fgMainLoop( void ) // compute simulated time (allowing for pause, warp, etc) and // real elapsed time double sim_dt, real_dt; - TimeManager* timeMgr = (TimeManager*) globals->get_subsystem("time"); + static TimeManager* timeMgr = (TimeManager*) globals->get_subsystem("time"); timeMgr->computeTimeDeltas(sim_dt, real_dt); // update magvar model @@ -184,6 +179,11 @@ struct GeneralInitOperation : public GraphicsContextOperation // then on. static void fgIdleFunction ( void ) { + // Specify our current idle function state. This is used to run all + // 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 osg::ref_ptr genOp; if ( idle_state == 0 ) { idle_state++; @@ -224,7 +224,7 @@ static void fgIdleFunction ( void ) { fgSplashProgress("initializing scenery system"); } else if ( idle_state == 4 ) { - idle_state++; + idle_state+=2; // based on the requested presets, calculate the true starting // lon, lat fgInitPosition(); @@ -265,11 +265,6 @@ static void fgIdleFunction ( void ) { fgSplashProgress("loading aircraft"); - } else if ( idle_state == 5 ) { - idle_state++; - - fgSplashProgress("initializing sky elements"); - } else if ( idle_state == 6 ) { idle_state++; @@ -277,10 +272,8 @@ static void fgIdleFunction ( void ) { SGMagVar *magvar = new SGMagVar(); globals->set_mag( magvar ); - // kludge to initialize mag compass - // (should only be done for in-flight - // startup) + // (should only be done for in-flight startup) // update magvar model globals->get_mag()->update( fgGetDouble("/position/longitude-deg") * SGD_DEGREES_TO_RADIANS, diff --git a/src/Main/main.hxx b/src/Main/main.hxx index 8ddea1a9e..145feacf1 100644 --- a/src/Main/main.hxx +++ b/src/Main/main.hxx @@ -1,14 +1,28 @@ +// main.hxx -- top level sim routines +// +// Written by Curtis Olson, started May 1997. +// +// Copyright (C) 1997 - 2002 Curtis L. Olson - http://www.flightgear.org/~curt +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef __FG_MAIN_HXX #define __FG_MAIN_HXX 1 -void fgUpdateTimeDepCalcs(); - int fgMainInit( int argc, char **argv ); - -extern int idle_state; - extern std::string homedir; extern std::string hostname; -- 2.39.2