Skip to content

Commit

Permalink
fix: removing redundant null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Frowen committed Apr 5, 2021
1 parent f8366d2 commit 909b668
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Assets/Mirage/Runtime/ClientObjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ void DestroyObject(uint netId)
{
if (logger.LogEnabled()) logger.Log("ClientScene.OnObjDestroy netId:" + netId);

if (Client.World.TryGetIdentity(netId, out NetworkIdentity localObject) && localObject != null)
if (Client.World.TryGetIdentity(netId, out NetworkIdentity localObject))
{
UnSpawn(localObject);
}
Expand All @@ -479,7 +479,7 @@ void DestroyObject(uint netId)

internal void OnHostClientSpawn(SpawnMessage msg)
{
if (Client.World.TryGetIdentity(msg.netId, out NetworkIdentity localObject) && localObject != null)
if (Client.World.TryGetIdentity(msg.netId, out NetworkIdentity localObject))
{
if (msg.isLocalPlayer)
InternalAddPlayer(localObject);
Expand All @@ -503,7 +503,7 @@ internal void OnRpcMessage(RpcMessage msg)
{
throw new MethodInvocationException($"Invalid RPC call with id {msg.functionHash}");
}
if (Client.World.TryGetIdentity(msg.netId, out NetworkIdentity identity) && identity != null)
if (Client.World.TryGetIdentity(msg.netId, out NetworkIdentity identity))
{
using (PooledNetworkReader networkReader = NetworkReaderPool.GetReader(msg.payload))
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/Mirage/Runtime/ServerObjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public void RemovePlayerForConnection(INetworkPlayer player, bool destroyServerO
/// <param name="msg"></param>
void OnServerRpcMessage(INetworkPlayer player, ServerRpcMessage msg)
{
if (!Server.World.TryGetIdentity(msg.netId, out NetworkIdentity identity) || identity is null)
if (!Server.World.TryGetIdentity(msg.netId, out NetworkIdentity identity))
{
if (logger.WarnEnabled()) logger.LogWarning("Spawned object not found when handling ServerRpc message [netId=" + msg.netId + "]");
return;
Expand Down

0 comments on commit 909b668

Please sign in to comment.