Enable NetManager latency sim on release, add no-bye to INetChannel.

A minute amount of tomfoolery.
This commit is contained in:
Pieter-Jan Briers
2022-05-09 15:43:30 +02:00
parent 7f47478997
commit 3ae4bb03f5
6 changed files with 24 additions and 12 deletions

View File

@@ -188,7 +188,6 @@ namespace Robust.Shared
public static readonly CVarDef<string> NetLidgrenAppIdentifier =
CVarDef.Create("net.lidgren_app_identifier", "RobustToolbox");
#if DEBUG
/// <summary>
/// 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.
/// </summary>
public static readonly CVarDef<float> NetFakeDuplicates = CVarDef.Create("net.fakeduplicates", 0f, CVar.CHEAT);
#endif
/**
* SUS

View File

@@ -81,5 +81,13 @@ namespace Robust.Shared.Network
/// </summary>
/// <param name="reason">Reason why it was disconnected.</param>
void Disconnect(string reason);
/// <summary>
/// Disconnects this channel from the remote peer.
/// </summary>
/// <param name="reason">Reason why it was disconnected.</param>
/// <param name="sendBye">If false, we ghost the remote client and don't tell them they got disconnected properly.</param>
void Disconnect(string reason, bool sendBye);
}
}

View File

@@ -86,9 +86,14 @@ namespace Robust.Shared.Network
/// <inheritdoc />
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()

View File

@@ -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
/// <summary>
/// Gets the NetChannel of a peer NetConnection.

View File

@@ -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