fixed race time problem that causes network play to work incorrectly
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@2557 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 4a25f3cacfe1341a32cd1cd0469a527d01e1e1e5 Former-commit-id: b46a503ac998c4bbf1bd6f0a6615199d63cf178e
This commit is contained in:
parent
c8e0787392
commit
c5f4f6d6cb
1 changed files with 16 additions and 2 deletions
|
@ -130,6 +130,7 @@ void Network::RaceInit(tSituation *s)
|
||||||
m_sendCarDataTime = 0.0;
|
m_sendCarDataTime = 0.0;
|
||||||
m_timePhysics = 0.0;
|
m_timePhysics = 0.0;
|
||||||
m_currentTime = 0.0;
|
m_currentTime = 0.0;
|
||||||
|
|
||||||
|
|
||||||
m_mapRanks.clear();
|
m_mapRanks.clear();
|
||||||
for (int i = 0; i < s->_ncars; i++)
|
for (int i = 0; i < s->_ncars; i++)
|
||||||
|
@ -466,8 +467,14 @@ void Network::SendCarStatusPacket(tSituation *s,bool bForce)
|
||||||
if (s->currentTime<0.0)
|
if (s->currentTime<0.0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
//Clock error fix it
|
||||||
|
if (s->currentTime<m_sendCtrlTime)
|
||||||
|
{
|
||||||
|
m_sendCarDataTime=s->currentTime-CAR_DATA_UPDATE;
|
||||||
|
}
|
||||||
|
|
||||||
//Send carinfo packet when enough time has passed(CAR_DATA_UPDATE)
|
//Send carinfo packet when enough time has passed(CAR_DATA_UPDATE)
|
||||||
if (((m_sendCarDataTime+CAR_DATA_UPDATE)>s->currentTime)&&(!bForce))
|
if (((m_sendCarDataTime+CAR_DATA_UPDATE)>=s->currentTime)&&(!bForce))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -532,10 +539,16 @@ void Network::SendCarControlsPacket(tSituation *s)
|
||||||
if (s->currentTime<0.0)
|
if (s->currentTime<0.0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
//Clock error fix it
|
||||||
|
if (s->currentTime<m_sendCtrlTime)
|
||||||
|
{
|
||||||
|
m_sendCtrlTime=s->currentTime-CAR_CONTROL_UPDATE;
|
||||||
|
}
|
||||||
|
|
||||||
SendCarStatusPacket(s,false);
|
SendCarStatusPacket(s,false);
|
||||||
|
|
||||||
//Send carinfo packet when enough time has passed(CAR_CONTROL_UPDATE)
|
//Send carinfo packet when enough time has passed(CAR_CONTROL_UPDATE)
|
||||||
if ((m_sendCtrlTime+CAR_CONTROL_UPDATE)>s->currentTime)
|
if ((m_sendCtrlTime+CAR_CONTROL_UPDATE)>=s->currentTime)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -566,6 +579,7 @@ void Network::SendCarControlsPacket(tSituation *s)
|
||||||
|
|
||||||
}
|
}
|
||||||
time = s->currentTime;
|
time = s->currentTime;
|
||||||
|
|
||||||
m_sendCtrlTime = s->currentTime;
|
m_sendCtrlTime = s->currentTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue