#include <Aircraft/aircraft.hxx>
#include <Include/general.hxx>
+#include <Main/globals.hxx>
#include <Main/options.hxx>
#include <Main/views.hxx>
#include <Scenery/scenery.hxx>
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);
#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"
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;
time_t
FGBFI::getTimeGMT ()
{
- return SGTime::cur_time_params->get_cur_time();
+ return globals->get_time_params()->get_cur_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();
}
#define _GLOBALS_HXX
+#include <simgear/timing/sg_time.hxx>
+
+
class FGGlobals {
private:
// to make time progress faster than normal (or even run in reverse.)
long int warp_delta;
+ // Time structure
+ SGTime *time_params;
+
public:
FGGlobals();
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; }
};
#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>
int speed;
f = current_aircraft.fdm_state;
- t = SGTime::cur_time_params;
v = ¤t_view;
FG_LOG( FG_INPUT, FG_DEBUG, "Key hit = " << k );
FGBFI::update();
fgLIGHT *l = &cur_light_params;
- SGTime *t = SGTime::cur_time_params;
- // FGView *v = ¤t_view;
static double last_visibility = -9999;
double angle;
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(),
// 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 = ¤t_view;
int i;
// update the flight model
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(),
// 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
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, "======= ==== ====");
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();
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() ) {
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()) {
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" );
# 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);
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);
#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"
int deg;
double min;
- SGTime *t = SGTime::cur_time_params;
+ SGTime *t = globals->get_time_params();
char utc[10];
sprintf( utc, "%02d%02d%02d",
#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"
int deg;
double min;
- SGTime *t = SGTime::cur_time_params;
+ SGTime *t = globals->get_time_params();
char utc[10];
sprintf( utc, "%02d%02d%02d",
#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>
// 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
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." );
#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>
// 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;
double moon_gd_lat, sl_radius;
l = &cur_light_params;
- t = SGTime::cur_time_params;
+ SGTime *t = globals->get_time_params();
v = ¤t_view;
FG_LOG( FG_EVENT, FG_INFO, " Updating Moon position" );
#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>
// 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;
double sun_gd_lat, sl_radius;
l = &cur_light_params;
- t = SGTime::cur_time_params;
+ SGTime *t = globals->get_time_params();
v = ¤t_view;
FG_LOG( FG_EVENT, FG_INFO, " Updating Sun position" );
#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"
// 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() );
}