From 8612c023a6f9113c868c7c7d66cf4d6e69982167 Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Mon, 6 Sep 2021 12:10:36 -0400 Subject: [PATCH] breaking: Remove Obsoletes (#2909) * breaking: Remove Obsoletes - MIRROR_47_0_OR_NEWER symbol added - A few obsoletes with Network Visibility remain...not ready to remove just yet. * fixed test --- .../Authenticators/BasicAuthenticator.cs | 4 - .../CompilerSymbols/PreprocessorDefine.cs | 3 +- .../Components/NetworkProximityChecker.cs | 18 -- Assets/Mirror/Runtime/ClientScene.cs | 95 ---------- Assets/Mirror/Runtime/Empty/ClientScene.cs | 1 + .../Runtime/{ => Empty}/ClientScene.cs.meta | 0 Assets/Mirror/Runtime/Messages.cs | 8 - Assets/Mirror/Runtime/NetworkAuthenticator.cs | 12 -- Assets/Mirror/Runtime/NetworkClient.cs | 53 ------ Assets/Mirror/Runtime/NetworkManager.cs | 28 +-- Assets/Mirror/Runtime/NetworkManagerHUD.cs | 8 - Assets/Mirror/Runtime/NetworkReader.cs | 26 --- Assets/Mirror/Runtime/NetworkServer.cs | 72 ------- Assets/Mirror/Runtime/NetworkTime.cs | 16 -- Assets/Mirror/Runtime/NetworkWriter.cs | 24 --- Assets/Mirror/Runtime/SyncList.cs | 20 -- .../Runtime/Transport/FallbackTransport.cs | 179 +----------------- Assets/Mirror/Runtime/Transport/Transport.cs | 36 +--- Assets/Mirror/Runtime/Utils.cs | 15 -- .../Mirror/Tests/Editor/NetworkServerTest.cs | 8 - ProjectSettings/ProjectSettings.asset | 2 +- 21 files changed, 13 insertions(+), 615 deletions(-) delete mode 100644 Assets/Mirror/Runtime/ClientScene.cs create mode 100644 Assets/Mirror/Runtime/Empty/ClientScene.cs rename Assets/Mirror/Runtime/{ => Empty}/ClientScene.cs.meta (100%) diff --git a/Assets/Mirror/Authenticators/BasicAuthenticator.cs b/Assets/Mirror/Authenticators/BasicAuthenticator.cs index 6a89e7a7a..56f899dd4 100644 --- a/Assets/Mirror/Authenticators/BasicAuthenticator.cs +++ b/Assets/Mirror/Authenticators/BasicAuthenticator.cs @@ -151,10 +151,6 @@ public override void OnClientAuthenticate() NetworkClient.connection.Send(authRequestMessage); } - // Deprecated 2021-04-29 - [Obsolete("Call OnAuthResponseMessage without the NetworkConnection parameter. It always points to NetworkClient.connection anyway.")] - public void OnAuthResponseMessage(NetworkConnection conn, AuthResponseMessage msg) => OnAuthResponseMessage(msg); - /// /// Called on client when the server's AuthResponseMessage arrives /// diff --git a/Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs b/Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs index 8fbbd931c..070f730d8 100644 --- a/Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs +++ b/Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs @@ -36,7 +36,8 @@ public static void AddDefineSymbols() "MIRROR_42_0_OR_NEWER", "MIRROR_43_0_OR_NEWER", "MIRROR_44_0_OR_NEWER", - "MIRROR_46_0_OR_NEWER" + "MIRROR_46_0_OR_NEWER", + "MIRROR_47_0_OR_NEWER" }; // only touch PlayerSettings if we actually modified it. diff --git a/Assets/Mirror/Components/NetworkProximityChecker.cs b/Assets/Mirror/Components/NetworkProximityChecker.cs index 81e6b5500..903dcb495 100644 --- a/Assets/Mirror/Components/NetworkProximityChecker.cs +++ b/Assets/Mirror/Components/NetworkProximityChecker.cs @@ -27,18 +27,6 @@ public class NetworkProximityChecker : NetworkVisibility [Tooltip("How often (in seconds) that this object should update the list of observers that can see it.")] public float visUpdateInterval = 1; - /// - /// Flag to force this object to be hidden for players. - /// If this object is a player object, it will not be hidden for that player. - /// - // Deprecated 2021-02-17 - [Obsolete("Use NetworkIdentity.visible mode instead of forceHidden!")] - public bool forceHidden - { - get => netIdentity.visible == Visibility.ForceHidden; - set => netIdentity.visible = value ? Visibility.ForceHidden : Visibility.Default; - } - public override void OnStartServer() { InvokeRepeating(nameof(RebuildObservers), 0, visUpdateInterval); @@ -61,9 +49,6 @@ void RebuildObservers() /// True if the player can see this object. public override bool OnCheckObserver(NetworkConnection conn) { - if (forceHidden) - return false; - return Vector3.Distance(conn.identity.transform.position, transform.position) < visRange; } @@ -76,9 +61,6 @@ public override bool OnCheckObserver(NetworkConnection conn) public override void OnRebuildObservers(HashSet observers, bool initialize) { // if force hidden then return without adding any observers. - if (forceHidden) - return; - // 'transform.' calls GetComponent, only do it once Vector3 position = transform.position; diff --git a/Assets/Mirror/Runtime/ClientScene.cs b/Assets/Mirror/Runtime/ClientScene.cs deleted file mode 100644 index d84ae21f3..000000000 --- a/Assets/Mirror/Runtime/ClientScene.cs +++ /dev/null @@ -1,95 +0,0 @@ -// moved into NetworkClient on 2021-03-07 -using System; -using System.Collections.Generic; -using UnityEngine; -using Guid = System.Guid; - -namespace Mirror -{ - // Deprecated 2021-03-07 - [Obsolete("Use NetworkClient instead")] - public static class ClientScene - { - [Obsolete("ClientScene.localPlayer was moved to NetworkClient.localPlayer")] - public static NetworkIdentity localPlayer - { - get { return NetworkClient.localPlayer; } - set { NetworkClient.localPlayer = value; } - } - - [Obsolete("ClientScene.ready was moved to NetworkClient.ready")] - public static bool ready - { - get { return NetworkClient.ready; } - set { NetworkClient.ready = value; } - } - - [Obsolete("ClientScene.readyConnection was moved to NetworkClient.readyConnection")] - public static NetworkConnection readyConnection - { - get { return NetworkClient.readyConnection; } - set { NetworkClient.connection = value; } - } - - [Obsolete("ClientScene.prefabs was moved to NetworkClient.prefabs")] - public static Dictionary prefabs => NetworkClient.prefabs; - - // add player ////////////////////////////////////////////////////////// - [Obsolete("ClientScene.AddPlayer was moved to NetworkClient.AddPlayer")] - public static bool AddPlayer(NetworkConnection readyConn) => NetworkClient.AddPlayer(readyConn); - - // ready /////////////////////////////////////////////////////////////// - [Obsolete("ClientScene.Ready was moved to NetworkClient.Ready")] - public static bool Ready(NetworkConnection conn) => NetworkClient.Ready(conn); - - [Obsolete("ClientScene.PrepareToSpawnSceneObjects was moved to NetworkClient.PrepareToSpawnSceneObjects")] - public static void PrepareToSpawnSceneObjects() => NetworkClient.PrepareToSpawnSceneObjects(); - - // spawnable prefabs /////////////////////////////////////////////////// - [Obsolete("ClientScene.GetPrefab was moved to NetworkClient.GetPrefab")] - public static bool GetPrefab(Guid assetId, out GameObject prefab) => NetworkClient.GetPrefab(assetId, out prefab); - - [Obsolete("ClientScene.RegisterPrefab was moved to NetworkClient.RegisterPrefab")] - public static void RegisterPrefab(GameObject prefab, Guid newAssetId) => NetworkClient.RegisterPrefab(prefab, newAssetId); - - [Obsolete("ClientScene.RegisterPrefab was moved to NetworkClient.RegisterPrefab")] - public static void RegisterPrefab(GameObject prefab) => NetworkClient.RegisterPrefab(prefab); - - [Obsolete("ClientScene.RegisterPrefab was moved to NetworkClient.RegisterPrefab")] - public static void RegisterPrefab(GameObject prefab, Guid newAssetId, SpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler) => - NetworkClient.RegisterPrefab(prefab, newAssetId, spawnHandler, unspawnHandler); - - [Obsolete("ClientScene.RegisterPrefab was moved to NetworkClient.RegisterPrefab")] - public static void RegisterPrefab(GameObject prefab, SpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler) => - NetworkClient.RegisterPrefab(prefab, spawnHandler, unspawnHandler); - - [Obsolete("ClientScene.RegisterPrefab was moved to NetworkClient.RegisterPrefab")] - public static void RegisterPrefab(GameObject prefab, Guid newAssetId, SpawnHandlerDelegate spawnHandler, UnSpawnDelegate unspawnHandler) => - NetworkClient.RegisterPrefab(prefab, newAssetId, spawnHandler, unspawnHandler); - - [Obsolete("ClientScene.RegisterPrefab was moved to NetworkClient.RegisterPrefab")] - public static void RegisterPrefab(GameObject prefab, SpawnHandlerDelegate spawnHandler, UnSpawnDelegate unspawnHandler) => - NetworkClient.RegisterPrefab(prefab, spawnHandler, unspawnHandler); - - [Obsolete("ClientScene.UnregisterPrefab was moved to NetworkClient.UnregisterPrefab")] - public static void UnregisterPrefab(GameObject prefab) => NetworkClient.UnregisterPrefab(prefab); - - // spawn handlers ////////////////////////////////////////////////////// - [Obsolete("ClientScene.RegisterSpawnHandler was moved to NetworkClient.RegisterSpawnHandler")] - public static void RegisterSpawnHandler(Guid assetId, SpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler) => - NetworkClient.RegisterSpawnHandler(assetId, spawnHandler, unspawnHandler); - - [Obsolete("ClientScene.RegisterSpawnHandler was moved to NetworkClient.RegisterSpawnHandler")] - public static void RegisterSpawnHandler(Guid assetId, SpawnHandlerDelegate spawnHandler, UnSpawnDelegate unspawnHandler) => - NetworkClient.RegisterSpawnHandler(assetId, spawnHandler, unspawnHandler); - - [Obsolete("ClientScene.UnregisterSpawnHandler was moved to NetworkClient.UnregisterSpawnHandler")] - public static void UnregisterSpawnHandler(Guid assetId) => NetworkClient.UnregisterSpawnHandler(assetId); - - [Obsolete("ClientScene.ClearSpawners was moved to NetworkClient.ClearSpawners")] - public static void ClearSpawners() => NetworkClient.ClearSpawners(); - - [Obsolete("ClientScene.DestroyAllClientObjects was moved to NetworkClient.DestroyAllClientObjects")] - public static void DestroyAllClientObjects() => NetworkClient.DestroyAllClientObjects(); - } -} diff --git a/Assets/Mirror/Runtime/Empty/ClientScene.cs b/Assets/Mirror/Runtime/Empty/ClientScene.cs new file mode 100644 index 000000000..0d1b96e78 --- /dev/null +++ b/Assets/Mirror/Runtime/Empty/ClientScene.cs @@ -0,0 +1 @@ +// moved into NetworkClient on 2021-03-07 diff --git a/Assets/Mirror/Runtime/ClientScene.cs.meta b/Assets/Mirror/Runtime/Empty/ClientScene.cs.meta similarity index 100% rename from Assets/Mirror/Runtime/ClientScene.cs.meta rename to Assets/Mirror/Runtime/Empty/ClientScene.cs.meta diff --git a/Assets/Mirror/Runtime/Messages.cs b/Assets/Mirror/Runtime/Messages.cs index eb3cbefd1..6ea2424e5 100644 --- a/Assets/Mirror/Runtime/Messages.cs +++ b/Assets/Mirror/Runtime/Messages.cs @@ -3,14 +3,6 @@ namespace Mirror { - // Deprecated 2020-10-06 - [Obsolete("Implement NetworkMessage instead. Use extension methods instead of Serialize/Deserialize, see https://github.com/vis2k/Mirror/pull/2317", true)] - public interface IMessageBase {} - - // Deprecated 2020-10-06 - [Obsolete("Implement NetworkMessage instead. Use extension methods instead of Serialize/Deserialize, see https://github.com/vis2k/Mirror/pull/2317", true)] - public class MessageBase : IMessageBase {} - public struct ReadyMessage : NetworkMessage {} public struct NotReadyMessage : NetworkMessage {} diff --git a/Assets/Mirror/Runtime/NetworkAuthenticator.cs b/Assets/Mirror/Runtime/NetworkAuthenticator.cs index e980a8911..c23371520 100644 --- a/Assets/Mirror/Runtime/NetworkAuthenticator.cs +++ b/Assets/Mirror/Runtime/NetworkAuthenticator.cs @@ -44,26 +44,14 @@ public virtual void OnStartClient() {} /// Called when client stops, used to unregister message handlers if needed. public virtual void OnStopClient() {} - // Deprecated 2021-03-13 - [Obsolete("Remove the NetworkConnection parameter from your override and use NetworkClient.connection instead")] - public virtual void OnClientAuthenticate(NetworkConnection conn) => OnClientAuthenticate(); - /// Called on client from OnClientAuthenticateInternal when a client needs to authenticate public abstract void OnClientAuthenticate(); - // Deprecated 2021-03-13 - [Obsolete("Remove the NetworkConnection parameter from your override and use NetworkClient.connection instead")] - protected void ClientAccept(NetworkConnection conn) => ClientAccept(); - protected void ClientAccept() { OnClientAuthenticated.Invoke(NetworkClient.connection); } - // Deprecated 2021-03-13 - [Obsolete("Remove the NetworkConnection parameter from your override and use NetworkClient.connection instead")] - protected void ClientReject(NetworkConnection conn) => ClientReject(); - protected void ClientReject() { // Set this on the client for local reference diff --git a/Assets/Mirror/Runtime/NetworkClient.cs b/Assets/Mirror/Runtime/NetworkClient.cs index f942d3622..5ef9daabc 100644 --- a/Assets/Mirror/Runtime/NetworkClient.cs +++ b/Assets/Mirror/Runtime/NetworkClient.cs @@ -39,12 +39,6 @@ public static class NetworkClient // way better for security if we can check states in callbacks public static bool ready; - /// The NetworkConnection object that is currently "ready". - // TODO this is from UNET. it's redundant and we should probably obsolete it. - // Deprecated 2021-03-10 - [Obsolete("NetworkClient.readyConnection is redundant. Use NetworkClient.connection and use NetworkClient.ready to check if it's ready.")] - public static NetworkConnection readyConnection => ready ? connection : null; - /// NetworkIdentity of the localPlayer public static NetworkIdentity localPlayer { get; internal set; } @@ -68,9 +62,6 @@ public static class NetworkClient /// True if client is running in host mode. public static bool isHostClient => connection is LocalConnectionToServer; - // Deprecated 2021-05-26 - [Obsolete("isLocalClient was renamed to isHostClient because that's what it actually means.")] - public static bool isLocalClient => isHostClient; // OnConnected / OnDisconnected used to be NetworkMessages that were // invoked. this introduced a bug where external clients could send @@ -248,23 +239,6 @@ public static void Disconnect() // connection = null; } - /// Disconnect host mode. - // this is needed to call DisconnectMessage for the host client too. - // Deprecated 2021-05-11 - [Obsolete("Call NetworkClient.Disconnect() instead. Nobody should use DisconnectLocalServer.")] - public static void DisconnectLocalServer() - { - // only if host connection is running - if (NetworkServer.localConnection != null) - { - // TODO ConnectLocalServer manually sends a ConnectMessage to the - // local connection. should we send a DisconnectMessage here too? - // (if we do then we get an Unknown Message ID log) - //NetworkServer.localConnection.Send(new DisconnectMessage()); - NetworkServer.OnTransportDisconnected(NetworkServer.localConnection.connectionId); - } - } - // transport events //////////////////////////////////////////////////// // called by Transport static void OnTransportConnected() @@ -460,20 +434,6 @@ public static void Send(T message, int channelId = Channels.Reliable) } // message handlers //////////////////////////////////////////////////// - /// Register a handler for a message type T. Most should require authentication. - // Deprecated 2021-03-13 - [Obsolete("Use RegisterHandler version without NetworkConnection parameter. It always points to NetworkClient.connection anyway.")] - public static void RegisterHandler(Action handler, bool requireAuthentication = true) - where T : struct, NetworkMessage - { - ushort msgType = MessagePacking.GetId(); - if (handlers.ContainsKey(msgType)) - { - Debug.LogWarning($"NetworkClient.RegisterHandler replacing handler for {typeof(T).FullName}, id={msgType}. If replacement is intentional, use ReplaceHandler instead to avoid this warning."); - } - handlers[msgType] = MessagePacking.WrapHandler(handler, requireAuthentication); - } - /// Register a handler for a message type T. Most should require authentication. public static void RegisterHandler(Action handler, bool requireAuthentication = true) where T : struct, NetworkMessage @@ -961,10 +921,6 @@ public static bool Ready() return true; } - // Deprecated 2021-03-13 - [Obsolete("NetworkClient.Ready doesn't need a NetworkConnection parameter anymore. It always uses NetworkClient.connection anyway.")] - public static bool Ready(NetworkConnection conn) => Ready(); - // add player ////////////////////////////////////////////////////////// // called from message handler for Owner message internal static void InternalAddPlayer(NetworkIdentity identity) @@ -1017,10 +973,6 @@ public static bool AddPlayer() return true; } - // Deprecated 2021-03-13 - [Obsolete("NetworkClient.AddPlayer doesn't need a NetworkConnection parameter anymore. It always uses NetworkClient.connection anyway.")] - public static bool AddPlayer(NetworkConnection readyConn) => AddPlayer(); - // spawning //////////////////////////////////////////////////////////// internal static void ApplySpawnPayload(NetworkIdentity identity, SpawnMessage message) { @@ -1398,11 +1350,6 @@ internal static void NetworkLateUpdate() Transport.activeTransport.ClientLateUpdate(); } - // obsolete to not break people's projects. Update was public. - // Deprecated 2021-03-02 - [Obsolete("NetworkClient.Update is now called internally from our custom update loop. No need to call Update manually anymore.")] - public static void Update() => NetworkLateUpdate(); - // shutdown //////////////////////////////////////////////////////////// /// Destroys all networked objects on the client. // Note: NetworkServer.CleanupNetworkIdentities does the same on server. diff --git a/Assets/Mirror/Runtime/NetworkManager.cs b/Assets/Mirror/Runtime/NetworkManager.cs index 56e1815b4..443df4a10 100644 --- a/Assets/Mirror/Runtime/NetworkManager.cs +++ b/Assets/Mirror/Runtime/NetworkManager.cs @@ -23,7 +23,7 @@ public class NetworkManager : MonoBehaviour [Tooltip("Should the Network Manager object be persisted through scene changes?")] public bool dontDestroyOnLoad = true; - // Deprecated 2021-03-10 + // Deprecated 2021-03-10 // Temporary bool to allow Network Manager to persist to offline scene // Based on Discord convo, BigBox is invoking StopHost in startup sequence, bouncing the server and clients back to offline scene, which resets Network Manager. // Request is for a checkbox to persist Network Manager to offline scene, despite the collision and warning. @@ -31,7 +31,7 @@ public class NetworkManager : MonoBehaviour [Tooltip("Should the Network Manager object be persisted through scene change to the offline scene?")] public bool PersistNetworkManagerToOfflineScene; - /// Multiplayer games should always run in the background so the network doesn't time out. + /// Multiplayer games should always run in the background so the network doesn't time out. [FormerlySerializedAs("m_RunInBackground")] [Tooltip("Multiplayer games should always run in the background so the network doesn't time out.")] public bool runInBackground = true; @@ -74,14 +74,6 @@ public class NetworkManager : MonoBehaviour [Tooltip("Maximum number of concurrent connections.")] public int maxConnections = 100; - // Deprecated 2021-05-10 - [Obsolete("Transport is responsible for timeouts.")] - public bool disconnectInactiveConnections; - - // Deprecated 2021-05-10 - [Obsolete("Transport is responsible for timeouts. Configure the Transport's timeout setting instead.")] - public float disconnectInactiveTimeout = 60f; - [Header("Authentication")] [Tooltip("Authentication component attached to this object")] public NetworkAuthenticator authenticator; @@ -257,12 +249,6 @@ void SetupServer() ConfigureHeadlessFrameRate(); - // Copy auto-disconnect settings to NetworkServer -#pragma warning disable 618 - NetworkServer.disconnectInactiveTimeout = disconnectInactiveTimeout; - NetworkServer.disconnectInactiveConnections = disconnectInactiveConnections; -#pragma warning restore 618 - // start listening to network connections NetworkServer.Listen(maxConnections); @@ -646,7 +632,7 @@ public virtual void OnApplicationQuit() } } - // DEPRECATED 2021-07-21 + // Deprecated 2021-07-21 [Obsolete("Renamed to ConfigureHeadlessFrameRate()")] public virtual void ConfigureServerFrameRate() {} @@ -1246,10 +1232,6 @@ public virtual void OnServerAddPlayer(NetworkConnection conn) NetworkServer.AddPlayerForConnection(conn, player); } - // Deprecated 2021-02-13 - [Obsolete("OnServerError was removed because it hasn't been used in a long time.")] - public virtual void OnServerError(NetworkConnection conn, int errorCode) {} - /// Called on server when transport raises an exception. NetworkConnection may be null. public virtual void OnServerError(NetworkConnection conn, Exception exception) {} @@ -1286,10 +1268,6 @@ public virtual void OnClientDisconnect(NetworkConnection conn) StopClient(); } - // Deprecated 2021-02-13 - [Obsolete("OnClientError was removed because it hasn't been used in a long time.")] - public virtual void OnClientError(NetworkConnection conn, int errorCode) {} - /// Called on client when transport raises an exception. public virtual void OnClientError(Exception exception) {} diff --git a/Assets/Mirror/Runtime/NetworkManagerHUD.cs b/Assets/Mirror/Runtime/NetworkManagerHUD.cs index 073806475..8fadbc846 100644 --- a/Assets/Mirror/Runtime/NetworkManagerHUD.cs +++ b/Assets/Mirror/Runtime/NetworkManagerHUD.cs @@ -14,10 +14,6 @@ public class NetworkManagerHUD : MonoBehaviour { NetworkManager manager; - // Deprecated 2021-02-24 - [Obsolete("showGUI will be removed unless someone has a valid use case. Simply use or don't use the HUD component.")] - public bool showGUI = true; - public int offsetX; public int offsetY; @@ -28,10 +24,6 @@ void Awake() void OnGUI() { -#pragma warning disable 618 - if (!showGUI) return; -#pragma warning restore 618 - GUILayout.BeginArea(new Rect(10 + offsetX, 40 + offsetY, 215, 9999)); if (!NetworkClient.isConnected && !NetworkServer.active) { diff --git a/Assets/Mirror/Runtime/NetworkReader.cs b/Assets/Mirror/Runtime/NetworkReader.cs index b22fcbce1..26abcd45d 100644 --- a/Assets/Mirror/Runtime/NetworkReader.cs +++ b/Assets/Mirror/Runtime/NetworkReader.cs @@ -129,20 +129,9 @@ public static class NetworkReaderExtensions public static byte ReadByte(this NetworkReader reader) => reader.ReadByte(); public static sbyte ReadSByte(this NetworkReader reader) => (sbyte)reader.ReadByte(); public static char ReadChar(this NetworkReader reader) => (char)reader.ReadUShort(); - - // Deprecated 2021-05-18 - [Obsolete("We've cleaned up the API. Use ReadBool instead.")] - public static bool ReadBoolean(this NetworkReader reader) => reader.ReadBool(); public static bool ReadBool(this NetworkReader reader) => reader.ReadByte() != 0; - - // Deprecated 2021-05-18 - [Obsolete("We've cleaned up the API. Use ReadShort instead.")] - public static short ReadInt16(this NetworkReader reader) => reader.ReadShort(); public static short ReadShort(this NetworkReader reader) => (short)reader.ReadUShort(); - // Deprecated 2021-05-18 - [Obsolete("We've cleaned up the API. Use ReadUShort instead.")] - public static ushort ReadUInt16(this NetworkReader reader) => reader.ReadUShort(); public static ushort ReadUShort(this NetworkReader reader) { ushort value = 0; @@ -151,14 +140,8 @@ public static ushort ReadUShort(this NetworkReader reader) return value; } - // Deprecated 2021-05-18 - [Obsolete("We've cleaned up the API. Use ReadInt instead.")] - public static int ReadInt32(this NetworkReader reader) => reader.ReadInt(); public static int ReadInt(this NetworkReader reader) => (int)reader.ReadUInt(); - // Deprecated 2021-05-18 - [Obsolete("We've cleaned up the API. Use ReadUInt instead.")] - public static uint ReadUInt32(this NetworkReader reader) => reader.ReadUInt(); public static uint ReadUInt(this NetworkReader reader) { uint value = 0; @@ -169,14 +152,8 @@ public static uint ReadUInt(this NetworkReader reader) return value; } - // Deprecated 2021-05-18 - [Obsolete("We've cleaned up the API. Use ReadLong instead.")] - public static long ReadInt64(this NetworkReader reader) => reader.ReadLong(); public static long ReadLong(this NetworkReader reader) => (long)reader.ReadULong(); - // Deprecated 2021-05-18 - [Obsolete("We've cleaned up the API. Use ReadULong instead.")] - public static ulong ReadUInt64(this NetworkReader reader) => reader.ReadULong(); public static ulong ReadULong(this NetworkReader reader) { ulong value = 0; @@ -191,9 +168,6 @@ public static ulong ReadULong(this NetworkReader reader) return value; } - // Deprecated 2021-05-18 - [Obsolete("We've cleaned up the API. Use ReadFloat instead.")] - public static float ReadSingle(this NetworkReader reader) => reader.ReadFloat(); public static float ReadFloat(this NetworkReader reader) { UIntFloat converter = new UIntFloat(); diff --git a/Assets/Mirror/Runtime/NetworkServer.cs b/Assets/Mirror/Runtime/NetworkServer.cs index fc1449e8a..6a641d425 100644 --- a/Assets/Mirror/Runtime/NetworkServer.cs +++ b/Assets/Mirror/Runtime/NetworkServer.cs @@ -45,14 +45,6 @@ public static class NetworkServer // by default, everyone observes everyone public static InterestManagement aoi; - // Deprecated 2021-05-10 - [Obsolete("Transport is responsible for timeouts.")] - public static bool disconnectInactiveConnections; - - // Deprecated 2021-05-10 - [Obsolete("Transport is responsible for timeouts. Configure the Transport's timeout setting instead.")] - public static float disconnectInactiveTimeout = 60f; - // OnConnected / OnDisconnected used to be NetworkMessages that were // invoked. this introduced a bug where external clients could send // Connected/Disconnected messages over the network causing undefined @@ -242,10 +234,6 @@ public static bool NoExternalConnections() (connections.Count == 1 && localConnection != null); } - // Deprecated 2021-03-07 - [Obsolete("NoConnections was renamed to NoExternalConnections because that's what it checks for.")] - public static bool NoConnections() => NoExternalConnections(); - // send //////////////////////////////////////////////////////////////// /// Send a message to all clients, even those that haven't joined the world yet (non ready) public static void SendToAll(T message, int channelId = Channels.Reliable, bool sendToReadyOnly = false) @@ -357,22 +345,6 @@ static void SendToObservers(NetworkIdentity identity, T message, int channelI } } - /// Send this message to the player only - // Deprecated 2021-03-04 - [Obsolete("Use identity.connectionToClient.Send() instead! Previously Mirror needed this function internally, but not anymore.")] - public static void SendToClientOfPlayer(NetworkIdentity identity, T msg, int channelId = Channels.Reliable) - where T : struct, NetworkMessage - { - if (identity != null) - { - identity.connectionToClient.Send(msg, channelId); - } - else - { - Debug.LogError("SendToClientOfPlayer: player has no NetworkIdentity: " + identity); - } - } - // transport events //////////////////////////////////////////////////// // called by transport static void OnTransportConnected(int connectionId) @@ -593,15 +565,6 @@ public static void RegisterHandler(Action handler, bool handlers[msgType] = MessagePacking.WrapHandler(handler, requireAuthentication); } - /// Register a handler for message type T. Most should require authentication. - // Deprecated 2021-02-24 - [Obsolete("Use RegisterHandler(Action(Action handler, bool requireAuthentication = true) - where T : struct, NetworkMessage - { - RegisterHandler((_, value) => { handler(value); }, requireAuthentication); - } - /// Replace a handler for message type T. Most should require authentication. public static void ReplaceHandler(Action handler, bool requireAuthentication = true) where T : struct, NetworkMessage @@ -678,14 +641,6 @@ public static void DisconnectAll() active = false; } - // Deprecated 2021-05-11 - [Obsolete("Call NetworkClient.DisconnectAll() instead")] - public static void DisconnectAllExternalConnections() => DisconnectAll(); - - // Deprecated 2021-05-11 - [Obsolete("Call NetworkClient.DisconnectAll() instead")] - public static void DisconnectAllConnections() => DisconnectAll(); - // add/remove/replace player /////////////////////////////////////////// /// Called by server after AddPlayer message to add the player for the connection. // When a player is added for a connection, the client for that @@ -1620,24 +1575,6 @@ static void BroadcastToConnection(NetworkConnectionToClient connection) } } - // helper function to check a connection for inactivity - // and disconnect if necessary - // => returns true if disconnected - static bool DisconnectIfInactive(NetworkConnectionToClient connection) - { - // check for inactivity -#pragma warning disable 618 - if (disconnectInactiveConnections && - !connection.IsAlive(disconnectInactiveTimeout)) - { - Debug.LogWarning($"Disconnecting {connection} for inactivity!"); - connection.Disconnect(); - return true; - } -#pragma warning restore 618 - return false; - } - // NetworkLateUpdate called after any Update/FixedUpdate/LateUpdate // (we add this to the UnityEngine in NetworkLoop) static readonly List connectionsCopy = @@ -1659,10 +1596,6 @@ static void Broadcast() // go through all connections foreach (NetworkConnectionToClient connection in connectionsCopy) { - // check for inactivity. disconnects if necessary. - if (DisconnectIfInactive(connection)) - continue; - // has this connection joined the world yet? // for each READY connection: // pull in UpdateVarsMessage for each entity it observes @@ -1710,10 +1643,5 @@ internal static void NetworkLateUpdate() if (Transport.activeTransport != null) Transport.activeTransport.ServerLateUpdate(); } - - // obsolete to not break people's projects. Update was public. - // Deprecated 2021-03-02 - [Obsolete("NetworkServer.Update is now called internally from our custom update loop. No need to call Update manually anymore.")] - public static void Update() => NetworkLateUpdate(); } } diff --git a/Assets/Mirror/Runtime/NetworkTime.cs b/Assets/Mirror/Runtime/NetworkTime.cs index c3331eac4..0d718e8af 100644 --- a/Assets/Mirror/Runtime/NetworkTime.cs +++ b/Assets/Mirror/Runtime/NetworkTime.cs @@ -55,18 +55,10 @@ static NetworkTime() // TODO does this need to be public? user should only need NetworkTime.time public static double timeVariance => _offset.Var; - // Deprecated 2021-03-10 - [Obsolete("NetworkTime.timeVar was renamed to timeVariance")] - public static double timeVar => timeVariance; - /// Time standard deviation. The highe, the less accurate the time is. // TODO does this need to be public? user should only need NetworkTime.time public static double timeStandardDeviation => Math.Sqrt(timeVariance); - // Deprecated 2021-03-10 - [Obsolete("NetworkTime.timeSd was renamed to timeStandardDeviation")] - public static double timeSd => timeStandardDeviation; - /// Clock difference in seconds between the client and the server. Always 0 on server. public static double offset => _offset.Value; @@ -77,18 +69,10 @@ static NetworkTime() // TODO does this need to be public? user should only need NetworkTime.time public static double rttVariance => _rtt.Var; - // Deprecated 2021-03-02 - [Obsolete("NetworkTime.rttVar was renamed to rttVariance")] - public static double rttVar => rttVariance; - /// Round trip time standard deviation. The higher, the less accurate the rtt is. // TODO does this need to be public? user should only need NetworkTime.time public static double rttStandardDeviation => Math.Sqrt(rttVariance); - // Deprecated 2021-03-02 - [Obsolete("NetworkTime.rttSd was renamed to rttStandardDeviation")] - public static double rttSd => rttStandardDeviation; - public static void Reset() { stopwatch.Restart(); diff --git a/Assets/Mirror/Runtime/NetworkWriter.cs b/Assets/Mirror/Runtime/NetworkWriter.cs index 7ed3b5bd4..d2e3fe26c 100644 --- a/Assets/Mirror/Runtime/NetworkWriter.cs +++ b/Assets/Mirror/Runtime/NetworkWriter.cs @@ -105,28 +105,16 @@ public static class NetworkWriterExtensions public static void WriteChar(this NetworkWriter writer, char value) => writer.WriteUShort(value); - // Deprecated 2021-05-18 - [Obsolete("We've cleaned up the API. Use WriteBool instead.")] - public static void WriteBoolean(this NetworkWriter writer, bool value) => writer.WriteBool(value); public static void WriteBool(this NetworkWriter writer, bool value) => writer.WriteByte((byte)(value ? 1 : 0)); - // Deprecated 2021-05-18 - [Obsolete("We've cleaned up the API. Use WriteUShort instead.")] - public static void WriteUInt16(this NetworkWriter writer, ushort value) => writer.WriteUShort(value); public static void WriteUShort(this NetworkWriter writer, ushort value) { writer.WriteByte((byte)value); writer.WriteByte((byte)(value >> 8)); } - // Deprecated 2021-05-18 - [Obsolete("We've cleaned up the API. Use WriteShort instead.")] - public static void WriteInt16(this NetworkWriter writer, short value) => writer.WriteShort(value); public static void WriteShort(this NetworkWriter writer, short value) => writer.WriteUShort((ushort)value); - // Deprecated 2021-05-18 - [Obsolete("We've cleaned up the API. Use WriteUInt instead.")] - public static void WriteUInt32(this NetworkWriter writer, uint value) => writer.WriteUInt(value); public static void WriteUInt(this NetworkWriter writer, uint value) { writer.WriteByte((byte)value); @@ -135,14 +123,8 @@ public static void WriteUInt(this NetworkWriter writer, uint value) writer.WriteByte((byte)(value >> 24)); } - // Deprecated 2021-05-18 - [Obsolete("We've cleaned up the API. Use WriteInt instead.")] - public static void WriteInt32(this NetworkWriter writer, int value) => writer.WriteInt(value); public static void WriteInt(this NetworkWriter writer, int value) => writer.WriteUInt((uint)value); - // Deprecated 2021-05-18 - [Obsolete("We've cleaned up the API. Use WriteULong instead.")] - public static void WriteUInt64(this NetworkWriter writer, ulong value) => writer.WriteULong(value); public static void WriteULong(this NetworkWriter writer, ulong value) { writer.WriteByte((byte)value); @@ -155,14 +137,8 @@ public static void WriteULong(this NetworkWriter writer, ulong value) writer.WriteByte((byte)(value >> 56)); } - // Deprecated 2021-05-18 - [Obsolete("We've cleaned up the API. Use WriteLong instead.")] - public static void WriteInt64(this NetworkWriter writer, long value) => writer.WriteLong(value); public static void WriteLong(this NetworkWriter writer, long value) => writer.WriteULong((ulong)value); - // Deprecated 2021-05-18 - [Obsolete("We've cleaned up the API. Use WriteFloat instead.")] - public static void WriteSingle(this NetworkWriter writer, float value) => writer.WriteFloat(value); public static void WriteFloat(this NetworkWriter writer, float value) { UIntFloat converter = new UIntFloat diff --git a/Assets/Mirror/Runtime/SyncList.cs b/Assets/Mirror/Runtime/SyncList.cs index 1ac230e18..ec760c427 100644 --- a/Assets/Mirror/Runtime/SyncList.cs +++ b/Assets/Mirror/Runtime/SyncList.cs @@ -4,26 +4,6 @@ namespace Mirror { - // Deprecated 2020-10-02 - [Obsolete("Use SyncList instead")] - public class SyncListString : SyncList {} - - // Deprecated 2020-10-02 - [Obsolete("Use SyncList instead")] - public class SyncListFloat : SyncList {} - - // Deprecated 2020-10-02 - [Obsolete("Use SyncList instead")] - public class SyncListInt : SyncList {} - - // Deprecated 2020-10-02 - [Obsolete("Use SyncList instead")] - public class SyncListUInt : SyncList {} - - // Deprecated 2020-10-02 - [Obsolete("Use SyncList instead")] - public class SyncListBool : SyncList {} - public class SyncList : IList, IReadOnlyList, SyncObject { public delegate void SyncListChanged(Operation op, int itemIndex, T oldItem, T newItem); diff --git a/Assets/Mirror/Runtime/Transport/FallbackTransport.cs b/Assets/Mirror/Runtime/Transport/FallbackTransport.cs index 738a47470..57f3344b7 100644 --- a/Assets/Mirror/Runtime/Transport/FallbackTransport.cs +++ b/Assets/Mirror/Runtime/Transport/FallbackTransport.cs @@ -1,178 +1 @@ -// uses the first available transport for server and client. -// example: to use Apathy if on Windows/Mac/Linux and fall back to Telepathy -// otherwise. -using System; -using UnityEngine; - -namespace Mirror -{ - // Deprecated 2021-05-13 - [HelpURL("https://mirror-networking.gitbook.io/docs/transports/fallback-transport")] - [DisallowMultipleComponent] - [Obsolete("Fallback Transport will be retired. It was only needed for Apathy/Libuv. Use kcp or Telepathy instead, those run everywhere.")] - public class FallbackTransport : Transport - { - public Transport[] transports; - - // the first transport that is available on this platform - Transport available; - - public void Awake() - { - if (transports == null || transports.Length == 0) - { - throw new Exception("FallbackTransport requires at least 1 underlying transport"); - } - available = GetAvailableTransport(); - Debug.Log("FallbackTransport available: " + available.GetType()); - } - - void OnEnable() - { - available.enabled = true; - } - - void OnDisable() - { - available.enabled = false; - } - - // The client just uses the first transport available - Transport GetAvailableTransport() - { - foreach (Transport transport in transports) - { - if (transport.Available()) - { - return transport; - } - } - throw new Exception("No transport suitable for this platform"); - } - - public override bool Available() - { - return available.Available(); - } - - public override void ClientConnect(string address) - { - available.OnClientConnected = OnClientConnected; - available.OnClientDataReceived = OnClientDataReceived; - available.OnClientError = OnClientError; - available.OnClientDisconnected = OnClientDisconnected; - available.ClientConnect(address); - } - - public override void ClientConnect(Uri uri) - { - foreach (Transport transport in transports) - { - if (transport.Available()) - { - try - { - transport.ClientConnect(uri); - available = transport; - } - catch (ArgumentException) - { - // transport does not support the schema, just move on to the next one - } - } - } - throw new Exception("No transport suitable for this platform"); - } - - public override bool ClientConnected() - { - return available.ClientConnected(); - } - - public override void ClientDisconnect() - { - available.ClientDisconnect(); - } - - public override void ClientSend(ArraySegment segment, int channelId) - { - available.ClientSend(segment, channelId); - } - - // right now this just returns the first available uri, - // should we return the list of all available uri? - public override Uri ServerUri() => available.ServerUri(); - - public override bool ServerActive() - { - return available.ServerActive(); - } - - public override string ServerGetClientAddress(int connectionId) - { - return available.ServerGetClientAddress(connectionId); - } - - public override void ServerDisconnect(int connectionId) - { - available.ServerDisconnect(connectionId); - } - - public override void ServerSend(int connectionId, ArraySegment segment, int channelId) - { - available.ServerSend(connectionId, segment, channelId); - } - - public override void ServerStart() - { - available.OnServerConnected = OnServerConnected; - available.OnServerDataReceived = OnServerDataReceived; - available.OnServerError = OnServerError; - available.OnServerDisconnected = OnServerDisconnected; - available.ServerStart(); - } - - public override void ServerStop() - { - available.ServerStop(); - } - - public override void ClientEarlyUpdate() => available.ClientEarlyUpdate(); - public override void ServerEarlyUpdate() => available.ServerEarlyUpdate(); - public override void ClientLateUpdate() => available.ClientLateUpdate(); - public override void ServerLateUpdate() => available.ServerLateUpdate(); - - public override void Shutdown() - { - available.Shutdown(); - } - - public override int GetMaxPacketSize(int channelId = 0) - { - // finding the max packet size in a fallback environment has to be - // done very carefully: - // * servers and clients might run different transports depending on - // which platform they are on. - // * there should only ever be ONE true max packet size for everyone, - // otherwise a spawn message might be sent to all tcp sockets, but - // be too big for some udp sockets. that would be a debugging - // nightmare and allow for possible exploits and players on - // different platforms seeing a different game state. - // => the safest solution is to use the smallest max size for all - // transports. that will never fail. - int mininumAllowedSize = int.MaxValue; - foreach (Transport transport in transports) - { - int size = transport.GetMaxPacketSize(channelId); - mininumAllowedSize = Mathf.Min(size, mininumAllowedSize); - } - return mininumAllowedSize; - } - - public override string ToString() - { - return available.ToString(); - } - - } -} +// removed 2021-05-13 \ No newline at end of file diff --git a/Assets/Mirror/Runtime/Transport/Transport.cs b/Assets/Mirror/Runtime/Transport/Transport.cs index a94440774..775a54d1e 100644 --- a/Assets/Mirror/Runtime/Transport/Transport.cs +++ b/Assets/Mirror/Runtime/Transport/Transport.cs @@ -64,17 +64,8 @@ public virtual void ClientConnect(Uri uri) /// Sends a message to the server over the given channel. // The ArraySegment is only valid until returning. Copy if needed. - // TODO make second version abstract after removing the obsolete version - // Deprecated 2021-05-17 - [Obsolete("Use ClientSend(segment, channelId) instead. channelId is now the last parameter.")] - public virtual void ClientSend(int channelId, ArraySegment segment) {} - public virtual void ClientSend(ArraySegment segment, int channelId) - { - // defaults to obsolete version to not force break transports. -#pragma warning disable 618 - ClientSend(channelId, segment); -#pragma warning restore 618 - } + // TODO make abstract + public virtual void ClientSend(ArraySegment segment, int channelId) {} /// Disconnects the client from the server public abstract void ClientDisconnect(); @@ -103,17 +94,8 @@ public virtual void ClientSend(ArraySegment segment, int channelId) public abstract void ServerStart(); /// Send a message to a client over the given channel. - // TODO make second version abstract after removing the obsolete version - // Deprecated 2021-05-17 - [Obsolete("Use ServerSend(connectionId, segment, channelId) instead. channelId is now the last parameter.")] - public virtual void ServerSend(int connectionId, int channelId, ArraySegment segment) {} - public virtual void ServerSend(int connectionId, ArraySegment segment, int channelId) - { - // defaults to obsolete version to not force break transports. -#pragma warning disable 618 - ServerSend(connectionId, channelId, segment); -#pragma warning restore 618 - } + // TODO make abstract + public virtual void ServerSend(int connectionId, ArraySegment segment, int channelId) {} /// Disconnect a client from the server. public abstract void ServerDisconnect(int connectionId); @@ -140,17 +122,9 @@ public virtual void ServerSend(int connectionId, ArraySegment segment, int // slow (head of line blocking etc.). public virtual int GetBatchThreshold(int channelId) { - // change to GetMaxPacketSize by default after removing obsolete -#pragma warning disable 618 - return GetMaxBatchSize(channelId); -#pragma warning restore 618 + return GetMaxPacketSize(channelId); } - // Deprecated 2021-06-17 - [Obsolete("GetMaxBatchSize was renamed to GetBatchThreshold.")] - public virtual int GetMaxBatchSize(int channelId) => - GetMaxPacketSize(channelId); - // block Update & LateUpdate to show warnings if Transports still use // them instead of using // Client/ServerEarlyUpdate: to process incoming messages diff --git a/Assets/Mirror/Runtime/Utils.cs b/Assets/Mirror/Runtime/Utils.cs index 0bfc18fbc..2ba7380b6 100644 --- a/Assets/Mirror/Runtime/Utils.cs +++ b/Assets/Mirror/Runtime/Utils.cs @@ -23,13 +23,6 @@ public enum MirrorInvokeType ClientRpc } - // Deprecated 2021-03-15 - [Obsolete("Version has never been used, neither by UNET nor by Mirror.")] - public enum Version - { - Current = 1 - } - // channels are const ints instead of an enum so people can add their own // channels (can't extend an enum otherwise). // @@ -41,14 +34,6 @@ public static class Channels { public const int Reliable = 0; // ordered public const int Unreliable = 1; // unordered - - // Deprecated 2021-03-15 - [Obsolete("Use Channels.Reliable instead")] - public const int DefaultReliable = Reliable; - - // Deprecated 2021-03-15 - [Obsolete("Use Channels.Unreliable instead")] - public const int DefaultUnreliable = Unreliable; } // -- helpers for float conversion without allocations -- diff --git a/Assets/Mirror/Tests/Editor/NetworkServerTest.cs b/Assets/Mirror/Tests/Editor/NetworkServerTest.cs index 9d5464f5f..171a70a0a 100644 --- a/Assets/Mirror/Tests/Editor/NetworkServerTest.cs +++ b/Assets/Mirror/Tests/Editor/NetworkServerTest.cs @@ -1259,10 +1259,6 @@ public void UpdateDetectsDestroyedEntryInObserving() public void UpdateWithTimedOutConnection() { // configure to disconnect with '0' timeout (= immediately) -#pragma warning disable 618 - NetworkServer.disconnectInactiveConnections = true; - NetworkServer.disconnectInactiveTimeout = 0; - // start NetworkServer.Listen(1); @@ -1271,10 +1267,6 @@ public void UpdateWithTimedOutConnection() // update NetworkServer.NetworkLateUpdate(); - - // clean up - NetworkServer.disconnectInactiveConnections = false; -#pragma warning restore 618 } } } diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index e5337cc78..580f6428b 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -576,7 +576,7 @@ PlayerSettings: webGLThreadsSupport: 0 webGLWasmStreaming: 0 scriptingDefineSymbols: - 1: MIRROR;MIRROR_17_0_OR_NEWER;MIRROR_18_0_OR_NEWER;MIRROR_24_0_OR_NEWER;MIRROR_26_0_OR_NEWER;MIRROR_27_0_OR_NEWER;MIRROR_28_0_OR_NEWER;MIRROR_29_0_OR_NEWER;MIRROR_30_0_OR_NEWER;MIRROR_30_5_2_OR_NEWER;MIRROR_32_1_2_OR_NEWER;MIRROR_32_1_4_OR_NEWER;MIRROR_35_0_OR_NEWER;MIRROR_35_1_OR_NEWER;MIRROR_37_0_OR_NEWER;MIRROR_38_0_OR_NEWER;MIRROR_39_0_OR_NEWER;MIRROR_40_0_OR_NEWER;MIRROR_41_0_OR_NEWER;MIRROR_42_0_OR_NEWER;MIRROR_43_0_OR_NEWER;MIRROR_44_0_OR_NEWER;MIRROR_46_0_OR_NEWER + 1: MIRROR;MIRROR_17_0_OR_NEWER;MIRROR_18_0_OR_NEWER;MIRROR_24_0_OR_NEWER;MIRROR_26_0_OR_NEWER;MIRROR_27_0_OR_NEWER;MIRROR_28_0_OR_NEWER;MIRROR_29_0_OR_NEWER;MIRROR_30_0_OR_NEWER;MIRROR_30_5_2_OR_NEWER;MIRROR_32_1_2_OR_NEWER;MIRROR_32_1_4_OR_NEWER;MIRROR_35_0_OR_NEWER;MIRROR_35_1_OR_NEWER;MIRROR_37_0_OR_NEWER;MIRROR_38_0_OR_NEWER;MIRROR_39_0_OR_NEWER;MIRROR_40_0_OR_NEWER;MIRROR_41_0_OR_NEWER;MIRROR_42_0_OR_NEWER;MIRROR_43_0_OR_NEWER;MIRROR_44_0_OR_NEWER;MIRROR_46_0_OR_NEWER;MIRROR_47_0_OR_NEWER platformArchitecture: {} scriptingBackend: {} il2cppCompilerConfiguration: {}