1
0
Fork 0

Better support for an alternate calendar time (i.e. if time/position/etc.

are being driven from an external data source.)

Akso found and fixed a bug in the simgear that caused the time to go goofy
temporarily while scenery was being loaded.
This commit is contained in:
curt 2002-02-11 23:33:20 +00:00
parent 527ada0e1d
commit dd8852dabe
7 changed files with 22 additions and 7 deletions

View file

@ -113,7 +113,7 @@ operator >> ( istream& in, FGATIS& a )
static double julian_date = 0; static double julian_date = 0;
static const double MJD0 = 2415020.0; static const double MJD0 = 2415020.0;
if ( first_time ) { if ( first_time ) {
julian_date = sgTimeCurrentMJD() + MJD0; julian_date = sgTimeCurrentMJD(0, 0) + MJD0;
first_time = false; first_time = false;
} }

View file

@ -590,6 +590,8 @@ SGTime *fgInitTime() {
= fgGetNode("/position/longitude-deg"); = fgGetNode("/position/longitude-deg");
static const SGPropertyNode *latitude static const SGPropertyNode *latitude
= fgGetNode("/position/latitude-deg"); = fgGetNode("/position/latitude-deg");
static const SGPropertyNode *cur_time_override
= fgGetNode("/sim/time/cur-time-override", true);
SGPath zone( globals->get_fg_root() ); SGPath zone( globals->get_fg_root() );
zone.append( "Timezone" ); zone.append( "Timezone" );
@ -597,7 +599,8 @@ SGTime *fgInitTime() {
* SGD_DEGREES_TO_RADIANS, * SGD_DEGREES_TO_RADIANS,
latitude->getDoubleValue() latitude->getDoubleValue()
* SGD_DEGREES_TO_RADIANS, * SGD_DEGREES_TO_RADIANS,
zone.str() ); zone.str(),
cur_time_override->getLongValue() );
// Handle potential user specified time offsets // Handle potential user specified time offsets
time_t cur_time = t->get_cur_time(); time_t cur_time = t->get_cur_time();
@ -633,7 +636,9 @@ SGTime *fgInitTime() {
globals->set_warp_delta( 0 ); globals->set_warp_delta( 0 );
t->update( 0.0, 0.0, globals->get_warp() ); t->update( 0.0, 0.0,
cur_time_override->getLongValue(),
globals->get_warp() );
return t; return t;
} }

View file

@ -476,6 +476,9 @@ getDateString ()
static void static void
setDateString (string date_string) setDateString (string date_string)
{ {
static const SGPropertyNode *cur_time_override
= fgGetNode("/sim/time/cur-time-override", true);
SGTime * st = globals->get_time_params(); SGTime * st = globals->get_time_params();
struct tm * current_time = st->getGmt(); struct tm * current_time = st->getGmt();
struct tm new_time; struct tm new_time;
@ -510,7 +513,7 @@ setDateString (string date_string)
double lon = current_aircraft.fdm_state->get_Longitude(); double lon = current_aircraft.fdm_state->get_Longitude();
double lat = current_aircraft.fdm_state->get_Latitude(); double lat = current_aircraft.fdm_state->get_Latitude();
globals->set_warp(warp); globals->set_warp(warp);
st->update(lon, lat, warp); st->update(lon, lat, cur_time_override->getLongValue(), warp);
fgUpdateSkyAndLightingParams(); fgUpdateSkyAndLightingParams();
} }
@ -525,6 +528,7 @@ getGMTString ()
struct tm *t = globals->get_time_params()->getGmt(); struct tm *t = globals->get_time_params()->getGmt();
sprintf(buf, " %.2d:%.2d:%.2d", sprintf(buf, " %.2d:%.2d:%.2d",
t->tm_hour, t->tm_min, t->tm_sec); t->tm_hour, t->tm_min, t->tm_sec);
// cout << t << " " << buf << endl;
out = buf; out = buf;
return out; return out;
} }

View file

@ -107,7 +107,7 @@ operator >> ( istream& in, FGNav& n )
static double julian_date = 0; static double julian_date = 0;
static const double MJD0 = 2415020.0; static const double MJD0 = 2415020.0;
if ( first_time ) { if ( first_time ) {
julian_date = sgTimeCurrentMJD() + MJD0; julian_date = sgTimeCurrentMJD(0,0) + MJD0;
first_time = false; first_time = false;
} }

View file

@ -119,6 +119,7 @@ FGTileLoader::remove( FGTileEntry* tile )
void void
FGTileLoader::update() FGTileLoader::update()
{ {
#ifdef ENABLE_THREADS #ifdef ENABLE_THREADS
// send a signal to the pager thread that it is allowed to load // send a signal to the pager thread that it is allowed to load
// another tile // another tile
@ -131,7 +132,9 @@ FGTileLoader::update()
// load the next tile in the queue // load the next tile in the queue
FGTileEntry* tile = tile_load_queue.front(); FGTileEntry* tile = tile_load_queue.front();
tile_load_queue.pop(); tile_load_queue.pop();
tile->load( tile_path, true ); tile->load( tile_path, true );
FGTileMgr::ready_to_attach( tile ); FGTileMgr::ready_to_attach( tile );
} }
@ -147,6 +150,7 @@ FGTileLoader::update()
#endif #endif
#endif // ENABLE_THREADS #endif // ENABLE_THREADS
} }

View file

@ -1042,6 +1042,7 @@ FGTileEntry::load( const SGPath& base, bool is_base )
SGPath custom_path = tile_path; SGPath custom_path = tile_path;
custom_path.append( name ); custom_path.append( name );
ssgBranch *custom_obj ssgBranch *custom_obj
= obj_load( custom_path.str(), NULL, false ); = obj_load( custom_path.str(), NULL, false );
if ( custom_obj != NULL ) { if ( custom_obj != NULL ) {

View file

@ -332,6 +332,7 @@ int FGTileMgr::update( double lon, double lat ) {
// activate loader thread one out of every 5 frames // activate loader thread one out of every 5 frames
if ( counter_hack == 0 ) { if ( counter_hack == 0 ) {
// Notify the tile loader that it can load another tile // Notify the tile loader that it can load another tile
loader.update(); loader.update();
} }