Store special time events for clients (otherwise incorrect or even

way too large dt is used in rewind).
This commit is contained in:
hiker 2017-01-23 08:23:54 +11:00
parent d038848c2e
commit 9b38e401f4
2 changed files with 11 additions and 4 deletions

View File

@ -195,6 +195,8 @@ void PlayerController::action(PlayerAction action, int value)
void PlayerController::actionFromNetwork(PlayerAction p_action, int value,
int value_l, int value_r)
{
if (m_steer_val_l != value_l || m_steer_val_r != value_r)
printf("");
m_steer_val_l = value_l;
m_steer_val_r = value_r;
action(p_action, value);

13
src/network/rewind_manager.cpp Normal file → Executable file
View File

@ -95,7 +95,7 @@ void RewindManager::reset()
m_rewind_queue.reset();
} // reset
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
/** Adds an event to the rewind data. The data to be stored must be allocated
* and not freed by the caller!
* \param time Time at which the event was recorded.
@ -162,11 +162,13 @@ void RewindManager::saveStates()
if(!m_enable_rewind_manager ||
m_all_rewinder.size()==0 ||
m_is_rewinding ) return;
if (NetworkConfig::get()->isClient())
return;
float time = World::getWorld()->getTime();
if(time - m_last_saved_state < m_state_frequency)
// Client doesn't save state (atm), so we need to store
// time infos to get the correct dt when rewinding
if(time - m_last_saved_state < m_state_frequency ||
NetworkConfig::get()->isClient())
{
// Avoid saving a time event for the same time, which happens
// with t=0.
@ -176,6 +178,8 @@ void RewindManager::saveStates()
// which increases replay precision (same time step size)
m_rewind_queue.addTimeEvent(getCurrentTime());
}
if (NetworkConfig::get()->isClient())
m_last_saved_state = time;
return;
}
@ -245,6 +249,7 @@ void RewindManager::playEventsTill(float time)
return;
}
++m_rewind_queue;
if(ri->isEvent())
ri->rewind();
else if (ri->isState())