mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
baselineTick safety chekc moved into DeserializeServerDelta
This commit is contained in:
parent
6529756c91
commit
22bc5f3fbd
@ -261,13 +261,23 @@ void SerializeServerDelta(NetworkWriter writer, byte baselineTick, Vector3? posi
|
||||
if (syncScale) writer.WriteVector3(scale.Value);
|
||||
}
|
||||
|
||||
void DeserializeServerDelta(NetworkReader reader, out byte baselineTick, out Vector3? position, out Quaternion? rotation, out Vector3? scale)
|
||||
bool DeserializeServerDelta(NetworkReader reader, out byte baselineTick, out Vector3? position, out Quaternion? rotation, out Vector3? scale)
|
||||
{
|
||||
baselineTick = reader.ReadByte();
|
||||
position = null;
|
||||
rotation = null;
|
||||
scale = null;
|
||||
|
||||
baselineTick = reader.ReadByte();
|
||||
|
||||
// unreliable messages may arrive out of order.
|
||||
// ensure this is for the intended baseline.
|
||||
// we don't want to put a delta onto an old baseline.
|
||||
if (baselineTick != lastDeserializedBaselineTick)
|
||||
{
|
||||
Debug.Log($"[{name}] Client discarding unreliable delta for baseline #{baselineTick} because we already received #{lastDeserializedBaselineTick}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (syncPosition)
|
||||
{
|
||||
position = reader.ReadVector3();
|
||||
@ -280,6 +290,8 @@ void DeserializeServerDelta(NetworkReader reader, out byte baselineTick, out Vec
|
||||
{
|
||||
scale = reader.ReadVector3();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// cmd /////////////////////////////////////////////////////////////////
|
||||
@ -359,8 +371,10 @@ void RpcServerToClientDeltaSync(ArraySegment<byte> message)
|
||||
{
|
||||
using (NetworkReaderPooled reader = NetworkReaderPool.Get(message))
|
||||
{
|
||||
DeserializeServerDelta(reader, out byte baselineTick, out Vector3? position, out Quaternion? rotation, out Vector3? scale);
|
||||
OnServerToClientDeltaSync(baselineTick, position, rotation, scale);
|
||||
if (DeserializeServerDelta(reader, out byte baselineTick, out Vector3? position, out Quaternion? rotation, out Vector3? scale))
|
||||
{
|
||||
OnServerToClientDeltaSync(baselineTick, position, rotation, scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -378,15 +392,6 @@ protected virtual void OnServerToClientDeltaSync(byte baselineTick, Vector3? pos
|
||||
// don't apply for local player with authority
|
||||
if (IsClientWithAuthority) return;
|
||||
|
||||
// unreliable messages may arrive out of order.
|
||||
// ensure this is for the intended baseline.
|
||||
// we don't want to put a delta onto an old baseline.
|
||||
if (baselineTick != lastDeserializedBaselineTick)
|
||||
{
|
||||
Debug.Log($"[{name}] Client discarding unreliable delta for baseline #{baselineTick} because we already received #{lastDeserializedBaselineTick}");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log($"[{name}] Client: received delta for baseline #{baselineTick}");
|
||||
|
||||
// on the client, we receive rpcs for all entities.
|
||||
|
Loading…
Reference in New Issue
Block a user