Adjust DT on client (due to server requests) at time DT is computed

(to keep consistent DT across all further calls, esp. avoid
issues with rewinding getting different DT).
This commit is contained in:
hiker 2017-06-05 09:46:34 +10:00
parent f32a1961e2
commit a13856c6d1
3 changed files with 16 additions and 15 deletions

View File

@ -136,6 +136,16 @@ float MainLoop::getLimitedDt()
PROFILER_POP_CPU_MARKER();
}
dt *= 0.001f;
// If this is a client, the server might request an
// adjustment of this client's world clock (to reduce
// number of rewinds).
if (World::getWorld() &&
NetworkConfig::get()->isClient() &&
!RewindManager::get()->isRewinding() )
{
dt = World::getWorld()->adjustDT(dt);
}
return dt;
} // getLimitedDt

View File

@ -393,23 +393,14 @@ void WorldStatus::updateTime(const float dt)
}
IrrlichtDevice *device = irr_driver->getDevice();
// If this is a client, the server might request an
// adjustment of this client's world clock (to reduce
// number of rewinds).
float actual_dt;
if (NetworkConfig::get()->isClient() &&
!RewindManager::get()->isRewinding())
actual_dt = adjustDT(dt);
else
actual_dt = dt;
switch (m_clock_mode)
{
case CLOCK_CHRONO:
if (!device->getTimer()->isStopped())
{
m_time += actual_dt;
m_count_up_timer += actual_dt;
m_time += dt;
m_count_up_timer += dt;
}
break;
case CLOCK_COUNTDOWN:
@ -423,8 +414,8 @@ void WorldStatus::updateTime(const float dt)
if (!device->getTimer()->isStopped())
{
m_time -= actual_dt;
m_count_up_timer += actual_dt;
m_time -= dt;
m_count_up_timer += dt;
}
if(m_time <= 0.0)

View File

@ -140,7 +140,6 @@ private:
* wait for all clients to indicate that they have started the race. */
bool m_server_is_ready;
float adjustDT(float dt);
void startEngines();
public:
@ -156,6 +155,7 @@ public:
virtual void enterRaceOverState();
virtual void terminateRace();
void setTime(const float time);
float adjustDT(float dt);
// ------------------------------------------------------------------------
// Note: GO_PHASE is both: start phase and race phase