TimeManager: handle reposition better
Extend the timeManager unit-tests to check for some movements, all seems to work correctly now.
This commit is contained in:
parent
9704c1cc93
commit
4eecd088e8
4 changed files with 29 additions and 4 deletions
|
@ -1241,9 +1241,11 @@ void fgStartReposition()
|
|||
globals->get_subsystem("xml-autopilot")->reinit();
|
||||
|
||||
// need to update the timezone
|
||||
SGTime *t = globals->get_time_params();
|
||||
t->updateLocal(globals->get_aircraft_position(), globals->get_fg_root() / "Timezone");
|
||||
|
||||
auto timeManager = globals->get_subsystem<TimeManager>();
|
||||
if (timeManager) {
|
||||
timeManager->reposition();
|
||||
}
|
||||
|
||||
// setup state to end re-init
|
||||
fgSetBool("/sim/signals/reinit", false);
|
||||
if ( !freeze ) {
|
||||
|
|
|
@ -404,6 +404,12 @@ void TimeManager::throttleUpdateRate()
|
|||
_frameWait->setDoubleValue(frameWaitStart.elapsedMSec());
|
||||
}
|
||||
|
||||
void TimeManager::reposition()
|
||||
{
|
||||
// force a zone check, next update()
|
||||
_lastTimeZoneCheckPosition = SGVec3d::zeros();
|
||||
}
|
||||
|
||||
// periodic time updater wrapper
|
||||
void TimeManager::updateLocalTime()
|
||||
{
|
||||
|
|
|
@ -43,6 +43,8 @@ public:
|
|||
void unbind() override;
|
||||
void update(double dt) override;
|
||||
|
||||
void reposition();
|
||||
|
||||
// Subsystem identification.
|
||||
static const char* staticSubsystemClassId() { return "time"; }
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ void TimeManagerTests::testTimeZones()
|
|||
|
||||
timeManager->update(0.0);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((time_t) 18000, globals->get_time_params()->get_local_offset());
|
||||
CPPUNIT_ASSERT_EQUAL((time_t)19800, globals->get_time_params()->get_local_offset());
|
||||
|
||||
auto gmt = globals->get_time_params()->getGmt();
|
||||
CPPUNIT_ASSERT_EQUAL(79, gmt->tm_year);
|
||||
|
@ -152,6 +152,21 @@ void TimeManagerTests::testTimeZones()
|
|||
|
||||
|
||||
// relocate to somewhere, check the time values update
|
||||
|
||||
auto eddf = FGAirport::getByIdent("EDDF");
|
||||
FGTestApi::setPositionAndStabilise(eddf->geod());
|
||||
timeManager->reposition();
|
||||
timeManager->update(0.0);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((time_t)3600, globals->get_time_params()->get_local_offset());
|
||||
|
||||
|
||||
auto zbaa = FGAirport::getByIdent("ZBAA");
|
||||
FGTestApi::setPositionAndStabilise(zbaa->geod());
|
||||
timeManager->reposition();
|
||||
timeManager->update(0.0);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((time_t)28800, globals->get_time_params()->get_local_offset());
|
||||
}
|
||||
|
||||
void TimeManagerTests::testSpecifyTimeOffset()
|
||||
|
|
Loading…
Reference in a new issue