Skip to content

Commit c933538

Browse files
committed
Remove pre-process loop TODO: pull out exceptions
1 parent 94bc9ff commit c933538

File tree

1 file changed

+0
-100
lines changed

1 file changed

+0
-100
lines changed

com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,56 +1520,6 @@ public static void NetworkShow(List<NetworkObject> networkObjects, ulong clientI
15201520
NetworkLog.LogErrorServer($"At least one {nameof(NetworkObject)} has to be provided when showing a list of {nameof(NetworkObject)}s!");
15211521
return;
15221522
}
1523-
1524-
// Do the safety loop first to prevent putting the netcode in an invalid state.
1525-
for (int i = 0; i < networkObjects.Count; i++)
1526-
{
1527-
var networkObject = networkObjects[i];
1528-
var networkManager = networkObject.NetworkManagerOwner;
1529-
1530-
if (!networkObject.IsSpawned)
1531-
{
1532-
throw new SpawnStateException("Object is not spawned");
1533-
}
1534-
1535-
if (networkManager.DistributedAuthorityMode && clientId == networkObject.OwnerClientId)
1536-
{
1537-
NetworkLog.LogErrorServer($"Cannot hide an object from the owner when distributed authority mode is enabled! (Skipping {networkObject.gameObject.name})");
1538-
}
1539-
else if (!networkManager.DistributedAuthorityMode && clientId == NetworkManager.ServerClientId)
1540-
{
1541-
NetworkLog.LogErrorServer("Cannot hide an object from the server!");
1542-
continue;
1543-
}
1544-
1545-
// Distributed authority mode adjustments to log a network error and continue when trying to show a NetworkObject
1546-
// that the local instance does not own
1547-
if (!networkObject.HasAuthority)
1548-
{
1549-
if (networkManager.DistributedAuthorityMode)
1550-
{
1551-
// It will log locally and to the "master-host".
1552-
NetworkLog.LogErrorServer("Only the owner-authority can change visibility when distributed authority mode is enabled!");
1553-
continue;
1554-
}
1555-
else
1556-
{
1557-
throw new NotServerException("Only server can change visibility");
1558-
}
1559-
}
1560-
1561-
1562-
if (networkObject.Observers.Contains(clientId))
1563-
{
1564-
throw new VisibilityChangeException($"{nameof(NetworkObject)} with NetworkId: {networkObject.NetworkObjectId} is already visible");
1565-
}
1566-
1567-
if (networkObject.NetworkManagerOwner != networkManager)
1568-
{
1569-
throw new ArgumentNullException("All " + nameof(NetworkObject) + "s must belong to the same " + nameof(networkManager));
1570-
}
1571-
}
1572-
15731523
foreach (var networkObject in networkObjects)
15741524
{
15751525
networkObject.NetworkShow(clientId);
@@ -1685,56 +1635,6 @@ public static void NetworkHide(List<NetworkObject> networkObjects, ulong clientI
16851635
NetworkLog.LogErrorServer($"At least one {nameof(NetworkObject)} has to be provided when hiding a list of {nameof(NetworkObject)}s!");
16861636
return;
16871637
}
1688-
1689-
// Do the safety loop first to prevent putting the netcode in an invalid state.
1690-
for (int i = 0; i < networkObjects.Count; i++)
1691-
{
1692-
var networkObject = networkObjects[i];
1693-
var networkManager = networkObject.NetworkManagerOwner;
1694-
1695-
if (networkManager.DistributedAuthorityMode && clientId == networkObject.OwnerClientId)
1696-
{
1697-
NetworkLog.LogErrorServer($"Cannot hide an object from the owner when distributed authority mode is enabled! (Skipping {networkObject.gameObject.name})");
1698-
}
1699-
else if (!networkManager.DistributedAuthorityMode && clientId == NetworkManager.ServerClientId)
1700-
{
1701-
NetworkLog.LogErrorServer("Cannot hide an object from the server!");
1702-
continue;
1703-
}
1704-
1705-
// Distributed authority mode adjustments to log a network error and continue when trying to show a NetworkObject
1706-
// that the local instance does not own
1707-
if (!networkObject.HasAuthority)
1708-
{
1709-
if (networkObject.NetworkManagerOwner.DistributedAuthorityMode)
1710-
{
1711-
// It will log locally and to the "master-host".
1712-
NetworkLog.LogErrorServer($"Only the owner-authority can change hide a {nameof(NetworkObject)} when distributed authority mode is enabled!");
1713-
continue;
1714-
}
1715-
else
1716-
{
1717-
throw new NotServerException("Only server can change visibility!");
1718-
}
1719-
}
1720-
1721-
// CLIENT SPAWNING TODO: Log error and continue as opposed to throwing an exception
1722-
if (!networkObject.IsSpawned)
1723-
{
1724-
throw new SpawnStateException("Object is not spawned");
1725-
}
1726-
1727-
if (!networkObject.Observers.Contains(clientId))
1728-
{
1729-
throw new VisibilityChangeException($"{nameof(NetworkObject)} with {nameof(NetworkObjectId)}: {networkObject.NetworkObjectId} is already hidden");
1730-
}
1731-
1732-
if (networkObject.NetworkManagerOwner != networkManager)
1733-
{
1734-
throw new ArgumentNullException("All " + nameof(NetworkObject) + "s must belong to the same " + nameof(networkManager));
1735-
}
1736-
}
1737-
17381638
foreach (var networkObject in networkObjects)
17391639
{
17401640
networkObject.NetworkHide(clientId);

0 commit comments

Comments
 (0)