]> git.mxchange.org Git - flightgear.git/commitdiff
More SGTime tidying.
authorcurt <curt>
Fri, 7 Jul 2000 20:28:51 +0000 (20:28 +0000)
committercurt <curt>
Fri, 7 Jul 2000 20:28:51 +0000 (20:28 +0000)
13 files changed:
src/Cockpit/cockpit.cxx
src/Cockpit/sp_panel.cxx
src/Main/bfi.cxx
src/Main/globals.hxx
src/Main/keyboard.cxx
src/Main/main.cxx
src/Main/options.cxx
src/Network/garmin.cxx
src/Network/nmea.cxx
src/Time/light.cxx
src/Time/moonpos.cxx
src/Time/sunpos.cxx
src/Time/tmp.cxx

index 9b14ab5ad4aee87c6add7b2ae4b046b4fc93e6e6..eecbf69ee58dcc5798260993cff79eedcc1f4fac 100644 (file)
@@ -43,6 +43,7 @@
 
 #include <Aircraft/aircraft.hxx>
 #include <Include/general.hxx>
+#include <Main/globals.hxx>
 #include <Main/options.hxx>
 #include <Main/views.hxx>
 #include <Scenery/scenery.hxx>
@@ -101,8 +102,7 @@ char*
 get_formated_gmt_time( void )
 {
     static char buf[32];
-    SGTime *t = SGTime::cur_time_params;
-    const struct tm *p = t->getGmt();
+    const struct tm *p = globals->get_time_params()->getGmt();
     sprintf( buf, "%d/%d/%4d %d:%02d:%02d", 
          p->tm_mon+1, p->tm_mday, 1900 + p->tm_year,
          p->tm_hour, p->tm_min, p->tm_sec);
index 933099ec6c516ed48e0c3c00bdd147687cb02d28..136fbefbcc16bd63d078046fed41c104cfcfd5a6 100644 (file)
@@ -29,9 +29,9 @@
 #include <map>
 
 #include <simgear/debug/logstream.hxx>
-#include <simgear/timing/sg_time.hxx>
 
 #include <Main/bfi.hxx>
+#include <Main/globals.hxx>
 
 #include "panel.hxx"
 #include "steam.hxx"
@@ -63,7 +63,7 @@ FG_USING_STD(map);
 static char * panelGetTime ()
 {
   static char buf[1024];       // FIXME: not thread-safe
-  struct tm * t = SGTime::cur_time_params->getGmt();
+  struct tm * t = globals->get_time_params()->getGmt();
   sprintf(buf, " %.2d:%.2d:%.2d",
          t->tm_hour, t->tm_min, t->tm_sec);
   return buf;
index 4962fa083fc06beae7d534d5e50f19c5af39d8f6..c0a06a9871c7c1496708fcf9baaeea81b28d5cc5 100644 (file)
@@ -378,7 +378,7 @@ FGBFI::setAircraftDir (const string &dir)
 time_t
 FGBFI::getTimeGMT ()
 {
-  return SGTime::cur_time_params->get_cur_time();
+  return globals->get_time_params()->get_cur_time();
 }
 
 
@@ -392,14 +392,14 @@ FGBFI::setTimeGMT (time_t time)
                                // and solar system
   current_options.set_time_offset(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() );
-  SGTime::cur_time_params->update( cur_fdm_state->get_Longitude(),
-                                  cur_fdm_state->get_Latitude(),
-                                  cur_fdm_state->get_Altitude()
-                                  * FEET_TO_METER,
-                                  globals->get_warp() );
+  globals->get_time_params()->init( cur_fdm_state->get_Longitude(),
+                                   cur_fdm_state->get_Latitude(),
+                                   current_options.get_fg_root() );
+  globals->get_time_params()->update( cur_fdm_state->get_Longitude(),
+                                     cur_fdm_state->get_Latitude(),
+                                     cur_fdm_state->get_Altitude()
+                                     * FEET_TO_METER,
+                                     globals->get_warp() );
   needReinit();
 }
 
index 5521a2bf66bca03e459f5f50833e53dac5490a33..d21fce514b8f07df96b3bab8fd4860da3e1551f9 100644 (file)
@@ -25,6 +25,9 @@
 #define _GLOBALS_HXX
 
 
+#include <simgear/timing/sg_time.hxx>
+
+
 class FGGlobals {
 
 private:
@@ -40,6 +43,9 @@ private:
     // to make time progress faster than normal (or even run in reverse.)
     long int warp_delta;
 
+    // Time structure
+    SGTime *time_params;
+
 public:
 
     FGGlobals();
@@ -55,6 +61,9 @@ public:
     inline long int get_warp_delta() const { return warp_delta; }
     inline void set_warp_delta( long int d ) { warp_delta = d; }
     inline void inc_warp_delta( long int d ) { warp_delta += d; }
+
+    inline SGTime *get_time_params() const { return time_params; }
+    inline void set_time_params( SGTime *t ) { time_params = t; }
 };
 
 
index 458ad8dd4fe322dc052be48e06389c010b741862..3171b28d776385f8219c26af70efa2b9e2647d45 100644 (file)
@@ -48,7 +48,6 @@
 #include <simgear/constants.h>
 #include <simgear/debug/logstream.hxx>
 #include <simgear/misc/fgpath.hxx>
-#include <simgear/timing/sg_time.hxx>
 
 #include <Aircraft/aircraft.hxx>
 #include <Autopilot/auto_gui.hxx>
@@ -84,7 +83,6 @@ void GLUTkey(unsigned char k, int x, int y) {
     int speed;
 
     f = current_aircraft.fdm_state;
-    t = SGTime::cur_time_params;
     v = &current_view;
 
     FG_LOG( FG_INPUT, FG_DEBUG, "Key hit = " << k );
index 3946503ba20763fb55ddb79bf2bacd766adc66b1..638bf612ffc736f5aa755452b2f91494e42c6a85 100644 (file)
@@ -278,8 +278,6 @@ void fgRenderFrame( void ) {
     FGBFI::update();
 
     fgLIGHT *l = &cur_light_params;
-    SGTime *t = SGTime::cur_time_params;
-    // FGView *v = &current_view;
     static double last_visibility = -9999;
 
     double angle;
@@ -442,7 +440,7 @@ void fgRenderFrame( void ) {
                                cur_fdm_state->get_Latitude(),
                                cur_fdm_state->get_Altitude() * FEET_TO_METER,
                                cur_light_params.sun_rotation,
-                               SGTime::cur_time_params->getGst(),
+                               globals->get_time_params()->getGst(),
                                ephem->getSunRightAscension(),
                                ephem->getSunDeclination(), 50000.0,
                                ephem->getMoonRightAscension(),
@@ -607,10 +605,7 @@ void fgRenderFrame( void ) {
 // Update internal time dependent calculations (i.e. flight model)
 void fgUpdateTimeDepCalcs(int multi_loop, int remainder) {
     static fdm_state_list fdm_list;
-    // FGInterface fdm_state;
     fgLIGHT *l = &cur_light_params;
-    SGTime *t = SGTime::cur_time_params;
-    // FGView *v = &current_view;
     int i;
 
     // update the flight model
@@ -698,7 +693,7 @@ void fgUpdateTimeDepCalcs(int multi_loop, int remainder) {
     l->UpdateAdjFog();
 
     // Update solar system
-    ephem->update( t, cur_fdm_state->get_Latitude() );
+    ephem->update( globals->get_time_params(), cur_fdm_state->get_Latitude() );
 
     // Update radio stack model
     current_radiostack->update( cur_fdm_state->get_Longitude(),
@@ -724,7 +719,6 @@ static const double alt_adjust_m = alt_adjust_ft * FEET_TO_METER;
 // What should we do when we have nothing else to do?  Let's get ready
 // for the next move and update the display?
 static void fgMainLoop( void ) {
-    SGTime *t;
     static long remainder = 0;
     long elapsed;
 #ifdef FANCY_FRAME_COUNTER
@@ -735,7 +729,7 @@ static void fgMainLoop( void ) {
     static int frames = 0;
 #endif // FANCY_FRAME_COUNTER
 
-    t = SGTime::cur_time_params;
+    SGTime *t = globals->get_time_params();
 
     FG_LOG( FG_ALL, FG_DEBUG, "Running Main Loop");
     FG_LOG( FG_ALL, FG_DEBUG, "======= ==== ====");
@@ -815,7 +809,7 @@ static void fgMainLoop( void ) {
     cur_magvar.update( cur_fdm_state->get_Longitude(),
                       cur_fdm_state->get_Latitude(),
                       cur_fdm_state->get_Altitude()* FEET_TO_METER,
-                      SGTime::cur_time_params->getJD() );
+                      globals->get_time_params()->getJD() );
 
     // Get elapsed time (in usec) for this past frame
     elapsed = fgGetTimeInterval();
@@ -1316,20 +1310,15 @@ int main( int argc, char **argv ) {
     guiInit();
 
     // Initialize time
-    SGTime::cur_time_params = new SGTime( current_options.get_fg_root() );
-    // 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() );
+    SGTime *t = new SGTime( current_options.get_fg_root() );
+    t->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() ) );
+    // Handle potential user specified time offsets
+    time_t cur_time = t->get_cur_time();
+    time_t currGMT = t->get_gmt( gmtime(&cur_time) );
+    time_t systemLocalTime = t->get_gmt( localtime(&cur_time) );
+    time_t aircraftLocalTime = 
+       t->get_gmt( fgLocaltime(&cur_time, t->get_zonename() ) );
 
     // Okay, we now have six possible scenarios
     switch ( current_options.get_time_offset_type() ) {
@@ -1366,7 +1355,9 @@ int main( int argc, char **argv ) {
 
     globals->set_warp_delta( 0 );
 
-    SGTime::cur_time_params->update( 0.0, 0.0, 0.0, globals->get_warp() );
+    t->update( 0.0, 0.0, 0.0, globals->get_warp() );
+
+    globals->set_time_params( t );
 
     // Do some quick general initializations
     if( !fgInitGeneral()) {
@@ -1399,7 +1390,7 @@ int main( int argc, char **argv ) {
     FGPath ephem_data_path( current_options.get_fg_root() );
     ephem_data_path.append( "Astro" );
     ephem = new FGEphemeris( ephem_data_path.c_str() );
-    ephem->update( SGTime::cur_time_params, 0.0 );
+    ephem->update( globals->get_time_params(), 0.0 );
 
     FGPath sky_tex_path( current_options.get_fg_root() );
     sky_tex_path.append( "Textures" );
index 4554821787fbd6be7224e2c60602845fdcbf6ffd..6e2ee313a875c2a1caf0d7800b3d324b0623ca5b 100644 (file)
@@ -52,8 +52,9 @@ bool global_fullscreen = true;
 #  include <NetworkOLK/network.h>
 #endif
 
-#include "views.hxx"
+#include "globals.hxx"
 #include "options.hxx"
+#include "views.hxx"
 
 FG_USING_STD(string);
 FG_USING_NAMESPACE(std);
@@ -432,12 +433,12 @@ long int fgOPTIONS::parse_date( const string& date)
        num[i] = '\0';
        gmt.tm_sec = atoi(num);
     }
-    time_t theTime = SGTime::cur_time_params->get_gmt(gmt.tm_year,
-                                                      gmt.tm_mon,
-                                                     gmt.tm_mday,
-                                                     gmt.tm_hour,
-                                                     gmt.tm_min,
-                                                     gmt.tm_sec);
+    time_t theTime = globals->get_time_params()->get_gmt(gmt.tm_year,
+                                                        gmt.tm_mon,
+                                                        gmt.tm_mday,
+                                                        gmt.tm_hour,
+                                                        gmt.tm_min,
+                                                        gmt.tm_sec);
     //printf ("Date is %s\n", ctime(&theTime));
     //printf ("in seconds that is %d\n", theTime);
     //exit(1);
index 2505c39db560a47691fe4a64961139761b4dea7a..41aa2a48b8f998809ce8f5462109188cabf693c2 100644 (file)
@@ -23,9 +23,9 @@
 
 #include <simgear/debug/logstream.hxx>
 #include <simgear/math/fg_geodesy.hxx>
-#include <simgear/timing/sg_time.hxx>
 
 #include <FDM/flight.hxx>
+#include <Main/globals.hxx>
 
 #include "iochannel.hxx"
 #include "garmin.hxx"
@@ -67,7 +67,7 @@ bool FGGarmin::gen_message() {
     int deg;
     double min;
 
-    SGTime *t = SGTime::cur_time_params;
+    SGTime *t = globals->get_time_params();
 
     char utc[10];
     sprintf( utc, "%02d%02d%02d", 
index c5f33701fcde746bd44e33f7fd28acf0b2e55a85..369f30affc214e269cde12941b241080c401e9e4 100644 (file)
@@ -23,9 +23,9 @@
 
 #include <simgear/debug/logstream.hxx>
 #include <simgear/math/fg_geodesy.hxx>
-#include <simgear/timing/sg_time.hxx>
 
 #include <FDM/flight.hxx>
+#include <Main/globals.hxx>
 
 #include "iochannel.hxx"
 #include "nmea.hxx"
@@ -68,7 +68,7 @@ bool FGNMEA::gen_message() {
     int deg;
     double min;
 
-    SGTime *t = SGTime::cur_time_params;
+    SGTime *t = globals->get_time_params();
 
     char utc[10];
     sprintf( utc, "%02d%02d%02d", 
index 56099286c6bc95f734d8c6f81e5aa92cd038e8fd..05cd0370b24ed3af41f4893bc3ce0a351c83bcfa 100644 (file)
@@ -54,7 +54,6 @@ FG_USING_STD(string);
 #include <simgear/math/interpolater.hxx>
 #include <simgear/math/polar3d.hxx>
 #include <simgear/misc/fgpath.hxx>
-#include <simgear/timing/sg_time.hxx>
 
 #include <Aircraft/aircraft.hxx>
 #include <Main/options.hxx>
@@ -100,7 +99,6 @@ void fgLIGHT::Init( void ) {
 // update lighting parameters based on current sun position
 void fgLIGHT::Update( void ) {
     FGInterface *f;
-    SGTime *t;
     // if the 4th field is 0.0, this specifies a direction ...
     GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
     // base sky color
@@ -110,7 +108,6 @@ void fgLIGHT::Update( void ) {
     double deg, ambient, diffuse, sky_brightness;
 
     f = current_aircraft.fdm_state;
-    t = SGTime::cur_time_params;
 
     FG_LOG( FG_EVENT, FG_INFO, "Updating light parameters." );
 
index ca6c7abfdcf521c1bb2fc63409e9b75833a440f3..6a7e895d8e96b51fe7768dcff2347395a5a543a0 100644 (file)
@@ -58,8 +58,8 @@
 #include <simgear/math/point3d.hxx>
 #include <simgear/math/polar3d.hxx>
 #include <simgear/math/vector.hxx>
-#include <simgear/timing/sg_time.hxx>
 
+#include <Main/globals.hxx>
 #include <Main/views.hxx>
 #include <Scenery/scenery.hxx>
 
@@ -337,7 +337,6 @@ static void fgMoonPositionGST(double gst, double *lon, double *lat) {
 // update the cur_time_params structure with the current moon position
 void fgUpdateMoonPos( void ) {
     fgLIGHT *l;
-    SGTime *t;
     FGView *v;
     sgVec3 nup, nmoon, v0, surface_to_moon;
     Point3D p, rel_moonpos;
@@ -345,7 +344,7 @@ void fgUpdateMoonPos( void ) {
     double moon_gd_lat, sl_radius;
 
     l = &cur_light_params;
-    t = SGTime::cur_time_params;
+    SGTime *t = globals->get_time_params();
     v = &current_view;
 
     FG_LOG( FG_EVENT, FG_INFO, "  Updating Moon position" );
index bba9faa885445938c241e3d723a2290a0e381ce9..68c35421cd9390a1015d6fb963391451eada1e2e 100644 (file)
@@ -60,8 +60,8 @@
 #include <simgear/math/point3d.hxx>
 #include <simgear/math/polar3d.hxx>
 #include <simgear/math/vector.hxx>
-#include <simgear/timing/sg_time.hxx>
 
+#include <Main/globals.hxx>
 #include <Main/views.hxx>
 #include <Scenery/scenery.hxx>
 
@@ -246,7 +246,6 @@ static void fgSunPositionGST(double gst, double *lon, double *lat) {
 // update the cur_time_params structure with the current sun position
 void fgUpdateSunPos( void ) {
     fgLIGHT *l;
-    SGTime *t;
     FGView *v;
     sgVec3 nup, nsun, v0, surface_to_sun;
     Point3D p, rel_sunpos;
@@ -254,7 +253,7 @@ void fgUpdateSunPos( void ) {
     double sun_gd_lat, sl_radius;
 
     l = &cur_light_params;
-    t = SGTime::cur_time_params;
+    SGTime *t = globals->get_time_params();
     v = &current_view;
 
     FG_LOG( FG_EVENT, FG_INFO, "  Updating Sun position" );
index d2fec7dcc00eff5c547565aeed1ac56abf392af0..988a5f3b315ff0a2a9d23feaeaa9906d395b1b05 100644 (file)
@@ -26,9 +26,9 @@
 #endif
 
 #include <simgear/magvar/magvar.hxx>
-#include <simgear/timing/sg_time.hxx>
 
 #include <FDM/flight.hxx>
+#include <Main/globals.hxx>
 #include <Main/options.hxx>
 
 #include "light.hxx"
@@ -58,9 +58,9 @@ FGMagVar cur_magvar;
 // periodic time updater wrapper
 void fgUpdateLocalTime() {
 
-    SGTime::cur_time_params->updateLocal( cur_fdm_state->get_Longitude(),
-                                         cur_fdm_state->get_Latitude(),
-                                         current_options.get_fg_root() );
+    globals->get_time_params()->updateLocal( cur_fdm_state->get_Longitude(),
+                                            cur_fdm_state->get_Latitude(),
+                                            current_options.get_fg_root() );
 }