Some follow up patches from Norman Vine.
This commit is contained in:
parent
fb5d5960a9
commit
7cd113fa2f
4 changed files with 75 additions and 63 deletions
|
@ -73,13 +73,18 @@ void reInit(puObject *cb)
|
|||
|
||||
globals->restoreInitialState();
|
||||
|
||||
// Unsuccessful KLUDGE to fix the 'every other time'
|
||||
// problem when doing a 'reset' after a 'goto airport'
|
||||
// Unsuccessful KLUDGE to fix the 'every other time'
|
||||
// problem when doing a 'reset' after a 'goto airport'
|
||||
|
||||
// string AptId( fgGetString("/sim/startup/airport-id") );
|
||||
// if( AptId.c_str() != "\0" )
|
||||
// fgSetPosFromAirportID( AptId );
|
||||
// string AptId( fgGetString("/sim/startup/airport-id") );
|
||||
// if( AptId.c_str() != "\0" )
|
||||
// fgSetPosFromAirportID( AptId );
|
||||
|
||||
SGTime *t = globals->get_time_params();
|
||||
delete t;
|
||||
t = fgInitTime();
|
||||
globals->set_time_params( t );
|
||||
|
||||
fgReInitSubsystems();
|
||||
|
||||
// reduntant(fgReInitSubsystems) ?
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#include <simgear/math/sg_geodesy.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/timing/sg_time.hxx>
|
||||
#include <simgear/timing/lowleveltime.h>
|
||||
|
||||
#include <Aircraft/aircraft.hxx>
|
||||
#include <FDM/UIUCModel/uiuc_aircraftdir.h>
|
||||
|
@ -583,6 +584,61 @@ void fgInitView() {
|
|||
}
|
||||
|
||||
|
||||
SGTime *fgInitTime() {
|
||||
// Initialize time
|
||||
static const SGPropertyNode *longitude
|
||||
= fgGetNode("/position/longitude-deg");
|
||||
static const SGPropertyNode *latitude
|
||||
= fgGetNode("/position/latitude-deg");
|
||||
|
||||
SGPath zone( globals->get_fg_root() );
|
||||
zone.append( "Timezone" );
|
||||
SGTime *t = new SGTime( longitude->getDoubleValue()
|
||||
* SGD_DEGREES_TO_RADIANS,
|
||||
latitude->getDoubleValue()
|
||||
* SGD_DEGREES_TO_RADIANS,
|
||||
zone.str() );
|
||||
|
||||
// Handle potential user specified time offsets
|
||||
time_t cur_time = t->get_cur_time();
|
||||
time_t currGMT = sgTimeGetGMT( gmtime(&cur_time) );
|
||||
time_t systemLocalTime = sgTimeGetGMT( localtime(&cur_time) );
|
||||
time_t aircraftLocalTime =
|
||||
sgTimeGetGMT( fgLocaltime(&cur_time, t->get_zonename() ) );
|
||||
|
||||
// Okay, we now have six possible scenarios
|
||||
int offset = fgGetInt("/sim/startup/time-offset");
|
||||
const string &offset_type = fgGetString("/sim/startup/time-offset-type");
|
||||
if (offset_type == "system-offset") {
|
||||
globals->set_warp( offset );
|
||||
} else if (offset_type == "gmt-offset") {
|
||||
globals->set_warp( offset - (currGMT - systemLocalTime) );
|
||||
} else if (offset_type == "latitude-offset") {
|
||||
globals->set_warp( offset - (aircraftLocalTime - systemLocalTime) );
|
||||
} else if (offset_type == "system") {
|
||||
globals->set_warp( offset - cur_time );
|
||||
} else if (offset_type == "gmt") {
|
||||
globals->set_warp( offset - currGMT );
|
||||
} else if (offset_type == "latitude") {
|
||||
globals->set_warp( offset - (aircraftLocalTime - systemLocalTime) -
|
||||
cur_time );
|
||||
} else {
|
||||
SG_LOG( SG_GENERAL, SG_ALERT,
|
||||
"FG_TIME::Unsupported offset type " << offset_type );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
SG_LOG( SG_GENERAL, SG_INFO, "After time init, warp = "
|
||||
<< globals->get_warp() );
|
||||
|
||||
globals->set_warp_delta( 0 );
|
||||
|
||||
t->update( 0.0, 0.0, globals->get_warp() );
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
// 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.
|
||||
|
@ -622,8 +678,8 @@ bool fgInitSubsystems( void ) {
|
|||
|
||||
if ( global_tile_mgr.init() ) {
|
||||
// Load the local scenery data
|
||||
global_tile_mgr.update( fgGetDouble("/position/longitude-deg"),
|
||||
fgGetDouble("/position/latitude-deg") );
|
||||
global_tile_mgr.update( longitude->getDoubleValue(),
|
||||
latitude->getDoubleValue() );
|
||||
} else {
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Error in Tile Manager initialization!" );
|
||||
exit(-1);
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/timing/sg_time.hxx>
|
||||
|
||||
#include STL_STRING
|
||||
|
||||
|
@ -79,6 +80,9 @@ bool fgSetPosFromAirportID( const string& id );
|
|||
// Set position and heading given an airport id and heading (degrees)
|
||||
bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg );
|
||||
|
||||
// Initialize various time dependent systems (lighting, sun position, etc.)
|
||||
// returns a new instance of the SGTime class
|
||||
SGTime *fgInitTime();
|
||||
|
||||
#endif // _FG_INIT_HXX
|
||||
|
||||
|
|
|
@ -561,9 +561,8 @@ void fgRenderFrame( void ) {
|
|||
#endif
|
||||
|
||||
thesky->modify_vis( cur_fdm_state->get_Altitude() * SG_FEET_TO_METER,
|
||||
( global_multi_loop *
|
||||
fgGetInt("/sim/speed-up") ) /
|
||||
(double)fgGetInt("/sim/model-hz") );
|
||||
( global_multi_loop * fgGetInt("/sim/speed-up") )
|
||||
/ (double)fgGetInt("/sim/model-hz") );
|
||||
|
||||
double actual_visibility = thesky->get_visibility();
|
||||
// cout << "actual visibility = " << actual_visibility << endl;
|
||||
|
@ -1518,59 +1517,7 @@ int mainLoop( int argc, char **argv ) {
|
|||
fgGetDouble("/orientation/heading-deg") );
|
||||
}
|
||||
|
||||
// Any time after globals is created we are ready to use the
|
||||
// property system
|
||||
static const SGPropertyNode *longitude
|
||||
= fgGetNode("/position/longitude-deg", true);
|
||||
static const SGPropertyNode *latitude
|
||||
= fgGetNode("/position/latitude-deg", true);
|
||||
|
||||
|
||||
// Initialize time
|
||||
SGPath zone( globals->get_fg_root() );
|
||||
zone.append( "Timezone" );
|
||||
SGTime *t = new SGTime( longitude->getDoubleValue()
|
||||
* SGD_DEGREES_TO_RADIANS,
|
||||
latitude->getDoubleValue()
|
||||
* SGD_DEGREES_TO_RADIANS,
|
||||
zone.str() );
|
||||
|
||||
// Handle potential user specified time offsets
|
||||
time_t cur_time = t->get_cur_time();
|
||||
time_t currGMT = sgTimeGetGMT( gmtime(&cur_time) );
|
||||
time_t systemLocalTime = sgTimeGetGMT( localtime(&cur_time) );
|
||||
time_t aircraftLocalTime =
|
||||
sgTimeGetGMT( fgLocaltime(&cur_time, t->get_zonename() ) );
|
||||
|
||||
// Okay, we now have six possible scenarios
|
||||
int offset = fgGetInt("/sim/startup/time-offset");
|
||||
const string &offset_type = fgGetString("/sim/startup/time-offset-type");
|
||||
if (offset_type == "system-offset") {
|
||||
globals->set_warp( offset );
|
||||
} else if (offset_type == "gmt-offset") {
|
||||
globals->set_warp( offset - (currGMT - systemLocalTime) );
|
||||
} else if (offset_type == "latitude-offset") {
|
||||
globals->set_warp( offset - (aircraftLocalTime - systemLocalTime) );
|
||||
} else if (offset_type == "system") {
|
||||
globals->set_warp( offset - cur_time );
|
||||
} else if (offset_type == "gmt") {
|
||||
globals->set_warp( offset - currGMT );
|
||||
} else if (offset_type == "latitude") {
|
||||
globals->set_warp( offset - (aircraftLocalTime - systemLocalTime) -
|
||||
cur_time );
|
||||
} else {
|
||||
SG_LOG( SG_GENERAL, SG_ALERT,
|
||||
"Unsupported offset type " << offset_type );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
SG_LOG( SG_GENERAL, SG_INFO, "After time init, warp = "
|
||||
<< globals->get_warp() );
|
||||
|
||||
globals->set_warp_delta( 0 );
|
||||
|
||||
t->update( 0.0, 0.0, globals->get_warp() );
|
||||
|
||||
SGTime *t = fgInitTime();
|
||||
globals->set_time_params( t );
|
||||
|
||||
// Do some quick general initializations
|
||||
|
|
Loading…
Reference in a new issue