diff --git a/Lidgren.Network/Lidgren.Network b/Lidgren.Network/Lidgren.Network index 45e45e61a..1e7fb3c2b 160000 --- a/Lidgren.Network/Lidgren.Network +++ b/Lidgren.Network/Lidgren.Network @@ -1 +1 @@ -Subproject commit 45e45e61ac254e8d4f8a7e961dbb71bdc4a0aa15 +Subproject commit 1e7fb3c2b6ca41c942939546357411ba0ad6e241 diff --git a/Robust.Shared/CVars.cs b/Robust.Shared/CVars.cs index 656bab0c1..dbb39ce05 100644 --- a/Robust.Shared/CVars.cs +++ b/Robust.Shared/CVars.cs @@ -188,7 +188,6 @@ namespace Robust.Shared public static readonly CVarDef NetLidgrenAppIdentifier = CVarDef.Create("net.lidgren_app_identifier", "RobustToolbox"); -#if DEBUG /// /// Add random fake network loss to all outgoing UDP network packets, as a ratio of how many packets to drop. /// 0 = no packet loss, 1 = all packets dropped @@ -213,7 +212,6 @@ namespace Robust.Shared /// 0 = no packets duplicated, 1 = all packets duplicated. /// public static readonly CVarDef NetFakeDuplicates = CVarDef.Create("net.fakeduplicates", 0f, CVar.CHEAT); -#endif /** * SUS diff --git a/Robust.Shared/Network/INetChannel.cs b/Robust.Shared/Network/INetChannel.cs index 51041ea96..7b6b67063 100644 --- a/Robust.Shared/Network/INetChannel.cs +++ b/Robust.Shared/Network/INetChannel.cs @@ -81,5 +81,13 @@ namespace Robust.Shared.Network /// /// Reason why it was disconnected. void Disconnect(string reason); + + /// + /// Disconnects this channel from the remote peer. + /// + /// Reason why it was disconnected. + /// If false, we ghost the remote client and don't tell them they got disconnected properly. + void Disconnect(string reason, bool sendBye); + } } diff --git a/Robust.Shared/Network/NetManager.NetChannel.cs b/Robust.Shared/Network/NetManager.NetChannel.cs index a060aa569..7bc9074bd 100644 --- a/Robust.Shared/Network/NetManager.NetChannel.cs +++ b/Robust.Shared/Network/NetManager.NetChannel.cs @@ -86,9 +86,14 @@ namespace Robust.Shared.Network /// public void Disconnect(string reason) + { + Disconnect(reason, true); + } + + public void Disconnect(string reason, bool sendBye) { if (_connection.Status == NetConnectionStatus.Connected) - _connection.Disconnect(reason); + _connection.Disconnect(reason, sendBye); } public override string ToString() diff --git a/Robust.Shared/Network/NetManager.cs b/Robust.Shared/Network/NetManager.cs index 7741151e5..db1cfbe55 100644 --- a/Robust.Shared/Network/NetManager.cs +++ b/Robust.Shared/Network/NetManager.cs @@ -248,12 +248,11 @@ namespace Robust.Shared.Network { _config.OnValueChanged(CVars.AuthMode, OnAuthModeChanged, invokeImmediately: true); } -#if DEBUG + _config.OnValueChanged(CVars.NetFakeLoss, _fakeLossChanged); _config.OnValueChanged(CVars.NetFakeLagMin, _fakeLagMinChanged); _config.OnValueChanged(CVars.NetFakeLagRand, _fakeLagRandomChanged); _config.OnValueChanged(CVars.NetFakeDuplicates, FakeDuplicatesChanged); -#endif _strings.Initialize(() => { Logger.InfoS("net", "Message string table loaded."); }, UpdateNetMessageFunctions); @@ -416,12 +415,11 @@ namespace Robust.Shared.Network { _config.UnsubValueChanged(CVars.AuthMode, OnAuthModeChanged); } -#if DEBUG + _config.UnsubValueChanged(CVars.NetFakeLoss, _fakeLossChanged); _config.UnsubValueChanged(CVars.NetFakeLagMin, _fakeLagMinChanged); _config.UnsubValueChanged(CVars.NetFakeLagRand, _fakeLagRandomChanged); _config.UnsubValueChanged(CVars.NetFakeDuplicates, FakeDuplicatesChanged); -#endif _serializer.ClientHandshakeComplete -= OnSerializerOnClientHandshakeComplete; @@ -589,7 +587,6 @@ namespace Robust.Shared.Network } -#if DEBUG //Simulate Latency netConfig.SimulatedLoss = _config.GetCVar(CVars.NetFakeLoss); netConfig.SimulatedMinimumLatency = _config.GetCVar(CVars.NetFakeLagMin); @@ -597,11 +594,10 @@ namespace Robust.Shared.Network netConfig.SimulatedDuplicatesChance = _config.GetCVar(CVars.NetFakeDuplicates); netConfig.ConnectionTimeout = 30000f; -#endif + return netConfig; } -#if DEBUG private void _fakeLossChanged(float newValue) { foreach (var peer in _netPeers) @@ -633,7 +629,6 @@ namespace Robust.Shared.Network peer.Peer.Configuration.SimulatedDuplicatesChance = newValue; } } -#endif /// /// Gets the NetChannel of a peer NetConnection. diff --git a/Robust.UnitTesting/RobustIntegrationTest.NetManager.cs b/Robust.UnitTesting/RobustIntegrationTest.NetManager.cs index a1860e4bc..8006af64b 100644 --- a/Robust.UnitTesting/RobustIntegrationTest.NetManager.cs +++ b/Robust.UnitTesting/RobustIntegrationTest.NetManager.cs @@ -445,6 +445,12 @@ namespace Robust.UnitTesting IsConnected = false; } + + public void Disconnect(string reason, bool sendBye) + { + // Don't handle bye sending in here I guess. + Disconnect(reason); + } } private sealed class ConnectMessage