Skip to content

Commit

Permalink
fix: Suppress Commands When Not Ready (#3009)
Browse files Browse the repository at this point in the history
* fix: Suppress Commands When Not Ready

* typo

* reverted change to separate PR
  • Loading branch information
MrGadget1024 committed Dec 2, 2021
1 parent 38c641b commit c291932
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions Assets/Mirror/Runtime/NetworkBehaviour.cs
Expand Up @@ -198,18 +198,22 @@ protected void SendCommandInternal(Type invokeClass, string cmdName, NetworkWrit
return;
}

// local players can always send commands, regardless of authority, other objects must have authority.
if (!(!requiresAuthority || isLocalPlayer || hasAuthority))
// previously we used NetworkClient.readyConnection.
// now we check .ready separately.
if (!NetworkClient.ready)
{
Debug.LogWarning($"Trying to send command for object without authority. {invokeClass}.{cmdName}");
// Unreliable Cmds from NetworkTransform may be generated,
// or client may have been set NotReady intentionally, so
// only warn if on the reliable channel.
if (channelId == Channels.Reliable)
Debug.LogWarning("Send command attempted while NetworkClient is not ready.\nThis may be ignored if client intentionally set NotReady.");
return;
}

// previously we used NetworkClient.readyConnection.
// now we check .ready separately and use .connection instead.
if (!NetworkClient.ready)
// local players can always send commands, regardless of authority, other objects must have authority.
if (!(!requiresAuthority || isLocalPlayer || hasAuthority))
{
Debug.LogError("Send command attempted while NetworkClient is not ready.");
Debug.LogWarning($"Trying to send command for object without authority. {invokeClass}.{cmdName}");
return;
}

Expand Down

0 comments on commit c291932

Please sign in to comment.