Added error checks on Sync messages
This commit is contained in:
parent
5d6114a457
commit
8ea338a5f8
@ -697,6 +697,21 @@ namespace MLAPI
|
|||||||
uint netId = messageReader.ReadUInt32(); //NetId the syncvar is from
|
uint netId = messageReader.ReadUInt32(); //NetId the syncvar is from
|
||||||
ushort orderIndex = messageReader.ReadUInt16();
|
ushort orderIndex = messageReader.ReadUInt16();
|
||||||
byte fieldIndex = messageReader.ReadByte();
|
byte fieldIndex = messageReader.ReadByte();
|
||||||
|
if(!SpawnManager.spawnedObjects.ContainsKey(netId))
|
||||||
|
{
|
||||||
|
Debug.LogWarning("MLAPI: Sync message recieved for a non existant object with id: " + netId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(SpawnManager.spawnedObjects[netId].GetBehaviourAtOrderIndex(orderIndex) == null)
|
||||||
|
{
|
||||||
|
Debug.LogWarning("MLAPI: Sync message recieved for a non existant behaviour");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(fieldIndex > (SpawnManager.spawnedObjects[netId].GetBehaviourAtOrderIndex(orderIndex).syncedFieldTypes.Count - 1))
|
||||||
|
{
|
||||||
|
Debug.LogWarning("MLAPI: Sync message recieved for field out of bounds");
|
||||||
|
return;
|
||||||
|
}
|
||||||
FieldType type = SpawnManager.spawnedObjects[netId].GetBehaviourAtOrderIndex(orderIndex).syncedFieldTypes[fieldIndex];
|
FieldType type = SpawnManager.spawnedObjects[netId].GetBehaviourAtOrderIndex(orderIndex).syncedFieldTypes[fieldIndex];
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user