mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkIdentity.UNetUpdate: component serialization size check moved to OnSerializeSafely so that it happens for both calling functions (UNetSerializeAllVars and UNetUpdate). Also simplifies UNetUpdate code and removes dependency on NetworkWriter.Position.
This commit is contained in:
parent
b76680dfda
commit
9227eacbbf
@ -429,6 +429,13 @@ internal bool OnSerializeSafely(NetworkBehaviour comp, NetworkWriter writer, boo
|
||||
byte[] bytes = temp.ToArray();
|
||||
if (LogFilter.logDebug) { Debug.Log("OnSerializeSafely written for object=" + comp.name + " component=" + comp.GetType() + " sceneId=" + m_SceneId + " length=" + bytes.Length); }
|
||||
|
||||
// original HLAPI had a warning in UNetUpdate() in case of large state updates. let's move it here, might
|
||||
// be useful for debugging.
|
||||
if (bytes.Length > NetworkServer.maxPacketSize)
|
||||
{
|
||||
if (LogFilter.logWarn) { Debug.LogWarning("Large state update of " + bytes.Length + " bytes for netId:" + netId + " from script:" + comp); }
|
||||
}
|
||||
|
||||
// serialize length,data into the real writer, untouched by user code
|
||||
writer.WriteBytesAndSize(bytes);
|
||||
return result;
|
||||
@ -684,10 +691,8 @@ internal void UNetUpdate()
|
||||
writer.Write(netId);
|
||||
|
||||
bool wroteData = false;
|
||||
int oldPos;
|
||||
for (int i = 0; i < m_NetworkBehaviours.Length; i++)
|
||||
{
|
||||
oldPos = writer.Position;
|
||||
NetworkBehaviour comp = m_NetworkBehaviours[i];
|
||||
if (comp.GetDirtyChannel() != channelId)
|
||||
{
|
||||
@ -708,10 +713,6 @@ internal void UNetUpdate()
|
||||
|
||||
wroteData = true;
|
||||
}
|
||||
if (writer.Position - oldPos > NetworkServer.maxPacketSize)
|
||||
{
|
||||
if (LogFilter.logWarn) { Debug.LogWarning("Large state update of " + (writer.Position - oldPos) + " bytes for netId:" + netId + " from script:" + comp); }
|
||||
}
|
||||
}
|
||||
|
||||
if (!wroteData)
|
||||
|
Loading…
Reference in New Issue
Block a user