Converted UInt32 ID's to UInt16
TODO: test everything, make sure nothing broke
This commit is contained in:
@@ -11,25 +11,25 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
private List<ClientEntityEvent> events;
|
||||
|
||||
private UInt32 ID;
|
||||
private UInt16 ID;
|
||||
|
||||
private GameClient thisClient;
|
||||
|
||||
//when was a specific entity event last sent to the client
|
||||
// key = event id, value = NetTime.Now when sending
|
||||
public Dictionary<UInt32, float> eventLastSent;
|
||||
public Dictionary<UInt16, float> eventLastSent;
|
||||
|
||||
public UInt32 LastReceivedID
|
||||
public UInt16 LastReceivedID
|
||||
{
|
||||
get { return lastReceivedID; }
|
||||
}
|
||||
|
||||
private UInt32 lastReceivedID;
|
||||
private UInt16 lastReceivedID;
|
||||
|
||||
public ClientEntityEventManager(GameClient client)
|
||||
{
|
||||
events = new List<ClientEntityEvent>();
|
||||
eventLastSent = new Dictionary<uint, float>();
|
||||
eventLastSent = new Dictionary<UInt16, float>();
|
||||
|
||||
thisClient = client;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ namespace Barotrauma.Networking
|
||||
//find the index of the first event the server hasn't received
|
||||
int startIndex = events.Count;
|
||||
while (startIndex > 0 &&
|
||||
events[startIndex-1].ID > thisClient.LastSentEntityEventID)
|
||||
NetIdUtils.IdMoreRecent(events[startIndex-1].ID,thisClient.LastSentEntityEventID))
|
||||
{
|
||||
startIndex--;
|
||||
}
|
||||
@@ -103,21 +103,21 @@ namespace Barotrauma.Networking
|
||||
/// </summary>
|
||||
public void Read(ServerNetObject type, NetIncomingMessage msg, float sendingTime)
|
||||
{
|
||||
UInt32 unreceivedEntityEventCount = 0;
|
||||
UInt32 firstNewID = 0;
|
||||
UInt16 unreceivedEntityEventCount = 0;
|
||||
UInt16 firstNewID = 0;
|
||||
|
||||
if (type == ServerNetObject.ENTITY_EVENT_INITIAL)
|
||||
{
|
||||
unreceivedEntityEventCount = msg.ReadUInt32();
|
||||
firstNewID = msg.ReadUInt32();
|
||||
unreceivedEntityEventCount = msg.ReadUInt16();
|
||||
firstNewID = msg.ReadUInt16();
|
||||
}
|
||||
|
||||
UInt32 firstEventID = msg.ReadUInt32();
|
||||
UInt16 firstEventID = msg.ReadUInt16();
|
||||
int eventCount = msg.ReadByte();
|
||||
|
||||
for (int i = 0; i < eventCount; i++)
|
||||
{
|
||||
UInt32 thisEventID = firstEventID + (UInt32)i;
|
||||
UInt16 thisEventID = (UInt16)(firstEventID + (UInt16)i);
|
||||
UInt16 entityID = msg.ReadUInt16();
|
||||
byte msgLength = msg.ReadByte();
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace Barotrauma.Networking
|
||||
if (lastReceivedID == unreceivedEntityEventCount - 1 ||
|
||||
unreceivedEntityEventCount == 0)
|
||||
{
|
||||
lastReceivedID = firstNewID - 1;
|
||||
lastReceivedID = (UInt16)(firstNewID - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
|
||||
public readonly Entity Entity;
|
||||
public readonly UInt32 ID;
|
||||
public readonly UInt16 ID;
|
||||
|
||||
//arbitrary extra data that will be passed to the Write method of the serializable entity
|
||||
//(the index of an itemcomponent for example)
|
||||
protected object[] Data;
|
||||
|
||||
protected NetEntityEvent(INetSerializable entity, UInt32 id)
|
||||
protected NetEntityEvent(INetSerializable entity, UInt16 id)
|
||||
{
|
||||
this.ID = id;
|
||||
this.Entity = entity as Entity;
|
||||
@@ -73,7 +73,7 @@ namespace Barotrauma.Networking
|
||||
get { return createTime; }
|
||||
}
|
||||
|
||||
public ServerEntityEvent(IServerSerializable entity, UInt32 id)
|
||||
public ServerEntityEvent(IServerSerializable entity, UInt16 id)
|
||||
: base(entity, id)
|
||||
{
|
||||
serializable = entity;
|
||||
@@ -93,7 +93,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
public UInt16 CharacterStateID;
|
||||
|
||||
public ClientEntityEvent(IClientSerializable entity, UInt32 id)
|
||||
public ClientEntityEvent(IClientSerializable entity, UInt16 id)
|
||||
: base(entity, id)
|
||||
{
|
||||
serializable = entity;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Barotrauma.Networking
|
||||
public const int MaxEventBufferLength = 1024;
|
||||
public const int MaxEventsPerWrite = 64;
|
||||
|
||||
//public UInt32 LastReceivedEntityEventID
|
||||
//public UInt16 LastReceivedEntityEventID
|
||||
//{
|
||||
// get { return lastReceivedEntityEventID; }
|
||||
//}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Barotrauma.Networking
|
||||
//used for syncing clients who join mid-round
|
||||
private List<ServerEntityEvent> uniqueEvents;
|
||||
|
||||
private UInt32 lastSentToAll;
|
||||
private UInt16 lastSentToAll;
|
||||
|
||||
public List<ServerEntityEvent> Events
|
||||
{
|
||||
@@ -49,7 +49,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
private List<BufferedEvent> bufferedEvents;
|
||||
|
||||
private UInt32 ID;
|
||||
private UInt16 ID;
|
||||
|
||||
private GameServer server;
|
||||
|
||||
@@ -127,14 +127,14 @@ namespace Barotrauma.Networking
|
||||
if (clients.Count > 0)
|
||||
{
|
||||
lastSentToAll = clients[0].lastRecvEntityEventID;
|
||||
clients.ForEach(c => { if (c.inGame) lastSentToAll = Math.Min(lastSentToAll, c.lastRecvEntityEventID); });
|
||||
clients.ForEach(c => { if (c.inGame && NetIdUtils.IdMoreRecent(lastSentToAll,c.lastRecvEntityEventID)) lastSentToAll = c.lastRecvEntityEventID; });
|
||||
|
||||
ServerEntityEvent firstEventToResend = events.Find(e => e.ID == (lastSentToAll + 1));
|
||||
if (firstEventToResend != null && (Timing.TotalTime-firstEventToResend.CreateTime)>10.0f)
|
||||
{
|
||||
//it's been 10 seconds since this event was created
|
||||
//kick everyone that hasn't received it yet, this is way too old
|
||||
List<Client> toKick = clients.FindAll(c => c.inGame && c.lastRecvEntityEventID <= lastSentToAll);
|
||||
List<Client> toKick = clients.FindAll(c => c.inGame && NetIdUtils.IdMoreRecent((UInt16)(lastSentToAll+1),c.lastRecvEntityEventID));
|
||||
if (toKick!=null) toKick.ForEach(c => GameMain.Server.DisconnectClient(c,"","You have been disconnected because of excessive desync"));
|
||||
}
|
||||
}
|
||||
@@ -247,7 +247,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (uniqueEvents.Count > 0)
|
||||
{
|
||||
client.UnreceivedEntityEventCount = (UInt32)uniqueEvents.Count;
|
||||
client.UnreceivedEntityEventCount = (UInt16)uniqueEvents.Count;
|
||||
client.NeedsMidRoundSync = true;
|
||||
}
|
||||
else
|
||||
@@ -262,12 +262,12 @@ namespace Barotrauma.Networking
|
||||
/// </summary>
|
||||
public void Read(NetIncomingMessage msg, Client sender = null)
|
||||
{
|
||||
UInt32 firstEventID = msg.ReadUInt32();
|
||||
UInt16 firstEventID = msg.ReadUInt16();
|
||||
int eventCount = msg.ReadByte();
|
||||
|
||||
for (int i = 0; i < eventCount; i++)
|
||||
{
|
||||
UInt32 thisEventID = firstEventID + (UInt32)i;
|
||||
UInt16 thisEventID = (UInt16)(firstEventID + (UInt16)i);
|
||||
UInt16 entityID = msg.ReadUInt16();
|
||||
byte msgLength = msg.ReadByte();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user