NetworkServer.SetClientReady: use if+else instead of if + early return

This commit is contained in:
vis2k 2019-03-22 12:00:16 +01:00
parent 0e8b442cad
commit c176da7bc3

View File

@ -789,36 +789,37 @@ public static void SetClientReady(NetworkConnection conn)
}
}
}
return;
}
// Spawn/update all current server objects
if (LogFilter.Debug) Debug.Log("Spawning " + NetworkIdentity.spawned.Count + " objects for conn " + conn.connectionId);
conn.Send(new ObjectSpawnStartedMessage());
foreach (NetworkIdentity identity in NetworkIdentity.spawned.Values)
else
{
if (identity == null)
// Spawn/update all current server objects
if (LogFilter.Debug) Debug.Log("Spawning " + NetworkIdentity.spawned.Count + " objects for conn " + conn.connectionId);
conn.Send(new ObjectSpawnStartedMessage());
foreach (NetworkIdentity identity in NetworkIdentity.spawned.Values)
{
Debug.LogWarning("Invalid object found in server local object list (null NetworkIdentity).");
continue;
}
if (!identity.gameObject.activeSelf)
{
continue;
if (identity == null)
{
Debug.LogWarning("Invalid object found in server local object list (null NetworkIdentity).");
continue;
}
if (!identity.gameObject.activeSelf)
{
continue;
}
if (LogFilter.Debug) Debug.Log("Sending spawn message for current server objects name='" + identity.name + "' netId=" + identity.netId);
bool visible = identity.OnCheckObserver(conn);
if (visible)
{
identity.AddObserver(conn);
}
}
if (LogFilter.Debug) Debug.Log("Sending spawn message for current server objects name='" + identity.name + "' netId=" + identity.netId);
bool visible = identity.OnCheckObserver(conn);
if (visible)
{
identity.AddObserver(conn);
}
conn.Send(new ObjectSpawnFinishedMessage());
}
conn.Send(new ObjectSpawnFinishedMessage());
}
internal static void ShowForConnection(NetworkIdentity identity, NetworkConnection conn)