NetworkServer: CleanupSerializations helper function

This commit is contained in:
vis2k 2021-05-26 17:51:15 +08:00
parent 2085cd387f
commit a8630abbf6

View File

@ -1438,6 +1438,20 @@ static Serialization GetEntitySerialization(NetworkIdentity identity)
return serializations[identity];
}
// helper function to clean up cached serializations
static void CleanupSerializations()
{
// return serialized writers to pool, clear set
// TODO this is for feature parity before push->pull change.
// make this more simple / unnecessary later.
foreach (Serialization entry in serializations.Values)
{
NetworkWriterPool.Recycle(entry.ownerWriter);
NetworkWriterPool.Recycle(entry.observersWriter);
}
serializations.Clear();
}
// helper function to broadcast the world to a connection
static void BroadcastToConnection(NetworkConnectionToClient connection)
{
@ -1542,15 +1556,8 @@ internal static void NetworkLateUpdate()
connection.Update();
}
// return serialized writers to pool, clear set
// TODO this is for feature parity before push->pull change.
// make this more simple / unnecessary later.
foreach (Serialization entry in serializations.Values)
{
NetworkWriterPool.Recycle(entry.ownerWriter);
NetworkWriterPool.Recycle(entry.observersWriter);
}
serializations.Clear();
// return serialized writers to pool
CleanupSerializations();
// TODO this unfortunately means we still need to iterate ALL
// spawned and not just the ones with observers. figure