From 442db9372efc01e75e7bb3fe5d81893edcacc862 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Mon, 7 Dec 2020 19:37:21 +0000 Subject: [PATCH 01/10] cleanup QSBAddPlayerMessage --- QuantumUNET/QSBAddPlayerMessage.cs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/QuantumUNET/QSBAddPlayerMessage.cs b/QuantumUNET/QSBAddPlayerMessage.cs index 02f07d3b..3c96b880 100644 --- a/QuantumUNET/QSBAddPlayerMessage.cs +++ b/QuantumUNET/QSBAddPlayerMessage.cs @@ -2,30 +2,28 @@ { internal class QSBAddPlayerMessage : QSBMessageBase { + public short playerControllerId; + public int msgSize; + public byte[] msgData; + public override void Deserialize(QSBNetworkReader reader) { - this.playerControllerId = (short)reader.ReadUInt16(); - this.msgData = reader.ReadBytesAndSize(); - if (this.msgData == null) + playerControllerId = reader.ReadInt16(); + msgData = reader.ReadBytesAndSize(); + if (msgData == null) { - this.msgSize = 0; + msgSize = 0; } else { - this.msgSize = this.msgData.Length; + msgSize = msgData.Length; } } public override void Serialize(QSBNetworkWriter writer) { - writer.Write((ushort)this.playerControllerId); - writer.WriteBytesAndSize(this.msgData, this.msgSize); + writer.Write(playerControllerId); + writer.WriteBytesAndSize(msgData, msgSize); } - - public short playerControllerId; - - public int msgSize; - - public byte[] msgData; } } \ No newline at end of file From 6ec83dac9418747aabe7cca714063bb97b972e26 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Mon, 7 Dec 2020 19:38:46 +0000 Subject: [PATCH 02/10] cleanup qsbreconnectmessage --- QuantumUNET/QSBReconnectMessage.cs | 34 +++++++++++++----------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/QuantumUNET/QSBReconnectMessage.cs b/QuantumUNET/QSBReconnectMessage.cs index 4cfa14ef..d4b8f344 100644 --- a/QuantumUNET/QSBReconnectMessage.cs +++ b/QuantumUNET/QSBReconnectMessage.cs @@ -4,31 +4,27 @@ namespace QuantumUNET { public class QSBReconnectMessage : QSBMessageBase { + public int oldConnectionId; + public short playerControllerId; + public NetworkInstanceId netId; + public int msgSize; + public byte[] msgData; + public override void Deserialize(QSBNetworkReader reader) { - this.oldConnectionId = (int)reader.ReadPackedUInt32(); - this.playerControllerId = (short)reader.ReadPackedUInt32(); - this.netId = reader.ReadNetworkId(); - this.msgData = reader.ReadBytesAndSize(); - this.msgSize = this.msgData.Length; + oldConnectionId = (int)reader.ReadPackedUInt32(); + playerControllerId = (short)reader.ReadPackedUInt32(); + netId = reader.ReadNetworkId(); + msgData = reader.ReadBytesAndSize(); + msgSize = msgData.Length; } public override void Serialize(QSBNetworkWriter writer) { - writer.WritePackedUInt32((uint)this.oldConnectionId); - writer.WritePackedUInt32((uint)this.playerControllerId); - writer.Write(this.netId); - writer.WriteBytesAndSize(this.msgData, this.msgSize); + writer.WritePackedUInt32((uint)oldConnectionId); + writer.WritePackedUInt32((uint)playerControllerId); + writer.Write(netId); + writer.WriteBytesAndSize(msgData, msgSize); } - - public int oldConnectionId; - - public short playerControllerId; - - public NetworkInstanceId netId; - - public int msgSize; - - public byte[] msgData; } } \ No newline at end of file From c56b23b34cb0eed0264bb9e281581a88db3f0222 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Mon, 7 Dec 2020 20:47:07 +0000 Subject: [PATCH 03/10] cleanup --- QuantumUNET/QSBNetworkClient.cs | 6 - QuantumUNET/QSBNetworkManagerHUD.cs | 154 +-- QuantumUNET/QSBNetworkManagerUNET.cs | 1016 +++----------------- QuantumUNET/QSBNetworkMigrationManager.cs | 1066 --------------------- QuantumUNET/QSBPeerAuthorityMessage.cs | 27 - QuantumUNET/QSBPeerListMessage.cs | 32 - QuantumUNET/QuantumUNET.csproj | 3 - 7 files changed, 189 insertions(+), 2115 deletions(-) delete mode 100644 QuantumUNET/QSBNetworkMigrationManager.cs delete mode 100644 QuantumUNET/QSBPeerAuthorityMessage.cs delete mode 100644 QuantumUNET/QSBPeerListMessage.cs diff --git a/QuantumUNET/QSBNetworkClient.cs b/QuantumUNET/QSBNetworkClient.cs index 8acce412..e6e4cc2b 100644 --- a/QuantumUNET/QSBNetworkClient.cs +++ b/QuantumUNET/QSBNetworkClient.cs @@ -170,12 +170,6 @@ namespace QuantumUNET return true; } - public void Connect(MatchInfo matchInfo) - { - PrepareForConnect(); - ConnectWithRelay(matchInfo); - } - public bool ReconnectToNewHost(string serverIp, int serverPort) { bool result; diff --git a/QuantumUNET/QSBNetworkManagerHUD.cs b/QuantumUNET/QSBNetworkManagerHUD.cs index d3015c63..78aed10d 100644 --- a/QuantumUNET/QSBNetworkManagerHUD.cs +++ b/QuantumUNET/QSBNetworkManagerHUD.cs @@ -8,62 +8,62 @@ namespace QuantumUNET { private void Awake() { - this.manager = base.GetComponent(); + manager = GetComponent(); } private void OnGUI() { - if (this.showGUI) + if (showGUI) { - int num = 10 + this.offsetX; - int num2 = 40 + this.offsetY; - bool flag = this.manager.client == null || this.manager.client.connection == null || this.manager.client.connection.connectionId == -1; - if (!this.manager.IsClientConnected() && !QSBNetworkServer.active && this.manager.matchMaker == null) + var num = 10 + offsetX; + var num2 = 40 + offsetY; + var flag = manager.client == null || manager.client.connection == null || manager.client.connection.connectionId == -1; + if (!manager.IsClientConnected() && !QSBNetworkServer.active) { if (flag) { if (Application.platform != RuntimePlatform.WebGLPlayer) { - if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "LAN Host(H)")) + if (GUI.Button(new Rect(num, num2, 200f, 20f), "Host")) { - this.manager.StartHost(); + manager.StartHost(); } num2 += 24; } - if (GUI.Button(new Rect((float)num, (float)num2, 105f, 20f), "LAN Client(C)")) + if (GUI.Button(new Rect(num, num2, 105f, 20f), "Connect")) { - this.manager.StartClient(); + manager.StartClient(); } - this.manager.networkAddress = GUI.TextField(new Rect((float)(num + 100), (float)num2, 95f, 20f), this.manager.networkAddress); + manager.networkAddress = GUI.TextField(new Rect(num + 100, num2, 95f, 20f), manager.networkAddress); num2 += 24; if (Application.platform == RuntimePlatform.WebGLPlayer) { - GUI.Box(new Rect((float)num, (float)num2, 200f, 25f), "( WebGL cannot be server )"); + GUI.Box(new Rect(num, num2, 200f, 25f), "( WebGL cannot be server )"); num2 += 24; } else { - if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "LAN Server Only(S)")) + if (GUI.Button(new Rect(num, num2, 200f, 20f), "LAN Server Only")) { - this.manager.StartServer(); + manager.StartServer(); } num2 += 24; } } else { - GUI.Label(new Rect((float)num, (float)num2, 200f, 20f), string.Concat(new object[] + GUI.Label(new Rect(num, num2, 200f, 20f), string.Concat(new object[] { "Connecting to ", - this.manager.networkAddress, + manager.networkAddress, ":", - this.manager.networkPort, + manager.networkPort, ".." })); num2 += 24; - if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Cancel Connection Attempt")) + if (GUI.Button(new Rect(num, num2, 200f, 20f), "Cancel Connection Attempt")) { - this.manager.StopClient(); + manager.StopClient(); } } } @@ -71,31 +71,25 @@ namespace QuantumUNET { if (QSBNetworkServer.active) { - string text = "Server: port=" + this.manager.networkPort; - if (this.manager.useWebSockets) + var text = $"Hosting on port {manager.networkPort}"; + if (manager.useWebSockets) { - text += " (Using WebSockets)"; + text += " (using WebSockets)"; } - GUI.Label(new Rect((float)num, (float)num2, 300f, 20f), text); + GUI.Label(new Rect(num, num2, 300f, 20f), text); num2 += 24; } - if (this.manager.IsClientConnected()) + if (manager.IsClientConnected()) { - GUI.Label(new Rect((float)num, (float)num2, 300f, 20f), string.Concat(new object[] - { - "Client: address=", - this.manager.networkAddress, - " port=", - this.manager.networkPort - })); + GUI.Label(new Rect(num, num2, 300f, 20f), $"Connected to {manager.networkAddress}, port {manager.networkPort}"); num2 += 24; } } - if (this.manager.IsClientConnected() && !QSBClientScene.ready) + if (manager.IsClientConnected() && !QSBClientScene.ready) { - if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Client Ready")) + if (GUI.Button(new Rect(num, num2, 200f, 20f), "Client Ready")) { - QSBClientScene.Ready(this.manager.client.connection); + QSBClientScene.Ready(manager.client.connection); if (QSBClientScene.localPlayers.Count == 0) { QSBClientScene.AddPlayer(0); @@ -103,102 +97,20 @@ namespace QuantumUNET } num2 += 24; } - if (QSBNetworkServer.active || this.manager.IsClientConnected()) + if (QSBNetworkServer.active || manager.IsClientConnected()) { - if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Stop (X)")) + if (GUI.Button(new Rect(num, num2, 200f, 20f), "Stop")) { - this.manager.StopHost(); + manager.StopHost(); } num2 += 24; } - if (!QSBNetworkServer.active && !this.manager.IsClientConnected() && flag) + if (!QSBNetworkServer.active && !manager.IsClientConnected() && flag) { num2 += 10; if (Application.platform == RuntimePlatform.WebGLPlayer) { - GUI.Box(new Rect((float)(num - 5), (float)num2, 220f, 25f), "(WebGL cannot use Match Maker)"); - } - else if (this.manager.matchMaker == null) - { - if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Enable Match Maker (M)")) - { - this.manager.StartMatchMaker(); - } - num2 += 24; - } - else - { - if (this.manager.matchInfo == null) - { - if (this.manager.matches == null) - { - if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Create Internet Match")) - { - this.manager.matchMaker.CreateMatch(this.manager.matchName, this.manager.matchSize, true, "", "", "", 0, 0, new NetworkMatch.DataResponseDelegate(this.manager.OnMatchCreate)); - } - num2 += 24; - GUI.Label(new Rect((float)num, (float)num2, 100f, 20f), "Room Name:"); - this.manager.matchName = GUI.TextField(new Rect((float)(num + 100), (float)num2, 100f, 20f), this.manager.matchName); - num2 += 24; - num2 += 10; - if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Find Internet Match")) - { - this.manager.matchMaker.ListMatches(0, 20, "", false, 0, 0, new NetworkMatch.DataResponseDelegate>(this.manager.OnMatchList)); - } - num2 += 24; - } - else - { - for (int i = 0; i < this.manager.matches.Count; i++) - { - MatchInfoSnapshot matchInfoSnapshot = this.manager.matches[i]; - if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Join Match:" + matchInfoSnapshot.name)) - { - this.manager.matchName = matchInfoSnapshot.name; - this.manager.matchMaker.JoinMatch(matchInfoSnapshot.networkId, "", "", "", 0, 0, new NetworkMatch.DataResponseDelegate(this.manager.OnMatchJoined)); - } - num2 += 24; - } - if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Back to Match Menu")) - { - this.manager.matches = null; - } - num2 += 24; - } - } - if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Change MM server")) - { - this.m_ShowServer = !this.m_ShowServer; - } - if (this.m_ShowServer) - { - num2 += 24; - if (GUI.Button(new Rect((float)num, (float)num2, 100f, 20f), "Local")) - { - this.manager.SetMatchHost("localhost", 1337, false); - this.m_ShowServer = false; - } - num2 += 24; - if (GUI.Button(new Rect((float)num, (float)num2, 100f, 20f), "Internet")) - { - this.manager.SetMatchHost("mm.unet.unity3d.com", 443, true); - this.m_ShowServer = false; - } - num2 += 24; - if (GUI.Button(new Rect((float)num, (float)num2, 100f, 20f), "Staging")) - { - this.manager.SetMatchHost("staging-mm.unet.unity3d.com", 443, true); - this.m_ShowServer = false; - } - } - num2 += 24; - GUI.Label(new Rect((float)num, (float)num2, 300f, 20f), "MM Uri: " + this.manager.matchMaker.baseUri); - num2 += 24; - if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Disable Match Maker")) - { - this.manager.StopMatchMaker(); - } - num2 += 24; + GUI.Box(new Rect(num - 5, num2, 220f, 25f), "(WebGL cannot use Match Maker)"); } } } diff --git a/QuantumUNET/QSBNetworkManagerUNET.cs b/QuantumUNET/QSBNetworkManagerUNET.cs index dac24195..8e8cb471 100644 --- a/QuantumUNET/QSBNetworkManagerUNET.cs +++ b/QuantumUNET/QSBNetworkManagerUNET.cs @@ -5,201 +5,53 @@ using System.Net; using UnityEngine; using UnityEngine.Networking; using UnityEngine.Networking.Match; -using UnityEngine.Networking.Types; using UnityEngine.SceneManagement; namespace QuantumUNET { public class QSBNetworkManagerUNET : MonoBehaviour { - public int networkPort - { - get - { - return m_NetworkPort; - } - set - { - m_NetworkPort = value; - } - } + public static QSBNetworkManagerUNET singleton; + public static string networkSceneName = ""; - public bool serverBindToIP - { - get - { - return m_ServerBindToIP; - } - set - { - m_ServerBindToIP = value; - } - } + public int networkPort { get; set; } = 7777; + public int simulatedLatency { get; set; } = 1; + public bool serverBindToIP { get; set; } + public bool dontDestroyOnLoad { get; set; } = true; + public bool runInBackground { get; set; } = true; + public bool scriptCRCCheck { get; set; } = true; + public bool autoCreatePlayer { get; set; } = true; + public bool isNetworkActive; + public bool useWebSockets { get; set; } + public bool useSimulator { get; set; } + public bool clientLoadedScene { get; set; } + public string serverBindAddress { get; set; } = ""; + public string networkAddress { get; set; } = "localhost"; + public string offlineScene { get; set; } = ""; + public string onlineScene { get; set; } = ""; + public float packetLossPercentage { get; set; } + public float maxDelay { get; set; } = 0.01f; + public GameObject playerPrefab { get; set; } + public PlayerSpawnMethod playerSpawnMethod { get; set; } + public List spawnPrefabs { get; } = new List(); + public string matchName = "default"; + public uint matchSize = 4U; + public QSBNetworkClient client; + public int maxConnections { get; set; } = 4; + public List channels { get; } = new List(); - public string serverBindAddress - { - get - { - return m_ServerBindAddress; - } - set - { - m_ServerBindAddress = value; - } - } - - public string networkAddress - { - get - { - return m_NetworkAddress; - } - set - { - m_NetworkAddress = value; - } - } - - public bool dontDestroyOnLoad - { - get - { - return m_DontDestroyOnLoad; - } - set - { - m_DontDestroyOnLoad = value; - } - } - - public bool runInBackground - { - get - { - return m_RunInBackground; - } - set - { - m_RunInBackground = value; - } - } - - public bool scriptCRCCheck - { - get - { - return m_ScriptCRCCheck; - } - set - { - m_ScriptCRCCheck = value; - } - } - - [Obsolete("moved to NetworkMigrationManager")] - public bool sendPeerInfo - { - get - { - return false; - } - set - { - } - } - - public float maxDelay - { - get - { - return m_MaxDelay; - } - set - { - m_MaxDelay = value; - } - } - - public LogFilter.FilterLevel logLevel - { - get - { - return m_LogLevel; - } - set - { - m_LogLevel = value; - LogFilter.currentLogLevel = (int)value; - } - } - - public GameObject playerPrefab - { - get - { - return m_PlayerPrefab; - } - set - { - m_PlayerPrefab = value; - } - } - - public bool autoCreatePlayer - { - get - { - return m_AutoCreatePlayer; - } - set - { - m_AutoCreatePlayer = value; - } - } - - public PlayerSpawnMethod playerSpawnMethod - { - get - { - return m_PlayerSpawnMethod; - } - set - { - m_PlayerSpawnMethod = value; - } - } - - public string offlineScene - { - get - { - return m_OfflineScene; - } - set - { - m_OfflineScene = value; - } - } - - public string onlineScene - { - get - { - return m_OnlineScene; - } - set - { - m_OnlineScene = value; - } - } - - public List spawnPrefabs - { - get - { - return m_SpawnPrefabs; - } - } + private ConnectionConfig m_ConnectionConfig; + private GlobalConfig m_GlobalConfig; + private int m_MaxBufferedPackets = 16; + private bool m_AllowFragmentation = true; + private static List s_StartPositions = new List(); + private static int s_StartPositionIndex; + private static QSBAddPlayerMessage s_AddPlayerMessage = new QSBAddPlayerMessage(); + private static QSBRemovePlayerMessage s_RemovePlayerMessage = new QSBRemovePlayerMessage(); + private static QSBErrorMessage s_ErrorMessage = new QSBErrorMessage(); + private static AsyncOperation s_LoadingSceneAsync; + private static QSBNetworkConnection s_ClientReadyConnection; + private static string s_Address; public List startPositions { @@ -209,17 +61,7 @@ namespace QuantumUNET } } - public bool customConfig - { - get - { - return m_CustomConfig; - } - set - { - m_CustomConfig = value; - } - } + public bool customConfig { get; set; } public ConnectionConfig connectionConfig { @@ -245,141 +87,17 @@ namespace QuantumUNET } } - public int maxConnections - { - get - { - return m_MaxConnections; - } - set - { - m_MaxConnections = value; - } - } - - public List channels - { - get - { - return m_Channels; - } - } - - public EndPoint secureTunnelEndpoint - { - get - { - return m_EndPoint; - } - set - { - m_EndPoint = value; - } - } - - public bool useWebSockets - { - get - { - return m_UseWebSockets; - } - set - { - m_UseWebSockets = value; - } - } - - public bool useSimulator - { - get - { - return m_UseSimulator; - } - set - { - m_UseSimulator = value; - } - } - - public int simulatedLatency - { - get - { - return m_SimulatedLatency; - } - set - { - m_SimulatedLatency = value; - } - } - - public float packetLossPercentage - { - get - { - return m_PacketLossPercentage; - } - set - { - m_PacketLossPercentage = value; - } - } - - public string matchHost - { - get - { - return m_MatchHost; - } - set - { - m_MatchHost = value; - } - } - - public int matchPort - { - get - { - return m_MatchPort; - } - set - { - m_MatchPort = value; - } - } - - public bool clientLoadedScene - { - get - { - return m_ClientLoadedScene; - } - set - { - m_ClientLoadedScene = value; - } - } - - public QSBNetworkMigrationManager migrationManager - { - get - { - return m_MigrationManager; - } - } - public int numPlayers { get { - int num = 0; - for (int i = 0; i < QSBNetworkServer.connections.Count; i++) + var num = 0; + for (var i = 0; i < QSBNetworkServer.connections.Count; i++) { - QSBNetworkConnection networkConnection = QSBNetworkServer.connections[i]; + var networkConnection = QSBNetworkServer.connections[i]; if (networkConnection != null) { - for (int j = 0; j < networkConnection.PlayerControllers.Count; j++) + for (var j = 0; j < networkConnection.PlayerControllers.Count; j++) { if (networkConnection.PlayerControllers[j].IsValid) { @@ -401,12 +119,7 @@ namespace QuantumUNET { if (!(singleton != null) || !(singleton == this)) { - int logLevel = (int)m_LogLevel; - if (logLevel != -1) - { - LogFilter.currentLogLevel = logLevel; - } - if (m_DontDestroyOnLoad) + if (dontDestroyOnLoad) { if (singleton != null) { @@ -426,80 +139,13 @@ namespace QuantumUNET Debug.Log("NetworkManager created singleton (ForScene)"); singleton = this; } - if (m_NetworkAddress != "") + if (networkAddress != "") { - s_Address = m_NetworkAddress; + s_Address = networkAddress; } else if (s_Address != "") { - m_NetworkAddress = s_Address; - } - } - } - - private void OnValidate() - { - if (m_SimulatedLatency < 1) - { - m_SimulatedLatency = 1; - } - if (m_SimulatedLatency > 500) - { - m_SimulatedLatency = 500; - } - if (m_PacketLossPercentage < 0f) - { - m_PacketLossPercentage = 0f; - } - if (m_PacketLossPercentage > 99f) - { - m_PacketLossPercentage = 99f; - } - if (m_MaxConnections <= 0) - { - m_MaxConnections = 1; - } - if (m_MaxConnections > 32000) - { - m_MaxConnections = 32000; - } - if (m_MaxBufferedPackets <= 0) - { - m_MaxBufferedPackets = 0; - } - if (m_MaxBufferedPackets > 512) - { - m_MaxBufferedPackets = 512; - if (LogFilter.logError) - { - Debug.LogError("NetworkManager - MaxBufferedPackets cannot be more than " + 512); - } - } - if (m_PlayerPrefab != null && m_PlayerPrefab.GetComponent() == null) - { - if (LogFilter.logError) - { - Debug.LogError("NetworkManager - playerPrefab must have a NetworkIdentity."); - } - m_PlayerPrefab = null; - } - if (m_ConnectionConfig != null && m_ConnectionConfig.MinUpdateTimeout <= 0U) - { - if (LogFilter.logError) - { - Debug.LogError("NetworkManager MinUpdateTimeout cannot be zero or less. The value will be reset to 1 millisecond"); - } - m_ConnectionConfig.MinUpdateTimeout = 1U; - } - if (m_GlobalConfig != null) - { - if (m_GlobalConfig.ThreadAwakeTimeout <= 0U) - { - if (LogFilter.logError) - { - Debug.LogError("NetworkManager ThreadAwakeTimeout cannot be zero or less. The value will be reset to 1 millisecond"); - } - m_GlobalConfig.ThreadAwakeTimeout = 1U; + networkAddress = s_Address; } } } @@ -514,11 +160,6 @@ namespace QuantumUNET QSBNetworkServer.RegisterHandler(34, new QSBNetworkMessageDelegate(OnServerErrorInternal)); } - public void SetupMigrationManager(QSBNetworkMigrationManager man) - { - m_MigrationManager = man; - } - public bool StartServer(ConnectionConfig config, int maxConnections) { return StartServer(null, config, maxConnections); @@ -538,24 +179,24 @@ namespace QuantumUNET { InitializeSingleton(); OnStartServer(); - if (m_RunInBackground) + if (runInBackground) { Application.runInBackground = true; } QSBNetworkCRC.scriptCRCCheck = scriptCRCCheck; - QSBNetworkServer.useWebSockets = m_UseWebSockets; + QSBNetworkServer.useWebSockets = useWebSockets; if (m_GlobalConfig != null) { NetworkTransport.Init(m_GlobalConfig); } - if (m_CustomConfig && m_ConnectionConfig != null && config == null) + if (customConfig && m_ConnectionConfig != null && config == null) { m_ConnectionConfig.Channels.Clear(); - for (int i = 0; i < m_Channels.Count; i++) + for (var i = 0; i < channels.Count; i++) { - m_ConnectionConfig.AddChannel(m_Channels[i]); + m_ConnectionConfig.AddChannel(channels[i]); } - QSBNetworkServer.Configure(m_ConnectionConfig, m_MaxConnections); + QSBNetworkServer.Configure(m_ConnectionConfig, this.maxConnections); } if (config != null) { @@ -563,7 +204,7 @@ namespace QuantumUNET } if (info != null) { - if (!QSBNetworkServer.Listen(info, m_NetworkPort)) + if (!QSBNetworkServer.Listen(info, networkPort)) { if (LogFilter.logError) { @@ -572,18 +213,18 @@ namespace QuantumUNET return false; } } - else if (m_ServerBindToIP && !string.IsNullOrEmpty(m_ServerBindAddress)) + else if (serverBindToIP && !string.IsNullOrEmpty(serverBindAddress)) { - if (!QSBNetworkServer.Listen(m_ServerBindAddress, m_NetworkPort)) + if (!QSBNetworkServer.Listen(serverBindAddress, networkPort)) { if (LogFilter.logError) { - Debug.LogError("StartServer listen on " + m_ServerBindAddress + " failed."); + Debug.LogError("StartServer listen on " + serverBindAddress + " failed."); } return false; } } - else if (!QSBNetworkServer.Listen(m_NetworkPort)) + else if (!QSBNetworkServer.Listen(networkPort)) { if (LogFilter.logError) { @@ -594,13 +235,13 @@ namespace QuantumUNET RegisterServerMessages(); if (LogFilter.logDebug) { - Debug.Log("NetworkManager StartServer port:" + m_NetworkPort); + Debug.Log("NetworkManager StartServer port:" + networkPort); } isNetworkActive = true; - string name = SceneManager.GetSceneAt(0).name; - if (!string.IsNullOrEmpty(m_OnlineScene) && m_OnlineScene != name && m_OnlineScene != m_OfflineScene) + var name = SceneManager.GetSceneAt(0).name; + if (!string.IsNullOrEmpty(onlineScene) && onlineScene != name && onlineScene != offlineScene) { - ServerChangeScene(m_OnlineScene); + ServerChangeScene(onlineScene); } else { @@ -616,13 +257,13 @@ namespace QuantumUNET client.RegisterHandler(36, new QSBNetworkMessageDelegate(OnClientNotReadyMessageInternal)); client.RegisterHandler(34, new QSBNetworkMessageDelegate(OnClientErrorInternal)); client.RegisterHandler(39, new QSBNetworkMessageDelegate(OnClientSceneInternal)); - if (m_PlayerPrefab != null) + if (playerPrefab != null) { - QSBClientScene.RegisterPrefab(m_PlayerPrefab); + QSBClientScene.RegisterPrefab(playerPrefab); } - for (int i = 0; i < m_SpawnPrefabs.Count; i++) + for (var i = 0; i < spawnPrefabs.Count; i++) { - GameObject gameObject = m_SpawnPrefabs[i]; + var gameObject = spawnPrefabs[i]; if (gameObject != null) { QSBClientScene.RegisterPrefab(gameObject); @@ -632,7 +273,7 @@ namespace QuantumUNET public void UseExternalClient(QSBNetworkClient externalClient) { - if (m_RunInBackground) + if (runInBackground) { Application.runInBackground = true; } @@ -640,8 +281,8 @@ namespace QuantumUNET { client = externalClient; isNetworkActive = true; - this.RegisterClientMessages(client); - this.OnStartClient(client); + RegisterClientMessages(client); + OnStartClient(client); } else { @@ -649,19 +290,18 @@ namespace QuantumUNET QSBClientScene.DestroyAllClientObjects(); QSBClientScene.HandleClientDisconnect(client.connection); client = null; - if (!string.IsNullOrEmpty(m_OfflineScene)) + if (!string.IsNullOrEmpty(offlineScene)) { - ClientChangeScene(m_OfflineScene, false); + ClientChangeScene(offlineScene, false); } } - s_Address = m_NetworkAddress; + s_Address = networkAddress; } - public QSBNetworkClient StartClient(MatchInfo info, ConnectionConfig config, int hostPort) + public QSBNetworkClient StartClient(ConnectionConfig config, int hostPort) { InitializeSingleton(); - matchInfo = info; - if (m_RunInBackground) + if (runInBackground) { Application.runInBackground = true; } @@ -670,8 +310,10 @@ namespace QuantumUNET { NetworkTransport.Init(m_GlobalConfig); } - client = new QSBNetworkClient(); - client.hostPort = hostPort; + client = new QSBNetworkClient + { + hostPort = hostPort + }; if (config != null) { if (config.UsePlatformSpecificProtocols && Application.platform != RuntimePlatform.PS4 && Application.platform != RuntimePlatform.PSP2) @@ -680,77 +322,55 @@ namespace QuantumUNET } client.Configure(config, 1); } - else if (m_CustomConfig && m_ConnectionConfig != null) + else if (customConfig && m_ConnectionConfig != null) { m_ConnectionConfig.Channels.Clear(); - for (int i = 0; i < m_Channels.Count; i++) + for (var i = 0; i < channels.Count; i++) { - m_ConnectionConfig.AddChannel(m_Channels[i]); + m_ConnectionConfig.AddChannel(channels[i]); } if (m_ConnectionConfig.UsePlatformSpecificProtocols && Application.platform != RuntimePlatform.PS4 && Application.platform != RuntimePlatform.PSP2) { throw new ArgumentOutOfRangeException("Platform specific protocols are not supported on this platform"); } - client.Configure(m_ConnectionConfig, m_MaxConnections); + client.Configure(m_ConnectionConfig, maxConnections); } - this.RegisterClientMessages(client); - if (matchInfo != null) + RegisterClientMessages(client); + if (string.IsNullOrEmpty(networkAddress)) { - ModConsole.OwmlConsole.WriteLine("NetworkManager StartClient match: " + matchInfo); - client.Connect(matchInfo); + ModConsole.OwmlConsole.WriteLine("Must set the Network Address field in the manager"); + return null; } - else if (m_EndPoint != null) + ModConsole.OwmlConsole.WriteLine(string.Concat(new object[] { - ModConsole.OwmlConsole.WriteLine("NetworkManager StartClient using provided SecureTunnel"); - client.Connect(m_EndPoint); + "NetworkManager StartClient address:", + networkAddress, + " port:", + networkPort + })); + if (useSimulator) + { + ModConsole.OwmlConsole.WriteLine("connecting with simulator"); + client.ConnectWithSimulator(networkAddress, networkPort, simulatedLatency, packetLossPercentage); } else { - if (string.IsNullOrEmpty(m_NetworkAddress)) - { - ModConsole.OwmlConsole.WriteLine("Must set the Network Address field in the manager"); - return null; - } - ModConsole.OwmlConsole.WriteLine(string.Concat(new object[] - { - "NetworkManager StartClient address:", - m_NetworkAddress, - " port:", - m_NetworkPort - })); - if (m_UseSimulator) - { - ModConsole.OwmlConsole.WriteLine("connecting with simulator"); - client.ConnectWithSimulator(m_NetworkAddress, m_NetworkPort, m_SimulatedLatency, m_PacketLossPercentage); - } - else - { - ModConsole.OwmlConsole.WriteLine("connecting"); - client.Connect(m_NetworkAddress, m_NetworkPort); - } + ModConsole.OwmlConsole.WriteLine("connecting"); + client.Connect(networkAddress, networkPort); } - if (m_MigrationManager != null) - { - m_MigrationManager.Initialize(client, matchInfo); - } - this.OnStartClient(client); - s_Address = m_NetworkAddress; + OnStartClient(client); + s_Address = networkAddress; return client; } - public QSBNetworkClient StartClient(MatchInfo matchInfo) - { - return StartClient(matchInfo, null); - } - public QSBNetworkClient StartClient() { - return StartClient(null, null); + return StartClient(null); } - public QSBNetworkClient StartClient(MatchInfo info, ConnectionConfig config) + public QSBNetworkClient StartClient(ConnectionConfig config) { - return StartClient(info, config, 0); + return StartClient(config, 0); } public virtual QSBNetworkClient StartHost(ConnectionConfig config, int maxConnections) @@ -759,7 +379,7 @@ namespace QuantumUNET QSBNetworkClient result; if (StartServer(config, maxConnections)) { - QSBNetworkClient networkClient = ConnectLocalClient(); + var networkClient = ConnectLocalClient(); OnServerConnect(networkClient.connection); OnStartClient(networkClient); result = networkClient; @@ -774,11 +394,10 @@ namespace QuantumUNET public virtual QSBNetworkClient StartHost(MatchInfo info) { OnStartHost(); - matchInfo = info; QSBNetworkClient result; if (StartServer(info)) { - QSBNetworkClient networkClient = ConnectLocalClient(); + var networkClient = ConnectLocalClient(); OnStartClient(networkClient); result = networkClient; } @@ -795,7 +414,7 @@ namespace QuantumUNET QSBNetworkClient result; if (StartServer()) { - QSBNetworkClient networkClient = ConnectLocalClient(); + var networkClient = ConnectLocalClient(); OnStartClient(networkClient); result = networkClient; } @@ -810,31 +429,19 @@ namespace QuantumUNET { if (LogFilter.logDebug) { - Debug.Log("NetworkManager StartHost port:" + m_NetworkPort); + Debug.Log("NetworkManager StartHost port:" + networkPort); } - m_NetworkAddress = "localhost"; + networkAddress = "localhost"; client = QSBClientScene.ConnectLocalServer(); - this.RegisterClientMessages(client); - if (m_MigrationManager != null) - { - m_MigrationManager.Initialize(client, matchInfo); - } + RegisterClientMessages(client); return client; } public void StopHost() { - bool active = QSBNetworkServer.active; OnStopHost(); StopServer(); StopClient(); - if (m_MigrationManager != null) - { - if (active) - { - m_MigrationManager.LostHostOnHost(); - } - } } public void StopServer() @@ -848,10 +455,10 @@ namespace QuantumUNET } isNetworkActive = false; QSBNetworkServer.Shutdown(); - StopMatchMaker(); - if (!string.IsNullOrEmpty(m_OfflineScene)) + //StopMatchMaker(); + if (!string.IsNullOrEmpty(offlineScene)) { - ServerChangeScene(m_OfflineScene); + ServerChangeScene(offlineScene); } CleanupNetworkIdentities(); } @@ -871,11 +478,11 @@ namespace QuantumUNET client.Shutdown(); client = null; } - StopMatchMaker(); + //StopMatchMaker(); QSBClientScene.DestroyAllClientObjects(); - if (!string.IsNullOrEmpty(m_OfflineScene)) + if (!string.IsNullOrEmpty(offlineScene)) { - ClientChangeScene(m_OfflineScene, false); + ClientChangeScene(offlineScene, false); } CleanupNetworkIdentities(); } @@ -898,7 +505,7 @@ namespace QuantumUNET QSBNetworkServer.SetAllClientsNotReady(); networkSceneName = newSceneName; s_LoadingSceneAsync = SceneManager.LoadSceneAsync(newSceneName); - QSBStringMessage msg = new QSBStringMessage(networkSceneName); + var msg = new QSBStringMessage(networkSceneName); QSBNetworkServer.SendToAll(39, msg); s_StartPositionIndex = 0; s_StartPositions.Clear(); @@ -907,7 +514,7 @@ namespace QuantumUNET private void CleanupNetworkIdentities() { - foreach (QSBNetworkIdentity networkIdentity in Resources.FindObjectsOfTypeAll()) + foreach (var networkIdentity in Resources.FindObjectsOfTypeAll()) { networkIdentity.MarkForReset(); } @@ -930,11 +537,6 @@ namespace QuantumUNET } if (newSceneName == networkSceneName) { - if (m_MigrationManager != null) - { - FinishLoadScene(); - return; - } if (!forceReload) { FinishLoadScene(); @@ -952,8 +554,8 @@ namespace QuantumUNET { if (s_ClientReadyConnection != null) { - m_ClientLoadedScene = true; - this.OnClientConnect(s_ClientReadyConnection); + clientLoadedScene = true; + OnClientConnect(s_ClientReadyConnection); s_ClientReadyConnection = null; } } @@ -968,8 +570,8 @@ namespace QuantumUNET } if (IsClientConnected() && client != null) { - this.RegisterClientMessages(client); - this.OnClientSceneChanged(client.connection); + RegisterClientMessages(client); + OnClientSceneChanged(client.connection); } } @@ -990,11 +592,6 @@ namespace QuantumUNET } } - private void OnDestroy() - { - Debug.Log("NetworkManager destroyed"); - } - public static void RegisterStartPosition(Transform start) { if (LogFilter.logDebug) @@ -1048,30 +645,26 @@ namespace QuantumUNET { Debug.Log("NetworkManager:OnServerConnectInternal"); } - netMsg.Connection.SetMaxDelay(m_MaxDelay); + netMsg.Connection.SetMaxDelay(maxDelay); if (m_MaxBufferedPackets != 512) { - for (int i = 0; i < QSBNetworkServer.numChannels; i++) + for (var i = 0; i < QSBNetworkServer.numChannels; i++) { netMsg.Connection.SetChannelOption(i, ChannelOption.MaxPendingBuffers, m_MaxBufferedPackets); } } if (!m_AllowFragmentation) { - for (int j = 0; j < QSBNetworkServer.numChannels; j++) + for (var j = 0; j < QSBNetworkServer.numChannels; j++) { netMsg.Connection.SetChannelOption(j, ChannelOption.AllowFragmentation, 0); } } - if (networkSceneName != "" && networkSceneName != m_OfflineScene) + if (networkSceneName != "" && networkSceneName != offlineScene) { - QSBStringMessage msg = new QSBStringMessage(networkSceneName); + var msg = new QSBStringMessage(networkSceneName); netMsg.Connection.Send(39, msg); } - if (m_MigrationManager != null) - { - m_MigrationManager.SendPeerInfo(); - } OnServerConnect(netMsg.Connection); } @@ -1081,10 +674,6 @@ namespace QuantumUNET { Debug.Log("NetworkManager:OnServerDisconnectInternal"); } - if (m_MigrationManager != null) - { - m_MigrationManager.SendPeerInfo(); - } OnServerDisconnect(netMsg.Connection); } @@ -1106,16 +695,12 @@ namespace QuantumUNET netMsg.ReadMessage(s_AddPlayerMessage); if (s_AddPlayerMessage.msgSize != 0) { - NetworkReader extraMessageReader = new NetworkReader(s_AddPlayerMessage.msgData); - this.OnServerAddPlayer(netMsg.Connection, s_AddPlayerMessage.playerControllerId, extraMessageReader); + var extraMessageReader = new NetworkReader(s_AddPlayerMessage.msgData); + OnServerAddPlayer(netMsg.Connection, s_AddPlayerMessage.playerControllerId, extraMessageReader); } else { - this.OnServerAddPlayer(netMsg.Connection, s_AddPlayerMessage.playerControllerId); - } - if (m_MigrationManager != null) - { - m_MigrationManager.SendPeerInfo(); + OnServerAddPlayer(netMsg.Connection, s_AddPlayerMessage.playerControllerId); } } @@ -1126,14 +711,9 @@ namespace QuantumUNET Debug.Log("NetworkManager:OnServerRemovePlayerMessageInternal"); } netMsg.ReadMessage(s_RemovePlayerMessage); - QSBPlayerController player; - netMsg.Connection.GetPlayerController(s_RemovePlayerMessage.PlayerControllerId, out player); + netMsg.Connection.GetPlayerController(s_RemovePlayerMessage.PlayerControllerId, out var player); OnServerRemovePlayer(netMsg.Connection, player); netMsg.Connection.RemovePlayerController(s_RemovePlayerMessage.PlayerControllerId); - if (m_MigrationManager != null) - { - m_MigrationManager.SendPeerInfo(); - } } internal void OnServerErrorInternal(QSBNetworkMessage netMsg) @@ -1143,7 +723,7 @@ namespace QuantumUNET Debug.Log("NetworkManager:OnServerErrorInternal"); } netMsg.ReadMessage(s_ErrorMessage); - this.OnServerError(netMsg.Connection, s_ErrorMessage.errorCode); + OnServerError(netMsg.Connection, s_ErrorMessage.errorCode); } internal void OnClientConnectInternal(QSBNetworkMessage netMsg) @@ -1152,11 +732,11 @@ namespace QuantumUNET { Debug.Log("NetworkManager:OnClientConnectInternal"); } - netMsg.Connection.SetMaxDelay(m_MaxDelay); - string name = SceneManager.GetSceneAt(0).name; - if (string.IsNullOrEmpty(m_OnlineScene) || m_OnlineScene == m_OfflineScene || name == m_OnlineScene) + netMsg.Connection.SetMaxDelay(maxDelay); + var name = SceneManager.GetSceneAt(0).name; + if (string.IsNullOrEmpty(onlineScene) || onlineScene == offlineScene || name == onlineScene) { - m_ClientLoadedScene = false; + clientLoadedScene = false; OnClientConnect(netMsg.Connection); } else @@ -1171,20 +751,9 @@ namespace QuantumUNET { Debug.Log("NetworkManager:OnClientDisconnectInternal"); } - if (m_MigrationManager != null) + if (!string.IsNullOrEmpty(offlineScene)) { - if (m_MigrationManager.LostHostOnClient(netMsg.Connection)) - { - return; - } - } - if (!string.IsNullOrEmpty(m_OfflineScene)) - { - ClientChangeScene(m_OfflineScene, false); - } - if (matchMaker != null && matchInfo != null && matchInfo.networkId != NetworkID.Invalid && matchInfo.nodeId != NodeID.Invalid) - { - matchMaker.DropConnection(matchInfo.networkId, matchInfo.nodeId, matchInfo.domain, new NetworkMatch.BasicResponseDelegate(OnDropConnection)); + ClientChangeScene(offlineScene, false); } OnClientDisconnect(netMsg.Connection); } @@ -1206,7 +775,7 @@ namespace QuantumUNET Debug.Log("NetworkManager:OnClientErrorInternal"); } netMsg.ReadMessage(s_ErrorMessage); - this.OnClientError(netMsg.Connection, s_ErrorMessage.errorCode); + OnClientError(netMsg.Connection, s_ErrorMessage.errorCode); } internal void OnClientSceneInternal(QSBNetworkMessage netMsg) @@ -1215,7 +784,7 @@ namespace QuantumUNET { Debug.Log("NetworkManager:OnClientSceneInternal"); } - string newSceneName = netMsg.Reader.ReadString(); + var newSceneName = netMsg.Reader.ReadString(); if (IsClientConnected() && !QSBNetworkServer.active) { ClientChangeScene(newSceneName, true); @@ -1262,21 +831,21 @@ namespace QuantumUNET private void OnServerAddPlayerInternal(QSBNetworkConnection conn, short playerControllerId) { - if (m_PlayerPrefab == null) + if (playerPrefab == null) { if (LogFilter.logError) { ModConsole.OwmlConsole.WriteLine("Error - The PlayerPrefab is empty on the QSBNetworkManager. Please setup a PlayerPrefab object."); } } - else if (m_PlayerPrefab.GetComponent() == null) + else if (playerPrefab.GetComponent() == null) { if (LogFilter.logError) { ModConsole.OwmlConsole.WriteLine("Error - The PlayerPrefab does not have a QSBNetworkIdentity. Please add a QSBNetworkIdentity to the player prefab."); } } - else if ((int)playerControllerId < conn.PlayerControllers.Count && conn.PlayerControllers[(int)playerControllerId].IsValid && conn.PlayerControllers[(int)playerControllerId].Gameobject != null) + else if (playerControllerId < conn.PlayerControllers.Count && conn.PlayerControllers[playerControllerId].IsValid && conn.PlayerControllers[playerControllerId].Gameobject != null) { if (LogFilter.logError) { @@ -1285,15 +854,15 @@ namespace QuantumUNET } else { - Transform startPosition = GetStartPosition(); + var startPosition = GetStartPosition(); GameObject player; if (startPosition != null) { - player = Instantiate(m_PlayerPrefab, startPosition.position, startPosition.rotation); + player = Instantiate(playerPrefab, startPosition.position, startPosition.rotation); } else { - player = Instantiate(m_PlayerPrefab, Vector3.zero, Quaternion.identity); + player = Instantiate(playerPrefab, Vector3.zero, Quaternion.identity); } QSBNetworkServer.AddPlayerForConnection(conn, player, playerControllerId); } @@ -1303,7 +872,7 @@ namespace QuantumUNET { if (s_StartPositions.Count > 0) { - for (int i = s_StartPositions.Count - 1; i >= 0; i--) + for (var i = s_StartPositions.Count - 1; i >= 0; i--) { if (s_StartPositions[i] == null) { @@ -1312,18 +881,18 @@ namespace QuantumUNET } } Transform result; - if (m_PlayerSpawnMethod == PlayerSpawnMethod.Random && s_StartPositions.Count > 0) + if (playerSpawnMethod == PlayerSpawnMethod.Random && s_StartPositions.Count > 0) { - int index = UnityEngine.Random.Range(0, s_StartPositions.Count); + var index = UnityEngine.Random.Range(0, s_StartPositions.Count); result = s_StartPositions[index]; } - else if (m_PlayerSpawnMethod == PlayerSpawnMethod.RoundRobin && s_StartPositions.Count > 0) + else if (playerSpawnMethod == PlayerSpawnMethod.RoundRobin && s_StartPositions.Count > 0) { if (s_StartPositionIndex >= s_StartPositions.Count) { s_StartPositionIndex = 0; } - Transform transform = s_StartPositions[s_StartPositionIndex]; + var transform = s_StartPositions[s_StartPositionIndex]; s_StartPositionIndex++; result = transform; } @@ -1355,7 +924,7 @@ namespace QuantumUNET if (!clientLoadedScene) { QSBClientScene.Ready(conn); - if (m_AutoCreatePlayer) + if (autoCreatePlayer) { QSBClientScene.AddPlayer(0); } @@ -1385,11 +954,11 @@ namespace QuantumUNET public virtual void OnClientSceneChanged(QSBNetworkConnection conn) { QSBClientScene.Ready(conn); - if (m_AutoCreatePlayer) + if (autoCreatePlayer) { - bool flag = QSBClientScene.localPlayers.Count == 0; - bool flag2 = false; - for (int i = 0; i < QSBClientScene.localPlayers.Count; i++) + var flag = QSBClientScene.localPlayers.Count == 0; + var flag2 = false; + for (var i = 0; i < QSBClientScene.localPlayers.Count; i++) { if (QSBClientScene.localPlayers[i].Gameobject != null) { @@ -1408,69 +977,6 @@ namespace QuantumUNET } } - public void StartMatchMaker() - { - if (LogFilter.logDebug) - { - Debug.Log("NetworkManager StartMatchMaker"); - } - SetMatchHost(m_MatchHost, m_MatchPort, m_MatchPort == 443); - } - - public void StopMatchMaker() - { - if (matchMaker != null && matchInfo != null && matchInfo.networkId != NetworkID.Invalid && matchInfo.nodeId != NodeID.Invalid) - { - matchMaker.DropConnection(matchInfo.networkId, matchInfo.nodeId, matchInfo.domain, new NetworkMatch.BasicResponseDelegate(OnDropConnection)); - } - if (matchMaker != null) - { - Destroy(matchMaker); - matchMaker = null; - } - matchInfo = null; - matches = null; - } - - public void SetMatchHost(string newHost, int port, bool https) - { - if (matchMaker == null) - { - matchMaker = base.gameObject.AddComponent(); - } - if (newHost == "127.0.0.1") - { - newHost = "localhost"; - } - string text = "http://"; - if (https) - { - text = "https://"; - } - if (newHost.StartsWith("http://")) - { - newHost = newHost.Replace("http://", ""); - } - if (newHost.StartsWith("https://")) - { - newHost = newHost.Replace("https://", ""); - } - m_MatchHost = newHost; - m_MatchPort = port; - string text2 = string.Concat(new object[] - { - text, - m_MatchHost, - ":", - m_MatchPort - }); - if (LogFilter.logDebug) - { - Debug.Log("SetMatchHost:" + text2); - } - matchMaker.baseUri = new Uri(text2); - } - public virtual void OnStartHost() { } @@ -1494,215 +1000,5 @@ namespace QuantumUNET public virtual void OnStopHost() { } - - public virtual void OnMatchCreate(bool success, string extendedInfo, MatchInfo matchInfo) - { - if (LogFilter.logDebug) - { - Debug.LogFormat("NetworkManager OnMatchCreate Success:{0}, ExtendedInfo:{1}, matchInfo:{2}", new object[] - { - success, - extendedInfo, - matchInfo - }); - } - if (success) - { - StartHost(matchInfo); - } - } - - public virtual void OnMatchList(bool success, string extendedInfo, List matchList) - { - if (LogFilter.logDebug) - { - Debug.LogFormat("NetworkManager OnMatchList Success:{0}, ExtendedInfo:{1}, matchList.Count:{2}", new object[] - { - success, - extendedInfo, - matchList.Count - }); - } - matches = matchList; - } - - public virtual void OnMatchJoined(bool success, string extendedInfo, MatchInfo matchInfo) - { - if (LogFilter.logDebug) - { - Debug.LogFormat("NetworkManager OnMatchJoined Success:{0}, ExtendedInfo:{1}, matchInfo:{2}", new object[] - { - success, - extendedInfo, - matchInfo - }); - } - if (success) - { - StartClient(matchInfo); - } - } - - public virtual void OnDestroyMatch(bool success, string extendedInfo) - { - if (LogFilter.logDebug) - { - Debug.LogFormat("NetworkManager OnDestroyMatch Success:{0}, ExtendedInfo:{1}", new object[] - { - success, - extendedInfo - }); - } - } - - public virtual void OnDropConnection(bool success, string extendedInfo) - { - if (LogFilter.logDebug) - { - Debug.LogFormat("NetworkManager OnDropConnection Success:{0}, ExtendedInfo:{1}", new object[] - { - success, - extendedInfo - }); - } - } - - public virtual void OnSetMatchAttributes(bool success, string extendedInfo) - { - if (LogFilter.logDebug) - { - Debug.LogFormat("NetworkManager OnSetMatchAttributes Success:{0}, ExtendedInfo:{1}", new object[] - { - success, - extendedInfo - }); - } - } - - [SerializeField] - private int m_NetworkPort = 7777; - - [SerializeField] - private bool m_ServerBindToIP; - - [SerializeField] - private string m_ServerBindAddress = ""; - - [SerializeField] - private string m_NetworkAddress = "localhost"; - - [SerializeField] - private bool m_DontDestroyOnLoad = true; - - [SerializeField] - private bool m_RunInBackground = true; - - [SerializeField] - private bool m_ScriptCRCCheck = true; - - [SerializeField] - private float m_MaxDelay = 0.01f; - - [SerializeField] - private LogFilter.FilterLevel m_LogLevel = LogFilter.FilterLevel.Info; - - [SerializeField] - private GameObject m_PlayerPrefab; - - [SerializeField] - private bool m_AutoCreatePlayer = true; - - [SerializeField] - private PlayerSpawnMethod m_PlayerSpawnMethod; - - [SerializeField] - private string m_OfflineScene = ""; - - [SerializeField] - private string m_OnlineScene = ""; - - [SerializeField] - private List m_SpawnPrefabs = new List(); - - [SerializeField] - private bool m_CustomConfig; - - [SerializeField] - private int m_MaxConnections = 4; - - [SerializeField] - private ConnectionConfig m_ConnectionConfig; - - [SerializeField] - private GlobalConfig m_GlobalConfig; - - [SerializeField] - private List m_Channels = new List(); - - [SerializeField] - private bool m_UseWebSockets; - - [SerializeField] - private bool m_UseSimulator; - - [SerializeField] - private int m_SimulatedLatency = 1; - - [SerializeField] - private float m_PacketLossPercentage; - - [SerializeField] - private int m_MaxBufferedPackets = 16; - - [SerializeField] - private bool m_AllowFragmentation = true; - - [SerializeField] - private string m_MatchHost = "mm.unet.unity3d.com"; - - [SerializeField] - private int m_MatchPort = 443; - - [SerializeField] - public string matchName = "default"; - - [SerializeField] - public uint matchSize = 4U; - - private QSBNetworkMigrationManager m_MigrationManager; - - private EndPoint m_EndPoint; - - private bool m_ClientLoadedScene; - - public static string networkSceneName = ""; - - public bool isNetworkActive; - - public QSBNetworkClient client; - - private static List s_StartPositions = new List(); - - private static int s_StartPositionIndex; - - public MatchInfo matchInfo; - - public NetworkMatch matchMaker; - - public List matches; - - public static QSBNetworkManagerUNET singleton; - - private static QSBAddPlayerMessage s_AddPlayerMessage = new QSBAddPlayerMessage(); - - private static QSBRemovePlayerMessage s_RemovePlayerMessage = new QSBRemovePlayerMessage(); - - private static QSBErrorMessage s_ErrorMessage = new QSBErrorMessage(); - - private static AsyncOperation s_LoadingSceneAsync; - - private static QSBNetworkConnection s_ClientReadyConnection; - - private static string s_Address; } } \ No newline at end of file diff --git a/QuantumUNET/QSBNetworkMigrationManager.cs b/QuantumUNET/QSBNetworkMigrationManager.cs deleted file mode 100644 index 5af90dc9..00000000 --- a/QuantumUNET/QSBNetworkMigrationManager.cs +++ /dev/null @@ -1,1066 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.Networking; -using UnityEngine.Networking.Match; -using UnityEngine.Networking.Types; - -namespace QuantumUNET -{ - public class QSBNetworkMigrationManager : MonoBehaviour - { - private void AddPendingPlayer(GameObject obj, int connectionId, NetworkInstanceId netId, short playerControllerId) - { - if (!this.m_PendingPlayers.ContainsKey(connectionId)) - { - ConnectionPendingPlayers value = default(ConnectionPendingPlayers); - value.players = new List(); - this.m_PendingPlayers[connectionId] = value; - } - PendingPlayerInfo item = default(PendingPlayerInfo); - item.netId = netId; - item.playerControllerId = playerControllerId; - item.obj = obj; - this.m_PendingPlayers[connectionId].players.Add(item); - } - - private GameObject FindPendingPlayer(int connectionId, NetworkInstanceId netId, short playerControllerId) - { - if (this.m_PendingPlayers.ContainsKey(connectionId)) - { - for (int i = 0; i < this.m_PendingPlayers[connectionId].players.Count; i++) - { - PendingPlayerInfo pendingPlayerInfo = this.m_PendingPlayers[connectionId].players[i]; - if (pendingPlayerInfo.netId == netId && pendingPlayerInfo.playerControllerId == playerControllerId) - { - return pendingPlayerInfo.obj; - } - } - } - return null; - } - - private void RemovePendingPlayer(int connectionId) - { - this.m_PendingPlayers.Remove(connectionId); - } - - public bool hostMigration - { - get - { - return this.m_HostMigration; - } - set - { - this.m_HostMigration = value; - } - } - - public bool showGUI - { - get - { - return this.m_ShowGUI; - } - set - { - this.m_ShowGUI = value; - } - } - - public int offsetX - { - get - { - return this.m_OffsetX; - } - set - { - this.m_OffsetX = value; - } - } - - public int offsetY - { - get - { - return this.m_OffsetY; - } - set - { - this.m_OffsetY = value; - } - } - - public QSBNetworkClient client - { - get - { - return this.m_Client; - } - } - - public bool waitingToBecomeNewHost - { - get - { - return this.m_WaitingToBecomeNewHost; - } - set - { - this.m_WaitingToBecomeNewHost = value; - } - } - - public bool waitingReconnectToNewHost - { - get - { - return this.m_WaitingReconnectToNewHost; - } - set - { - this.m_WaitingReconnectToNewHost = value; - } - } - - public bool disconnectedFromHost - { - get - { - return this.m_DisconnectedFromHost; - } - } - - public bool hostWasShutdown - { - get - { - return this.m_HostWasShutdown; - } - } - - public MatchInfo matchInfo - { - get - { - return this.m_MatchInfo; - } - } - - public int oldServerConnectionId - { - get - { - return this.m_OldServerConnectionId; - } - } - - public string newHostAddress - { - get - { - return this.m_NewHostAddress; - } - set - { - this.m_NewHostAddress = value; - } - } - - public QSBPeerInfoMessage[] peers - { - get - { - return this.m_Peers; - } - } - - public Dictionary pendingPlayers - { - get - { - return this.m_PendingPlayers; - } - } - - private void Start() - { - this.Reset(-1); - } - - public void Reset(int reconnectId) - { - this.m_OldServerConnectionId = -1; - this.m_WaitingToBecomeNewHost = false; - this.m_WaitingReconnectToNewHost = false; - this.m_DisconnectedFromHost = false; - this.m_HostWasShutdown = false; - QSBClientScene.SetReconnectId(reconnectId, this.m_Peers); - if (QSBNetworkManagerUNET.singleton != null) - { - QSBNetworkManagerUNET.singleton.SetupMigrationManager(this); - } - } - - internal void AssignAuthorityCallback(QSBNetworkConnection conn, QSBNetworkIdentity uv, bool authorityState) - { - QSBPeerAuthorityMessage peerAuthorityMessage = new QSBPeerAuthorityMessage(); - peerAuthorityMessage.connectionId = conn.connectionId; - peerAuthorityMessage.netId = uv.NetId; - peerAuthorityMessage.authorityState = authorityState; - if (LogFilter.logDebug) - { - Debug.Log("AssignAuthorityCallback send for netId" + uv.NetId); - } - for (int i = 0; i < QSBNetworkServer.connections.Count; i++) - { - QSBNetworkConnection networkConnection = QSBNetworkServer.connections[i]; - if (networkConnection != null) - { - networkConnection.Send(18, peerAuthorityMessage); - } - } - } - - public void Initialize(QSBNetworkClient newClient, MatchInfo newMatchInfo) - { - Debug.Log("NetworkMigrationManager initialize"); - this.m_Client = newClient; - this.m_MatchInfo = newMatchInfo; - newClient.RegisterHandlerSafe(11, new QSBNetworkMessageDelegate(this.OnPeerInfo)); - newClient.RegisterHandlerSafe(18, new QSBNetworkMessageDelegate(this.OnPeerClientAuthority)); - QSBNetworkIdentity.clientAuthorityCallback = new QSBNetworkIdentity.ClientAuthorityCallback(this.AssignAuthorityCallback); - } - - public void DisablePlayerObjects() - { - Debug.Log("NetworkMigrationManager DisablePlayerObjects"); - if (this.m_Peers != null) - { - for (int i = 0; i < this.m_Peers.Length; i++) - { - QSBPeerInfoMessage peerInfoMessage = this.m_Peers[i]; - if (peerInfoMessage.playerIds != null) - { - for (int j = 0; j < peerInfoMessage.playerIds.Length; j++) - { - QSBPeerInfoPlayer peerInfoPlayer = peerInfoMessage.playerIds[j]; - Debug.Log(string.Concat(new object[] - { - "DisablePlayerObjects disable player for ", - peerInfoMessage.address, - " netId:", - peerInfoPlayer.netId, - " control:", - peerInfoPlayer.playerControllerId - })); - GameObject gameObject = QSBClientScene.FindLocalObject(peerInfoPlayer.netId); - if (gameObject != null) - { - gameObject.SetActive(false); - this.AddPendingPlayer(gameObject, peerInfoMessage.connectionId, peerInfoPlayer.netId, peerInfoPlayer.playerControllerId); - } - else if (LogFilter.logWarn) - { - Debug.LogWarning(string.Concat(new object[] - { - "DisablePlayerObjects didnt find player Conn:", - peerInfoMessage.connectionId, - " NetId:", - peerInfoPlayer.netId - })); - } - } - } - } - } - } - - public void SendPeerInfo() - { - if (this.m_HostMigration) - { - QSBPeerListMessage peerListMessage = new QSBPeerListMessage(); - List list = new List(); - for (int i = 0; i < QSBNetworkServer.connections.Count; i++) - { - QSBNetworkConnection networkConnection = QSBNetworkServer.connections[i]; - if (networkConnection != null) - { - QSBPeerInfoMessage peerInfoMessage = new QSBPeerInfoMessage(); - string address; - int port; - NetworkID networkID; - NodeID nodeID; - byte b; - NetworkTransport.GetConnectionInfo(QSBNetworkServer.serverHostId, networkConnection.connectionId, out address, out port, out networkID, out nodeID, out b); - peerInfoMessage.connectionId = networkConnection.connectionId; - peerInfoMessage.port = port; - if (i == 0) - { - peerInfoMessage.port = QSBNetworkServer.listenPort; - peerInfoMessage.isHost = true; - peerInfoMessage.address = ""; - } - else - { - peerInfoMessage.address = address; - peerInfoMessage.isHost = false; - } - List list2 = new List(); - for (int j = 0; j < networkConnection.PlayerControllers.Count; j++) - { - QSBPlayerController playerController = networkConnection.PlayerControllers[j]; - if (playerController != null && playerController.UnetView != null) - { - QSBPeerInfoPlayer item; - item.netId = playerController.UnetView.NetId; - item.playerControllerId = playerController.UnetView.PlayerControllerId; - list2.Add(item); - } - } - if (networkConnection.ClientOwnedObjects != null) - { - foreach (NetworkInstanceId netId in networkConnection.ClientOwnedObjects) - { - GameObject gameObject = QSBNetworkServer.FindLocalObject(netId); - if (!(gameObject == null)) - { - QSBNetworkIdentity component = gameObject.GetComponent(); - if (component.PlayerControllerId == -1) - { - QSBPeerInfoPlayer item2; - item2.netId = netId; - item2.playerControllerId = -1; - list2.Add(item2); - } - } - } - } - if (list2.Count > 0) - { - peerInfoMessage.playerIds = list2.ToArray(); - } - list.Add(peerInfoMessage); - } - } - peerListMessage.peers = list.ToArray(); - for (int k = 0; k < QSBNetworkServer.connections.Count; k++) - { - QSBNetworkConnection networkConnection2 = QSBNetworkServer.connections[k]; - if (networkConnection2 != null) - { - peerListMessage.oldServerConnectionId = networkConnection2.connectionId; - networkConnection2.Send(11, peerListMessage); - } - } - } - } - - private void OnPeerClientAuthority(QSBNetworkMessage netMsg) - { - QSBPeerAuthorityMessage peerAuthorityMessage = netMsg.ReadMessage(); - if (LogFilter.logDebug) - { - Debug.Log("OnPeerClientAuthority for netId:" + peerAuthorityMessage.netId); - } - if (this.m_Peers != null) - { - for (int i = 0; i < this.m_Peers.Length; i++) - { - QSBPeerInfoMessage peerInfoMessage = this.m_Peers[i]; - if (peerInfoMessage.connectionId == peerAuthorityMessage.connectionId) - { - if (peerInfoMessage.playerIds == null) - { - peerInfoMessage.playerIds = new QSBPeerInfoPlayer[0]; - } - if (peerAuthorityMessage.authorityState) - { - for (int j = 0; j < peerInfoMessage.playerIds.Length; j++) - { - if (peerInfoMessage.playerIds[j].netId == peerAuthorityMessage.netId) - { - return; - } - } - QSBPeerInfoPlayer item = default(QSBPeerInfoPlayer); - item.netId = peerAuthorityMessage.netId; - item.playerControllerId = -1; - peerInfoMessage.playerIds = new List(peerInfoMessage.playerIds) - { - item - }.ToArray(); - } - else - { - for (int k = 0; k < peerInfoMessage.playerIds.Length; k++) - { - if (peerInfoMessage.playerIds[k].netId == peerAuthorityMessage.netId) - { - List list = new List(peerInfoMessage.playerIds); - list.RemoveAt(k); - peerInfoMessage.playerIds = list.ToArray(); - break; - } - } - } - } - } - GameObject go = QSBClientScene.FindLocalObject(peerAuthorityMessage.netId); - this.OnAuthorityUpdated(go, peerAuthorityMessage.connectionId, peerAuthorityMessage.authorityState); - } - } - - private void OnPeerInfo(QSBNetworkMessage netMsg) - { - if (LogFilter.logDebug) - { - Debug.Log("OnPeerInfo"); - } - netMsg.ReadMessage(this.m_PeerListMessage); - this.m_Peers = this.m_PeerListMessage.peers; - this.m_OldServerConnectionId = this.m_PeerListMessage.oldServerConnectionId; - for (int i = 0; i < this.m_Peers.Length; i++) - { - if (LogFilter.logDebug) - { - Debug.Log(string.Concat(new object[] - { - "peer conn ", - this.m_Peers[i].connectionId, - " your conn ", - this.m_PeerListMessage.oldServerConnectionId - })); - } - if (this.m_Peers[i].connectionId == this.m_PeerListMessage.oldServerConnectionId) - { - this.m_Peers[i].isYou = true; - break; - } - } - this.OnPeersUpdated(this.m_PeerListMessage); - } - - private void OnServerReconnectPlayerMessage(QSBNetworkMessage netMsg) - { - QSBReconnectMessage reconnectMessage = netMsg.ReadMessage(); - Debug.Log(string.Concat(new object[] - { - "OnReconnectMessage: connId=", - reconnectMessage.oldConnectionId, - " playerControllerId:", - reconnectMessage.playerControllerId, - " netId:", - reconnectMessage.netId - })); - GameObject gameObject = this.FindPendingPlayer(reconnectMessage.oldConnectionId, reconnectMessage.netId, reconnectMessage.playerControllerId); - if (gameObject == null) - { - if (LogFilter.logError) - { - Debug.LogError(string.Concat(new object[] - { - "OnReconnectMessage connId=", - reconnectMessage.oldConnectionId, - " player null for netId:", - reconnectMessage.netId, - " msg.playerControllerId:", - reconnectMessage.playerControllerId - })); - } - } - else if (gameObject.activeSelf) - { - if (LogFilter.logError) - { - Debug.LogError("OnReconnectMessage connId=" + reconnectMessage.oldConnectionId + " player already active?"); - } - } - else - { - if (LogFilter.logDebug) - { - Debug.Log("OnReconnectMessage: player=" + gameObject); - } - NetworkReader networkReader = null; - if (reconnectMessage.msgSize != 0) - { - networkReader = new NetworkReader(reconnectMessage.msgData); - } - if (reconnectMessage.playerControllerId != -1) - { - if (networkReader == null) - { - this.OnServerReconnectPlayer(netMsg.Connection, gameObject, reconnectMessage.oldConnectionId, reconnectMessage.playerControllerId); - } - else - { - this.OnServerReconnectPlayer(netMsg.Connection, gameObject, reconnectMessage.oldConnectionId, reconnectMessage.playerControllerId, networkReader); - } - } - else - { - this.OnServerReconnectObject(netMsg.Connection, gameObject, reconnectMessage.oldConnectionId); - } - } - } - - public bool ReconnectObjectForConnection(QSBNetworkConnection newConnection, GameObject oldObject, int oldConnectionId) - { - bool result; - if (!QSBNetworkServer.active) - { - if (LogFilter.logError) - { - Debug.LogError("ReconnectObjectForConnection must have active server"); - } - result = false; - } - else - { - if (LogFilter.logDebug) - { - Debug.Log(string.Concat(new object[] - { - "ReconnectObjectForConnection: oldConnId=", - oldConnectionId, - " obj=", - oldObject, - " conn:", - newConnection - })); - } - if (!this.m_PendingPlayers.ContainsKey(oldConnectionId)) - { - if (LogFilter.logError) - { - Debug.LogError("ReconnectObjectForConnection oldConnId=" + oldConnectionId + " not found."); - } - result = false; - } - else - { - oldObject.SetActive(true); - oldObject.GetComponent().SetNetworkInstanceId(new NetworkInstanceId(0U)); - if (!QSBNetworkServer.SpawnWithClientAuthority(oldObject, newConnection)) - { - if (LogFilter.logError) - { - Debug.LogError("ReconnectObjectForConnection oldConnId=" + oldConnectionId + " SpawnWithClientAuthority failed."); - } - result = false; - } - else - { - result = true; - } - } - } - return result; - } - - public bool ReconnectPlayerForConnection(QSBNetworkConnection newConnection, GameObject oldPlayer, int oldConnectionId, short playerControllerId) - { - bool result; - if (!QSBNetworkServer.active) - { - if (LogFilter.logError) - { - Debug.LogError("ReconnectPlayerForConnection must have active server"); - } - result = false; - } - else - { - if (LogFilter.logDebug) - { - Debug.Log(string.Concat(new object[] - { - "ReconnectPlayerForConnection: oldConnId=", - oldConnectionId, - " player=", - oldPlayer, - " conn:", - newConnection - })); - } - if (!this.m_PendingPlayers.ContainsKey(oldConnectionId)) - { - if (LogFilter.logError) - { - Debug.LogError("ReconnectPlayerForConnection oldConnId=" + oldConnectionId + " not found."); - } - result = false; - } - else - { - oldPlayer.SetActive(true); - QSBNetworkServer.Spawn(oldPlayer); - if (!QSBNetworkServer.AddPlayerForConnection(newConnection, oldPlayer, playerControllerId)) - { - if (LogFilter.logError) - { - Debug.LogError("ReconnectPlayerForConnection oldConnId=" + oldConnectionId + " AddPlayerForConnection failed."); - } - result = false; - } - else - { - if (QSBNetworkServer.localClientActive) - { - this.SendPeerInfo(); - } - result = true; - } - } - } - return result; - } - - public bool LostHostOnClient(QSBNetworkConnection conn) - { - if (LogFilter.logDebug) - { - Debug.Log("NetworkMigrationManager client OnDisconnectedFromHost"); - } - bool result; - if (Application.platform == RuntimePlatform.WebGLPlayer) - { - if (LogFilter.logError) - { - Debug.LogError("LostHostOnClient: Host migration not supported on WebGL"); - } - result = false; - } - else if (this.m_Client == null) - { - if (LogFilter.logError) - { - Debug.LogError("NetworkMigrationManager LostHostOnHost client was never initialized."); - } - result = false; - } - else if (!this.m_HostMigration) - { - if (LogFilter.logError) - { - Debug.LogError("NetworkMigrationManager LostHostOnHost migration not enabled."); - } - result = false; - } - else - { - this.m_DisconnectedFromHost = true; - this.DisablePlayerObjects(); - byte b; - NetworkTransport.Disconnect(this.m_Client.hostId, this.m_Client.connection.connectionId, out b); - if (this.m_OldServerConnectionId != -1) - { - SceneChangeOption sceneChangeOption; - this.OnClientDisconnectedFromHost(conn, out sceneChangeOption); - result = (sceneChangeOption == SceneChangeOption.StayInOnlineScene); - } - else - { - result = false; - } - } - return result; - } - - public void LostHostOnHost() - { - if (LogFilter.logDebug) - { - Debug.Log("NetworkMigrationManager LostHostOnHost"); - } - if (Application.platform == RuntimePlatform.WebGLPlayer) - { - if (LogFilter.logError) - { - Debug.LogError("LostHostOnHost: Host migration not supported on WebGL"); - } - } - else - { - this.OnServerHostShutdown(); - if (this.m_Peers == null) - { - if (LogFilter.logError) - { - Debug.LogError("NetworkMigrationManager LostHostOnHost no peers"); - } - } - else if (this.m_Peers.Length != 1) - { - this.m_HostWasShutdown = true; - } - } - } - - public bool BecomeNewHost(int port) - { - if (LogFilter.logDebug) - { - Debug.Log("NetworkMigrationManager BecomeNewHost " + this.m_MatchInfo); - } - QSBNetworkServer.RegisterHandler(47, new QSBNetworkMessageDelegate(this.OnServerReconnectPlayerMessage)); - QSBNetworkClient networkClient = QSBNetworkServer.BecomeHost(this.m_Client, port, this.m_MatchInfo, this.oldServerConnectionId, this.peers); - bool result; - if (networkClient != null) - { - if (QSBNetworkManagerUNET.singleton != null) - { - QSBNetworkManagerUNET.singleton.RegisterServerMessages(); - QSBNetworkManagerUNET.singleton.UseExternalClient(networkClient); - } - else - { - Debug.LogWarning("MigrationManager BecomeNewHost - No NetworkManager."); - } - networkClient.RegisterHandlerSafe(11, new QSBNetworkMessageDelegate(this.OnPeerInfo)); - this.RemovePendingPlayer(this.m_OldServerConnectionId); - this.Reset(-1); - this.SendPeerInfo(); - result = true; - } - else - { - if (LogFilter.logError) - { - Debug.LogError("NetworkServer.BecomeHost failed"); - } - result = false; - } - return result; - } - - protected virtual void OnClientDisconnectedFromHost(QSBNetworkConnection conn, out SceneChangeOption sceneChange) - { - sceneChange = SceneChangeOption.StayInOnlineScene; - } - - protected virtual void OnServerHostShutdown() - { - } - - protected virtual void OnServerReconnectPlayer(QSBNetworkConnection newConnection, GameObject oldPlayer, int oldConnectionId, short playerControllerId) - { - this.ReconnectPlayerForConnection(newConnection, oldPlayer, oldConnectionId, playerControllerId); - } - - protected virtual void OnServerReconnectPlayer(QSBNetworkConnection newConnection, GameObject oldPlayer, int oldConnectionId, short playerControllerId, NetworkReader extraMessageReader) - { - this.ReconnectPlayerForConnection(newConnection, oldPlayer, oldConnectionId, playerControllerId); - } - - protected virtual void OnServerReconnectObject(QSBNetworkConnection newConnection, GameObject oldObject, int oldConnectionId) - { - this.ReconnectObjectForConnection(newConnection, oldObject, oldConnectionId); - } - - protected virtual void OnPeersUpdated(QSBPeerListMessage peers) - { - Debug.Log("NetworkMigrationManager NumPeers " + peers.peers.Length); - } - - protected virtual void OnAuthorityUpdated(GameObject go, int connectionId, bool authorityState) - { - Debug.Log(string.Concat(new object[] - { - "NetworkMigrationManager OnAuthorityUpdated for ", - go, - " conn:", - connectionId, - " state:", - authorityState - })); - } - - public virtual bool FindNewHost(out QSBPeerInfoMessage newHostInfo, out bool youAreNewHost) - { - bool result; - if (this.m_Peers == null) - { - if (LogFilter.logError) - { - Debug.LogError("NetworkMigrationManager FindLowestHost no peers"); - } - newHostInfo = null; - youAreNewHost = false; - result = false; - } - else - { - Debug.Log("NetworkMigrationManager FindLowestHost"); - newHostInfo = new QSBPeerInfoMessage(); - newHostInfo.connectionId = 50000; - newHostInfo.address = ""; - newHostInfo.port = 0; - int num = -1; - youAreNewHost = false; - if (this.m_Peers == null) - { - result = false; - } - else - { - for (int i = 0; i < this.m_Peers.Length; i++) - { - QSBPeerInfoMessage peerInfoMessage = this.m_Peers[i]; - if (peerInfoMessage.connectionId != 0) - { - if (!peerInfoMessage.isHost) - { - if (peerInfoMessage.isYou) - { - num = peerInfoMessage.connectionId; - } - if (peerInfoMessage.connectionId < newHostInfo.connectionId) - { - newHostInfo = peerInfoMessage; - } - } - } - } - if (newHostInfo.connectionId == 50000) - { - result = false; - } - else - { - if (newHostInfo.connectionId == num) - { - youAreNewHost = true; - } - Debug.Log("FindNewHost new host is " + newHostInfo.address); - result = true; - } - } - } - return result; - } - - private void OnGUIHost() - { - int num = this.m_OffsetY; - GUI.Label(new Rect((float)this.m_OffsetX, (float)num, 200f, 40f), "Host Was Shutdown ID(" + this.m_OldServerConnectionId + ")"); - num += 25; - if (Application.platform == RuntimePlatform.WebGLPlayer) - { - GUI.Label(new Rect((float)this.m_OffsetX, (float)num, 200f, 40f), "Host Migration not supported for WebGL"); - } - else - { - if (this.m_WaitingReconnectToNewHost) - { - if (GUI.Button(new Rect((float)this.m_OffsetX, (float)num, 200f, 20f), "Reconnect as Client")) - { - this.Reset(0); - if (NetworkManager.singleton != null) - { - NetworkManager.singleton.networkAddress = GUI.TextField(new Rect((float)(this.m_OffsetX + 100), (float)num, 95f, 20f), NetworkManager.singleton.networkAddress); - NetworkManager.singleton.StartClient(); - } - else - { - Debug.LogWarning("MigrationManager Old Host Reconnect - No NetworkManager."); - } - } - num += 25; - } - else - { - if (GUI.Button(new Rect((float)this.m_OffsetX, (float)num, 200f, 20f), "Pick New Host")) - { - bool flag; - if (this.FindNewHost(out this.m_NewHostInfo, out flag)) - { - this.m_NewHostAddress = this.m_NewHostInfo.address; - if (flag) - { - Debug.LogWarning("MigrationManager FindNewHost - new host is self?"); - } - else - { - this.m_WaitingReconnectToNewHost = true; - } - } - } - num += 25; - } - if (GUI.Button(new Rect((float)this.m_OffsetX, (float)num, 200f, 20f), "Leave Game")) - { - if (NetworkManager.singleton != null) - { - NetworkManager.singleton.SetupMigrationManager(null); - NetworkManager.singleton.StopHost(); - } - else - { - Debug.LogWarning("MigrationManager Old Host LeaveGame - No NetworkManager."); - } - this.Reset(-1); - } - num += 25; - } - } - - private void OnGUIClient() - { - int num = this.m_OffsetY; - GUI.Label(new Rect((float)this.m_OffsetX, (float)num, 200f, 40f), "Lost Connection To Host ID(" + this.m_OldServerConnectionId + ")"); - num += 25; - if (Application.platform == RuntimePlatform.WebGLPlayer) - { - GUI.Label(new Rect((float)this.m_OffsetX, (float)num, 200f, 40f), "Host Migration not supported for WebGL"); - } - else - { - if (this.m_WaitingToBecomeNewHost) - { - GUI.Label(new Rect((float)this.m_OffsetX, (float)num, 200f, 40f), "You are the new host"); - num += 25; - if (GUI.Button(new Rect((float)this.m_OffsetX, (float)num, 200f, 20f), "Start As Host")) - { - if (NetworkManager.singleton != null) - { - this.BecomeNewHost(NetworkManager.singleton.networkPort); - } - else - { - Debug.LogWarning("MigrationManager Client BecomeNewHost - No NetworkManager."); - } - } - num += 25; - } - else if (this.m_WaitingReconnectToNewHost) - { - GUI.Label(new Rect((float)this.m_OffsetX, (float)num, 200f, 40f), "New host is " + this.m_NewHostAddress); - num += 25; - if (GUI.Button(new Rect((float)this.m_OffsetX, (float)num, 200f, 20f), "Reconnect To New Host")) - { - this.Reset(this.m_OldServerConnectionId); - if (NetworkManager.singleton != null) - { - NetworkManager.singleton.networkAddress = this.m_NewHostAddress; - NetworkManager.singleton.client.ReconnectToNewHost(this.m_NewHostAddress, NetworkManager.singleton.networkPort); - } - else - { - Debug.LogWarning("MigrationManager Client reconnect - No NetworkManager."); - } - } - num += 25; - } - else - { - if (GUI.Button(new Rect((float)this.m_OffsetX, (float)num, 200f, 20f), "Pick New Host")) - { - bool flag; - if (this.FindNewHost(out this.m_NewHostInfo, out flag)) - { - this.m_NewHostAddress = this.m_NewHostInfo.address; - if (flag) - { - this.m_WaitingToBecomeNewHost = true; - } - else - { - this.m_WaitingReconnectToNewHost = true; - } - } - } - num += 25; - } - if (GUI.Button(new Rect((float)this.m_OffsetX, (float)num, 200f, 20f), "Leave Game")) - { - if (NetworkManager.singleton != null) - { - NetworkManager.singleton.SetupMigrationManager(null); - NetworkManager.singleton.StopHost(); - } - else - { - Debug.LogWarning("MigrationManager Client LeaveGame - No NetworkManager."); - } - this.Reset(-1); - } - num += 25; - } - } - - private void OnGUI() - { - if (this.m_ShowGUI) - { - if (this.m_HostWasShutdown) - { - this.OnGUIHost(); - } - else if (this.m_DisconnectedFromHost && this.m_OldServerConnectionId != -1) - { - this.OnGUIClient(); - } - } - } - - [SerializeField] - private bool m_HostMigration = true; - - [SerializeField] - private bool m_ShowGUI = true; - - [SerializeField] - private int m_OffsetX = 10; - - [SerializeField] - private int m_OffsetY = 300; - - private QSBNetworkClient m_Client; - - private bool m_WaitingToBecomeNewHost; - - private bool m_WaitingReconnectToNewHost; - - private bool m_DisconnectedFromHost; - - private bool m_HostWasShutdown; - - private MatchInfo m_MatchInfo; - - private int m_OldServerConnectionId = -1; - - private string m_NewHostAddress; - - private QSBPeerInfoMessage m_NewHostInfo = new QSBPeerInfoMessage(); - - private QSBPeerListMessage m_PeerListMessage = new QSBPeerListMessage(); - - private QSBPeerInfoMessage[] m_Peers; - - private Dictionary m_PendingPlayers = new Dictionary(); - - public enum SceneChangeOption - { - StayInOnlineScene, - SwitchToOfflineScene - } - - public struct PendingPlayerInfo - { - public NetworkInstanceId netId; - - public short playerControllerId; - - public GameObject obj; - } - - public struct ConnectionPendingPlayers - { - public List players; - } - } -} \ No newline at end of file diff --git a/QuantumUNET/QSBPeerAuthorityMessage.cs b/QuantumUNET/QSBPeerAuthorityMessage.cs deleted file mode 100644 index 1ef5ec75..00000000 --- a/QuantumUNET/QSBPeerAuthorityMessage.cs +++ /dev/null @@ -1,27 +0,0 @@ -using UnityEngine.Networking; - -namespace QuantumUNET -{ - public class QSBPeerAuthorityMessage : QSBMessageBase - { - public override void Deserialize(QSBNetworkReader reader) - { - this.connectionId = (int)reader.ReadPackedUInt32(); - this.netId = reader.ReadNetworkId(); - this.authorityState = reader.ReadBoolean(); - } - - public override void Serialize(QSBNetworkWriter writer) - { - writer.WritePackedUInt32((uint)this.connectionId); - writer.Write(this.netId); - writer.Write(this.authorityState); - } - - public int connectionId; - - public NetworkInstanceId netId; - - public bool authorityState; - } -} \ No newline at end of file diff --git a/QuantumUNET/QSBPeerListMessage.cs b/QuantumUNET/QSBPeerListMessage.cs deleted file mode 100644 index 17ab9241..00000000 --- a/QuantumUNET/QSBPeerListMessage.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace QuantumUNET -{ - public class QSBPeerListMessage : QSBMessageBase - { - public override void Deserialize(QSBNetworkReader reader) - { - this.oldServerConnectionId = (int)reader.ReadPackedUInt32(); - int num = (int)reader.ReadUInt16(); - this.peers = new QSBPeerInfoMessage[num]; - for (int i = 0; i < this.peers.Length; i++) - { - QSBPeerInfoMessage peerInfoMessage = new QSBPeerInfoMessage(); - peerInfoMessage.Deserialize(reader); - this.peers[i] = peerInfoMessage; - } - } - - public override void Serialize(QSBNetworkWriter writer) - { - writer.WritePackedUInt32((uint)this.oldServerConnectionId); - writer.Write((ushort)this.peers.Length); - for (int i = 0; i < this.peers.Length; i++) - { - this.peers[i].Serialize(writer); - } - } - - public QSBPeerInfoMessage[] peers; - - public int oldServerConnectionId; - } -} \ No newline at end of file diff --git a/QuantumUNET/QuantumUNET.csproj b/QuantumUNET/QuantumUNET.csproj index bd737170..019e0ae1 100644 --- a/QuantumUNET/QuantumUNET.csproj +++ b/QuantumUNET/QuantumUNET.csproj @@ -120,7 +120,6 @@ - @@ -133,10 +132,8 @@ - - From 83b5daf205dd1978f536a60da8b42051409b155f Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Mon, 7 Dec 2020 20:49:51 +0000 Subject: [PATCH 04/10] code cleanup --- QSB/OrbSync/Events/OrbSlotEvent.cs | 2 -- QSB/OrbSync/Events/OrbSlotMessage.cs | 4 ---- QuantumUNET/QSBNetworkManagerHUD.cs | 4 +--- QuantumUNET/QSBNetworkManagerUNET.cs | 1 - 4 files changed, 1 insertion(+), 10 deletions(-) diff --git a/QSB/OrbSync/Events/OrbSlotEvent.cs b/QSB/OrbSync/Events/OrbSlotEvent.cs index 0713a14a..4f713325 100644 --- a/QSB/OrbSync/Events/OrbSlotEvent.cs +++ b/QSB/OrbSync/Events/OrbSlotEvent.cs @@ -1,7 +1,5 @@ using QSB.EventsCore; -using QSB.Utility; using QSB.WorldSync; -using QSB.WorldSync.Events; namespace QSB.OrbSync.Events { diff --git a/QSB/OrbSync/Events/OrbSlotMessage.cs b/QSB/OrbSync/Events/OrbSlotMessage.cs index a61c2731..c25da215 100644 --- a/QSB/OrbSync/Events/OrbSlotMessage.cs +++ b/QSB/OrbSync/Events/OrbSlotMessage.cs @@ -1,9 +1,5 @@ using QSB.Messaging; using QuantumUNET; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace QSB.OrbSync.Events { diff --git a/QuantumUNET/QSBNetworkManagerHUD.cs b/QuantumUNET/QSBNetworkManagerHUD.cs index 78aed10d..59c17d32 100644 --- a/QuantumUNET/QSBNetworkManagerHUD.cs +++ b/QuantumUNET/QSBNetworkManagerHUD.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.Networking.Match; +using UnityEngine; namespace QuantumUNET { diff --git a/QuantumUNET/QSBNetworkManagerUNET.cs b/QuantumUNET/QSBNetworkManagerUNET.cs index 8e8cb471..515cee78 100644 --- a/QuantumUNET/QSBNetworkManagerUNET.cs +++ b/QuantumUNET/QSBNetworkManagerUNET.cs @@ -1,7 +1,6 @@ using OWML.Logging; using System; using System.Collections.Generic; -using System.Net; using UnityEngine; using UnityEngine.Networking; using UnityEngine.Networking.Match; From 24806ebb984695c67b36a7ffdf37c2903a15ad26 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Mon, 7 Dec 2020 20:52:10 +0000 Subject: [PATCH 05/10] remove more --- QuantumUNET/QSBNetworkClient.cs | 16 ---------- QuantumUNET/QSBNetworkManagerUNET.cs | 47 ++-------------------------- 2 files changed, 3 insertions(+), 60 deletions(-) diff --git a/QuantumUNET/QSBNetworkClient.cs b/QuantumUNET/QSBNetworkClient.cs index e6e4cc2b..bce38ca2 100644 --- a/QuantumUNET/QSBNetworkClient.cs +++ b/QuantumUNET/QSBNetworkClient.cs @@ -5,7 +5,6 @@ using System.Net; using System.Net.Sockets; using UnityEngine; using UnityEngine.Networking; -using UnityEngine.Networking.Match; using UnityEngine.Networking.NetworkSystem; namespace QuantumUNET @@ -574,21 +573,6 @@ namespace QuantumUNET m_Connection.Initialize(m_ServerIp, m_ClientId, m_ClientConnectionId, m_HostTopology); } - private void ConnectWithRelay(MatchInfo info) - { - m_AsyncConnect = ConnectState.Connecting; - Update(); - byte b; - m_ClientConnectionId = NetworkTransport.ConnectToNetworkPeer(m_ClientId, info.address, info.port, 0, 0, info.networkId, QSBUtility.GetSourceID(), info.nodeId, out b); - m_Connection = (QSBNetworkConnection)Activator.CreateInstance(m_NetworkConnectionClass); - m_Connection.SetHandlers(m_MessageHandlers); - m_Connection.Initialize(info.address, m_ClientId, m_ClientConnectionId, m_HostTopology); - if (b != 0) - { - Debug.LogError("ConnectToNetworkPeer Error: " + b); - } - } - public virtual void Disconnect() { m_AsyncConnect = ConnectState.Disconnected; diff --git a/QuantumUNET/QSBNetworkManagerUNET.cs b/QuantumUNET/QSBNetworkManagerUNET.cs index 515cee78..c44e5855 100644 --- a/QuantumUNET/QSBNetworkManagerUNET.cs +++ b/QuantumUNET/QSBNetworkManagerUNET.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; -using UnityEngine.Networking.Match; using UnityEngine.SceneManagement; namespace QuantumUNET @@ -33,8 +32,6 @@ namespace QuantumUNET public GameObject playerPrefab { get; set; } public PlayerSpawnMethod playerSpawnMethod { get; set; } public List spawnPrefabs { get; } = new List(); - public string matchName = "default"; - public uint matchSize = 4U; public QSBNetworkClient client; public int maxConnections { get; set; } = 4; public List channels { get; } = new List(); @@ -159,22 +156,12 @@ namespace QuantumUNET QSBNetworkServer.RegisterHandler(34, new QSBNetworkMessageDelegate(OnServerErrorInternal)); } - public bool StartServer(ConnectionConfig config, int maxConnections) - { - return StartServer(null, config, maxConnections); - } - public bool StartServer() { - return StartServer(null); + return StartServer(null, -1); } - public bool StartServer(MatchInfo info) - { - return StartServer(info, null, -1); - } - - private bool StartServer(MatchInfo info, ConnectionConfig config, int maxConnections) + private bool StartServer(ConnectionConfig config, int maxConnections) { InitializeSingleton(); OnStartServer(); @@ -201,18 +188,7 @@ namespace QuantumUNET { QSBNetworkServer.Configure(config, maxConnections); } - if (info != null) - { - if (!QSBNetworkServer.Listen(info, networkPort)) - { - if (LogFilter.logError) - { - Debug.LogError("StartServer listen failed."); - } - return false; - } - } - else if (serverBindToIP && !string.IsNullOrEmpty(serverBindAddress)) + if (serverBindToIP && !string.IsNullOrEmpty(serverBindAddress)) { if (!QSBNetworkServer.Listen(serverBindAddress, networkPort)) { @@ -390,23 +366,6 @@ namespace QuantumUNET return result; } - public virtual QSBNetworkClient StartHost(MatchInfo info) - { - OnStartHost(); - QSBNetworkClient result; - if (StartServer(info)) - { - var networkClient = ConnectLocalClient(); - OnStartClient(networkClient); - result = networkClient; - } - else - { - result = null; - } - return result; - } - public virtual QSBNetworkClient StartHost() { OnStartHost(); From a814c418a779972b1151ad0bc1d65aefcaead7e0 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Mon, 7 Dec 2020 20:54:14 +0000 Subject: [PATCH 06/10] more cleanup --- QuantumUNET/QSBNetworkManagerUNET.cs | 2 -- QuantumUNET/QSBNetworkServer.cs | 40 ++++++---------------------- 2 files changed, 8 insertions(+), 34 deletions(-) diff --git a/QuantumUNET/QSBNetworkManagerUNET.cs b/QuantumUNET/QSBNetworkManagerUNET.cs index c44e5855..6f45f518 100644 --- a/QuantumUNET/QSBNetworkManagerUNET.cs +++ b/QuantumUNET/QSBNetworkManagerUNET.cs @@ -413,7 +413,6 @@ namespace QuantumUNET } isNetworkActive = false; QSBNetworkServer.Shutdown(); - //StopMatchMaker(); if (!string.IsNullOrEmpty(offlineScene)) { ServerChangeScene(offlineScene); @@ -436,7 +435,6 @@ namespace QuantumUNET client.Shutdown(); client = null; } - //StopMatchMaker(); QSBClientScene.DestroyAllClientObjects(); if (!string.IsNullOrEmpty(offlineScene)) { diff --git a/QuantumUNET/QSBNetworkServer.cs b/QuantumUNET/QSBNetworkServer.cs index 3c4a405b..84218235 100644 --- a/QuantumUNET/QSBNetworkServer.cs +++ b/QuantumUNET/QSBNetworkServer.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using UnityEngine; using UnityEngine.Networking; -using UnityEngine.Networking.Match; using UnityEngine.Networking.Types; namespace QuantumUNET @@ -213,21 +212,6 @@ namespace QuantumUNET s_Active = false; } - public static bool Listen(MatchInfo matchInfo, int listenPort) - { - bool result; - if (!matchInfo.usingRelay) - { - result = instance.InternalListen(null, listenPort); - } - else - { - instance.InternalListenRelay(matchInfo.address, matchInfo.port, matchInfo.networkId, QSBUtility.GetSourceID(), matchInfo.nodeId); - result = true; - } - return result; - } - internal void RegisterMessageHandlers() { m_SimpleServerSimple.RegisterHandlerSafe((short)35, new QSBNetworkMessageDelegate(OnClientReadyMessage)); @@ -279,12 +263,12 @@ namespace QuantumUNET return true; } - public static QSBNetworkClient BecomeHost(QSBNetworkClient oldClient, int port, MatchInfo matchInfo, int oldConnectionId, QSBPeerInfoMessage[] peers) + public static QSBNetworkClient BecomeHost(QSBNetworkClient oldClient, int port, int oldConnectionId, QSBPeerInfoMessage[] peers) { - return instance.BecomeHostInternal(oldClient, port, matchInfo, oldConnectionId, peers); + return instance.BecomeHostInternal(oldClient, port, oldConnectionId, peers); } - internal QSBNetworkClient BecomeHostInternal(QSBNetworkClient oldClient, int port, MatchInfo matchInfo, int oldConnectionId, QSBPeerInfoMessage[] peers) + internal QSBNetworkClient BecomeHostInternal(QSBNetworkClient oldClient, int port, int oldConnectionId, QSBPeerInfoMessage[] peers) { QSBNetworkClient result; if (s_Active) @@ -306,22 +290,14 @@ namespace QuantumUNET else { Configure(hostTopology); - if (matchInfo == null) + Debug.Log("BecomeHost Listen on " + port); + if (!Listen(port)) { - Debug.Log("BecomeHost Listen on " + port); - if (!Listen(port)) + if (LogFilter.logError) { - if (LogFilter.logError) - { - Debug.LogError("BecomeHost bind failed."); - } - return null; + Debug.LogError("BecomeHost bind failed."); } - } - else - { - Debug.Log("BecomeHost match:" + matchInfo.networkId); - ListenRelay(matchInfo.address, matchInfo.port, matchInfo.networkId, QSBUtility.GetSourceID(), matchInfo.nodeId); + return null; } foreach (var networkIdentity in QSBClientScene.Objects.Values) { From f726e651b887485c0ddf66badeba4b01bbdabfb2 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Mon, 7 Dec 2020 21:04:52 +0000 Subject: [PATCH 07/10] cleanup --- QuantumUNET/QSBNetworkClient.cs | 9 -- QuantumUNET/QSBNetworkConnection.cs | 3 - QuantumUNET/QSBNetworkManagerHUD.cs | 21 --- QuantumUNET/QSBNetworkReader.cs | 236 ++++++++++------------------ QuantumUNET/QSBNetworkScene.cs | 46 +++--- QuantumUNET/QSBNetworkServer.cs | 59 ++----- 6 files changed, 113 insertions(+), 261 deletions(-) diff --git a/QuantumUNET/QSBNetworkClient.cs b/QuantumUNET/QSBNetworkClient.cs index bce38ca2..40cba469 100644 --- a/QuantumUNET/QSBNetworkClient.cs +++ b/QuantumUNET/QSBNetworkClient.cs @@ -75,15 +75,6 @@ namespace QuantumUNET } } - [Obsolete("Moved to NetworkMigrationManager.")] - public PeerInfoMessage[] peers - { - get - { - return null; - } - } - internal int hostId { get diff --git a/QuantumUNET/QSBNetworkConnection.cs b/QuantumUNET/QSBNetworkConnection.cs index 9b0cddb8..37b9c0c9 100644 --- a/QuantumUNET/QSBNetworkConnection.cs +++ b/QuantumUNET/QSBNetworkConnection.cs @@ -450,9 +450,6 @@ namespace QuantumUNET public virtual void TransportReceive(byte[] bytes, int numBytes, int channelId) => HandleBytes(bytes, numBytes, channelId); - [Obsolete("TransportRecieve has been deprecated. Use TransportReceive instead (UnityUpgradable) -> TransportReceive(*)", false)] - public virtual void TransportRecieve(byte[] bytes, int numBytes, int channelId) => TransportReceive(bytes, numBytes, channelId); - public virtual bool TransportSend(byte[] bytes, int numBytes, int channelId, out byte error) => NetworkTransport.Send(hostId, connectionId, channelId, bytes, numBytes, out error); internal void AddOwnedObject(QSBNetworkIdentity obj) diff --git a/QuantumUNET/QSBNetworkManagerHUD.cs b/QuantumUNET/QSBNetworkManagerHUD.cs index 59c17d32..046016c0 100644 --- a/QuantumUNET/QSBNetworkManagerHUD.cs +++ b/QuantumUNET/QSBNetworkManagerHUD.cs @@ -34,19 +34,6 @@ namespace QuantumUNET } manager.networkAddress = GUI.TextField(new Rect(num + 100, num2, 95f, 20f), manager.networkAddress); num2 += 24; - if (Application.platform == RuntimePlatform.WebGLPlayer) - { - GUI.Box(new Rect(num, num2, 200f, 25f), "( WebGL cannot be server )"); - num2 += 24; - } - else - { - if (GUI.Button(new Rect(num, num2, 200f, 20f), "LAN Server Only")) - { - manager.StartServer(); - } - num2 += 24; - } } else { @@ -103,14 +90,6 @@ namespace QuantumUNET } num2 += 24; } - if (!QSBNetworkServer.active && !manager.IsClientConnected() && flag) - { - num2 += 10; - if (Application.platform == RuntimePlatform.WebGLPlayer) - { - GUI.Box(new Rect(num - 5, num2, 220f, 25f), "(WebGL cannot use Match Maker)"); - } - } } } diff --git a/QuantumUNET/QSBNetworkReader.cs b/QuantumUNET/QSBNetworkReader.cs index c4a676c3..1200d589 100644 --- a/QuantumUNET/QSBNetworkReader.cs +++ b/QuantumUNET/QSBNetworkReader.cs @@ -7,11 +7,9 @@ namespace QuantumUNET { public class QSBNetworkReader { - public QSBNetworkReader() - { - m_buf = new QSBNetBuffer(); - Initialize(); - } + private QSBNetBuffer m_buf; + private static byte[] s_StringReaderBuffer; + private static Encoding s_Encoding; public QSBNetworkReader(QSBNetworkWriter writer) { @@ -34,69 +32,51 @@ namespace QuantumUNET } } - public uint Position - { - get - { - return m_buf.Position; - } - } + public uint Position => m_buf.Position; - public int Length - { - get - { - return m_buf.Length; - } - } + public int Length => m_buf.Length; - public void SeekZero() - { - m_buf.SeekZero(); - } + public void SeekZero() => m_buf.SeekZero(); - internal void Replace(byte[] buffer) - { - m_buf.Replace(buffer); - } + internal void Replace(byte[] buffer) => m_buf.Replace(buffer); public uint ReadPackedUInt32() { - byte b = ReadByte(); + var b = ReadByte(); uint result; if (b < 241) { - result = (uint)b; + result = b; } else { - byte b2 = ReadByte(); + var b2 = ReadByte(); if (b >= 241 && b <= 248) { - result = 240U + 256U * (uint)(b - 241) + (uint)b2; + result = 240U + (256U * (uint)(b - 241)) + b2; } else { - byte b3 = ReadByte(); + var b3 = ReadByte(); if (b == 249) { - result = 2288U + 256U * (uint)b2 + (uint)b3; + result = 2288U + (256U * b2) + b3; } else { - byte b4 = ReadByte(); + var b4 = ReadByte(); if (b == 250) { - result = (uint)((int)b2 + ((int)b3 << 8) + ((int)b4 << 16)); + result = (uint)(b2 + (b3 << 8) + (b4 << 16)); } else { - byte b5 = ReadByte(); + var b5 = ReadByte(); if (b < 251) { throw new IndexOutOfRangeException("ReadPackedUInt32() failure: " + b); } - result = (uint)((int)b2 + ((int)b3 << 8) + ((int)b4 << 16) + ((int)b5 << 24)); + result = (uint)(b2 + (b3 << 8) + (b4 << 16) + (b5 << 24)); } } } @@ -106,69 +86,69 @@ namespace QuantumUNET public ulong ReadPackedUInt64() { - byte b = ReadByte(); + var b = ReadByte(); ulong result; if (b < 241) { - result = (ulong)b; + result = b; } else { - byte b2 = ReadByte(); + var b2 = ReadByte(); if (b >= 241 && b <= 248) { - result = 240UL + 256UL * ((ulong)b - 241UL) + (ulong)b2; + result = 240UL + (256UL * (b - 241UL)) + b2; } else { - byte b3 = ReadByte(); + var b3 = ReadByte(); if (b == 249) { - result = 2288UL + 256UL * (ulong)b2 + (ulong)b3; + result = 2288UL + (256UL * b2) + b3; } else { - byte b4 = ReadByte(); + var b4 = ReadByte(); if (b == 250) { - result = (ulong)b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16); + result = b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16); } else { - byte b5 = ReadByte(); + var b5 = ReadByte(); if (b == 251) { - result = (ulong)b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24); + result = b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24); } else { - byte b6 = ReadByte(); + var b6 = ReadByte(); if (b == 252) { - result = (ulong)b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32); + result = b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32); } else { - byte b7 = ReadByte(); + var b7 = ReadByte(); if (b == 253) { - result = (ulong)b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32) + ((ulong)b7 << 40); + result = b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32) + ((ulong)b7 << 40); } else { - byte b8 = ReadByte(); + var b8 = ReadByte(); if (b == 254) { - result = (ulong)b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32) + ((ulong)b7 << 40) + ((ulong)b8 << 48); + result = b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32) + ((ulong)b7 << 40) + ((ulong)b8 << 48); } else { - byte b9 = ReadByte(); + var b9 = ReadByte(); if (b != 255) { throw new IndexOutOfRangeException("ReadPackedUInt64() failure: " + b); } - result = (ulong)b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32) + ((ulong)b7 << 40) + ((ulong)b8 << 48) + ((ulong)b9 << 56); + result = b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32) + ((ulong)b7 << 40) + ((ulong)b8 << 48) + ((ulong)b9 << 56); } } } @@ -180,61 +160,46 @@ namespace QuantumUNET return result; } - public NetworkInstanceId ReadNetworkId() - { - return new NetworkInstanceId(ReadPackedUInt32()); - } + public NetworkInstanceId ReadNetworkId() => new NetworkInstanceId(ReadPackedUInt32()); - public NetworkSceneId ReadSceneId() - { - return new NetworkSceneId(ReadPackedUInt32()); - } + public NetworkSceneId ReadSceneId() => new NetworkSceneId(ReadPackedUInt32()); - public byte ReadByte() - { - return m_buf.ReadByte(); - } + public byte ReadByte() => m_buf.ReadByte(); - public sbyte ReadSByte() - { - return (sbyte)m_buf.ReadByte(); - } + public sbyte ReadSByte() => (sbyte)m_buf.ReadByte(); public short ReadInt16() { ushort num = 0; - num |= (ushort)m_buf.ReadByte(); + num |= m_buf.ReadByte(); num |= (ushort)(m_buf.ReadByte() << 8); return (short)num; } - public ushort ReadUInt16() - { - return (ushort)((uint)(ushort)(0U | (uint)m_buf.ReadByte()) | (uint)(ushort)((uint)m_buf.ReadByte() << 8)); - } + public ushort ReadUInt16() => (ushort)((ushort)(0U | m_buf.ReadByte()) | (uint)(ushort)((uint)m_buf.ReadByte() << 8)); public int ReadInt32() { - uint num = 0U; - num |= (uint)m_buf.ReadByte(); - num |= (uint)((uint)m_buf.ReadByte() << 8); - num |= (uint)((uint)m_buf.ReadByte() << 16); - return (int)(num | (uint)((uint)m_buf.ReadByte() << 24)); + var num = 0U; + num |= m_buf.ReadByte(); + num |= (uint)m_buf.ReadByte() << 8; + num |= (uint)m_buf.ReadByte() << 16; + return (int)(num | ((uint)m_buf.ReadByte() << 24)); } public uint ReadUInt32() { - uint num = 0U; - num |= (uint)m_buf.ReadByte(); - num |= (uint)((uint)m_buf.ReadByte() << 8); - num |= (uint)((uint)m_buf.ReadByte() << 16); - return num | (uint)((uint)m_buf.ReadByte() << 24); + var num = 0U; + num |= m_buf.ReadByte(); + num |= (uint)m_buf.ReadByte() << 8; + num |= (uint)m_buf.ReadByte() << 16; + return num | ((uint)m_buf.ReadByte() << 24); } public long ReadInt64() { - ulong num = 0UL; - ulong num2 = (ulong)m_buf.ReadByte(); + var num = 0UL; + var num2 = (ulong)m_buf.ReadByte(); num |= num2; num2 = (ulong)m_buf.ReadByte() << 8; num |= num2; @@ -254,8 +219,8 @@ namespace QuantumUNET public ulong ReadUInt64() { - ulong num = 0UL; - ulong num2 = (ulong)m_buf.ReadByte(); + var num = 0UL; + var num2 = (ulong)m_buf.ReadByte(); num |= num2; num2 = (ulong)m_buf.ReadByte() << 8; num |= num2; @@ -298,7 +263,7 @@ namespace QuantumUNET public string ReadString() { - ushort num = ReadUInt16(); + var num = ReadUInt16(); string result; if (num == 0) { @@ -310,25 +275,22 @@ namespace QuantumUNET { throw new IndexOutOfRangeException("ReadString() too long: " + num); } - while ((int)num > s_StringReaderBuffer.Length) + while (num > s_StringReaderBuffer.Length) { s_StringReaderBuffer = new byte[s_StringReaderBuffer.Length * 2]; } - m_buf.ReadBytes(s_StringReaderBuffer, (uint)num); - char[] chars = s_Encoding.GetChars(s_StringReaderBuffer, 0, (int)num); + m_buf.ReadBytes(s_StringReaderBuffer, num); + var chars = s_Encoding.GetChars(s_StringReaderBuffer, 0, num); result = new string(chars); } return result; } - public char ReadChar() - { - return (char)m_buf.ReadByte(); - } + public char ReadChar() => (char)m_buf.ReadByte(); public bool ReadBoolean() { - int num = (int)m_buf.ReadByte(); + var num = (int)m_buf.ReadByte(); return num == 1; } @@ -338,14 +300,14 @@ namespace QuantumUNET { throw new IndexOutOfRangeException("NetworkReader ReadBytes " + count); } - byte[] array = new byte[count]; + var array = new byte[count]; m_buf.ReadBytes(array, (uint)count); return array; } public byte[] ReadBytesAndSize() { - ushort num = ReadUInt16(); + var num = ReadUInt16(); byte[] result; if (num == 0) { @@ -353,55 +315,28 @@ namespace QuantumUNET } else { - result = ReadBytes((int)num); + result = ReadBytes(num); } return result; } - public Vector2 ReadVector2() - { - return new Vector2(ReadSingle(), ReadSingle()); - } + public Vector2 ReadVector2() => new Vector2(ReadSingle(), ReadSingle()); - public Vector3 ReadVector3() - { - return new Vector3(ReadSingle(), ReadSingle(), ReadSingle()); - } + public Vector3 ReadVector3() => new Vector3(ReadSingle(), ReadSingle(), ReadSingle()); - public Vector4 ReadVector4() - { - return new Vector4(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle()); - } + public Vector4 ReadVector4() => new Vector4(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle()); - public Color ReadColor() - { - return new Color(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle()); - } + public Color ReadColor() => new Color(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle()); - public Color32 ReadColor32() - { - return new Color32(ReadByte(), ReadByte(), ReadByte(), ReadByte()); - } + public Color32 ReadColor32() => new Color32(ReadByte(), ReadByte(), ReadByte(), ReadByte()); - public Quaternion ReadQuaternion() - { - return new Quaternion(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle()); - } + public Quaternion ReadQuaternion() => new Quaternion(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle()); - public Rect ReadRect() - { - return new Rect(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle()); - } + public Rect ReadRect() => new Rect(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle()); - public Plane ReadPlane() - { - return new Plane(ReadVector3(), ReadSingle()); - } + public Plane ReadPlane() => new Plane(ReadVector3(), ReadSingle()); - public Ray ReadRay() - { - return new Ray(ReadVector3(), ReadVector3()); - } + public Ray ReadRay() => new Ray(ReadVector3(), ReadVector3()); public Matrix4x4 ReadMatrix4x4() { @@ -450,7 +385,7 @@ namespace QuantumUNET public Transform ReadTransform() { - NetworkInstanceId networkInstanceId = ReadNetworkId(); + var networkInstanceId = ReadNetworkId(); Transform result; if (networkInstanceId.IsEmpty()) { @@ -458,7 +393,7 @@ namespace QuantumUNET } else { - GameObject gameObject = QSBClientScene.FindLocalObject(networkInstanceId); + var gameObject = QSBClientScene.FindLocalObject(networkInstanceId); if (gameObject == null) { if (LogFilter.logDebug) @@ -477,7 +412,7 @@ namespace QuantumUNET public GameObject ReadGameObject() { - NetworkInstanceId networkInstanceId = ReadNetworkId(); + var networkInstanceId = ReadNetworkId(); GameObject result; if (networkInstanceId.IsEmpty()) { @@ -508,7 +443,7 @@ namespace QuantumUNET public QSBNetworkIdentity ReadNetworkIdentity() { - NetworkInstanceId networkInstanceId = ReadNetworkId(); + var networkInstanceId = ReadNetworkId(); QSBNetworkIdentity result; if (networkInstanceId.IsEmpty()) { @@ -541,26 +476,13 @@ namespace QuantumUNET return result; } - public override string ToString() - { - return m_buf.ToString(); - } + public override string ToString() => m_buf.ToString(); public TMsg ReadMessage() where TMsg : QSBMessageBase, new() { - TMsg result = Activator.CreateInstance(); + var result = Activator.CreateInstance(); result.Deserialize(this); return result; } - - private QSBNetBuffer m_buf; - - private const int k_MaxStringLength = 32768; - - private const int k_InitialStringBufferSize = 1024; - - private static byte[] s_StringReaderBuffer; - - private static Encoding s_Encoding; } } \ No newline at end of file diff --git a/QuantumUNET/QSBNetworkScene.cs b/QuantumUNET/QSBNetworkScene.cs index 31346daa..a88b6255 100644 --- a/QuantumUNET/QSBNetworkScene.cs +++ b/QuantumUNET/QSBNetworkScene.cs @@ -18,13 +18,13 @@ namespace QuantumUNET { get { - return this.m_LocalObjects; + return m_LocalObjects; } } internal void Shutdown() { - this.ClearLocalObjects(); + ClearLocalObjects(); ClearSpawners(); } @@ -32,19 +32,19 @@ namespace QuantumUNET { if (obj == null) { - this.localObjects[netId] = null; + localObjects[netId] = null; } else { QSBNetworkIdentity networkIdentity = null; - if (this.localObjects.ContainsKey(netId)) + if (localObjects.ContainsKey(netId)) { - networkIdentity = this.localObjects[netId]; + networkIdentity = localObjects[netId]; } if (networkIdentity == null) { networkIdentity = obj.GetComponent(); - this.localObjects[netId] = networkIdentity; + localObjects[netId] = networkIdentity; } networkIdentity.UpdateClientServer(isClient, isServer); } @@ -52,9 +52,9 @@ namespace QuantumUNET internal GameObject FindLocalObject(NetworkInstanceId netId) { - if (this.localObjects.ContainsKey(netId)) + if (localObjects.ContainsKey(netId)) { - QSBNetworkIdentity networkIdentity = this.localObjects[netId]; + var networkIdentity = localObjects[netId]; if (networkIdentity != null) { return networkIdentity.gameObject; @@ -87,11 +87,11 @@ namespace QuantumUNET internal bool RemoveLocalObjectAndDestroy(NetworkInstanceId netId) { bool result; - if (this.localObjects.ContainsKey(netId)) + if (localObjects.ContainsKey(netId)) { - QSBNetworkIdentity networkIdentity = this.localObjects[netId]; + var networkIdentity = localObjects[netId]; UnityEngine.Object.Destroy(networkIdentity.gameObject); - result = this.localObjects.Remove(netId); + result = localObjects.Remove(netId); } else { @@ -102,12 +102,12 @@ namespace QuantumUNET internal void ClearLocalObjects() { - this.localObjects.Clear(); + localObjects.Clear(); } internal static void RegisterPrefab(GameObject prefab, NetworkHash128 newAssetId) { - QSBNetworkIdentity component = prefab.GetComponent(); + var component = prefab.GetComponent(); if (component) { component.SetDynamicAssetId(newAssetId); @@ -121,11 +121,11 @@ namespace QuantumUNET internal static void RegisterPrefab(GameObject prefab) { - QSBNetworkIdentity component = prefab.GetComponent(); + var component = prefab.GetComponent(); if (component) { guidToPrefab[component.AssetId] = prefab; - NetworkIdentity[] componentsInChildren = prefab.GetComponentsInChildren(); + var componentsInChildren = prefab.GetComponentsInChildren(); if (componentsInChildren.Length > 1) { if (LogFilter.logWarn) @@ -192,7 +192,7 @@ namespace QuantumUNET internal static void UnregisterPrefab(GameObject prefab) { - QSBNetworkIdentity component = prefab.GetComponent(); + var component = prefab.GetComponent(); if (component == null) { if (LogFilter.logError) @@ -209,7 +209,7 @@ namespace QuantumUNET internal static void RegisterPrefab(GameObject prefab, SpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler) { - QSBNetworkIdentity component = prefab.GetComponent(); + var component = prefab.GetComponent(); if (component == null) { Debug.LogError("Could not register '" + prefab.name + "' since it contains no NetworkIdentity component"); @@ -250,7 +250,7 @@ namespace QuantumUNET bool result; if (unspawnHandlers.ContainsKey(assetId) && unspawnHandlers[assetId] != null) { - UnSpawnDelegate unSpawnDelegate = unspawnHandlers[assetId]; + var unSpawnDelegate = unspawnHandlers[assetId]; unSpawnDelegate(obj); result = true; } @@ -263,9 +263,9 @@ namespace QuantumUNET internal void DestroyAllClientObjects() { - foreach (NetworkInstanceId key in this.localObjects.Keys) + foreach (var key in localObjects.Keys) { - QSBNetworkIdentity networkIdentity = this.localObjects[key]; + var networkIdentity = localObjects[key]; if (networkIdentity != null && networkIdentity.gameObject != null) { if (!InvokeUnSpawnHandler(networkIdentity.AssetId, networkIdentity.gameObject)) @@ -282,14 +282,14 @@ namespace QuantumUNET } } } - this.ClearLocalObjects(); + ClearLocalObjects(); } internal void DumpAllClientObjects() { - foreach (NetworkInstanceId networkInstanceId in this.localObjects.Keys) + foreach (var networkInstanceId in localObjects.Keys) { - QSBNetworkIdentity networkIdentity = this.localObjects[networkInstanceId]; + var networkIdentity = localObjects[networkInstanceId]; if (networkIdentity != null) { Debug.Log(string.Concat(new object[] diff --git a/QuantumUNET/QSBNetworkServer.cs b/QuantumUNET/QSBNetworkServer.cs index 84218235..838a24ad 100644 --- a/QuantumUNET/QSBNetworkServer.cs +++ b/QuantumUNET/QSBNetworkServer.cs @@ -75,29 +75,7 @@ namespace QuantumUNET } } - [Obsolete("Moved to NetworkMigrationManager")] - public static bool sendPeerInfo - { - get - { - return false; - } - set - { - } - } - - public static bool dontListen - { - get - { - return m_DontListen; - } - set - { - m_DontListen = value; - } - } + public static bool dontListen { get; set; } public static bool useWebSockets { @@ -130,13 +108,7 @@ namespace QuantumUNET } } - public static bool active - { - get - { - return s_Active; - } - } + public static bool active { get; private set; } public static bool localClientActive { @@ -194,7 +166,7 @@ namespace QuantumUNET NetworkTransport.Shutdown(); NetworkTransport.Init(); s_Instance = null; - s_Active = false; + active = false; } public static void Shutdown() @@ -202,14 +174,14 @@ namespace QuantumUNET if (s_Instance != null) { s_Instance.InternalDisconnectAll(); - if (!m_DontListen) + if (!dontListen) { s_Instance.m_SimpleServerSimple.Stop(); } s_Instance = null; } - m_DontListen = false; - s_Active = false; + dontListen = false; + active = false; } internal void RegisterMessageHandlers() @@ -233,7 +205,7 @@ namespace QuantumUNET private void InternalListenRelay(string relayIp, int relayPort, NetworkID netGuid, SourceID sourceId, NodeID nodeId) { m_SimpleServerSimple.ListenRelay(relayIp, relayPort, netGuid, sourceId, nodeId); - s_Active = true; + active = true; RegisterMessageHandlers(); } @@ -249,7 +221,7 @@ namespace QuantumUNET internal bool InternalListen(string ipAddress, int serverPort) { - if (m_DontListen) + if (dontListen) { m_SimpleServerSimple.Initialize(); } @@ -258,7 +230,7 @@ namespace QuantumUNET return false; } maxPacketSize = hostTopology.DefaultConfig.PacketSize; - s_Active = true; + active = true; RegisterMessageHandlers(); return true; } @@ -271,7 +243,7 @@ namespace QuantumUNET internal QSBNetworkClient BecomeHostInternal(QSBNetworkClient oldClient, int port, int oldConnectionId, QSBPeerInfoMessage[] peers) { QSBNetworkClient result; - if (s_Active) + if (active) { if (LogFilter.logError) { @@ -741,7 +713,7 @@ namespace QuantumUNET internal void InternalUpdate() { m_SimpleServerSimple.Update(); - if (m_DontListen) + if (dontListen) { m_SimpleServerSimple.UpdateConnections(); } @@ -1916,19 +1888,10 @@ namespace QuantumUNET } } - [Obsolete("moved to NetworkMigrationManager")] - public void SendNetworkInfo(NetworkConnection targetConnection) - { - } - - private static bool s_Active; - private static volatile QSBNetworkServer s_Instance; private static object s_Sync = new UnityEngine.Object(); - private static bool m_DontListen; - private bool m_LocalClientActive; private List m_LocalConnectionsFakeList = new List(); From 2f1e4373cf7daf63a9dae6f854a173a10b5a55f5 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Mon, 7 Dec 2020 21:05:01 +0000 Subject: [PATCH 08/10] Update QSBNetworkClient.cs --- QuantumUNET/QSBNetworkClient.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/QuantumUNET/QSBNetworkClient.cs b/QuantumUNET/QSBNetworkClient.cs index 40cba469..2b72f8eb 100644 --- a/QuantumUNET/QSBNetworkClient.cs +++ b/QuantumUNET/QSBNetworkClient.cs @@ -5,7 +5,6 @@ using System.Net; using System.Net.Sockets; using UnityEngine; using UnityEngine.Networking; -using UnityEngine.Networking.NetworkSystem; namespace QuantumUNET { From 36f925a983ed5664ed9f9bda51467a5277ca5e67 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Mon, 7 Dec 2020 21:19:16 +0000 Subject: [PATCH 09/10] re-organize --- QSB/Animation/AnimationSync.cs | 1 + QSB/MessagesCore/MessageHandler.cs | 1 + QSB/MessagesCore/PlayerMessage.cs | 1 + QSB/OrbSync/Events/OrbUserEvent.cs | 1 + QSB/Player/PlayerSyncObject.cs | 1 + QSB/Player/QSBPlayerManager.cs | 1 + QSB/QSB.cs | 1 + QSB/QSBNetworkManager.cs | 1 + .../{ => Components}/QSBNetworkAnimator.cs | 5 +- .../{ => Components}/QSBNetworkIdentity.cs | 3 +- .../{ => Components}/QSBNetworkManagerHUD.cs | 2 +- .../{ => Components}/QSBNetworkManagerUNET.cs | 3 +- .../{ => Components}/QSBNetworkTransform.cs | 3 +- .../{ => Messages}/QSBAddPlayerMessage.cs | 2 +- .../{ => Messages}/QSBAnimationMessage.cs | 2 +- .../QSBAnimationParametersMessage.cs | 2 +- .../QSBAnimationTriggerMessage.cs | 2 +- QuantumUNET/{ => Messages}/QSBCRCMessage.cs | 2 +- .../QSBClientAuthorityMessage.cs | 2 +- QuantumUNET/{ => Messages}/QSBEmptyMessage.cs | 2 +- QuantumUNET/{ => Messages}/QSBErrorMessage.cs | 2 +- QuantumUNET/{ => Messages}/QSBMessageBase.cs | 2 +- .../{ => Messages}/QSBNetworkMessage.cs | 2 +- .../QSBNetworkMessageDelegate.cs | 2 +- .../{ => Messages}/QSBNotReadyMessage.cs | 2 +- .../{ => Messages}/QSBObjectDestroyMessage.cs | 2 +- .../QSBObjectSpawnFinishedMessage.cs | 2 +- .../{ => Messages}/QSBObjectSpawnMessage.cs | 2 +- .../QSBObjectSpawnSceneMessage.cs | 2 +- QuantumUNET/{ => Messages}/QSBOwnerMessage.cs | 2 +- .../{ => Messages}/QSBPeerInfoMessage.cs | 2 +- QuantumUNET/{ => Messages}/QSBReadyMessage.cs | 2 +- .../{ => Messages}/QSBReconnectMessage.cs | 2 +- .../{ => Messages}/QSBRemovePlayerMessage.cs | 2 +- .../{ => Messages}/QSBStringMessage.cs | 2 +- QuantumUNET/QSBChannelBuffer.cs | 3 +- QuantumUNET/QSBClientScene.cs | 4 +- QuantumUNET/QSBLocalClient.cs | 3 +- QuantumUNET/QSBNetworkBehaviour.cs | 1 + QuantumUNET/QSBNetworkClient.cs | 1 + QuantumUNET/QSBNetworkConnection.cs | 2 + QuantumUNET/QSBNetworkMessageHandlers.cs | 3 +- QuantumUNET/QSBNetworkReader.cs | 4 +- QuantumUNET/QSBNetworkScene.cs | 3 +- QuantumUNET/QSBNetworkServer.cs | 2 + QuantumUNET/QSBNetworkServerSimple.cs | 3 +- QuantumUNET/QSBNetworkWriter.cs | 4 +- QuantumUNET/QSBPlayerController.cs | 3 +- QuantumUNET/QSBULocalConnectionToClient.cs | 4 +- QuantumUNET/QSBULocalConnectionToServer.cs | 3 +- QuantumUNET/QuantumUNET.csproj | 54 +++++++++---------- 51 files changed, 99 insertions(+), 66 deletions(-) rename QuantumUNET/{ => Components}/QSBNetworkAnimator.cs (99%) rename QuantumUNET/{ => Components}/QSBNetworkIdentity.cs (99%) rename QuantumUNET/{ => Components}/QSBNetworkManagerHUD.cs (98%) rename QuantumUNET/{ => Components}/QSBNetworkManagerUNET.cs (99%) rename QuantumUNET/{ => Components}/QSBNetworkTransform.cs (99%) rename QuantumUNET/{ => Messages}/QSBAddPlayerMessage.cs (94%) rename QuantumUNET/{ => Messages}/QSBAnimationMessage.cs (96%) rename QuantumUNET/{ => Messages}/QSBAnimationParametersMessage.cs (94%) rename QuantumUNET/{ => Messages}/QSBAnimationTriggerMessage.cs (93%) rename QuantumUNET/{ => Messages}/QSBCRCMessage.cs (95%) rename QuantumUNET/{ => Messages}/QSBClientAuthorityMessage.cs (93%) rename QuantumUNET/{ => Messages}/QSBEmptyMessage.cs (84%) rename QuantumUNET/{ => Messages}/QSBErrorMessage.cs (89%) rename QuantumUNET/{ => Messages}/QSBMessageBase.cs (84%) rename QuantumUNET/{ => Messages}/QSBNetworkMessage.cs (94%) rename QuantumUNET/{ => Messages}/QSBNetworkMessageDelegate.cs (69%) rename QuantumUNET/{ => Messages}/QSBNotReadyMessage.cs (63%) rename QuantumUNET/{ => Messages}/QSBObjectDestroyMessage.cs (91%) rename QuantumUNET/{ => Messages}/QSBObjectSpawnFinishedMessage.cs (89%) rename QuantumUNET/{ => Messages}/QSBObjectSpawnMessage.cs (96%) rename QuantumUNET/{ => Messages}/QSBObjectSpawnSceneMessage.cs (95%) rename QuantumUNET/{ => Messages}/QSBOwnerMessage.cs (93%) rename QuantumUNET/{ => Messages}/QSBPeerInfoMessage.cs (98%) rename QuantumUNET/{ => Messages}/QSBReadyMessage.cs (62%) rename QuantumUNET/{ => Messages}/QSBReconnectMessage.cs (96%) rename QuantumUNET/{ => Messages}/QSBRemovePlayerMessage.cs (90%) rename QuantumUNET/{ => Messages}/QSBStringMessage.cs (91%) diff --git a/QSB/Animation/AnimationSync.cs b/QSB/Animation/AnimationSync.cs index 6d425a83..af08996d 100644 --- a/QSB/Animation/AnimationSync.cs +++ b/QSB/Animation/AnimationSync.cs @@ -4,6 +4,7 @@ using QSB.EventsCore; using QSB.Player; using QSB.Utility; using QuantumUNET; +using QuantumUNET.Components; using System.Linq; using UnityEngine; diff --git a/QSB/MessagesCore/MessageHandler.cs b/QSB/MessagesCore/MessageHandler.cs index 729c59c9..c5ff89df 100644 --- a/QSB/MessagesCore/MessageHandler.cs +++ b/QSB/MessagesCore/MessageHandler.cs @@ -2,6 +2,7 @@ using QSB.EventsCore; using QSB.Utility; using QuantumUNET; +using QuantumUNET.Messages; using System; using System.Linq; using UnityEngine.Networking; diff --git a/QSB/MessagesCore/PlayerMessage.cs b/QSB/MessagesCore/PlayerMessage.cs index 51609d9e..4362eb0e 100644 --- a/QSB/MessagesCore/PlayerMessage.cs +++ b/QSB/MessagesCore/PlayerMessage.cs @@ -1,4 +1,5 @@ using QuantumUNET; +using QuantumUNET.Messages; namespace QSB.Messaging { diff --git a/QSB/OrbSync/Events/OrbUserEvent.cs b/QSB/OrbSync/Events/OrbUserEvent.cs index d9b9cf48..ba30815d 100644 --- a/QSB/OrbSync/Events/OrbUserEvent.cs +++ b/QSB/OrbSync/Events/OrbUserEvent.cs @@ -4,6 +4,7 @@ using QSB.Utility; using QSB.WorldSync; using QSB.WorldSync.Events; using QuantumUNET; +using QuantumUNET.Components; using System.Linq; namespace QSB.OrbSync.Events diff --git a/QSB/Player/PlayerSyncObject.cs b/QSB/Player/PlayerSyncObject.cs index 7cd9145e..9ac03338 100644 --- a/QSB/Player/PlayerSyncObject.cs +++ b/QSB/Player/PlayerSyncObject.cs @@ -1,4 +1,5 @@ using QuantumUNET; +using QuantumUNET.Components; namespace QSB.Player { diff --git a/QSB/Player/QSBPlayerManager.cs b/QSB/Player/QSBPlayerManager.cs index c31956e1..467d30f4 100644 --- a/QSB/Player/QSBPlayerManager.cs +++ b/QSB/Player/QSBPlayerManager.cs @@ -3,6 +3,7 @@ using QSB.Player.Events; using QSB.TransformSync; using QSB.Utility; using QuantumUNET; +using QuantumUNET.Components; using System.Collections.Generic; using System.Linq; diff --git a/QSB/QSB.cs b/QSB/QSB.cs index 1235976c..53e50f40 100644 --- a/QSB/QSB.cs +++ b/QSB/QSB.cs @@ -10,6 +10,7 @@ using QSB.SectorSync; using QSB.TimeSync; using QSB.Utility; using QuantumUNET; +using QuantumUNET.Components; using UnityEngine; using UnityEngine.Networking; diff --git a/QSB/QSBNetworkManager.cs b/QSB/QSBNetworkManager.cs index a178292f..b8665452 100644 --- a/QSB/QSBNetworkManager.cs +++ b/QSB/QSBNetworkManager.cs @@ -15,6 +15,7 @@ using QSB.TransformSync; using QSB.Utility; using QSB.WorldSync; using QuantumUNET; +using QuantumUNET.Components; using System; using System.Linq; using UnityEngine; diff --git a/QuantumUNET/QSBNetworkAnimator.cs b/QuantumUNET/Components/QSBNetworkAnimator.cs similarity index 99% rename from QuantumUNET/QSBNetworkAnimator.cs rename to QuantumUNET/Components/QSBNetworkAnimator.cs index 542fd693..4cfacf72 100644 --- a/QuantumUNET/QSBNetworkAnimator.cs +++ b/QuantumUNET/Components/QSBNetworkAnimator.cs @@ -1,6 +1,7 @@ -using UnityEngine; +using QuantumUNET.Messages; +using UnityEngine; -namespace QuantumUNET +namespace QuantumUNET.Components { public class QSBNetworkAnimator : QSBNetworkBehaviour { diff --git a/QuantumUNET/QSBNetworkIdentity.cs b/QuantumUNET/Components/QSBNetworkIdentity.cs similarity index 99% rename from QuantumUNET/QSBNetworkIdentity.cs rename to QuantumUNET/Components/QSBNetworkIdentity.cs index a4dc90d1..4c144e0c 100644 --- a/QuantumUNET/QSBNetworkIdentity.cs +++ b/QuantumUNET/Components/QSBNetworkIdentity.cs @@ -1,11 +1,12 @@ using OWML.Logging; +using QuantumUNET.Messages; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using UnityEngine; using UnityEngine.Networking; -namespace QuantumUNET +namespace QuantumUNET.Components { public sealed class QSBNetworkIdentity : MonoBehaviour { diff --git a/QuantumUNET/QSBNetworkManagerHUD.cs b/QuantumUNET/Components/QSBNetworkManagerHUD.cs similarity index 98% rename from QuantumUNET/QSBNetworkManagerHUD.cs rename to QuantumUNET/Components/QSBNetworkManagerHUD.cs index 046016c0..58cc9ddf 100644 --- a/QuantumUNET/QSBNetworkManagerHUD.cs +++ b/QuantumUNET/Components/QSBNetworkManagerHUD.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace QuantumUNET +namespace QuantumUNET.Components { public class QSBNetworkManagerHUD : MonoBehaviour { diff --git a/QuantumUNET/QSBNetworkManagerUNET.cs b/QuantumUNET/Components/QSBNetworkManagerUNET.cs similarity index 99% rename from QuantumUNET/QSBNetworkManagerUNET.cs rename to QuantumUNET/Components/QSBNetworkManagerUNET.cs index 6f45f518..39a321a0 100644 --- a/QuantumUNET/QSBNetworkManagerUNET.cs +++ b/QuantumUNET/Components/QSBNetworkManagerUNET.cs @@ -1,11 +1,12 @@ using OWML.Logging; +using QuantumUNET.Messages; using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; using UnityEngine.SceneManagement; -namespace QuantumUNET +namespace QuantumUNET.Components { public class QSBNetworkManagerUNET : MonoBehaviour { diff --git a/QuantumUNET/QSBNetworkTransform.cs b/QuantumUNET/Components/QSBNetworkTransform.cs similarity index 99% rename from QuantumUNET/QSBNetworkTransform.cs rename to QuantumUNET/Components/QSBNetworkTransform.cs index 7c438520..66de6f11 100644 --- a/QuantumUNET/QSBNetworkTransform.cs +++ b/QuantumUNET/Components/QSBNetworkTransform.cs @@ -1,8 +1,9 @@ using OWML.Logging; +using QuantumUNET.Messages; using UnityEngine; using UnityEngine.Networking; -namespace QuantumUNET +namespace QuantumUNET.Components { public class QSBNetworkTransform : QSBNetworkBehaviour { diff --git a/QuantumUNET/QSBAddPlayerMessage.cs b/QuantumUNET/Messages/QSBAddPlayerMessage.cs similarity index 94% rename from QuantumUNET/QSBAddPlayerMessage.cs rename to QuantumUNET/Messages/QSBAddPlayerMessage.cs index 3c96b880..34d65148 100644 --- a/QuantumUNET/QSBAddPlayerMessage.cs +++ b/QuantumUNET/Messages/QSBAddPlayerMessage.cs @@ -1,4 +1,4 @@ -namespace QuantumUNET +namespace QuantumUNET.Messages { internal class QSBAddPlayerMessage : QSBMessageBase { diff --git a/QuantumUNET/QSBAnimationMessage.cs b/QuantumUNET/Messages/QSBAnimationMessage.cs similarity index 96% rename from QuantumUNET/QSBAnimationMessage.cs rename to QuantumUNET/Messages/QSBAnimationMessage.cs index b5bc2de0..7278d7a9 100644 --- a/QuantumUNET/QSBAnimationMessage.cs +++ b/QuantumUNET/Messages/QSBAnimationMessage.cs @@ -1,6 +1,6 @@ using UnityEngine.Networking; -namespace QuantumUNET +namespace QuantumUNET.Messages { internal class QSBAnimationMessage : QSBMessageBase { diff --git a/QuantumUNET/QSBAnimationParametersMessage.cs b/QuantumUNET/Messages/QSBAnimationParametersMessage.cs similarity index 94% rename from QuantumUNET/QSBAnimationParametersMessage.cs rename to QuantumUNET/Messages/QSBAnimationParametersMessage.cs index 0ff4098e..d28169e5 100644 --- a/QuantumUNET/QSBAnimationParametersMessage.cs +++ b/QuantumUNET/Messages/QSBAnimationParametersMessage.cs @@ -1,6 +1,6 @@ using UnityEngine.Networking; -namespace QuantumUNET +namespace QuantumUNET.Messages { internal class QSBAnimationParametersMessage : QSBMessageBase { diff --git a/QuantumUNET/QSBAnimationTriggerMessage.cs b/QuantumUNET/Messages/QSBAnimationTriggerMessage.cs similarity index 93% rename from QuantumUNET/QSBAnimationTriggerMessage.cs rename to QuantumUNET/Messages/QSBAnimationTriggerMessage.cs index a4497280..832dfa57 100644 --- a/QuantumUNET/QSBAnimationTriggerMessage.cs +++ b/QuantumUNET/Messages/QSBAnimationTriggerMessage.cs @@ -1,6 +1,6 @@ using UnityEngine.Networking; -namespace QuantumUNET +namespace QuantumUNET.Messages { internal class QSBAnimationTriggerMessage : QSBMessageBase { diff --git a/QuantumUNET/QSBCRCMessage.cs b/QuantumUNET/Messages/QSBCRCMessage.cs similarity index 95% rename from QuantumUNET/QSBCRCMessage.cs rename to QuantumUNET/Messages/QSBCRCMessage.cs index 59462ef1..df45dd7a 100644 --- a/QuantumUNET/QSBCRCMessage.cs +++ b/QuantumUNET/Messages/QSBCRCMessage.cs @@ -1,4 +1,4 @@ -namespace QuantumUNET +namespace QuantumUNET.Messages { internal class QSBCRCMessage : QSBMessageBase { diff --git a/QuantumUNET/QSBClientAuthorityMessage.cs b/QuantumUNET/Messages/QSBClientAuthorityMessage.cs similarity index 93% rename from QuantumUNET/QSBClientAuthorityMessage.cs rename to QuantumUNET/Messages/QSBClientAuthorityMessage.cs index 66889b3d..925bc3ee 100644 --- a/QuantumUNET/QSBClientAuthorityMessage.cs +++ b/QuantumUNET/Messages/QSBClientAuthorityMessage.cs @@ -1,6 +1,6 @@ using UnityEngine.Networking; -namespace QuantumUNET +namespace QuantumUNET.Messages { internal class QSBClientAuthorityMessage : QSBMessageBase { diff --git a/QuantumUNET/QSBEmptyMessage.cs b/QuantumUNET/Messages/QSBEmptyMessage.cs similarity index 84% rename from QuantumUNET/QSBEmptyMessage.cs rename to QuantumUNET/Messages/QSBEmptyMessage.cs index 00d1ce19..27dbc785 100644 --- a/QuantumUNET/QSBEmptyMessage.cs +++ b/QuantumUNET/Messages/QSBEmptyMessage.cs @@ -1,4 +1,4 @@ -namespace QuantumUNET +namespace QuantumUNET.Messages { public class QSBEmptyMessage : QSBMessageBase { diff --git a/QuantumUNET/QSBErrorMessage.cs b/QuantumUNET/Messages/QSBErrorMessage.cs similarity index 89% rename from QuantumUNET/QSBErrorMessage.cs rename to QuantumUNET/Messages/QSBErrorMessage.cs index ebb436db..3a55c670 100644 --- a/QuantumUNET/QSBErrorMessage.cs +++ b/QuantumUNET/Messages/QSBErrorMessage.cs @@ -1,4 +1,4 @@ -namespace QuantumUNET +namespace QuantumUNET.Messages { public class QSBErrorMessage : QSBMessageBase { diff --git a/QuantumUNET/QSBMessageBase.cs b/QuantumUNET/Messages/QSBMessageBase.cs similarity index 84% rename from QuantumUNET/QSBMessageBase.cs rename to QuantumUNET/Messages/QSBMessageBase.cs index dce35c36..241af116 100644 --- a/QuantumUNET/QSBMessageBase.cs +++ b/QuantumUNET/Messages/QSBMessageBase.cs @@ -1,4 +1,4 @@ -namespace QuantumUNET +namespace QuantumUNET.Messages { public abstract class QSBMessageBase { diff --git a/QuantumUNET/QSBNetworkMessage.cs b/QuantumUNET/Messages/QSBNetworkMessage.cs similarity index 94% rename from QuantumUNET/QSBNetworkMessage.cs rename to QuantumUNET/Messages/QSBNetworkMessage.cs index 8628bcf7..f5b68c0d 100644 --- a/QuantumUNET/QSBNetworkMessage.cs +++ b/QuantumUNET/Messages/QSBNetworkMessage.cs @@ -1,6 +1,6 @@ using System; -namespace QuantumUNET +namespace QuantumUNET.Messages { public class QSBNetworkMessage { diff --git a/QuantumUNET/QSBNetworkMessageDelegate.cs b/QuantumUNET/Messages/QSBNetworkMessageDelegate.cs similarity index 69% rename from QuantumUNET/QSBNetworkMessageDelegate.cs rename to QuantumUNET/Messages/QSBNetworkMessageDelegate.cs index 1add490e..c88035d5 100644 --- a/QuantumUNET/QSBNetworkMessageDelegate.cs +++ b/QuantumUNET/Messages/QSBNetworkMessageDelegate.cs @@ -1,4 +1,4 @@ -namespace QuantumUNET +namespace QuantumUNET.Messages { public delegate void QSBNetworkMessageDelegate(QSBNetworkMessage netMsg); } \ No newline at end of file diff --git a/QuantumUNET/QSBNotReadyMessage.cs b/QuantumUNET/Messages/QSBNotReadyMessage.cs similarity index 63% rename from QuantumUNET/QSBNotReadyMessage.cs rename to QuantumUNET/Messages/QSBNotReadyMessage.cs index b8bcc65e..619c7e24 100644 --- a/QuantumUNET/QSBNotReadyMessage.cs +++ b/QuantumUNET/Messages/QSBNotReadyMessage.cs @@ -1,4 +1,4 @@ -namespace QuantumUNET +namespace QuantumUNET.Messages { public class QSBNotReadyMessage : QSBEmptyMessage { diff --git a/QuantumUNET/QSBObjectDestroyMessage.cs b/QuantumUNET/Messages/QSBObjectDestroyMessage.cs similarity index 91% rename from QuantumUNET/QSBObjectDestroyMessage.cs rename to QuantumUNET/Messages/QSBObjectDestroyMessage.cs index 0bd94521..62a641c1 100644 --- a/QuantumUNET/QSBObjectDestroyMessage.cs +++ b/QuantumUNET/Messages/QSBObjectDestroyMessage.cs @@ -1,6 +1,6 @@ using UnityEngine.Networking; -namespace QuantumUNET +namespace QuantumUNET.Messages { internal class QSBObjectDestroyMessage : QSBMessageBase { diff --git a/QuantumUNET/QSBObjectSpawnFinishedMessage.cs b/QuantumUNET/Messages/QSBObjectSpawnFinishedMessage.cs similarity index 89% rename from QuantumUNET/QSBObjectSpawnFinishedMessage.cs rename to QuantumUNET/Messages/QSBObjectSpawnFinishedMessage.cs index 3ceb71a1..66f1c192 100644 --- a/QuantumUNET/QSBObjectSpawnFinishedMessage.cs +++ b/QuantumUNET/Messages/QSBObjectSpawnFinishedMessage.cs @@ -1,4 +1,4 @@ -namespace QuantumUNET +namespace QuantumUNET.Messages { internal class QSBObjectSpawnFinishedMessage : QSBMessageBase { diff --git a/QuantumUNET/QSBObjectSpawnMessage.cs b/QuantumUNET/Messages/QSBObjectSpawnMessage.cs similarity index 96% rename from QuantumUNET/QSBObjectSpawnMessage.cs rename to QuantumUNET/Messages/QSBObjectSpawnMessage.cs index 32b5c9d7..98f5fe6c 100644 --- a/QuantumUNET/QSBObjectSpawnMessage.cs +++ b/QuantumUNET/Messages/QSBObjectSpawnMessage.cs @@ -1,7 +1,7 @@ using UnityEngine; using UnityEngine.Networking; -namespace QuantumUNET +namespace QuantumUNET.Messages { internal class QSBObjectSpawnMessage : QSBMessageBase { diff --git a/QuantumUNET/QSBObjectSpawnSceneMessage.cs b/QuantumUNET/Messages/QSBObjectSpawnSceneMessage.cs similarity index 95% rename from QuantumUNET/QSBObjectSpawnSceneMessage.cs rename to QuantumUNET/Messages/QSBObjectSpawnSceneMessage.cs index cf49fe77..88cb6825 100644 --- a/QuantumUNET/QSBObjectSpawnSceneMessage.cs +++ b/QuantumUNET/Messages/QSBObjectSpawnSceneMessage.cs @@ -1,7 +1,7 @@ using UnityEngine; using UnityEngine.Networking; -namespace QuantumUNET +namespace QuantumUNET.Messages { internal class QSBObjectSpawnSceneMessage : QSBMessageBase { diff --git a/QuantumUNET/QSBOwnerMessage.cs b/QuantumUNET/Messages/QSBOwnerMessage.cs similarity index 93% rename from QuantumUNET/QSBOwnerMessage.cs rename to QuantumUNET/Messages/QSBOwnerMessage.cs index b5aafc2e..7ba81954 100644 --- a/QuantumUNET/QSBOwnerMessage.cs +++ b/QuantumUNET/Messages/QSBOwnerMessage.cs @@ -1,6 +1,6 @@ using UnityEngine.Networking; -namespace QuantumUNET +namespace QuantumUNET.Messages { internal class QSBOwnerMessage : QSBMessageBase { diff --git a/QuantumUNET/QSBPeerInfoMessage.cs b/QuantumUNET/Messages/QSBPeerInfoMessage.cs similarity index 98% rename from QuantumUNET/QSBPeerInfoMessage.cs rename to QuantumUNET/Messages/QSBPeerInfoMessage.cs index a564670d..a876df83 100644 --- a/QuantumUNET/QSBPeerInfoMessage.cs +++ b/QuantumUNET/Messages/QSBPeerInfoMessage.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace QuantumUNET +namespace QuantumUNET.Messages { public class QSBPeerInfoMessage : QSBMessageBase { diff --git a/QuantumUNET/QSBReadyMessage.cs b/QuantumUNET/Messages/QSBReadyMessage.cs similarity index 62% rename from QuantumUNET/QSBReadyMessage.cs rename to QuantumUNET/Messages/QSBReadyMessage.cs index 0403fe81..c100560f 100644 --- a/QuantumUNET/QSBReadyMessage.cs +++ b/QuantumUNET/Messages/QSBReadyMessage.cs @@ -1,4 +1,4 @@ -namespace QuantumUNET +namespace QuantumUNET.Messages { public class QSBReadyMessage : QSBEmptyMessage { diff --git a/QuantumUNET/QSBReconnectMessage.cs b/QuantumUNET/Messages/QSBReconnectMessage.cs similarity index 96% rename from QuantumUNET/QSBReconnectMessage.cs rename to QuantumUNET/Messages/QSBReconnectMessage.cs index d4b8f344..f43c20f2 100644 --- a/QuantumUNET/QSBReconnectMessage.cs +++ b/QuantumUNET/Messages/QSBReconnectMessage.cs @@ -1,6 +1,6 @@ using UnityEngine.Networking; -namespace QuantumUNET +namespace QuantumUNET.Messages { public class QSBReconnectMessage : QSBMessageBase { diff --git a/QuantumUNET/QSBRemovePlayerMessage.cs b/QuantumUNET/Messages/QSBRemovePlayerMessage.cs similarity index 90% rename from QuantumUNET/QSBRemovePlayerMessage.cs rename to QuantumUNET/Messages/QSBRemovePlayerMessage.cs index 1399e1fa..59d1d307 100644 --- a/QuantumUNET/QSBRemovePlayerMessage.cs +++ b/QuantumUNET/Messages/QSBRemovePlayerMessage.cs @@ -1,4 +1,4 @@ -namespace QuantumUNET +namespace QuantumUNET.Messages { public class QSBRemovePlayerMessage : QSBMessageBase { diff --git a/QuantumUNET/QSBStringMessage.cs b/QuantumUNET/Messages/QSBStringMessage.cs similarity index 91% rename from QuantumUNET/QSBStringMessage.cs rename to QuantumUNET/Messages/QSBStringMessage.cs index 5b352d9d..74dd198d 100644 --- a/QuantumUNET/QSBStringMessage.cs +++ b/QuantumUNET/Messages/QSBStringMessage.cs @@ -1,4 +1,4 @@ -namespace QuantumUNET +namespace QuantumUNET.Messages { public class QSBStringMessage : QSBMessageBase { diff --git a/QuantumUNET/QSBChannelBuffer.cs b/QuantumUNET/QSBChannelBuffer.cs index d3d91149..5f6d610f 100644 --- a/QuantumUNET/QSBChannelBuffer.cs +++ b/QuantumUNET/QSBChannelBuffer.cs @@ -1,4 +1,5 @@ -using System; +using QuantumUNET.Messages; +using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; diff --git a/QuantumUNET/QSBClientScene.cs b/QuantumUNET/QSBClientScene.cs index 2052c805..a7a4fe69 100644 --- a/QuantumUNET/QSBClientScene.cs +++ b/QuantumUNET/QSBClientScene.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +using QuantumUNET.Components; +using QuantumUNET.Messages; +using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; diff --git a/QuantumUNET/QSBLocalClient.cs b/QuantumUNET/QSBLocalClient.cs index f6e546c8..ce65e123 100644 --- a/QuantumUNET/QSBLocalClient.cs +++ b/QuantumUNET/QSBLocalClient.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using QuantumUNET.Messages; +using System.Collections.Generic; using UnityEngine; namespace QuantumUNET diff --git a/QuantumUNET/QSBNetworkBehaviour.cs b/QuantumUNET/QSBNetworkBehaviour.cs index 7ae19ce7..734c2ad2 100644 --- a/QuantumUNET/QSBNetworkBehaviour.cs +++ b/QuantumUNET/QSBNetworkBehaviour.cs @@ -1,4 +1,5 @@ using OWML.Logging; +using QuantumUNET.Components; using System; using System.Collections.Generic; using System.Net.Sockets; diff --git a/QuantumUNET/QSBNetworkClient.cs b/QuantumUNET/QSBNetworkClient.cs index 2b72f8eb..04a5169c 100644 --- a/QuantumUNET/QSBNetworkClient.cs +++ b/QuantumUNET/QSBNetworkClient.cs @@ -1,4 +1,5 @@ using OWML.Logging; +using QuantumUNET.Messages; using System; using System.Collections.Generic; using System.Net; diff --git a/QuantumUNET/QSBNetworkConnection.cs b/QuantumUNET/QSBNetworkConnection.cs index 37b9c0c9..ecc79483 100644 --- a/QuantumUNET/QSBNetworkConnection.cs +++ b/QuantumUNET/QSBNetworkConnection.cs @@ -1,4 +1,6 @@ using OWML.Logging; +using QuantumUNET.Components; +using QuantumUNET.Messages; using System; using System.Collections.Generic; using System.Text; diff --git a/QuantumUNET/QSBNetworkMessageHandlers.cs b/QuantumUNET/QSBNetworkMessageHandlers.cs index d0c65120..9fa676b7 100644 --- a/QuantumUNET/QSBNetworkMessageHandlers.cs +++ b/QuantumUNET/QSBNetworkMessageHandlers.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using QuantumUNET.Messages; +using System.Collections.Generic; using UnityEngine; namespace QuantumUNET diff --git a/QuantumUNET/QSBNetworkReader.cs b/QuantumUNET/QSBNetworkReader.cs index 1200d589..afdb40e3 100644 --- a/QuantumUNET/QSBNetworkReader.cs +++ b/QuantumUNET/QSBNetworkReader.cs @@ -1,4 +1,6 @@ -using System; +using QuantumUNET.Components; +using QuantumUNET.Messages; +using System; using System.Text; using UnityEngine; using UnityEngine.Networking; diff --git a/QuantumUNET/QSBNetworkScene.cs b/QuantumUNET/QSBNetworkScene.cs index a88b6255..d3d94d17 100644 --- a/QuantumUNET/QSBNetworkScene.cs +++ b/QuantumUNET/QSBNetworkScene.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using QuantumUNET.Components; +using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; diff --git a/QuantumUNET/QSBNetworkServer.cs b/QuantumUNET/QSBNetworkServer.cs index 838a24ad..b00aedaf 100644 --- a/QuantumUNET/QSBNetworkServer.cs +++ b/QuantumUNET/QSBNetworkServer.cs @@ -1,4 +1,6 @@ using OWML.Logging; +using QuantumUNET.Components; +using QuantumUNET.Messages; using System; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/QuantumUNET/QSBNetworkServerSimple.cs b/QuantumUNET/QSBNetworkServerSimple.cs index 3b670cbc..5d9a1545 100644 --- a/QuantumUNET/QSBNetworkServerSimple.cs +++ b/QuantumUNET/QSBNetworkServerSimple.cs @@ -1,4 +1,5 @@ -using System; +using QuantumUNET.Messages; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using UnityEngine; diff --git a/QuantumUNET/QSBNetworkWriter.cs b/QuantumUNET/QSBNetworkWriter.cs index 1e32bdac..86a95178 100644 --- a/QuantumUNET/QSBNetworkWriter.cs +++ b/QuantumUNET/QSBNetworkWriter.cs @@ -1,4 +1,6 @@ -using System; +using QuantumUNET.Components; +using QuantumUNET.Messages; +using System; using System.Text; using UnityEngine; using UnityEngine.Networking; diff --git a/QuantumUNET/QSBPlayerController.cs b/QuantumUNET/QSBPlayerController.cs index 88b8ac0f..745ad2a3 100644 --- a/QuantumUNET/QSBPlayerController.cs +++ b/QuantumUNET/QSBPlayerController.cs @@ -1,4 +1,5 @@ -using UnityEngine; +using QuantumUNET.Components; +using UnityEngine; namespace QuantumUNET { diff --git a/QuantumUNET/QSBULocalConnectionToClient.cs b/QuantumUNET/QSBULocalConnectionToClient.cs index 312647d1..72419eab 100644 --- a/QuantumUNET/QSBULocalConnectionToClient.cs +++ b/QuantumUNET/QSBULocalConnectionToClient.cs @@ -1,4 +1,6 @@ -namespace QuantumUNET +using QuantumUNET.Messages; + +namespace QuantumUNET { internal class QSBULocalConnectionToClient : QSBNetworkConnection { diff --git a/QuantumUNET/QSBULocalConnectionToServer.cs b/QuantumUNET/QSBULocalConnectionToServer.cs index f1aa485a..51d2d4db 100644 --- a/QuantumUNET/QSBULocalConnectionToServer.cs +++ b/QuantumUNET/QSBULocalConnectionToServer.cs @@ -1,4 +1,5 @@ -using UnityEngine; +using QuantumUNET.Messages; +using UnityEngine; using UnityEngine.Networking; namespace QuantumUNET diff --git a/QuantumUNET/QuantumUNET.csproj b/QuantumUNET/QuantumUNET.csproj index 019e0ae1..9c7c0851 100644 --- a/QuantumUNET/QuantumUNET.csproj +++ b/QuantumUNET/QuantumUNET.csproj @@ -94,51 +94,51 @@ - - - - + + + + - + - + - - + + - + - + - - - - - + + + + + - + - - - - - - - + + + + + + + - - - - + + + + From 2cb296c0db8b274d4e76656edd3328f32f4e4784 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Mon, 7 Dec 2020 21:21:03 +0000 Subject: [PATCH 10/10] cleanup --- QSB/Animation/AnimationSync.cs | 1 - QSB/Player/QSBPlayerManager.cs | 1 - QSB/QSB.cs | 1 - 3 files changed, 3 deletions(-) diff --git a/QSB/Animation/AnimationSync.cs b/QSB/Animation/AnimationSync.cs index af08996d..fb892cd2 100644 --- a/QSB/Animation/AnimationSync.cs +++ b/QSB/Animation/AnimationSync.cs @@ -3,7 +3,6 @@ using OWML.ModHelper.Events; using QSB.EventsCore; using QSB.Player; using QSB.Utility; -using QuantumUNET; using QuantumUNET.Components; using System.Linq; using UnityEngine; diff --git a/QSB/Player/QSBPlayerManager.cs b/QSB/Player/QSBPlayerManager.cs index 467d30f4..2de27749 100644 --- a/QSB/Player/QSBPlayerManager.cs +++ b/QSB/Player/QSBPlayerManager.cs @@ -2,7 +2,6 @@ using QSB.Player.Events; using QSB.TransformSync; using QSB.Utility; -using QuantumUNET; using QuantumUNET.Components; using System.Collections.Generic; using System.Linq; diff --git a/QSB/QSB.cs b/QSB/QSB.cs index 53e50f40..5d03544e 100644 --- a/QSB/QSB.cs +++ b/QSB/QSB.cs @@ -9,7 +9,6 @@ using QSB.Patches; using QSB.SectorSync; using QSB.TimeSync; using QSB.Utility; -using QuantumUNET; using QuantumUNET.Components; using UnityEngine; using UnityEngine.Networking;