]> git.mxchange.org Git - flightgear.git/commitdiff
Updates to go along with SGTime tweaks in SimGear.
authorcurt <curt>
Fri, 7 Jul 2000 17:27:37 +0000 (17:27 +0000)
committercurt <curt>
Fri, 7 Jul 2000 17:27:37 +0000 (17:27 +0000)
src/Main/Makefile.am
src/Main/bfi.cxx
src/Main/fg_init.cxx
src/Main/keyboard.cxx
src/Main/main.cxx
src/Time/sunpos.cxx
src/WeatherCM/FGWeatherDefs.h

index 18e96056f482b796c8dd91c55132dd8a8264a165..705c7aba46f7e2a8df229a54e258fdbef6659faf 100644 (file)
@@ -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 \
index 441004135d6b5ae6430efe415deb0efa7e768e6e..4962fa083fc06beae7d534d5e50f19c5af39d8f6 100644 (file)
@@ -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();
 }
 
index cbd19bf915ac7b6bceecb2f0e0b84978db31414c..adb7877e964accda5a0f9e9749b7975ceca2fdfa 100644 (file)
@@ -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, "========== ==========");
index 328e15146e9c0b82493f2e12180915acd35692ea..458ad8dd4fe322dc052be48e06389c010b741862 100644 (file)
@@ -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(&current_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(&current_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
index db96444358022045576349d3228390a68a8d093e..3946503ba20763fb55ddb79bf2bacd766adc66b1 100644 (file)
@@ -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>
 
 #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()) {
index a79d7d2600648e03d54a00c6baf7af53d94c8cd1..bba9faa885445938c241e3d723a2290a0e381ce9 100644 (file)
@@ -258,6 +258,7 @@ void fgUpdateSunPos( void ) {
     v = &current_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);
 
index f0af6fcfbc3b10990ccd9103a06747042e11c979..f357a9f3e2b9bb7c96559e8491efb4aad7a4147c 100644 (file)
@@ -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*/