Updates to go along with SGTime tweaks in SimGear.
This commit is contained in:
parent
0ffa19cd32
commit
f9b28c103d
7 changed files with 72 additions and 18 deletions
src
|
@ -36,6 +36,7 @@ fgfs_SOURCES = \
|
|||
bfi.cxx bfi.hxx \
|
||||
fg_init.cxx fg_init.hxx \
|
||||
fg_io.cxx fg_io.hxx \
|
||||
globals.cxx globals.hxx \
|
||||
keyboard.cxx keyboard.hxx \
|
||||
options.cxx options.hxx \
|
||||
save.cxx save.hxx \
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
# include <Weather/weather.hxx>
|
||||
#endif
|
||||
|
||||
#include "globals.hxx"
|
||||
#include "options.hxx"
|
||||
#include "save.hxx"
|
||||
#include "fg_init.hxx"
|
||||
|
@ -393,13 +394,12 @@ FGBFI::setTimeGMT (time_t time)
|
|||
current_options.set_time_offset_type(SG_TIME_GMT_ABSOLUTE);
|
||||
SGTime::cur_time_params->init( cur_fdm_state->get_Longitude(),
|
||||
cur_fdm_state->get_Latitude(),
|
||||
current_options.get_fg_root(),
|
||||
current_options.get_time_offset(),
|
||||
current_options.get_time_offset_type() );
|
||||
current_options.get_fg_root() );
|
||||
SGTime::cur_time_params->update( cur_fdm_state->get_Longitude(),
|
||||
cur_fdm_state->get_Latitude(),
|
||||
cur_fdm_state->get_Altitude()
|
||||
* FEET_TO_METER );
|
||||
* FEET_TO_METER,
|
||||
globals->get_warp() );
|
||||
needReinit();
|
||||
}
|
||||
|
||||
|
|
|
@ -245,7 +245,6 @@ bool fgInitGeneral( void ) {
|
|||
// Returns non-zero if a problem encountered.
|
||||
bool fgInitSubsystems( void ) {
|
||||
fgLIGHT *l = &cur_light_params;
|
||||
SGTime *t = SGTime::cur_time_params;
|
||||
|
||||
FG_LOG( FG_GENERAL, FG_INFO, "Initialize Subsystems");
|
||||
FG_LOG( FG_GENERAL, FG_INFO, "========== ==========");
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
#endif
|
||||
|
||||
#include "bfi.hxx"
|
||||
#include "globals.hxx"
|
||||
#include "keyboard.hxx"
|
||||
#include "options.hxx"
|
||||
#include "save.hxx"
|
||||
|
@ -194,14 +195,14 @@ void GLUTkey(unsigned char k, int x, int y) {
|
|||
fgHUDInit2(¤t_aircraft);
|
||||
return;
|
||||
case 77: // M key
|
||||
t->adjust_warp(-60);
|
||||
globals->inc_warp( -60 );
|
||||
fgUpdateSkyAndLightingParams();
|
||||
return;
|
||||
case 80: // P key
|
||||
current_options.toggle_panel();
|
||||
break;
|
||||
case 84: // T key
|
||||
t->adjust_warp_delta(-30);
|
||||
globals->inc_warp_delta( -30 );
|
||||
fgUpdateSkyAndLightingParams();
|
||||
return;
|
||||
case 87: // W key
|
||||
|
@ -339,7 +340,7 @@ void GLUTkey(unsigned char k, int x, int y) {
|
|||
fgHUDInit(¤t_aircraft); // normal HUD
|
||||
return;
|
||||
case 109: // m key
|
||||
t->adjust_warp (+60);
|
||||
globals->inc_warp( 60 );
|
||||
fgUpdateSkyAndLightingParams();
|
||||
return;
|
||||
case 112: // p key
|
||||
|
@ -367,7 +368,7 @@ void GLUTkey(unsigned char k, int x, int y) {
|
|||
}
|
||||
return;
|
||||
case 116: // t key
|
||||
t->adjust_warp_delta (+30);
|
||||
globals->inc_warp_delta( 30 );
|
||||
fgUpdateSkyAndLightingParams();
|
||||
return;
|
||||
case 118: // v key
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
#include <simgear/misc/fgpath.hxx>
|
||||
#include <simgear/sky/sky.hxx>
|
||||
#include <simgear/timing/sg_time.hxx>
|
||||
#include <simgear/timing/lowleveltime.h>
|
||||
|
||||
#include <Include/general.hxx>
|
||||
|
||||
|
@ -105,6 +106,7 @@
|
|||
#include "bfi.hxx"
|
||||
#include "fg_init.hxx"
|
||||
#include "fg_io.hxx"
|
||||
#include "globals.hxx"
|
||||
#include "keyboard.hxx"
|
||||
#include "options.hxx"
|
||||
#include "splash.hxx"
|
||||
|
@ -796,11 +798,16 @@ static void fgMainLoop( void ) {
|
|||
cur_fdm_state->get_Altitude() * FEET_TO_METER); */
|
||||
|
||||
// update "time"
|
||||
if ( globals->get_warp_delta() != 0 ) {
|
||||
globals->inc_warp( globals->get_warp_delta() );
|
||||
}
|
||||
|
||||
t->update( cur_fdm_state->get_Longitude(),
|
||||
cur_fdm_state->get_Latitude(),
|
||||
cur_fdm_state->get_Altitude()* FEET_TO_METER );
|
||||
cur_fdm_state->get_Altitude()* FEET_TO_METER,
|
||||
globals->get_warp() );
|
||||
|
||||
if ( t->get_warp_delta() != 0 ) {
|
||||
if ( globals->get_warp_delta() != 0 ) {
|
||||
fgUpdateSkyAndLightingParams();
|
||||
}
|
||||
|
||||
|
@ -1277,6 +1284,9 @@ int main( int argc, char **argv ) {
|
|||
|
||||
aircraft_dir = ""; // Initialize the Aircraft directory to "" (UIUC)
|
||||
|
||||
// needs to happen before we parse command line options
|
||||
globals = new FGGlobals;
|
||||
|
||||
// Load the configuration parameters
|
||||
if ( !fgInitConfig(argc, argv) ) {
|
||||
FG_LOG( FG_GENERAL, FG_ALERT, "Config option parsing failed ..." );
|
||||
|
@ -1310,11 +1320,53 @@ int main( int argc, char **argv ) {
|
|||
// SGTime::cur_time_params->init( cur_fdm_state->get_Longitude(),
|
||||
// cur_fdm_state->get_Latitude() );
|
||||
// SGTime::cur_time_params->update( cur_fdm_state->get_Longitude() );
|
||||
SGTime::cur_time_params->init( 0.0, 0.0,
|
||||
current_options.get_fg_root(),
|
||||
current_options.get_time_offset(),
|
||||
current_options.get_time_offset_type() );
|
||||
SGTime::cur_time_params->update( 0.0, 0.0, 0.0 );
|
||||
SGTime::cur_time_params->init( 0.0, 0.0, current_options.get_fg_root() );
|
||||
|
||||
// Handle user specified offsets
|
||||
// current_options.get_time_offset(),
|
||||
// current_options.get_time_offset_type() );
|
||||
|
||||
time_t cur_time = SGTime::cur_time_params->get_cur_time();
|
||||
time_t currGMT = SGTime::cur_time_params->get_gmt( gmtime(&cur_time) );
|
||||
time_t systemLocalTime = SGTime::cur_time_params->get_gmt( localtime(&cur_time) );
|
||||
time_t aircraftLocalTime = SGTime::cur_time_params->get_gmt( fgLocaltime(&cur_time, SGTime::cur_time_params->get_zonename() ) );
|
||||
|
||||
// Okay, we now have six possible scenarios
|
||||
switch ( current_options.get_time_offset_type() ) {
|
||||
case SG_TIME_SYS_OFFSET:
|
||||
globals->set_warp( current_options.get_time_offset() );
|
||||
break;
|
||||
case SG_TIME_GMT_OFFSET:
|
||||
globals->set_warp( current_options.get_time_offset() -
|
||||
(currGMT - systemLocalTime) );
|
||||
break;
|
||||
case SG_TIME_LAT_OFFSET:
|
||||
globals->set_warp( current_options.get_time_offset() -
|
||||
(aircraftLocalTime - systemLocalTime) );
|
||||
break;
|
||||
case SG_TIME_SYS_ABSOLUTE:
|
||||
globals->set_warp( current_options.get_time_offset() - cur_time );
|
||||
//printf("warp = %d\n", warp);
|
||||
break;
|
||||
case SG_TIME_GMT_ABSOLUTE:
|
||||
globals->set_warp( current_options.get_time_offset() - currGMT );
|
||||
break;
|
||||
case SG_TIME_LAT_ABSOLUTE:
|
||||
globals->set_warp( current_options.get_time_offset() -
|
||||
(aircraftLocalTime - systemLocalTime) -
|
||||
cur_time );
|
||||
break;
|
||||
default:
|
||||
FG_LOG( FG_GENERAL, FG_ALERT, "Unsupported type" );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
FG_LOG( FG_GENERAL, FG_INFO, "After time init, warp = "
|
||||
<< globals->get_warp() );
|
||||
|
||||
globals->set_warp_delta( 0 );
|
||||
|
||||
SGTime::cur_time_params->update( 0.0, 0.0, 0.0, globals->get_warp() );
|
||||
|
||||
// Do some quick general initializations
|
||||
if( !fgInitGeneral()) {
|
||||
|
|
|
@ -258,6 +258,7 @@ void fgUpdateSunPos( void ) {
|
|||
v = ¤t_view;
|
||||
|
||||
FG_LOG( FG_EVENT, FG_INFO, " Updating Sun position" );
|
||||
FG_LOG( FG_EVENT, FG_INFO, " Gst = " << t->getGst() );
|
||||
|
||||
fgSunPositionGST(t->getGst(), &l->sun_lon, &sun_gd_lat);
|
||||
|
||||
|
|
|
@ -57,8 +57,8 @@ typedef float WeatherPrecision;
|
|||
#define MINIMUM_WEATHER_VISIBILITY 10.0 /* metres */
|
||||
#define DEFAULT_WEATHER_VISIBILITY 32000.0 /* metres */
|
||||
//prefered way the database is working
|
||||
// #define PREFERED_WORKING_TYPE default_mode
|
||||
#define PREFERED_WORKING_TYPE use_internet
|
||||
#define PREFERED_WORKING_TYPE default_mode
|
||||
// #define PREFERED_WORKING_TYPE use_internet
|
||||
|
||||
#define FG_WEATHER_DEFAULT_TEMPERATURE (15.0+273.16) /*15°C or 288.16°K*/
|
||||
#define FG_WEATHER_DEFAULT_VAPORPRESSURE (0.0) /*in Pascal 1 Pa = N/m^2*/
|
||||
|
|
Loading…
Add table
Reference in a new issue