Skip to content

Commit e2f1640

Browse files
committed
Add check for the received rpc's that it's object is in the spawned list otherwise it gets ignored.
1 parent c29011b commit e2f1640

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

MLAPI/NetworkingManagerComponents/Core/InternalMessageHandler.Receive.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,11 @@ internal static void HandleServerRPC(uint clientId, Stream stream, int channelId
343343
ushort behaviourId = reader.ReadUInt16Packed();
344344
ulong hash = reader.ReadUInt64Packed();
345345

346-
NetworkedBehaviour behaviour = SpawnManager.SpawnedObjects[networkId].GetBehaviourAtOrderIndex(behaviourId);
347-
behaviour.OnRemoteServerRPC(hash, clientId, stream);
346+
if (SpawnManager.SpawnedObjects.ContainsKey(networkId))
347+
{
348+
NetworkedBehaviour behaviour = SpawnManager.SpawnedObjects[networkId].GetBehaviourAtOrderIndex(behaviourId);
349+
behaviour.OnRemoteServerRPC(hash, clientId, stream);
350+
}
348351
}
349352
}
350353

@@ -356,8 +359,11 @@ internal static void HandleClientRPC(uint clientId, Stream stream, int channelId
356359
ushort behaviourId = reader.ReadUInt16Packed();
357360
ulong hash = reader.ReadUInt64Packed();
358361

359-
NetworkedBehaviour behaviour = SpawnManager.SpawnedObjects[networkId].GetBehaviourAtOrderIndex(behaviourId);
360-
behaviour.OnRemoteClientRPC(hash, clientId, stream);
362+
if (SpawnManager.SpawnedObjects.ContainsKey(networkId))
363+
{
364+
NetworkedBehaviour behaviour = SpawnManager.SpawnedObjects[networkId].GetBehaviourAtOrderIndex(behaviourId);
365+
behaviour.OnRemoteClientRPC(hash, clientId, stream);
366+
}
361367
}
362368
}
363369

0 commit comments

Comments
 (0)