mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
fix out of order check: use remoteTimestamp not local time, and allow == time
This commit is contained in:
parent
a7639243e0
commit
254dc864b1
@ -1400,18 +1400,20 @@ static void OnEntityStateMessageUnreliable(EntityStateMessageUnreliable message)
|
||||
// Debug.Log($"NetworkClient.OnUpdateVarsMessage {msg.netId}");
|
||||
if (spawned.TryGetValue(message.netId, out NetworkIdentity identity) && identity != null)
|
||||
{
|
||||
// unreliable state sync messages may arrive out of order, or duplicated.
|
||||
// unreliable state sync messages may arrive out of order.
|
||||
// only ever apply state that's newer than the last received state.
|
||||
if (connection.lastMessageTime <= identity.lastUnreliableStateTime)
|
||||
// note that we send one EntityStateMessage per Entity,
|
||||
// so there will be multiple with the same == timestamp.
|
||||
if (connection.remoteTimeStamp < identity.lastUnreliableStateTime)
|
||||
{
|
||||
// debug log to show that it's working.
|
||||
// can be tested via LatencySimulation scramble easily.
|
||||
Debug.Log($"Client caught out of order Unreliable state message for {identity.name}. This is fine.\nIdentity timestamp={identity.lastUnreliableStateTime} message timestamp={connection.lastMessageTime}");
|
||||
Debug.Log($"Client caught out of order Unreliable state message for {identity.name}. This is fine.\nIdentity timestamp={identity.lastUnreliableStateTime} batch remoteTimestamp={connection.remoteTimeStamp}");
|
||||
return;
|
||||
}
|
||||
|
||||
// set the new last received time for unreliable
|
||||
identity.lastUnreliableStateTime = connection.lastMessageTime;
|
||||
identity.lastUnreliableStateTime = connection.remoteTimeStamp;
|
||||
|
||||
// iniital is always 'true' because unreliable state sync alwasy serializes full
|
||||
using (NetworkReaderPooled reader = NetworkReaderPool.Get(message.payload))
|
||||
|
@ -421,18 +421,20 @@ static void OnEntityStateMessageUnreliable(NetworkConnectionToClient connection,
|
||||
// owned by the connection?
|
||||
if (identity.connectionToClient == connection)
|
||||
{
|
||||
// unreliable state sync messages may arrive out of order, or duplicated.
|
||||
// unreliable state sync messages may arrive out of order.
|
||||
// only ever apply state that's newer than the last received state.
|
||||
if (connection.lastMessageTime <= identity.lastUnreliableStateTime)
|
||||
// note that we send one EntityStateMessage per Entity,
|
||||
// so there will be multiple with the same == timestamp.
|
||||
if (connection.remoteTimeStamp < identity.lastUnreliableStateTime)
|
||||
{
|
||||
// debug log to show that it's working.
|
||||
// can be tested via LatencySimulation scramble easily.
|
||||
Debug.Log($"Server caught out of order Unreliable state message for {identity.name}. This is fine.\nIdentity timestamp={identity.lastUnreliableStateTime} message timestamp={connection.lastMessageTime}");
|
||||
Debug.Log($"Server caught out of order Unreliable state message for {identity.name}. This is fine.\nIdentity timestamp={identity.lastUnreliableStateTime} batch remoteTimestamp={connection.remoteTimeStamp}");
|
||||
return;
|
||||
}
|
||||
|
||||
// set the new last received time for unreliable
|
||||
identity.lastUnreliableStateTime = connection.lastMessageTime;
|
||||
identity.lastUnreliableStateTime = connection.remoteTimeStamp;
|
||||
|
||||
using (NetworkReaderPooled reader = NetworkReaderPool.Get(message.payload))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user