From: curt Date: Mon, 11 Feb 2002 23:33:20 +0000 (+0000) Subject: Better support for an alternate calendar time (i.e. if time/position/etc. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=dd8852dabe4dc2f10261625bb669b50355976362;p=flightgear.git 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. --- diff --git a/src/ATC/atis.hxx b/src/ATC/atis.hxx index b84cfa2d3..cf7b0de22 100644 --- a/src/ATC/atis.hxx +++ b/src/ATC/atis.hxx @@ -113,7 +113,7 @@ operator >> ( istream& in, FGATIS& a ) static double julian_date = 0; static const double MJD0 = 2415020.0; if ( first_time ) { - julian_date = sgTimeCurrentMJD() + MJD0; + julian_date = sgTimeCurrentMJD(0, 0) + MJD0; first_time = false; } diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 8174feee8..09748891a 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -590,14 +590,17 @@ SGTime *fgInitTime() { = fgGetNode("/position/longitude-deg"); static const SGPropertyNode *latitude = fgGetNode("/position/latitude-deg"); - + static const SGPropertyNode *cur_time_override + = fgGetNode("/sim/time/cur-time-override", true); + SGPath zone( globals->get_fg_root() ); zone.append( "Timezone" ); SGTime *t = new SGTime( longitude->getDoubleValue() * SGD_DEGREES_TO_RADIANS, latitude->getDoubleValue() * SGD_DEGREES_TO_RADIANS, - zone.str() ); + zone.str(), + cur_time_override->getLongValue() ); // Handle potential user specified time offsets time_t cur_time = t->get_cur_time(); @@ -633,7 +636,9 @@ SGTime *fgInitTime() { 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; } diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx index edd3d916c..f937887b8 100644 --- a/src/Main/fg_props.cxx +++ b/src/Main/fg_props.cxx @@ -476,6 +476,9 @@ getDateString () static void setDateString (string date_string) { + static const SGPropertyNode *cur_time_override + = fgGetNode("/sim/time/cur-time-override", true); + SGTime * st = globals->get_time_params(); struct tm * current_time = st->getGmt(); struct tm new_time; @@ -510,7 +513,7 @@ setDateString (string date_string) double lon = current_aircraft.fdm_state->get_Longitude(); double lat = current_aircraft.fdm_state->get_Latitude(); globals->set_warp(warp); - st->update(lon, lat, warp); + st->update(lon, lat, cur_time_override->getLongValue(), warp); fgUpdateSkyAndLightingParams(); } @@ -522,9 +525,10 @@ getGMTString () { string out; char buf[16]; - struct tm * t = globals->get_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); + // cout << t << " " << buf << endl; out = buf; return out; } diff --git a/src/Navaids/nav.hxx b/src/Navaids/nav.hxx index ae8cf431b..8eaf3fa5f 100644 --- a/src/Navaids/nav.hxx +++ b/src/Navaids/nav.hxx @@ -107,7 +107,7 @@ operator >> ( istream& in, FGNav& n ) static double julian_date = 0; static const double MJD0 = 2415020.0; if ( first_time ) { - julian_date = sgTimeCurrentMJD() + MJD0; + julian_date = sgTimeCurrentMJD(0,0) + MJD0; first_time = false; } diff --git a/src/Scenery/FGTileLoader.cxx b/src/Scenery/FGTileLoader.cxx index 69338c03b..07ab84080 100644 --- a/src/Scenery/FGTileLoader.cxx +++ b/src/Scenery/FGTileLoader.cxx @@ -119,6 +119,7 @@ FGTileLoader::remove( FGTileEntry* tile ) void FGTileLoader::update() { + #ifdef ENABLE_THREADS // send a signal to the pager thread that it is allowed to load // another tile @@ -131,7 +132,9 @@ FGTileLoader::update() // load the next tile in the queue FGTileEntry* tile = tile_load_queue.front(); tile_load_queue.pop(); + tile->load( tile_path, true ); + FGTileMgr::ready_to_attach( tile ); } @@ -147,6 +150,7 @@ FGTileLoader::update() #endif #endif // ENABLE_THREADS + } diff --git a/src/Scenery/tileentry.cxx b/src/Scenery/tileentry.cxx index e2431a131..0e63d7e55 100644 --- a/src/Scenery/tileentry.cxx +++ b/src/Scenery/tileentry.cxx @@ -1042,6 +1042,7 @@ FGTileEntry::load( const SGPath& base, bool is_base ) SGPath custom_path = tile_path; custom_path.append( name ); + ssgBranch *custom_obj = obj_load( custom_path.str(), NULL, false ); if ( custom_obj != NULL ) { diff --git a/src/Scenery/tilemgr.cxx b/src/Scenery/tilemgr.cxx index 5d7f125a4..0238f3215 100644 --- a/src/Scenery/tilemgr.cxx +++ b/src/Scenery/tilemgr.cxx @@ -332,6 +332,7 @@ int FGTileMgr::update( double lon, double lat ) { // activate loader thread one out of every 5 frames if ( counter_hack == 0 ) { // Notify the tile loader that it can load another tile + loader.update(); }