Server sends ServerEntityEvents to clients, NetEntityEvents can contain an object array which will be passed to the serializable entity (now only used for ItemComponent indices)

This commit is contained in:
Regalis
2016-11-13 13:56:48 +02:00
parent c314b37029
commit 498c72c64a
24 changed files with 133 additions and 43 deletions

View File

@@ -12,6 +12,11 @@ namespace Barotrauma.Networking
{
const int MaxEventsPerWrite = 255;
public UInt32 LastReceivedEntityEventID
{
get { return lastReceivedEntityEventID; }
}
private UInt32 lastReceivedEntityEventID;
/// <summary>
@@ -62,17 +67,20 @@ namespace Barotrauma.Networking
byte msgLength = msg.ReadByte();
INetSerializable entity = Entity.FindEntityByID(entityID) as INetSerializable;
//skip the event if we've already received it or if the entity isn't found
if (thisEventID <= lastReceivedEntityEventID || entity == null)
if (thisEventID != lastReceivedEntityEventID+1 || entity == null)
{
DebugConsole.NewMessage("received msg "+thisEventID, Microsoft.Xna.Framework.Color.Red);
msg.Position += msgLength * 8;
}
else
{
DebugConsole.NewMessage("received msg "+thisEventID, Microsoft.Xna.Framework.Color.Green);
ReadEvent(msg, entity, sendingTime);
lastReceivedEntityEventID = thisEventID;
}
msg.ReadPadBits();
}
}