mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkIdentity: OnSerializeAllSafely renamed to SerializeAll
This commit is contained in:
parent
b292aebd08
commit
41f60a5486
@ -909,7 +909,7 @@ void Serialize(NetworkBehaviour comp, NetworkWriter writer, bool initialState)
|
||||
// check ownerWritten/observersWritten to know if anything was written
|
||||
// We pass dirtyComponentsMask into this function so that we can check
|
||||
// if any Components are dirty before creating writers
|
||||
internal void OnSerializeAllSafely(bool initialState, NetworkWriter ownerWriter, NetworkWriter observersWriter)
|
||||
internal void SerializeAll(bool initialState, NetworkWriter ownerWriter, NetworkWriter observersWriter)
|
||||
{
|
||||
// check if components are in byte.MaxRange just to be 100% sure
|
||||
// that we avoid overflows
|
||||
@ -926,7 +926,7 @@ internal void OnSerializeAllSafely(bool initialState, NetworkWriter ownerWriter,
|
||||
NetworkBehaviour comp = components[i];
|
||||
if (initialState || comp.IsDirty())
|
||||
{
|
||||
//Debug.Log($"OnSerializeAllSafely: {name} -> {comp.GetType()} initial:{ initialState}");
|
||||
//Debug.Log($"SerializeAll: {name} -> {comp.GetType()} initial:{ initialState}");
|
||||
|
||||
// remember start position in case we need to copy it into
|
||||
// observers writer too
|
||||
@ -981,9 +981,9 @@ internal NetworkIdentitySerialization GetSerializationAtTick(int tick)
|
||||
lastSerialization.observersWriter.Position = 0;
|
||||
|
||||
// serialize
|
||||
OnSerializeAllSafely(false,
|
||||
lastSerialization.ownerWriter,
|
||||
lastSerialization.observersWriter);
|
||||
SerializeAll(false,
|
||||
lastSerialization.ownerWriter,
|
||||
lastSerialization.observersWriter);
|
||||
|
||||
// clear dirty bits for the components that we serialized.
|
||||
// previously we did this in NetworkServer.BroadcastToConnection
|
||||
@ -992,7 +992,7 @@ internal NetworkIdentitySerialization GetSerializationAtTick(int tick)
|
||||
// 'lastSerialization.tick != tick' scope.
|
||||
// so only do it once.
|
||||
//
|
||||
// NOTE: not in OnSerializeAllSafely as that should only do one
|
||||
// NOTE: not in Serializell as that should only do one
|
||||
// thing: serialize data.
|
||||
//
|
||||
//
|
||||
|
@ -989,7 +989,7 @@ static void OnCommandMessage(NetworkConnectionToClient conn, CommandMessage msg,
|
||||
// spawning ////////////////////////////////////////////////////////////
|
||||
static ArraySegment<byte> CreateSpawnMessagePayload(bool isOwner, NetworkIdentity identity, NetworkWriterPooled ownerWriter, NetworkWriterPooled observersWriter)
|
||||
{
|
||||
// Only call OnSerializeAllSafely if there are NetworkBehaviours
|
||||
// Only call SerializeAll if there are NetworkBehaviours
|
||||
if (identity.NetworkBehaviours.Length == 0)
|
||||
{
|
||||
return default;
|
||||
@ -997,7 +997,7 @@ static ArraySegment<byte> CreateSpawnMessagePayload(bool isOwner, NetworkIdentit
|
||||
|
||||
// serialize all components with initialState = true
|
||||
// (can be null if has none)
|
||||
identity.OnSerializeAllSafely(true, ownerWriter, observersWriter);
|
||||
identity.SerializeAll(true, ownerWriter, observersWriter);
|
||||
|
||||
// convert to ArraySegment to avoid reader allocations
|
||||
// if nothing was written, .ToArraySegment returns an empty segment.
|
||||
|
@ -31,7 +31,7 @@ public override void TearDown()
|
||||
// serialize -> deserialize. multiple components to be sure.
|
||||
// one for Owner, one for Observer
|
||||
[Test]
|
||||
public void OnSerializeAndDeserializeAllSafely()
|
||||
public void SerializeAndDeserializeAll()
|
||||
{
|
||||
// need two of both versions so we can serialize -> deserialize
|
||||
CreateNetworkedAndSpawn(
|
||||
@ -48,7 +48,7 @@ public void OnSerializeAndDeserializeAllSafely()
|
||||
serverComp2.value = "42";
|
||||
|
||||
// serialize server object
|
||||
serverIdentity.OnSerializeAllSafely(true, ownerWriter, observersWriter);
|
||||
serverIdentity.SerializeAll(true, ownerWriter, observersWriter);
|
||||
|
||||
// deserialize client object with OWNER payload
|
||||
NetworkReader reader = new NetworkReader(ownerWriter.ToArray());
|
||||
@ -94,7 +94,7 @@ public void SerializationException()
|
||||
// serialize server object
|
||||
// should work even if compExc throws an exception.
|
||||
// error log because of the exception is expected.
|
||||
serverIdentity.OnSerializeAllSafely(true, ownerWriter, observersWriter);
|
||||
serverIdentity.SerializeAll(true, ownerWriter, observersWriter);
|
||||
|
||||
// deserialize client object with OWNER payload
|
||||
// should work even if compExc throws an exception
|
||||
@ -148,7 +148,7 @@ public void TooManyComponents()
|
||||
LogAssert.ignoreFailingMessages = false;
|
||||
|
||||
// try to serialize
|
||||
serverIdentity.OnSerializeAllSafely(true, ownerWriter, observersWriter);
|
||||
serverIdentity.SerializeAll(true, ownerWriter, observersWriter);
|
||||
|
||||
// Should still write with too many Components because NetworkBehavioursCache should handle the error
|
||||
Assert.That(ownerWriter.Position, Is.GreaterThan(0));
|
||||
@ -172,7 +172,7 @@ public void SerializationMismatch()
|
||||
serverComp.value = "42";
|
||||
|
||||
// serialize server object
|
||||
serverIdentity.OnSerializeAllSafely(true, ownerWriter, observersWriter);
|
||||
serverIdentity.SerializeAll(true, ownerWriter, observersWriter);
|
||||
|
||||
// deserialize on client
|
||||
// ignore warning log because of serialization mismatch
|
||||
|
@ -407,7 +407,7 @@ public void TestSyncingAbstractNetworkBehaviour()
|
||||
NetworkWriter ownerWriter = new NetworkWriter();
|
||||
// not really used in this Test
|
||||
NetworkWriter observersWriter = new NetworkWriter();
|
||||
serverIdentity.OnSerializeAllSafely(true, ownerWriter, observersWriter);
|
||||
serverIdentity.SerializeAll(true, ownerWriter, observersWriter);
|
||||
|
||||
// set up a "client" object
|
||||
CreateNetworked(out _, out NetworkIdentity clientIdentity, out SyncVarAbstractNetworkBehaviour clientBehaviour);
|
||||
|
Loading…
Reference in New Issue
Block a user