mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Simplify network connection clientOwnedObjects (#758)
* Simplify network connection clientOwnedObjects * Whoops, missed this null check in NetworkServer. Thanks vis
This commit is contained in:
parent
146988a6bb
commit
b7ae7f006c
@ -16,7 +16,7 @@ public class NetworkConnection : IDisposable
|
|||||||
public string address;
|
public string address;
|
||||||
public float lastMessageTime;
|
public float lastMessageTime;
|
||||||
public NetworkIdentity playerController { get; internal set; }
|
public NetworkIdentity playerController { get; internal set; }
|
||||||
public HashSet<uint> clientOwnedObjects;
|
public HashSet<uint> clientOwnedObjects = new HashSet<uint>();
|
||||||
public bool logNetworkMessages;
|
public bool logNetworkMessages;
|
||||||
|
|
||||||
// this is always true for regular connections, false for local
|
// this is always true for regular connections, false for local
|
||||||
@ -58,8 +58,6 @@ public void Dispose()
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
|
||||||
if (clientOwnedObjects != null)
|
|
||||||
{
|
{
|
||||||
foreach (uint netId in clientOwnedObjects)
|
foreach (uint netId in clientOwnedObjects)
|
||||||
{
|
{
|
||||||
@ -68,8 +66,7 @@ protected virtual void Dispose(bool disposing)
|
|||||||
identity.clientAuthorityOwner = null;
|
identity.clientAuthorityOwner = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
clientOwnedObjects.Clear();
|
||||||
clientOwnedObjects = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Disconnect()
|
public void Disconnect()
|
||||||
@ -278,13 +275,12 @@ public virtual bool TransportSend(int channelId, byte[] bytes, out byte error)
|
|||||||
|
|
||||||
internal void AddOwnedObject(NetworkIdentity obj)
|
internal void AddOwnedObject(NetworkIdentity obj)
|
||||||
{
|
{
|
||||||
clientOwnedObjects = clientOwnedObjects ?? new HashSet<uint>();
|
|
||||||
clientOwnedObjects.Add(obj.netId);
|
clientOwnedObjects.Add(obj.netId);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RemoveOwnedObject(NetworkIdentity obj)
|
internal void RemoveOwnedObject(NetworkIdentity obj)
|
||||||
{
|
{
|
||||||
clientOwnedObjects?.Remove(obj.netId);
|
clientOwnedObjects.Remove(obj.netId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -977,8 +977,6 @@ public static void DestroyPlayerForConnection(NetworkConnection conn)
|
|||||||
// so we need null checks for both of them.
|
// so we need null checks for both of them.
|
||||||
// => destroy what we can destroy.
|
// => destroy what we can destroy.
|
||||||
|
|
||||||
if (conn.clientOwnedObjects != null)
|
|
||||||
{
|
|
||||||
HashSet<uint> tmp = new HashSet<uint>(conn.clientOwnedObjects);
|
HashSet<uint> tmp = new HashSet<uint>(conn.clientOwnedObjects);
|
||||||
foreach (uint netId in tmp)
|
foreach (uint netId in tmp)
|
||||||
{
|
{
|
||||||
@ -987,7 +985,6 @@ public static void DestroyPlayerForConnection(NetworkConnection conn)
|
|||||||
Destroy(identity.gameObject);
|
Destroy(identity.gameObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (conn.playerController != null)
|
if (conn.playerController != null)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user