(d9829ac) v0.9.4.0
This commit is contained in:
+22
-2
@@ -116,6 +116,7 @@ namespace Barotrauma.Networking
|
||||
IReadMessage inc = new ReadOnlyMessage(data, false, 1, dataLength - 1, ServerConnection);
|
||||
string msg = inc.ReadString();
|
||||
Close(msg);
|
||||
OnDisconnectMessageReceived?.Invoke(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -270,8 +271,27 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
|
||||
heartbeatTimer = 5.0;
|
||||
bool successSend = SteamManager.Instance.Networking.SendP2PPacket(hostSteamId, buf, length + 4, sendType);
|
||||
|
||||
#if DEBUG
|
||||
CoroutineManager.InvokeAfter(() =>
|
||||
{
|
||||
if (Rand.Range(0.0f, 1.0f) < GameMain.Client.SimulatedLoss && sendType != Facepunch.Steamworks.Networking.SendType.Reliable) { return; }
|
||||
int count = Rand.Range(0.0f, 1.0f) < GameMain.Client.SimulatedDuplicatesChance ? 2 : 1;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
Send(buf, length + 4, sendType);
|
||||
}
|
||||
},
|
||||
GameMain.Client.SimulatedMinimumLatency + Rand.Range(0.0f, GameMain.Client.SimulatedRandomLatency));
|
||||
|
||||
#else
|
||||
Send(buf, length + 4, sendType);
|
||||
#endif
|
||||
}
|
||||
|
||||
private void Send(byte[] buf, int length, Facepunch.Steamworks.Networking.SendType sendType)
|
||||
{
|
||||
bool successSend = SteamManager.Instance.Networking.SendP2PPacket(hostSteamId, buf, length + 4, sendType);
|
||||
if (!successSend)
|
||||
{
|
||||
if (sendType != Facepunch.Steamworks.Networking.SendType.Reliable)
|
||||
@@ -332,7 +352,7 @@ namespace Barotrauma.Networking
|
||||
steamAuthTicket?.Cancel(); steamAuthTicket = null;
|
||||
hostSteamId = 0;
|
||||
|
||||
OnDisconnect?.Invoke(msg);
|
||||
OnDisconnect?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user