mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
comments
This commit is contained in:
parent
7b2427ce76
commit
a91f3a88c3
@ -280,9 +280,8 @@ public static T[] ReadArray<T>(this NetworkReader reader)
|
||||
{
|
||||
int length = reader.ReadInt();
|
||||
|
||||
// we write -1 for null
|
||||
if (length < 0)
|
||||
return null;
|
||||
// 'null' is encoded as '-1'
|
||||
if (length < 0) return null;
|
||||
|
||||
// todo throw an exception for other negative values (we never write them, likely to be attacker)
|
||||
|
||||
|
@ -258,7 +258,7 @@ public static void WriteNetworkBehaviour(this NetworkWriter writer, NetworkBehav
|
||||
writer.WriteUInt(0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// users might try to use unspawned / prefab NetworkBehaviours in
|
||||
// rpcs/cmds/syncvars/messages. they would be null on the other
|
||||
// end, and it might not be obvious why. let's make it obvious.
|
||||
@ -352,11 +352,13 @@ public static void WriteHashSet<T>(this NetworkWriter writer, HashSet<T> hashSet
|
||||
|
||||
public static void WriteArray<T>(this NetworkWriter writer, T[] array)
|
||||
{
|
||||
// 'null' is encoded as '-1'
|
||||
if (array is null)
|
||||
{
|
||||
writer.WriteInt(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
writer.WriteInt(array.Length);
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
writer.Write(array[i]);
|
||||
|
Loading…
Reference in New Issue
Block a user