diff --git a/Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs b/Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs index 112701dba..47dcc3ac1 100644 --- a/Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs +++ b/Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs @@ -23,7 +23,8 @@ public static void AddDefineSymbols() "MIRROR_7_0_OR_NEWER", "MIRROR_8_0_OR_NEWER", "MIRROR_9_0_OR_NEWER", - "MIRROR_10_0_OR_NEWER" + "MIRROR_10_0_OR_NEWER", + "MIRROR_11_0_OR_NEWER" }; PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, string.Join(";", defines)); } diff --git a/Assets/Mirror/Editor/NetworkAnimatorEditor.cs b/Assets/Mirror/Editor/NetworkAnimatorEditor.cs deleted file mode 100644 index 20db50b05..000000000 --- a/Assets/Mirror/Editor/NetworkAnimatorEditor.cs +++ /dev/null @@ -1,5 +0,0 @@ -// This file was removed in Mirror 3.4.9 -// The purpose of this file is to get the old file overwritten -// when users update from the asset store to prevent a flood of errors -// from having the old file still in the project as a straggler. -// This file will be dropped from the Asset Store package in May 2019 diff --git a/Assets/Mirror/Editor/NetworkAnimatorEditor.cs.meta b/Assets/Mirror/Editor/NetworkAnimatorEditor.cs.meta deleted file mode 100644 index 1b537bc42..000000000 --- a/Assets/Mirror/Editor/NetworkAnimatorEditor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9589e903d4e98490fb1157762a307fd7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Mirror/Editor/NetworkIdentityEditor.cs b/Assets/Mirror/Editor/NetworkIdentityEditor.cs deleted file mode 100644 index 461b87d4a..000000000 --- a/Assets/Mirror/Editor/NetworkIdentityEditor.cs +++ /dev/null @@ -1 +0,0 @@ -// This file has been removed \ No newline at end of file diff --git a/Assets/Mirror/Editor/NetworkIdentityEditor.cs.meta b/Assets/Mirror/Editor/NetworkIdentityEditor.cs.meta deleted file mode 100644 index b9f412cf1..000000000 --- a/Assets/Mirror/Editor/NetworkIdentityEditor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ae4acb8316d250d4f9e9604c3b0051a4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Mirror/Editor/PreprocessorDefine.cs b/Assets/Mirror/Editor/PreprocessorDefine.cs deleted file mode 100644 index ca5fffa83..000000000 --- a/Assets/Mirror/Editor/PreprocessorDefine.cs +++ /dev/null @@ -1,4 +0,0 @@ -// This file was moved to Mirror/CompilerSymbols in Mirror 4.0 -// The purpose of this file is to get the old file overwritten -// when users update from the asset store to prevent a flood of errors -// from having the old file still in the project as a straggler. diff --git a/Assets/Mirror/Editor/PreprocessorDefine.cs.meta b/Assets/Mirror/Editor/PreprocessorDefine.cs.meta deleted file mode 100644 index cd72047f4..000000000 --- a/Assets/Mirror/Editor/PreprocessorDefine.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 42760e6965bea614ca5706a6ba059531 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Mirror/Runtime/ClientScene.cs b/Assets/Mirror/Runtime/ClientScene.cs index b763123a8..825d938aa 100644 --- a/Assets/Mirror/Runtime/ClientScene.cs +++ b/Assets/Mirror/Runtime/ClientScene.cs @@ -1,6 +1,4 @@ -using System; using System.Collections.Generic; -using System.ComponentModel; using System.Linq; using UnityEngine; using Guid = System.Guid; @@ -132,13 +130,7 @@ public static bool AddPlayer(NetworkConnection readyConn, byte[] extraData) if (LogFilter.Debug) Debug.Log("ClientScene.AddPlayer() called with connection [" + readyConnection + "]"); - AddPlayerMessage message = new AddPlayerMessage - { -#pragma warning disable CS0618 // Type or member is obsolete - value = extraData -#pragma warning restore CS0618 // Type or member is obsolete - }; - readyConnection.Send(message); + readyConnection.Send(new AddPlayerMessage()); return true; } @@ -459,20 +451,6 @@ public static void DestroyAllClientObjects() NetworkIdentity.spawned.Clear(); } - // Deprecated 01/15/2019 - /// - /// Obsolete: Use instead. - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkIdentity.spawned[netId] instead.")] - public static GameObject FindLocalObject(uint netId) - { - if (NetworkIdentity.spawned.TryGetValue(netId, out NetworkIdentity identity)) - { - return identity.gameObject; - } - return null; - } - static void ApplySpawnPayload(NetworkIdentity identity, SpawnMessage msg) { identity.Reset(); diff --git a/Assets/Mirror/Runtime/CustomAttributes.cs b/Assets/Mirror/Runtime/CustomAttributes.cs index 4610fe243..c05f3a678 100644 --- a/Assets/Mirror/Runtime/CustomAttributes.cs +++ b/Assets/Mirror/Runtime/CustomAttributes.cs @@ -1,17 +1,8 @@ using System; -using System.ComponentModel; using UnityEngine; namespace Mirror { - // Deprecated 12/31/2018 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkBehaviour.syncInterval field instead. Can be modified in the Inspector too.")] - [AttributeUsage(AttributeTargets.Class)] - public class NetworkSettingsAttribute : Attribute - { - public float sendInterval = 0.1f; - } - /// /// SyncVars are used to synchronize a variable from the server to all clients automatically. /// Value must be changed on server, not directly by clients. Hook parameter allows you to define a client-side method to be invoked when the client gets an update from the server. diff --git a/Assets/Mirror/Runtime/LocalClient.cs b/Assets/Mirror/Runtime/LocalClient.cs deleted file mode 100644 index 20db50b05..000000000 --- a/Assets/Mirror/Runtime/LocalClient.cs +++ /dev/null @@ -1,5 +0,0 @@ -// This file was removed in Mirror 3.4.9 -// The purpose of this file is to get the old file overwritten -// when users update from the asset store to prevent a flood of errors -// from having the old file still in the project as a straggler. -// This file will be dropped from the Asset Store package in May 2019 diff --git a/Assets/Mirror/Runtime/LocalClient.cs.meta b/Assets/Mirror/Runtime/LocalClient.cs.meta deleted file mode 100644 index 6c073e640..000000000 --- a/Assets/Mirror/Runtime/LocalClient.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5c4d04450e91c438385de7300abef1b6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Mirror/Runtime/MessagePacker.cs b/Assets/Mirror/Runtime/MessagePacker.cs index 1d9e9d1ec..d871de630 100644 --- a/Assets/Mirror/Runtime/MessagePacker.cs +++ b/Assets/Mirror/Runtime/MessagePacker.cs @@ -30,30 +30,6 @@ public static int GetId(Type type) return type.FullName.GetStableHashCode() & 0xFFFF; } - // pack message before sending - // -> NetworkWriter passed as arg so that we can use .ToArraySegment - // and do an allocation free send before recycling it. - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use Pack instead")] - public static byte[] PackMessage(int msgType, MessageBase msg) - { - using (PooledNetworkWriter writer = NetworkWriterPool.GetWriter()) - { - try - { - // write message type - writer.WriteInt16((short)msgType); - - // serialize message into writer - msg.Serialize(writer); - - // return byte[] - return writer.ToArray(); - } - finally { } - } - } - // pack message before sending // -> NetworkWriter passed as arg so that we can use .ToArraySegment // and do an allocation free send before recycling it. @@ -122,7 +98,10 @@ public static bool UnpackMessage(NetworkReader messageReader, out int msgType) } } - internal static NetworkMessageDelegate MessageHandler(Action handler, bool requireAuthenication) where T : IMessageBase, new() => networkMessage => + internal static NetworkMessageDelegate MessageHandler(Action handler, bool requireAuthenication) + where T : IMessageBase, new() + where C : NetworkConnection + => (conn, reader, channelId) => { // protect against DOS attacks if attackers try to send invalid // data packets to crash the server/client. there are a thousand @@ -139,29 +118,30 @@ public static bool UnpackMessage(NetworkReader messageReader, out int msgType) T message = default; try { - if (requireAuthenication && !networkMessage.conn.isAuthenticated) + if (requireAuthenication && !conn.isAuthenticated) { // message requires authentication, but the connection was not authenticated - Debug.LogWarning($"Closing connection: {networkMessage.conn}. Received message {typeof(T)} that required authentication, but the user has not authenticated yet"); - networkMessage.conn.Disconnect(); + Debug.LogWarning($"Closing connection: {conn}. Received message {typeof(T)} that required authentication, but the user has not authenticated yet"); + conn.Disconnect(); return; } - message = networkMessage.ReadMessage(); + message = typeof(T).IsValueType ? default(T) : new T(); + message.Deserialize(reader); } catch (Exception exception) { - Debug.LogError("Closed connection: " + networkMessage.conn + ". This can happen if the other side accidentally (or an attacker intentionally) sent invalid data. Reason: " + exception); - networkMessage.conn.Disconnect(); + Debug.LogError("Closed connection: " + conn + ". This can happen if the other side accidentally (or an attacker intentionally) sent invalid data. Reason: " + exception); + conn.Disconnect(); return; } finally { // TODO: Figure out the correct channel - NetworkDiagnostics.OnReceive(message, networkMessage.channelId, networkMessage.reader.Length); + NetworkDiagnostics.OnReceive(message, channelId, reader.Length); } - handler(networkMessage.conn, message); + handler((C)conn, message); }; } } diff --git a/Assets/Mirror/Runtime/Messages.cs b/Assets/Mirror/Runtime/Messages.cs index ee5a59737..c7eadac2c 100644 --- a/Assets/Mirror/Runtime/Messages.cs +++ b/Assets/Mirror/Runtime/Messages.cs @@ -19,138 +19,6 @@ public virtual void Deserialize(NetworkReader reader) { } public virtual void Serialize(NetworkWriter writer) { } } - #region General Typed Messages - - // Deprecated 11/20/2019 - [Obsolete("Create your own message class instead")] - public class StringMessage : MessageBase - { - public string value; - - public StringMessage() { } - - public StringMessage(string v) - { - value = v; - } - - public override void Deserialize(NetworkReader reader) - { - value = reader.ReadString(); - } - - public override void Serialize(NetworkWriter writer) - { - writer.WriteString(value); - } - } - - // Deprecated 11/20/2019 - [Obsolete("Create your own message class instead")] - public class ByteMessage : MessageBase - { - public byte value; - - public ByteMessage() { } - - public ByteMessage(byte v) - { - value = v; - } - - public override void Deserialize(NetworkReader reader) - { - value = reader.ReadByte(); - } - - public override void Serialize(NetworkWriter writer) - { - writer.WriteByte(value); - } - } - - // Deprecated 11/20/2019 - [Obsolete("Create your own message class instead")] - public class BytesMessage : MessageBase - { - public byte[] value; - - public BytesMessage() { } - - public BytesMessage(byte[] v) - { - value = v; - } - - public override void Deserialize(NetworkReader reader) - { - value = reader.ReadBytesAndSize(); - } - - public override void Serialize(NetworkWriter writer) - { - writer.WriteBytesAndSize(value); - } - } - - // Deprecated 11/20/2019 - [Obsolete("Create your own message class instead")] - public class IntegerMessage : MessageBase - { - public int value; - - public IntegerMessage() { } - - public IntegerMessage(int v) - { - value = v; - } - - public override void Deserialize(NetworkReader reader) - { - value = reader.ReadPackedInt32(); - } - - public override void Serialize(NetworkWriter writer) - { - writer.WritePackedInt32(value); - } - } - - // Deprecated 11/20/2019 - [Obsolete("Create your own message class instead")] - public class DoubleMessage : MessageBase - { - public double value; - - public DoubleMessage() { } - - public DoubleMessage(double v) - { - value = v; - } - - public override void Deserialize(NetworkReader reader) - { - value = reader.ReadDouble(); - } - - public override void Serialize(NetworkWriter writer) - { - writer.WriteDouble(value); - } - } - - // Deprecated 11/20/2019 - [Obsolete("Create your own message class instead")] - public class EmptyMessage : MessageBase - { - public override void Deserialize(NetworkReader reader) { } - - public override void Serialize(NetworkWriter writer) { } - } - #endregion - #region Public System Messages public struct ErrorMessage : IMessageBase { @@ -188,32 +56,9 @@ public void Serialize(NetworkWriter writer) { } public struct AddPlayerMessage : IMessageBase { - // Deprecated 09/29/2019 - /// - /// Obsolete: Create your own message instead. See Custom Players - /// - [Obsolete("Create your own message instead. See https://mirror-networking.com/docs/Guides/GameObjects/SpawnPlayerCustom.html")] - public byte[] value; + public void Deserialize(NetworkReader reader) { } - // Deprecated 09/29/2019 - /// - /// Obsolete: Create your own message instead. See Custom Players - /// - [Obsolete("Create your own message instead. See https://mirror-networking.com/docs/Guides/GameObjects/SpawnPlayerCustom.html")] - public void Deserialize(NetworkReader reader) - { - value = reader.ReadBytesAndSize(); - } - - // Deprecated 09/29/2019 - /// - /// Obsolete: Create your own message instead. See Custom Players - /// - [Obsolete("Create your own message instead. See https://mirror-networking.com/docs/Guides/GameObjects/SpawnPlayerCustom.html")] - public void Serialize(NetworkWriter writer) - { - writer.WriteBytesAndSize(value); - } + public void Serialize(NetworkWriter writer) { } } public struct RemovePlayerMessage : IMessageBase diff --git a/Assets/Mirror/Runtime/NetworkBehaviour.cs b/Assets/Mirror/Runtime/NetworkBehaviour.cs index dc37f42fe..6c3354fae 100644 --- a/Assets/Mirror/Runtime/NetworkBehaviour.cs +++ b/Assets/Mirror/Runtime/NetworkBehaviour.cs @@ -102,13 +102,6 @@ protected void setSyncVarHookGuard(ulong dirtyBit, bool value) syncVarHookGuard &= ~dirtyBit; } - // Deprecated 04/07/2019 - /// - /// Obsolete: Use instead. - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use syncObjects instead.")] - protected List m_SyncObjects => syncObjects; - /// /// objects that can synchronize themselves, such as synclists /// @@ -819,10 +812,6 @@ public virtual bool OnRebuildObservers(HashSet observers, boo return false; } - // Deprecated 11/21/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Rename to OnSetHostVisibility instead.")] - public virtual void OnSetLocalVisibility(bool visible) { } - /// /// Callback used by the visibility system for objects on a host. /// Objects on a host (with a local client) cannot be disabled or destroyed when they are not visibile to the local client. So this function is called to allow custom code to hide these objects. A typical implementation will disable renderer components on the object. This is only called on local clients on a host. diff --git a/Assets/Mirror/Runtime/NetworkClient.cs b/Assets/Mirror/Runtime/NetworkClient.cs index 64ddf2ab0..d9966b1e2 100644 --- a/Assets/Mirror/Runtime/NetworkClient.cs +++ b/Assets/Mirror/Runtime/NetworkClient.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using UnityEngine; namespace Mirror @@ -13,31 +12,14 @@ public enum ConnectState Disconnected } - // TODO make fully static after removing obsoleted singleton! /// /// This is a network client class used by the networking system. It contains a NetworkConnection that is used to connect to a network server. /// The NetworkClient handle connection state, messages handlers, and connection configuration. There can be many NetworkClient instances in a process at a time, but only one that is connected to a game server (NetworkServer) that uses spawned objects. /// NetworkClient has an internal update function where it handles events from the transport layer. This includes asynchronous connect events, disconnect events and incoming data from a server. /// The NetworkManager has a NetworkClient instance that it uses for games that it starts, but the NetworkClient may be used by itself. /// - public class NetworkClient + public static class NetworkClient { - // Deprecated 03/25/2019 - /// - /// Obsolete: Use directly. - /// Singleton isn't needed anymore, all functions are static now. For example: NetworkClient.Send(message) instead of NetworkClient.singleton.Send(message). - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkClient directly. Singleton isn't needed anymore, all functions are static now. For example: NetworkClient.Send(message) instead of NetworkClient.singleton.Send(message).")] - public static NetworkClient singleton = new NetworkClient(); - - // Deprecated 03/25/2019 - /// - /// A list of all the active network clients in the current process. - /// This is NOT a list of all clients that are connected to the remote server, it is client instances on the local game. - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkClient directly instead. There is always exactly one client.")] - public static List allClients => new List { singleton }; - /// /// The registered network message handlers. /// @@ -228,26 +210,6 @@ static void RemoveTransportHandlers() Transport.activeTransport.OnClientError.RemoveListener(OnError); } - // Deprecated 03/03/2019 - /// - /// Obsolete: Use instead with no message id instead - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use Send instead with no message id instead")] - public static bool Send(short msgType, MessageBase msg) - { - if (connection != null) - { - if (connectState != ConnectState.Connected) - { - Debug.LogError("NetworkClient Send when not connected to a server"); - return false; - } - return connection.Send(msgType, msg); - } - Debug.LogError("NetworkClient Send with no connection"); - return false; - } - /// /// This sends a network message with a message Id to the server. This message is sent on channel zero, which by default is the reliable channel. /// The message must be an instance of a class derived from MessageBase. @@ -290,62 +252,6 @@ internal static void Update() } } - /* TODO use or remove - void GenerateConnectError(byte error) - { - Debug.LogError("Mirror Client Error Connect Error: " + error); - GenerateError(error); - } - - void GenerateDataError(byte error) - { - NetworkError dataError = (NetworkError)error; - Debug.LogError("Mirror Client Data Error: " + dataError); - GenerateError(error); - } - - void GenerateDisconnectError(byte error) - { - NetworkError disconnectError = (NetworkError)error; - Debug.LogError("Mirror Client Disconnect Error: " + disconnectError); - GenerateError(error); - } - - void GenerateError(byte error) - { - int msgId = MessageBase.GetId(); - if (handlers.TryGetValue(msgId, out NetworkMessageDelegate msgDelegate)) - { - ErrorMessage msg = new ErrorMessage - { - value = error - }; - - // write the message to a local buffer - NetworkWriter writer = new NetworkWriter(); - msg.Serialize(writer); - - NetworkMessage netMsg = new NetworkMessage - { - msgType = msgId, - reader = new NetworkReader(writer.ToArray()), - conn = connection - }; - msgDelegate(netMsg); - } - } - */ - - // Deprecated 10/05/2018 - /// - /// Obsolete: Use instead - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkTime.rtt instead")] - public static float GetRTT() - { - return (float)NetworkTime.rtt; - } - internal static void RegisterSystemHandlers(bool hostMode) { // host mode client / regular client react to some messages differently. @@ -375,30 +281,6 @@ internal static void RegisterSystemHandlers(bool hostMode) RegisterHandler(ClientScene.OnSyncEventMessage); } - // Deprecated 03/03/2019 - /// - /// Obsolete: Use instead - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use RegisterHandler instead")] - public static void RegisterHandler(int msgType, NetworkMessageDelegate handler) - { - if (handlers.ContainsKey(msgType)) - { - if (LogFilter.Debug) Debug.Log("NetworkClient.RegisterHandler replacing " + handler + " - " + msgType); - } - handlers[msgType] = handler; - } - - // Deprecated 03/03/2019 - /// - /// Obsolete: Use instead - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use RegisterHandler instead")] - public static void RegisterHandler(MsgType msgType, NetworkMessageDelegate handler) - { - RegisterHandler((int)msgType, handler); - } - /// /// Register a handler for a particular message type. /// There are several system message types which you can add handlers for. You can also add your own message types. @@ -413,7 +295,7 @@ public static void RegisterHandler(MsgType msgType, NetworkMessageDelegate handl { if (LogFilter.Debug) Debug.Log("NetworkClient.RegisterHandler replacing " + handler + " - " + msgType); } - handlers[msgType] = MessagePacker.MessageHandler(handler, requireAuthentication); + handlers[msgType] = MessagePacker.MessageHandler(handler, requireAuthentication); } /// @@ -428,26 +310,6 @@ public static void RegisterHandler(MsgType msgType, NetworkMessageDelegate handl RegisterHandler((NetworkConnection _, T value) => { handler(value); }, requireAuthentication); } - // Deprecated 03/03/2019 - /// - /// Obsolete: Use instead - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use UnregisterHandler instead")] - public static void UnregisterHandler(int msgType) - { - handlers.Remove(msgType); - } - - // Deprecated 03/03/2019 - /// - /// Obsolete: Use instead - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use UnregisterHandler instead")] - public static void UnregisterHandler(MsgType msgType) - { - UnregisterHandler((int)msgType); - } - /// /// Unregisters a network message handler. /// @@ -475,15 +337,5 @@ public static void Shutdown() // supposed to be shut down too! Transport.activeTransport.ClientDisconnect(); } - - // Deprecated 03/22/2019 - /// - /// Obsolete: Call instead. There is only one client. - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Call Shutdown() instead. There is only one client.")] - public static void ShutdownAll() - { - Shutdown(); - } } } diff --git a/Assets/Mirror/Runtime/NetworkConnection.cs b/Assets/Mirror/Runtime/NetworkConnection.cs index 596ac23eb..d99728b82 100644 --- a/Assets/Mirror/Runtime/NetworkConnection.cs +++ b/Assets/Mirror/Runtime/NetworkConnection.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using UnityEngine; namespace Mirror @@ -62,23 +61,6 @@ public abstract class NetworkConnection : IDisposable /// public float lastMessageTime; - /// - /// Obsolete: use instead - /// - // Deprecated 09/18/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkConnection.identity instead")] - public NetworkIdentity playerController - { - get - { - return identity; - } - internal set - { - identity = value; - } - } - /// /// The NetworkIdentity for this connection. /// @@ -103,18 +85,6 @@ internal set /// public bool logNetworkMessages; - // this is always true for regular connections, false for local - // connections because it's set in the constructor and never reset. - // Deprecated 02/26/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("isConnected will be removed because it's pointless. A NetworkConnection is always connected.")] - public bool isConnected { get; protected set; } - - // this is always 0 for regular connections, -1 for local - // connections because it's set in the constructor and never reset. - // Deprecated 02/26/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("hostId will be removed because it's not needed ever since we removed LLAPI as default. It's always 0 for regular connections and -1 for local connections. Use connection.GetType() == typeof(NetworkConnection) to check if it's a regular or local connection.")] - public int hostId = -1; - /// /// Creates a new NetworkConnection with the specified address /// @@ -129,10 +99,6 @@ internal NetworkConnection() internal NetworkConnection(int networkConnectionId) { connectionId = networkConnectionId; -#pragma warning disable 618 - isConnected = true; - hostId = 0; -#pragma warning restore 618 } ~NetworkConnection() @@ -167,42 +133,6 @@ internal void SetHandlers(Dictionary handlers) messageHandlers = handlers; } - // Deprecated 04/09/2019 - /// - /// Obsolete: Use or instead - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkClient/NetworkServer.RegisterHandler instead")] - public void RegisterHandler(short msgType, NetworkMessageDelegate handler) - { - if (messageHandlers.ContainsKey(msgType)) - { - if (LogFilter.Debug) Debug.Log("NetworkConnection.RegisterHandler replacing " + msgType); - } - messageHandlers[msgType] = handler; - } - - // Deprecated 04/09/2019 - /// - /// Obsolete: Use and instead - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkClient/NetworkServer.UnregisterHandler instead")] - public void UnregisterHandler(short msgType) - { - messageHandlers.Remove(msgType); - } - - // Deprecated 03/03/2019 - /// - /// Obsolete: use instead - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("use Send(msg, channelId) instead")] - public bool Send(int msgType, MessageBase msg, int channelId = Channels.DefaultReliable) - { - // pack message and send - byte[] message = MessagePacker.PackMessage(msgType, msg); - return Send(new ArraySegment(message), channelId); - } - /// /// This sends a network message with a message ID on the connection. This message is sent on channel zero, which by default is the reliable channel. /// @@ -282,29 +212,11 @@ internal void RemoveObservers() visList.Clear(); } - // Deprecated 04/03/2019 - /// - /// Obsolete: Use instead - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use InvokeHandler instead")] - public bool InvokeHandlerNoData(int msgType) - { - return InvokeHandler(msgType, null, -1); - } - internal bool InvokeHandler(int msgType, NetworkReader reader, int channelId) { if (messageHandlers.TryGetValue(msgType, out NetworkMessageDelegate msgDelegate)) { - NetworkMessage message = new NetworkMessage - { - msgType = msgType, - reader = reader, - conn = this, - channelId = channelId - }; - - msgDelegate(message); + msgDelegate(this, reader, channelId); return true; } Debug.LogError("Unknown message ID " + msgType + " " + this); diff --git a/Assets/Mirror/Runtime/NetworkIdentity.cs b/Assets/Mirror/Runtime/NetworkIdentity.cs index ccd5c914f..8b86a57fd 100644 --- a/Assets/Mirror/Runtime/NetworkIdentity.cs +++ b/Assets/Mirror/Runtime/NetworkIdentity.cs @@ -109,13 +109,6 @@ public sealed class NetworkIdentity : MonoBehaviour [FormerlySerializedAs("m_ServerOnly")] public bool serverOnly; - /// - /// Obsolete: Use instead - /// - // Deprecated 11/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use connectionToClient instead")] - public NetworkConnectionToClient clientAuthorityOwner => connectionToClient; - /// /// The NetworkConnection associated with this NetworkIdentity. This is only valid for player objects on a local client. /// @@ -189,13 +182,6 @@ internal set // keep track of all sceneIds to detect scene duplicates static readonly Dictionary sceneIds = new Dictionary(); - /// - /// Obsolete: Use instead - /// - // Deprecated 01/23/2020 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use GetSceneIdentity instead")] - public static NetworkIdentity GetSceneIdenity(ulong id) => GetSceneIdentity(id); - /// /// Gets the NetworkIdentity from the sceneIds dictionary with the corresponding id /// @@ -655,9 +641,6 @@ internal void OnSetHostVisibility(bool visible) { try { -#pragma warning disable 618 - comp.OnSetLocalVisibility(visible); // remove later! -#pragma warning restore 618 comp.OnSetHostVisibility(visible); } catch (Exception e) @@ -1154,19 +1137,6 @@ public bool AssignClientAuthority(NetworkConnection conn) return true; } - // Deprecated 09/25/2019 - /// - /// Obsolete: Use instead - /// - /// The connection of the client to remove authority for. - /// True if authority is removed. - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("NetworkConnection parameter is no longer needed and nothing is returned")] - public bool RemoveClientAuthority(NetworkConnection conn) - { - RemoveClientAuthority(); - return true; - } - /// /// Removes ownership for an object. /// This applies to objects that had authority set by AssignClientAuthority, or NetworkServer.Spawn with a NetworkConnection parameter included. diff --git a/Assets/Mirror/Runtime/NetworkManager.cs b/Assets/Mirror/Runtime/NetworkManager.cs index 11647b144..e71c0f016 100644 --- a/Assets/Mirror/Runtime/NetworkManager.cs +++ b/Assets/Mirror/Runtime/NetworkManager.cs @@ -162,28 +162,6 @@ public class NetworkManager : MonoBehaviour [NonSerialized] public bool clientLoadedScene; - // Deprecated 03/27/2019 - /// - /// Obsolete: Use instead - /// - /// Returns True if NetworkClient.isConnected - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkClient.isConnected instead")] - public bool IsClientConnected() - { - return NetworkClient.isConnected; - } - - // Deprecated 04/09/2019 - /// - /// Obsolete: Use instead. - /// This is a static property now. This method will be removed by summer 2019. - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use isHeadless instead of IsHeadless()")] - public static bool IsHeadless() - { - return isHeadless; - } - /// /// headless mode detection /// @@ -197,14 +175,6 @@ public static bool IsHeadless() // during FinishLoadScene. public NetworkManagerMode mode { get; private set; } - // Deprecated 03/25/2019 - /// - /// Obsolete: Use directly - /// For example, use NetworkClient.Send(message) instead of NetworkManager.client.Send(message) - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkClient directly, it will be made static soon. For example, use NetworkClient.Send(message) instead of NetworkManager.client.Send(message)")] - public NetworkClient client => NetworkClient.singleton; - #region Unity Callbacks /// @@ -1131,7 +1101,7 @@ void OnServerReadyMessageInternal(NetworkConnection conn, ReadyMessage msg) OnServerReady(conn); } - void OnServerAddPlayerInternal(NetworkConnection conn, AddPlayerMessage extraMessage) + void OnServerAddPlayerInternal(NetworkConnection conn, AddPlayerMessage msg) { if (LogFilter.Debug) Debug.Log("NetworkManager.OnServerAddPlayer"); @@ -1153,9 +1123,7 @@ void OnServerAddPlayerInternal(NetworkConnection conn, AddPlayerMessage extraMes return; } -#pragma warning disable CS0618 // Type or member is obsolete - OnServerAddPlayer(conn, extraMessage); -#pragma warning restore CS0618 // Type or member is obsolete + OnServerAddPlayer(conn); } void OnServerRemovePlayerMessageInternal(NetworkConnection conn, RemovePlayerMessage msg) @@ -1287,17 +1255,6 @@ public virtual void OnServerReady(NetworkConnection conn) NetworkServer.SetClientReady(conn); } - // Deprecated 10/02/2019 - /// - /// Obsolete: Override instead. - /// See Custom Players for details. - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Override OnServerAddPlayer(NetworkConnection conn) instead. See https://mirror-networking.com/docs/Guides/GameObjects/SpawnPlayerCustom.html for details.")] - public virtual void OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage) - { - OnServerAddPlayer(conn); - } - /// /// Called on the server when a client adds a new player with ClientScene.AddPlayer. /// The default implementation for this function creates a new player object from the playerPrefab. @@ -1421,16 +1378,6 @@ public virtual void OnClientError(NetworkConnection conn, int errorCode) { } /// Connection to the server. public virtual void OnClientNotReady(NetworkConnection conn) { } - // Deprecated 09/17/2019 - /// - /// Obsolete: Use instead.). - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Override OnClientChangeScene(string newSceneName, SceneOperation sceneOperation, bool customHandling) instead")] - public virtual void OnClientChangeScene(string newSceneName) - { - OnClientChangeScene(newSceneName, SceneOperation.Normal, false); - } - // Deprecated 12/22/2019 /// /// Obsolete: Use instead.). @@ -1488,24 +1435,10 @@ public virtual void OnStartHost() { } /// public virtual void OnStartServer() { } - // Deprecated 03/25/2019 - /// - /// Obsolete: Use instead of OnStartClient(NetworkClient client). - /// All NetworkClient functions are static now, so you can use NetworkClient.Send(message) instead of client.Send(message) directly now. - /// - /// The NetworkClient object that was started. - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use OnStartClient() instead of OnStartClient(NetworkClient client). All NetworkClient functions are static now, so you can use NetworkClient.Send(message) instead of client.Send(message) directly now.")] - public virtual void OnStartClient(NetworkClient client) { } - /// /// This is invoked when the client is started. /// - public virtual void OnStartClient() - { -#pragma warning disable CS0618 // Type or member is obsolete - OnStartClient(NetworkClient.singleton); -#pragma warning restore CS0618 // Type or member is obsolete - } + public virtual void OnStartClient() { } /// /// This is called when a server is stopped - including when a host is stopped. diff --git a/Assets/Mirror/Runtime/NetworkMessage.cs b/Assets/Mirror/Runtime/NetworkMessage.cs index 6e4e1e990..300b10e65 100644 --- a/Assets/Mirror/Runtime/NetworkMessage.cs +++ b/Assets/Mirror/Runtime/NetworkMessage.cs @@ -1,26 +1 @@ -namespace Mirror -{ - public struct NetworkMessage - { - public int msgType; - public NetworkConnection conn; - public NetworkReader reader; - public int channelId; - - public TMsg ReadMessage() where TMsg : IMessageBase, new() - { - // Normally I would just do: - // TMsg msg = new TMsg(); - // but mono calls an expensive method Activator.CreateInstance - // For value types this is unnecesary, just use the default value - TMsg msg = typeof(TMsg).IsValueType ? default(TMsg) : new TMsg(); - msg.Deserialize(reader); - return msg; - } - - public void ReadMessage(TMsg msg) where TMsg : IMessageBase - { - msg.Deserialize(reader); - } - } -} +// file removed 03/17/2020 diff --git a/Assets/Mirror/Runtime/NetworkServer.cs b/Assets/Mirror/Runtime/NetworkServer.cs index 8b99658ea..b0f9b5945 100644 --- a/Assets/Mirror/Runtime/NetworkServer.cs +++ b/Assets/Mirror/Runtime/NetworkServer.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using UnityEngine; namespace Mirror @@ -256,27 +255,6 @@ static void SendToObservers(NetworkIdentity identity, T msg, int channelId = } } - // Deprecated 03/03/2019 - /// - /// Obsolete: Use instead. - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use SendToAll instead.")] - public static bool SendToAll(int msgType, MessageBase msg, int channelId = Channels.DefaultReliable) - { - if (LogFilter.Debug) Debug.Log("Server.SendToAll id:" + msgType); - - // pack message into byte[] once - byte[] bytes = MessagePacker.PackMessage((ushort)msgType, msg); - - // send to all - bool result = true; - foreach (KeyValuePair kvp in connections) - { - result &= kvp.Value.Send(new ArraySegment(bytes), channelId); - } - return result; - } - /// /// Send a message structure with the given type number to all connected clients. /// This applies to clients that are ready and not-ready. @@ -323,34 +301,6 @@ public static bool SendToAll(T msg, int channelId = Channels.DefaultReliable) } } - // Deprecated 03/03/2019 - /// - /// Obsolete: Use instead. - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use SendToReady instead.")] - public static bool SendToReady(NetworkIdentity identity, short msgType, MessageBase msg, int channelId = Channels.DefaultReliable) - { - if (LogFilter.Debug) Debug.Log("Server.SendToReady msgType:" + msgType); - - if (identity != null && identity.observers != null) - { - // pack message into byte[] once - byte[] bytes = MessagePacker.PackMessage((ushort)msgType, msg); - - // send to all ready observers - bool result = true; - foreach (KeyValuePair kvp in identity.observers) - { - if (kvp.Value.isReady) - { - result &= kvp.Value.Send(new ArraySegment(bytes), channelId); - } - } - return result; - } - return false; - } - /// /// Send a message structure with the given type number to only clients which are ready. /// See Networking.NetworkClient.Ready. @@ -561,30 +511,6 @@ static void OnError(int connectionId, Exception exception) Debug.LogException(exception); } - // Deprecated 03/03/2019 - /// - /// Obsolete: Use instead. - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use RegisterHandler(Action, bool) instead.")] - public static void RegisterHandler(int msgType, NetworkMessageDelegate handler) - { - if (handlers.ContainsKey(msgType)) - { - if (LogFilter.Debug) Debug.Log("NetworkServer.RegisterHandler replacing " + msgType); - } - handlers[msgType] = handler; - } - - // Deprecated 03/03/2019 - /// - /// Obsolete: Use instead. - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use RegisterHandler(Action, bool) instead.")] - public static void RegisterHandler(MsgType msgType, NetworkMessageDelegate handler) - { - RegisterHandler((int)msgType, handler); - } - /// /// Register a handler for a particular message type. /// There are several system message types which you can add handlers for. You can also add your own message types. @@ -614,26 +540,6 @@ public static void RegisterHandler(MsgType msgType, NetworkMessageDelegate handl RegisterHandler((_, value) => { handler(value); }, requireAuthentication); } - // Deprecated 03/03/2019 - /// - /// Obsolete: Use instead. - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use UnregisterHandler instead.")] - public static void UnregisterHandler(int msgType) - { - handlers.Remove(msgType); - } - - // Deprecated 03/03/2019 - /// - /// Obsolete: Use instead. - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use UnregisterHandler instead.")] - public static void UnregisterHandler(MsgType msgType) - { - UnregisterHandler((int)msgType); - } - /// /// Unregisters a handler for a particular message type. /// @@ -652,53 +558,6 @@ public static void ClearHandlers() handlers.Clear(); } - // Deprecated 03/03/2019 - /// - /// Obsolete: Use instead. - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkConnection.Send(msg) instead.")] - public static void SendToClient(int connectionId, int msgType, MessageBase msg) - { - if (connections.TryGetValue(connectionId, out NetworkConnectionToClient conn)) - { - conn.Send(msgType, msg); - return; - } - Debug.LogError("Failed to send message to connection ID '" + connectionId + ", not found in connection list"); - } - - // Deprecated 10/22/2019 - /// - /// Obsolete: Use instead. - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use connection.Send(msg) instead")] - public static void SendToClient(int connectionId, T msg) where T : IMessageBase - { - if (connections.TryGetValue(connectionId, out NetworkConnectionToClient conn)) - { - conn.Send(msg); - return; - } - Debug.LogError("Failed to send message to connection ID '" + connectionId + ", not found in connection list"); - } - - // Deprecated 03/03/2019 - /// - /// Obsolete: Use instead. - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use SendToClientOfPlayer instead.")] - public static void SendToClientOfPlayer(NetworkIdentity identity, int msgType, MessageBase msg) - { - if (identity != null) - { - identity.connectionToClient.Send(msgType, msg); - } - else - { - Debug.LogError("SendToClientOfPlayer: player has no NetworkIdentity: " + identity.name); - } - } - /// /// send this message to the player only /// @@ -1156,17 +1015,6 @@ static bool VerifyCanSpawn(GameObject obj) return true; } - // Deprecated 11/23/2019 - /// - /// Obsolete: Use instead. - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use Spawn(GameObject, GameObject) instead.")] - public static bool SpawnWithClientAuthority(GameObject obj, GameObject player) - { - Spawn(obj, player); - return true; - } - // Deprecated 11/23/2019 /// /// This spawns an object like NetworkServer.Spawn() but also assigns Client Authority to the specified client. @@ -1192,28 +1040,6 @@ public static void Spawn(GameObject obj, GameObject player) Spawn(obj, identity.connectionToClient); } - // Deprecated 11/23/2019 - /// - /// Use instead - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use Spawn(obj, connection) instead")] - public static bool SpawnWithClientAuthority(GameObject obj, NetworkConnection ownerConnection) - { - Spawn(obj, ownerConnection); - return true; - } - - // Deprecated 11/23/2019 - /// - /// Use instead - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use Spawn(obj, assetId, connection) instead")] - public static bool SpawnWithClientAuthority(GameObject obj, Guid assetId, NetworkConnection ownerConnection) - { - Spawn(obj, assetId, ownerConnection); - return true; - } - /// /// This spawns an object like NetworkServer.Spawn() but also assigns Client Authority to the specified client. /// This is the same as calling NetworkIdentity.AssignClientAuthority on the spawned object. @@ -1299,20 +1125,6 @@ public static void UnSpawn(GameObject obj) } } - // Deprecated 01/15/2019 - /// - /// Obsolete: Use instead. - /// - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkIdentity.spawned[netId] instead.")] - public static GameObject FindLocalObject(uint netId) - { - if (NetworkIdentity.spawned.TryGetValue(netId, out NetworkIdentity identity)) - { - return identity.gameObject; - } - return null; - } - internal static bool ValidateSceneObject(NetworkIdentity identity) { if (identity.gameObject.hideFlags == HideFlags.NotEditable || diff --git a/Assets/Mirror/Runtime/NetworkWriter.cs b/Assets/Mirror/Runtime/NetworkWriter.cs index d050950a7..54308a34c 100644 --- a/Assets/Mirror/Runtime/NetworkWriter.cs +++ b/Assets/Mirror/Runtime/NetworkWriter.cs @@ -1,5 +1,4 @@ using System; -using System.ComponentModel; using System.IO; using System.Text; using UnityEngine; @@ -85,135 +84,6 @@ public void WriteUInt64(ulong value) } public void WriteInt64(long value) => WriteUInt64((ulong)value); - - #region Obsoletes - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteUInt16 instead")] - public void Write(ushort value) => this.WriteUInt16(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteUInt32 instead")] - public void Write(uint value) => WriteUInt32(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteUInt64 instead")] - public void Write(ulong value) => WriteUInt64(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteByte instead")] - public void Write(byte value) => stream.WriteByte(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteSByte instead")] - public void Write(sbyte value) => WriteByte((byte)value); - - // write char the same way that NetworkReader reads it (2 bytes) - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteChar instead")] - public void Write(char value) => this.WriteUInt16((ushort)value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteBoolean instead")] - public void Write(bool value) => WriteByte((byte)(value ? 1 : 0)); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteInt16 instead")] - public void Write(short value) => this.WriteUInt16((ushort)value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteInt32 instead")] - public void Write(int value) => WriteUInt32((uint)value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteInt64 instead")] - public void Write(long value) => WriteUInt64((ulong)value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteSingle instead")] - public void Write(float value) => this.WriteSingle(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteDouble instead")] - public void Write(double value) => this.WriteDouble(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteDecimal instead")] - public void Write(decimal value) => this.WriteDecimal(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteString instead")] - public void Write(string value) => this.WriteString(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteBytes instead")] - public void Write(byte[] buffer, int offset, int count) => WriteBytes(buffer, offset, count); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteVector2 instead")] - public void Write(Vector2 value) => this.WriteVector2(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteVector3 instead")] - public void Write(Vector3 value) => this.WriteVector3(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteVector4 instead")] - public void Write(Vector4 value) => this.WriteVector4(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteVector2Int instead")] - public void Write(Vector2Int value) => this.WriteVector2Int(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteVector3Int instead")] - public void Write(Vector3Int value) => this.WriteVector3Int(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteColor instead")] - public void Write(Color value) => this.WriteColor(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteColor32 instead")] - public void Write(Color32 value) => this.WriteColor32(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteQuaternion instead")] - public void Write(Quaternion value) => this.WriteQuaternion(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteRect instead")] - public void Write(Rect value) => this.WriteRect(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WritePlane instead")] - public void Write(Plane value) => this.WritePlane(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteRay instead")] - public void Write(Ray value) => this.WriteRay(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteMatrix4x4 instead")] - public void Write(Matrix4x4 value) => this.WriteMatrix4x4(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteGuid instead")] - public void Write(Guid value) => this.WriteGuid(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteNetworkIdentity instead")] - public void Write(NetworkIdentity value) => this.WriteNetworkIdentity(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteTransform instead")] - public void Write(Transform value) => this.WriteTransform(value); - - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteGameObject instead")] - public void Write(GameObject value) => this.WriteGameObject(value); - - #endregion } @@ -598,12 +468,5 @@ public static void WriteMessage(this NetworkWriter writer, T msg) where T : I { msg.Serialize(writer); } - - // Deprecated 02/06/2020 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteMessage instead")] - public static void Write(this NetworkWriter writer, T msg) where T : IMessageBase - { - WriteMessage(writer, msg); - } } } diff --git a/Assets/Mirror/Runtime/SyncDictionary.cs b/Assets/Mirror/Runtime/SyncDictionary.cs index 7ed4a89b1..5160e4ee2 100644 --- a/Assets/Mirror/Runtime/SyncDictionary.cs +++ b/Assets/Mirror/Runtime/SyncDictionary.cs @@ -22,10 +22,7 @@ public enum Operation : byte OP_ADD, OP_CLEAR, OP_REMOVE, - OP_SET, - // Deprecated 12/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("SyncDictionaries now use OP_SET instead of OP_DIRTY")] - OP_DIRTY + OP_SET } struct Change diff --git a/Assets/Mirror/Runtime/SyncList.cs b/Assets/Mirror/Runtime/SyncList.cs index 5b3a4f24c..5a2134761 100644 --- a/Assets/Mirror/Runtime/SyncList.cs +++ b/Assets/Mirror/Runtime/SyncList.cs @@ -35,15 +35,6 @@ public class SyncListBool : SyncList protected override bool DeserializeItem(NetworkReader reader) => reader.ReadBoolean(); } - // Original UNET name is SyncListStruct and original Weaver weavers anything - // that contains the name 'SyncListStruct', without considering the namespace. - // Deprecated 03/20/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use SyncList instead")] - public class SyncListSTRUCT : SyncList where T : struct - { - public T GetItem(int i) => base[i]; - } - [EditorBrowsable(EditorBrowsableState.Never)] public abstract class SyncList : IList, IReadOnlyList, SyncObject { @@ -61,14 +52,8 @@ public enum Operation : byte OP_ADD, OP_CLEAR, OP_INSERT, - // Deprecated 10/21/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Lists now pass OP_REMOVEAT")] - OP_REMOVE, OP_REMOVEAT, - OP_SET, - // Deprecated 12/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Lists now use OP_SET instead of OP_DIRTY")] - OP_DIRTY + OP_SET } struct Change diff --git a/Assets/Mirror/Runtime/Transport/Transport.cs b/Assets/Mirror/Runtime/Transport/Transport.cs index dd7c74682..6cd9fd5da 100644 --- a/Assets/Mirror/Runtime/Transport/Transport.cs +++ b/Assets/Mirror/Runtime/Transport/Transport.cs @@ -2,7 +2,6 @@ // note: not all transports need a port, so add it to yours if needed. using System; using System.Collections.Generic; -using System.ComponentModel; using UnityEngine; using UnityEngine.Events; @@ -154,18 +153,6 @@ public virtual void ClientConnect(Uri uri) /// true if the client was kicked public abstract bool ServerDisconnect(int connectionId); - /// - /// Obsolete: Use instead - /// - // Removed 2/17/2019 and restored 3/2/2019 - // Deprecated 03/02/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use ServerGetClientAddress(int connectionId) instead")] - public virtual bool GetConnectionInfo(int connectionId, out string address) - { - address = ServerGetClientAddress(connectionId); - return true; - } - /// /// Get the client address /// diff --git a/Assets/Mirror/Runtime/UNetwork.cs b/Assets/Mirror/Runtime/UNetwork.cs index d63a5fc5c..19350fb6a 100644 --- a/Assets/Mirror/Runtime/UNetwork.cs +++ b/Assets/Mirror/Runtime/UNetwork.cs @@ -1,12 +1,11 @@ using System; -using System.ComponentModel; using System.Runtime.InteropServices; using UnityEngine; namespace Mirror { // Handles network messages on client and server - public delegate void NetworkMessageDelegate(NetworkMessage netMsg); + public delegate void NetworkMessageDelegate(NetworkConnection conn, NetworkReader reader, int channelId); // Handles requests to spawn objects on the client public delegate GameObject SpawnDelegate(Vector3 position, Guid assetId); @@ -24,45 +23,6 @@ public enum MirrorInvokeType SyncEvent } - // built-in system network messages - // original HLAPI uses short, so let's keep short to not break packet header etc. - // => use .ToString() to get the field name from the field value - // => we specify the short values so it's easier to look up opcodes when debugging packets - // Deprecated 03/03/2019 - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use Send with no message id instead")] - public enum MsgType : short - { - // internal system messages - cannot be replaced by user code - ObjectDestroy = 1, - Rpc = 2, - Owner = 4, - Command = 5, - SyncEvent = 7, - UpdateVars = 8, - SpawnPrefab = 3, - SpawnSceneObject = 10, - SpawnStarted = 11, - SpawnFinished = 12, - ObjectHide = 13, - LocalClientAuthority = 15, - - // public system messages - can be replaced by user code - Connect = 32, - Disconnect = 33, - Error = 34, - Ready = 35, - NotReady = 36, - AddPlayer = 37, - RemovePlayer = 38, - Scene = 39, - - // time synchronization - Ping = 43, - Pong = 44, - - Highest = 47 - } - public enum Version { Current = 1 diff --git a/Assets/Mirror/Tests/Editor/LocalConnectionTest.cs b/Assets/Mirror/Tests/Editor/LocalConnectionTest.cs index e69ea5022..d5618c707 100644 --- a/Assets/Mirror/Tests/Editor/LocalConnectionTest.cs +++ b/Assets/Mirror/Tests/Editor/LocalConnectionTest.cs @@ -8,11 +8,11 @@ namespace Mirror.Tests public class LocalConnectionTest { - class MyMessage : MessageBase + /*class MyMessage : MessageBase { public int id; public string name; - } + }*/ ULocalConnectionToClient connectionToClient; ULocalConnectionToServer connectionToServer; @@ -33,7 +33,7 @@ public void Disconnect() connectionToServer.Disconnect(); } - [Test] + /*[Test] public void ServerToClientTest() { Assert.That(connectionToClient.address, Is.EqualTo("localhost")); @@ -46,7 +46,7 @@ public void ServerToClientTest() bool invoked = false; - void handler(NetworkMessage msg) + void handler(NetworkConnection conn, NetworkReader reader, int channelId) { MyMessage received = msg.ReadMessage(); Assert.That(received.id, Is.EqualTo(3)); @@ -63,9 +63,9 @@ void handler(NetworkMessage msg) connectionToServer.Update(); Assert.True(invoked, "handler should have been invoked"); - } + }*/ - [Test] + /*[Test] public void ClientToServerTest() { Assert.That(connectionToServer.address, Is.EqualTo("localhost")); @@ -78,7 +78,7 @@ public void ClientToServerTest() bool invoked = false; - void handler(NetworkMessage msg) + void handler(NetworkConnection conn, NetworkReader reader, int channelId) { MyMessage received = msg.ReadMessage(); Assert.That(received.id, Is.EqualTo(3)); @@ -95,7 +95,7 @@ void handler(NetworkMessage msg) connectionToServer.Update(); Assert.True(invoked, "handler should have been invoked"); - } + }*/ [Test] public void ClientToServerFailTest() diff --git a/Assets/Mirror/Tests/Editor/MessageTests.cs b/Assets/Mirror/Tests/Editor/MessageTests.cs index a977ed5e7..58ce7bd75 100644 --- a/Assets/Mirror/Tests/Editor/MessageTests.cs +++ b/Assets/Mirror/Tests/Editor/MessageTests.cs @@ -227,27 +227,6 @@ public void ReadyMessageTest() fresh.Deserialize(new NetworkReader(writerData)); } - [Obsolete("The field we are testing will go away")] - [Test] - public void AddPlayerMessageTest() - { - // try setting value with constructor - AddPlayerMessage message = new AddPlayerMessage - { - value = new byte[]{1,2} - }; - - // serialize - NetworkWriter writer = new NetworkWriter(); - message.Serialize(writer); - byte[] writerData = writer.ToArray(); - - // deserialize the same data - do we get the same result? - AddPlayerMessage fresh = new AddPlayerMessage(); - fresh.Deserialize(new NetworkReader(writerData)); - Assert.That(fresh.value, Is.EqualTo(message.value)); - } - [Test] public void RemovePlayerMessageTest() { diff --git a/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs b/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs index 7c8b2e99d..791c7c544 100644 --- a/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs +++ b/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs @@ -580,7 +580,7 @@ public void AssignAndRemoveClientAuthority() owner.connectionToServer = new ULocalConnectionToServer(); int spawnCalled = 0; owner.connectionToServer.SetHandlers(new Dictionary{ - { MessagePacker.GetId(), (msg => ++spawnCalled) } + { MessagePacker.GetId(), ((conn, reader, channelId) => ++spawnCalled) } }); // assigning authority should only work on server. @@ -1254,7 +1254,7 @@ public void ServerUpdate() int ownerCalled = 0; owner.connectionToServer.SetHandlers(new Dictionary { - { MessagePacker.GetId(), (msg => ++ownerCalled) } + { MessagePacker.GetId(), ((conn, reader, channelId) => ++ownerCalled) } }); identity.connectionToClient = owner; @@ -1266,7 +1266,7 @@ public void ServerUpdate() int observerCalled = 0; observer.connectionToServer.SetHandlers(new Dictionary { - { MessagePacker.GetId(), (msg => ++observerCalled) } + { MessagePacker.GetId(), ((conn, reader, channelId) => ++observerCalled) } }); identity.observers[observer.connectionId] = observer; diff --git a/Assets/Mirror/Tests/Editor/NetworkServerTest.cs b/Assets/Mirror/Tests/Editor/NetworkServerTest.cs index a9a29500c..297ea3b37 100644 --- a/Assets/Mirror/Tests/Editor/NetworkServerTest.cs +++ b/Assets/Mirror/Tests/Editor/NetworkServerTest.cs @@ -743,7 +743,7 @@ public void SendToAllTest() int called = 0; connection.connectionToServer.SetHandlers(new Dictionary() { - { MessagePacker.GetId(), (msg => ++called) } + { MessagePacker.GetId(), ((conn, reader, channelId) => ++called) } }); NetworkServer.AddConnection(connection); @@ -847,7 +847,7 @@ public void SendToClientOfPlayer() int called = 0; connection.connectionToServer.SetHandlers(new Dictionary() { - { MessagePacker.GetId(), (msg => ++called) } + { MessagePacker.GetId(), ((conn, reader, channelId) => ++called) } }); NetworkServer.AddConnection(connection); @@ -922,7 +922,7 @@ public void ShowForConnection() int called = 0; connection.connectionToServer.SetHandlers(new Dictionary() { - { MessagePacker.GetId(), (msg => ++called) } + { MessagePacker.GetId(), ((conn, reader, channelId) => ++called) } }); NetworkServer.AddConnection(connection); @@ -972,7 +972,7 @@ public void HideForConnection() int called = 0; connection.connectionToServer.SetHandlers(new Dictionary() { - { MessagePacker.GetId(), (msg => ++called) } + { MessagePacker.GetId(), ((conn, reader, channelId) => ++called) } }); NetworkServer.AddConnection(connection); diff --git a/Assets/Mirror/Tests/Editor/WeaverTest.cs b/Assets/Mirror/Tests/Editor/WeaverTest.cs index c6319a013..27a54a2a2 100644 --- a/Assets/Mirror/Tests/Editor/WeaverTest.cs +++ b/Assets/Mirror/Tests/Editor/WeaverTest.cs @@ -78,12 +78,6 @@ public void TestCleanup() #endregion #region General tests - [Test] - public void InvalidType() - { - Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); - Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: System.AccessViolationException MirrorTest.MirrorTestPlayer/MyStruct::violatedPotato has unsupported type. Use a type supported by Mirror instead")); - } [Test] public void RecursionCount() @@ -92,36 +86,6 @@ public void RecursionCount() Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: MirrorTest.MirrorTestPlayer/Potato1 can't be serialized because it references itself")); } - [Test] - public void ClientGuardWrongClass() - { - Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); - Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: [Client] System.Void MirrorTest.MirrorTestPlayer::CantClientGuardInThisClass() must be declared in a NetworkBehaviour")); - } - - [Test] - public void ServerGuardWrongClass() - { - Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); - Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: [Server] System.Void MirrorTest.MirrorTestPlayer::CantServerGuardInThisClass() must be declared in a NetworkBehaviour")); - } - - [Test] - public void GuardCmdWrongClass() - { - Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); - Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: [Server] System.Void MirrorTest.MirrorTestPlayer::CantServerGuardInThisClass() must be declared in a NetworkBehaviour")); - Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: [Server] System.Void MirrorTest.MirrorTestPlayer::CantServerCallbackGuardInThisClass() must be declared in a NetworkBehaviour")); - Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: [Client] System.Void MirrorTest.MirrorTestPlayer::CantClientGuardInThisClass() must be declared in a NetworkBehaviour")); - Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: [Client] System.Void MirrorTest.MirrorTestPlayer::CantClientCallbackGuardInThisClass() must be declared in a NetworkBehaviour")); - } - - [Test] - public void JaggedArray() - { - Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); - Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: System.Int32[][] is an unsupported type. Jagged and multidimensional arrays are not supported")); - } #endregion #region SyncVar tests @@ -243,43 +207,6 @@ public void SyncListByteValid() #endregion - #region SyncListStruct tests - [Test] - public void SyncListStructValid() - { - Assert.That(CompilationFinishedHook.WeaveFailed, Is.False); - Assert.That(weaverErrors, Is.Empty); - } - - [Test] - public void SyncListStructGenericGeneric() - { - Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); - Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: MirrorTest.MirrorTestPlayer/MyStructClass cannot have generic elements MirrorTest.MirrorTestPlayer/MyGenericStruct`1")); - } - - [Test] - public void SyncListStructMemberGeneric() - { - Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); - Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: Cannot generate writer for generic type MirrorTest.MirrorTestPlayer/MyGenericStruct`1. Use a concrete type or provide a custom writer")); - } - - [Test] - public void SyncListStructMemberInterface() - { - Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); - Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: Cannot generate writer for interface MirrorTest.MirrorTestPlayer/IPotato. Use a concrete type or provide a custom writer")); - } - - [Test] - public void SyncListStructMemberBasicType() - { - Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); - Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: MirrorTest.MirrorTestPlayer/MyStructClass cannot have item of type MirrorTest.MirrorTestPlayer/MyStruct. Use a type supported by mirror instead")); - } - #endregion - #region NetworkBehaviour tests [Test] public void NetworkBehaviourValid() diff --git a/Assets/Mirror/Tests/Editor/WeaverTests~/ClientGuardWrongClass.cs b/Assets/Mirror/Tests/Editor/WeaverTests~/ClientGuardWrongClass.cs deleted file mode 100644 index 5eee5ce38..000000000 --- a/Assets/Mirror/Tests/Editor/WeaverTests~/ClientGuardWrongClass.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using UnityEngine; -using Mirror; - -namespace MirrorTest -{ - class MirrorTestPlayer - { - // defining a SyncListStruct here will force Weaver to do work on this class - // which will then force it to check for Server / Client guards and fail - struct MyStruct - { - int potato; - float floatingpotato; - double givemetwopotatoes; - } - class MyStructClass : SyncListSTRUCT {}; - MyStructClass Foo; - - [Client] - public void CantClientGuardInThisClass() {} - } -} diff --git a/Assets/Mirror/Tests/Editor/WeaverTests~/GuardCmdWrongClass.cs b/Assets/Mirror/Tests/Editor/WeaverTests~/GuardCmdWrongClass.cs deleted file mode 100644 index 31d5b014b..000000000 --- a/Assets/Mirror/Tests/Editor/WeaverTests~/GuardCmdWrongClass.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using UnityEngine; -using Mirror; - -namespace MirrorTest -{ - class MirrorTestPlayer - { - // defining a SyncListStruct here will force Weaver to do work on this class - // which will then force it to check for Server / Client guards and fail - struct MyStruct - { - int potato; - float floatingpotato; - double givemetwopotatoes; - } - class MyStructClass : SyncListSTRUCT {}; - MyStructClass Foo; - - [Server] - public void CantServerGuardInThisClass() {} - - [ServerCallback] - public void CantServerCallbackGuardInThisClass() {} - - [Client] - public void CantClientGuardInThisClass() {} - - [ClientCallback] - public void CantClientCallbackGuardInThisClass() {} - } -} diff --git a/Assets/Mirror/Tests/Editor/WeaverTests~/InvalidType.cs b/Assets/Mirror/Tests/Editor/WeaverTests~/InvalidType.cs deleted file mode 100644 index a2506edb9..000000000 --- a/Assets/Mirror/Tests/Editor/WeaverTests~/InvalidType.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using UnityEngine; -using Mirror; - -namespace MirrorTest -{ - class MirrorTestPlayer : NetworkBehaviour - { - struct MyStruct - { - public AccessViolationException violatedPotato; - } - - class MyStructClass : SyncListSTRUCT {}; - - MyStructClass harpseals; - } -} diff --git a/Assets/Mirror/Tests/Editor/WeaverTests~/JaggedArray.cs b/Assets/Mirror/Tests/Editor/WeaverTests~/JaggedArray.cs deleted file mode 100644 index c702f8f77..000000000 --- a/Assets/Mirror/Tests/Editor/WeaverTests~/JaggedArray.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using UnityEngine; -using Mirror; - -namespace MirrorTest -{ - class MirrorTestPlayer : NetworkBehaviour - { - // defining a SyncListStruct here will force Weaver to do work on this class - // which will then force it to check for Server / Client guards and fail - struct MyStruct - { - public int[][] jaggedArray; - public float floatingpotato; - public double givemetwopotatoes; - } - class MyStructClass : SyncListSTRUCT {}; - MyStructClass Foo; - } -} diff --git a/Assets/Mirror/Tests/Editor/WeaverTests~/ServerGuardWrongClass.cs b/Assets/Mirror/Tests/Editor/WeaverTests~/ServerGuardWrongClass.cs deleted file mode 100644 index 404df2716..000000000 --- a/Assets/Mirror/Tests/Editor/WeaverTests~/ServerGuardWrongClass.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using UnityEngine; -using Mirror; - -namespace MirrorTest -{ - class MirrorTestPlayer - { - // defining a SyncListStruct here will force Weaver to do work on this class - // which will then force it to check for Server / Client guards and fail - struct MyStruct - { - int potato; - float floatingpotato; - double givemetwopotatoes; - } - class MyStructClass : SyncListSTRUCT {}; - MyStructClass Foo; - - [Server] - public void CantServerGuardInThisClass() {} - } -}