Skip to content

Commit 0cb55e7

Browse files
committed
Fixed local message for host on RPCs
1 parent 09ebb6d commit 0cb55e7

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -568,15 +568,12 @@ internal void SendServerRPCPerformance(ulong hash, Stream messageStream)
568568
messageWriter.WriteUInt64Packed(hash);
569569

570570
stream.CopyFrom(messageStream);
571-
572-
if (isHost)
573-
{
574-
using (PooledBitStream localStream = PooledBitStream.Get())
575-
{
576-
localStream.CopyFrom(messageStream);
577-
InvokeServerRPCLocal(hash, NetworkingManager.singleton.LocalClientId, localStream);
578-
}
579-
}
571+
572+
if (isHost)
573+
{
574+
messageStream.Position = 0;
575+
InvokeServerRPCLocal(hash, NetworkingManager.singleton.LocalClientId, messageStream);
576+
}
580577

581578
InternalMessageHandler.Send(NetworkingManager.singleton.NetworkConfig.NetworkTransport.ServerNetId, "MLAPI_SERVER_RPC", "MLAPI_DEFAULT_MESSAGE", stream);
582579
}
@@ -606,6 +603,7 @@ internal void SendClientRPCPerformance(ulong hash, List<uint> clientIds, Stream
606603
{
607604
if (isHost && NetworkingManager.singleton.ConnectedClientsList[i].ClientId == NetworkingManager.singleton.LocalClientId)
608605
{
606+
messageStream.Position = 0;
609607
InvokeClientRPCLocal(hash, NetworkingManager.singleton.LocalClientId, messageStream);
610608
}
611609
else
@@ -620,11 +618,8 @@ internal void SendClientRPCPerformance(ulong hash, List<uint> clientIds, Stream
620618
{
621619
if (isHost && clientIds[i] == NetworkingManager.singleton.LocalClientId)
622620
{
623-
using (PooledBitStream localStream = PooledBitStream.Get())
624-
{
625-
localStream.CopyFrom(messageStream);
626-
InvokeClientRPCLocal(hash, NetworkingManager.singleton.LocalClientId, localStream);
627-
}
621+
messageStream.Position = 0;
622+
InvokeClientRPCLocal(hash, NetworkingManager.singleton.LocalClientId, messageStream);
628623
}
629624
else
630625
{
@@ -653,14 +648,11 @@ internal void SendClientRPCPerformance(ulong hash, uint clientId, Stream message
653648

654649
stream.CopyFrom(messageStream);
655650

656-
if (isHost && clientId == NetworkingManager.singleton.LocalClientId)
657-
{
658-
using (PooledBitStream localStream = PooledBitStream.Get())
659-
{
660-
localStream.CopyFrom(messageStream);
661-
InvokeClientRPCLocal(hash, NetworkingManager.singleton.LocalClientId, localStream);
662-
}
663-
}
651+
if (isHost && clientId == NetworkingManager.singleton.LocalClientId)
652+
{
653+
messageStream.Position = 0;
654+
InvokeClientRPCLocal(hash, NetworkingManager.singleton.LocalClientId, messageStream);
655+
}
664656
else
665657
{
666658
InternalMessageHandler.Send(clientId, "MLAPI_CLIENT_RPC", "MLAPI_DEFAULT_MESSAGE", stream);

0 commit comments

Comments
 (0)