@@ -71,13 +71,6 @@ private ConnectionConfig Init(NetworkingConfiguration netConfig)
71
71
MessageManager . reverseMessageTypes = new Dictionary < ushort , string > ( ) ;
72
72
SpawnManager . spawnedObjects = new Dictionary < uint , NetworkedObject > ( ) ;
73
73
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
- }
81
74
if ( NetworkConfig . HandleObjectSpawning )
82
75
{
83
76
NetworkedObject [ ] sceneObjects = FindObjectsOfType < NetworkedObject > ( ) ;
@@ -119,10 +112,19 @@ private ConnectionConfig Init(NetworkingConfiguration netConfig)
119
112
ushort messageId = 32 ;
120
113
for ( ushort i = 0 ; i < NetworkConfig . MessageTypes . Count ; i ++ )
121
114
{
122
- MessageManager . reverseMessageTypes . Add ( messageId , NetworkConfig . MessageTypes [ i ] ) ;
123
115
MessageManager . messageTypes . Add ( NetworkConfig . MessageTypes [ i ] , messageId ) ;
116
+ MessageManager . reverseMessageTypes . Add ( messageId , NetworkConfig . MessageTypes [ i ] ) ;
124
117
messageId ++ ;
125
118
}
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
+
126
128
return cConfig ;
127
129
}
128
130
@@ -373,12 +375,16 @@ private void HandleIncomingData(int clientId, byte[] data, int channelId)
373
375
Debug . LogWarning ( "MLAPI: Server tried to send a passthrough message for a messageType not registered as passthrough" ) ;
374
376
return ;
375
377
}
376
- else if ( isServer && NetworkConfig . AllowPassthroughMessages && connectedClients . ContainsKey ( passthroughTarget ) )
378
+ else if ( isServer && isPassthrough )
377
379
{
380
+ if ( ! connectedClients . ContainsKey ( passthroughTarget ) )
381
+ {
382
+ Debug . LogWarning ( "MLAPI: Passthrough message was sent with invalid target: " + passthroughTarget + " from client " + clientId ) ;
383
+ return ;
384
+ }
378
385
uint ? netIdTarget = null ;
379
386
if ( targeted )
380
387
netIdTarget = targetNetworkId ;
381
-
382
388
PassthroughSend ( passthroughTarget , clientId , messageType , channelId , incommingData , netIdTarget ) ;
383
389
return ;
384
390
}
0 commit comments