@@ -71,13 +71,6 @@ private ConnectionConfig Init(NetworkingConfiguration netConfig)
7171 MessageManager . reverseMessageTypes = new Dictionary < ushort , string > ( ) ;
7272 SpawnManager . spawnedObjects = new Dictionary < uint , NetworkedObject > ( ) ;
7373 SpawnManager . releasedNetworkObjectIds = new Stack < uint > ( ) ;
74- if ( NetworkConfig . AllowPassthroughMessages )
75- {
76- for ( int i = 0 ; i < NetworkConfig . PassthroughMessageTypes . Count ; i ++ )
77- {
78- NetworkConfig . RegisteredPassthroughMessageTypes . Add ( MessageManager . messageTypes [ NetworkConfig . PassthroughMessageTypes [ i ] ] ) ;
79- }
80- }
8174 if ( NetworkConfig . HandleObjectSpawning )
8275 {
8376 NetworkedObject [ ] sceneObjects = FindObjectsOfType < NetworkedObject > ( ) ;
@@ -119,10 +112,19 @@ private ConnectionConfig Init(NetworkingConfiguration netConfig)
119112 ushort messageId = 32 ;
120113 for ( ushort i = 0 ; i < NetworkConfig . MessageTypes . Count ; i ++ )
121114 {
122- MessageManager . reverseMessageTypes . Add ( messageId , NetworkConfig . MessageTypes [ i ] ) ;
123115 MessageManager . messageTypes . Add ( NetworkConfig . MessageTypes [ i ] , messageId ) ;
116+ MessageManager . reverseMessageTypes . Add ( messageId , NetworkConfig . MessageTypes [ i ] ) ;
124117 messageId ++ ;
125118 }
119+
120+ if ( NetworkConfig . AllowPassthroughMessages )
121+ {
122+ for ( int i = 0 ; i < NetworkConfig . PassthroughMessageTypes . Count ; i ++ )
123+ {
124+ NetworkConfig . RegisteredPassthroughMessageTypes . Add ( MessageManager . messageTypes [ NetworkConfig . PassthroughMessageTypes [ i ] ] ) ;
125+ }
126+ }
127+
126128 return cConfig ;
127129 }
128130
@@ -373,12 +375,16 @@ private void HandleIncomingData(int clientId, byte[] data, int channelId)
373375 Debug . LogWarning ( "MLAPI: Server tried to send a passthrough message for a messageType not registered as passthrough" ) ;
374376 return ;
375377 }
376- else if ( isServer && NetworkConfig . AllowPassthroughMessages && connectedClients . ContainsKey ( passthroughTarget ) )
378+ else if ( isServer && isPassthrough )
377379 {
380+ if ( ! connectedClients . ContainsKey ( passthroughTarget ) )
381+ {
382+ Debug . LogWarning ( "MLAPI: Passthrough message was sent with invalid target: " + passthroughTarget + " from client " + clientId ) ;
383+ return ;
384+ }
378385 uint ? netIdTarget = null ;
379386 if ( targeted )
380387 netIdTarget = targetNetworkId ;
381-
382388 PassthroughSend ( passthroughTarget , clientId , messageType , channelId , incommingData , netIdTarget ) ;
383389 return ;
384390 }
0 commit comments