NetworkIdentity.RebuildObservers: put conn null/ready checks into one line

This commit is contained in:
vis2k 2020-03-04 13:20:39 +01:00
parent 4ba456439a
commit 0f110eb4b7

View File

@ -1049,21 +1049,16 @@ public void RebuildObservers(bool initialize)
// add all newObservers that aren't in .observers yet
foreach (NetworkConnection conn in newObservers)
{
if (conn != null)
// only add ready connections.
// otherwise the player might not be in the world yet or anymore
if (conn != null && conn.isReady)
{
if (conn.isReady)
if (initialize || !observers.ContainsKey(conn.connectionId))
{
if (initialize || !observers.ContainsKey(conn.connectionId))
{
// new observer
conn.AddToVisList(this);
if (LogFilter.Debug) Debug.Log("New Observer for " + gameObject + " " + conn);
changed = true;
}
}
else
{
if (LogFilter.Debug) Debug.Log("Observer is not ready for " + gameObject + " " + conn);
// new observer
conn.AddToVisList(this);
if (LogFilter.Debug) Debug.Log("New Observer for " + gameObject + " " + conn);
changed = true;
}
}
}