Fixed "trying to read past the buffer size" errors caused by item updates sent by clients, midround syncing timeout period is calculated based on the number of events the client needs to receive
This commit is contained in:
@@ -1818,6 +1818,7 @@ namespace Barotrauma
|
|||||||
WritePropertyChange(msg, extraData);
|
WritePropertyChange(msg, extraData);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
msg.WritePadBits();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ServerRead(ClientNetObject type, NetBuffer msg, Client c)
|
public void ServerRead(ClientNetObject type, NetBuffer msg, Client c)
|
||||||
|
|||||||
@@ -61,6 +61,11 @@ namespace Barotrauma.Networking
|
|||||||
get { return entityEventManager; }
|
get { return entityEventManager; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TimeSpan UpdateInterval
|
||||||
|
{
|
||||||
|
get { return updateInterval; }
|
||||||
|
}
|
||||||
|
|
||||||
public GameServer(string name, int port, bool isPublic = false, string password = "", bool attemptUPnP = false, int maxPlayers = 10)
|
public GameServer(string name, int port, bool isPublic = false, string password = "", bool attemptUPnP = false, int maxPlayers = 10)
|
||||||
{
|
{
|
||||||
name = name.Replace(":", "");
|
name = name.Replace(":", "");
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Barotrauma.Networking
|
namespace Barotrauma.Networking
|
||||||
{
|
{
|
||||||
@@ -252,9 +250,12 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
if (uniqueEvents.Count > 0)
|
if (uniqueEvents.Count > 0)
|
||||||
{
|
{
|
||||||
|
double midRoundSyncTimeOut = uniqueEvents.Count / MaxEventsPerWrite * server.UpdateInterval.TotalSeconds;
|
||||||
|
midRoundSyncTimeOut = Math.Max(5.0f, midRoundSyncTimeOut * 1.5f);
|
||||||
|
|
||||||
client.UnreceivedEntityEventCount = (UInt16)uniqueEvents.Count;
|
client.UnreceivedEntityEventCount = (UInt16)uniqueEvents.Count;
|
||||||
client.NeedsMidRoundSync = true;
|
client.NeedsMidRoundSync = true;
|
||||||
client.MidRoundSyncTimeOut = Timing.TotalTime + 10.0;
|
client.MidRoundSyncTimeOut = Timing.TotalTime + midRoundSyncTimeOut;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -294,10 +295,12 @@ namespace Barotrauma.Networking
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
DebugConsole.NewMessage("received msg " + thisEventID, Microsoft.Xna.Framework.Color.Green);
|
||||||
|
|
||||||
UInt16 characterStateID = msg.ReadUInt16();
|
UInt16 characterStateID = msg.ReadUInt16();
|
||||||
|
|
||||||
NetBuffer buffer = new NetBuffer();
|
NetBuffer buffer = new NetBuffer();
|
||||||
buffer.Write(msg.ReadBytes(msgLength-2));
|
buffer.Write(msg.ReadBytes(msgLength - 2));
|
||||||
BufferEvent(new BufferedEvent(sender, sender.Character, characterStateID, entity, buffer));
|
BufferEvent(new BufferedEvent(sender, sender.Character, characterStateID, entity, buffer));
|
||||||
|
|
||||||
sender.lastSentEntityEventID++;
|
sender.lastSentEntityEventID++;
|
||||||
|
|||||||
Reference in New Issue
Block a user