src/Aircraft/replay.*: use getMPProtocolClockSec if /sim/time/simple-time/enabled is set.
Also, when moving MP packets around, medium_term buffer can become empty. Have added checks for empty short, medium and long term buffers when moving packets.
This commit is contained in:
parent
745273ab26
commit
70647ffd35
2 changed files with 26 additions and 13 deletions
|
@ -42,6 +42,7 @@
|
||||||
|
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
#include <MultiPlayer/mpmessages.hxx>
|
#include <MultiPlayer/mpmessages.hxx>
|
||||||
|
#include <Time/TimeManager.hxx>
|
||||||
#include <Viewer/renderer.hxx>
|
#include <Viewer/renderer.hxx>
|
||||||
#include <Viewer/FGEventHandler.hxx>
|
#include <Viewer/FGEventHandler.hxx>
|
||||||
|
|
||||||
|
@ -161,7 +162,8 @@ FGReplay::FGReplay() :
|
||||||
m_medium_sample_rate(0.5), // medium term sample rate (sec)
|
m_medium_sample_rate(0.5), // medium term sample rate (sec)
|
||||||
m_long_sample_rate(5.0), // long term sample rate (sec)
|
m_long_sample_rate(5.0), // long term sample rate (sec)
|
||||||
m_pRecorder(new FGFlightRecorder("replay-config")),
|
m_pRecorder(new FGFlightRecorder("replay-config")),
|
||||||
m_MultiplayMgr(globals->get_subsystem<FGMultiplayMgr>())
|
m_MultiplayMgr(globals->get_subsystem<FGMultiplayMgr>()),
|
||||||
|
m_simple_time_enabled(fgGetNode("/sim/time/simple-time/enabled", true))
|
||||||
{
|
{
|
||||||
SGPropertyNode* continuous = fgGetNode("/sim/replay/record-continuous", true);
|
SGPropertyNode* continuous = fgGetNode("/sim/replay/record-continuous", true);
|
||||||
SGPropertyNode* fdm = fgGetNode("/sim/signals/fdm-initialized", true);
|
SGPropertyNode* fdm = fgGetNode("/sim/signals/fdm-initialized", true);
|
||||||
|
@ -906,7 +908,7 @@ FGReplay::update( double dt )
|
||||||
int current_replay_state = last_replay_state;
|
int current_replay_state = last_replay_state;
|
||||||
timingInfo.clear();
|
timingInfo.clear();
|
||||||
stamp("begin");
|
stamp("begin");
|
||||||
|
|
||||||
if ( disable_replay->getBoolValue() )
|
if ( disable_replay->getBoolValue() )
|
||||||
{
|
{
|
||||||
if (fgGetBool("/sim/freeze/master",false)||
|
if (fgGetBool("/sim/freeze/master",false)||
|
||||||
|
@ -1061,6 +1063,11 @@ FGReplay::update( double dt )
|
||||||
if ((!fgGetBool("/sim/fdm-initialized", false))||(dt==0.0))
|
if ((!fgGetBool("/sim/fdm-initialized", false))||(dt==0.0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (m_simple_time_enabled->getBoolValue())
|
||||||
|
{
|
||||||
|
sim_time = globals->get_subsystem<TimeManager>()->getMPProtocolClockSec();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
double new_sim_time = sim_time + dt;
|
double new_sim_time = sim_time + dt;
|
||||||
// don't record multiple records with the same timestamp (or go backwards in time)
|
// don't record multiple records with the same timestamp (or go backwards in time)
|
||||||
|
@ -1151,7 +1158,7 @@ FGReplay::update( double dt )
|
||||||
|
|
||||||
if ( sim_time - st_front->sim_time > m_high_res_time )
|
if ( sim_time - st_front->sim_time > m_high_res_time )
|
||||||
{
|
{
|
||||||
while ( sim_time - st_front->sim_time > m_high_res_time )
|
while ( !short_term.empty() && sim_time - st_front->sim_time > m_high_res_time )
|
||||||
{
|
{
|
||||||
st_front = short_term.front();
|
st_front = short_term.front();
|
||||||
MoveFrontMultiplayerPackets(short_term);
|
MoveFrontMultiplayerPackets(short_term);
|
||||||
|
@ -1163,14 +1170,16 @@ FGReplay::update( double dt )
|
||||||
if ( sim_time - last_mt_time > m_medium_sample_rate )
|
if ( sim_time - last_mt_time > m_medium_sample_rate )
|
||||||
{
|
{
|
||||||
last_mt_time = sim_time;
|
last_mt_time = sim_time;
|
||||||
st_front = short_term.front();
|
if (!short_term.empty()) {
|
||||||
medium_term.push_back( st_front );
|
st_front = short_term.front();
|
||||||
short_term.pop_front();
|
medium_term.push_back( st_front );
|
||||||
|
short_term.pop_front();
|
||||||
|
}
|
||||||
|
|
||||||
FGReplayData *mt_front = medium_term.front();
|
FGReplayData *mt_front = medium_term.front();
|
||||||
if ( sim_time - mt_front->sim_time > m_medium_res_time )
|
if ( sim_time - mt_front->sim_time > m_medium_res_time )
|
||||||
{
|
{
|
||||||
while ( sim_time - mt_front->sim_time > m_medium_res_time )
|
while ( !medium_term.empty() && sim_time - mt_front->sim_time > m_medium_res_time )
|
||||||
{
|
{
|
||||||
mt_front = medium_term.front();
|
mt_front = medium_term.front();
|
||||||
MoveFrontMultiplayerPackets(medium_term);
|
MoveFrontMultiplayerPackets(medium_term);
|
||||||
|
@ -1181,14 +1190,16 @@ FGReplay::update( double dt )
|
||||||
if ( sim_time - last_lt_time > m_long_sample_rate )
|
if ( sim_time - last_lt_time > m_long_sample_rate )
|
||||||
{
|
{
|
||||||
last_lt_time = sim_time;
|
last_lt_time = sim_time;
|
||||||
mt_front = medium_term.front();
|
if (!medium_term.empty()) {
|
||||||
long_term.push_back( mt_front );
|
mt_front = medium_term.front();
|
||||||
medium_term.pop_front();
|
long_term.push_back( mt_front );
|
||||||
|
medium_term.pop_front();
|
||||||
|
}
|
||||||
|
|
||||||
FGReplayData *lt_front = long_term.front();
|
FGReplayData *lt_front = long_term.front();
|
||||||
if ( sim_time - lt_front->sim_time > m_low_res_time )
|
if ( sim_time - lt_front->sim_time > m_low_res_time )
|
||||||
{
|
{
|
||||||
while ( sim_time - lt_front->sim_time > m_low_res_time )
|
while ( !long_term.empty() && sim_time - lt_front->sim_time > m_low_res_time )
|
||||||
{
|
{
|
||||||
lt_front = long_term.front();
|
lt_front = long_term.front();
|
||||||
MoveFrontMultiplayerPackets(long_term);
|
MoveFrontMultiplayerPackets(long_term);
|
||||||
|
@ -1216,7 +1227,7 @@ FGReplay::update( double dt )
|
||||||
}
|
}
|
||||||
|
|
||||||
FGReplayData*
|
FGReplayData*
|
||||||
FGReplay::record(double time)
|
FGReplay::record(double sim_time)
|
||||||
{
|
{
|
||||||
FGReplayData* r = NULL;
|
FGReplayData* r = NULL;
|
||||||
|
|
||||||
|
@ -1226,7 +1237,7 @@ FGReplay::record(double time)
|
||||||
recycler.pop_front();
|
recycler.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_pRecorder->capture(time, r);
|
return m_pRecorder->capture(sim_time, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -274,6 +274,8 @@ private:
|
||||||
// For writing uncompressed fgtape file.
|
// For writing uncompressed fgtape file.
|
||||||
SGPropertyNode_ptr m_continuous_out_config;
|
SGPropertyNode_ptr m_continuous_out_config;
|
||||||
std::ofstream m_continuous_out;
|
std::ofstream m_continuous_out;
|
||||||
|
|
||||||
|
SGPropertyNode_ptr m_simple_time_enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _FG_REPLAY_HXX
|
#endif // _FG_REPLAY_HXX
|
||||||
|
|
Loading…
Add table
Reference in a new issue