1
0
Fork 0

src/Time/TimeManager.*: fixed simple-time indeterminism that could cause hang on startup.

_simple_time_fdm was not being initialised, which was causing occasional hangs
on startup. So set to zero in constructor and TimeManager::init().

For simplicity, we also initialise all other basic type state in the
TimeManager class.

If _simple_time_fdm's starting value happens to be very large (e.g. 1e228),
_simple_time_fdm + fixed_dt would result in _simple_time_fdm, so we would end
up always setting simDt and realDt to zero.

This stops SGEventMgr from processing any events, which means that
initPosition()'s event to call finalizePosition() is never processed so
/sim/position-finalized is stuck on false, which results in the FDM never
setting /sim/fdm-initialized.
This commit is contained in:
Julian Smith 2021-12-19 12:39:31 +00:00
parent 5f66ffc96b
commit cb7343eb35
2 changed files with 16 additions and 12 deletions

View file

@ -134,9 +134,12 @@ void TimeManager::init()
}
_computeDrift->setBoolValue(true);
_simpleTimeEnabledPrev = false;
_simpleTimeEnabled = fgGetNode("/sim/time/simple-time/enabled", true);
_simpleTimeUtc = fgGetNode("/sim/time/simple-time/utc", true);
_simpleTimeFdm = fgGetNode("/sim/time/simple-time/fdm", true);
_simple_time_utc = 0;
_simple_time_fdm = 0;
}
void TimeManager::unbind()

View file

@ -84,12 +84,12 @@ private:
// set up a time offset (aka warp) if one is specified
void initTimeOffset();
bool _inited;
SGTime* _impl;
bool _inited = false;
SGTime* _impl = nullptr;
SGTimeStamp _lastStamp;
SGTimeStamp _systemStamp;
bool _firstUpdate;
double _dtRemainder;
bool _firstUpdate = true;
double _dtRemainder = 0;
SGPropertyNode_ptr _maxDtPerFrame;
SGPropertyNode_ptr _clockFreeze;
SGPropertyNode_ptr _timeOverride;
@ -117,25 +117,26 @@ private:
SGPropertyNode_ptr _frameRate;
SGPropertyNode_ptr _frameRateWorst;
SGPropertyNode_ptr _frameLatency;
time_t _lastFrameTime;
double _frameLatencyMax;
double _mpProtocolClock;
double _steadyClock;
int _frameCount;
time_t _lastFrameTime = 0;
double _frameLatencyMax = 0;
double _mpProtocolClock = 0;
double _steadyClock = 0;
int _frameCount = 0;
// we update TZ after moving more than a threshold distance
SGVec3d _lastTimeZoneCheckPosition;
SGPropertyNode_ptr _sceneryLoaded;
SGPropertyNode_ptr _modelHz;
SGPropertyNode_ptr _timeDelta, _simTimeDelta;
SGPropertyNode_ptr _timeDelta;
SGPropertyNode_ptr _simTimeDelta;
bool _simpleTimeEnabledPrev = false;
SGPropertyNode_ptr _simpleTimeEnabled;
SGPropertyNode_ptr _simpleTimeUtc;
SGPropertyNode_ptr _simpleTimeFdm;
double _simple_time_utc;
double _simple_time_fdm;
double _simple_time_utc = 0;
double _simple_time_fdm = 0;
};
#endif // of FG_TIME_TIMEMANAGER_HXX