From 06db2fed86ef68007ff7c91e8b11eca03e4f6143 Mon Sep 17 00:00:00 2001 From: Regalis Date: Tue, 2 May 2017 22:15:18 +0300 Subject: [PATCH] Fixed clients incrementing their lastReceivedID every time they receive an empty entity event (even if the event has already been received) --- .../Networking/NetEntityEvent/ClientEntityEventManager.cs | 6 ++++-- .../Networking/NetEntityEvent/NetEntityEventManager.cs | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Subsurface/Source/Networking/NetEntityEvent/ClientEntityEventManager.cs b/Subsurface/Source/Networking/NetEntityEvent/ClientEntityEventManager.cs index de0dd1538..cef87377d 100644 --- a/Subsurface/Source/Networking/NetEntityEvent/ClientEntityEventManager.cs +++ b/Subsurface/Source/Networking/NetEntityEvent/ClientEntityEventManager.cs @@ -130,9 +130,11 @@ namespace Barotrauma.Networking { UInt16 thisEventID = (UInt16)(firstEventID + (UInt16)i); UInt16 entityID = msg.ReadUInt16(); - - if (entityID == 0) + + if (entityID == 0 && thisEventID == (UInt16)(lastReceivedID + 1)) { + DebugConsole.NewMessage("received empty event " + thisEventID, Microsoft.Xna.Framework.Color.Orange); + msg.ReadPadBits(); lastReceivedID++; continue; diff --git a/Subsurface/Source/Networking/NetEntityEvent/NetEntityEventManager.cs b/Subsurface/Source/Networking/NetEntityEvent/NetEntityEventManager.cs index b2a7187b6..495f4e705 100644 --- a/Subsurface/Source/Networking/NetEntityEvent/NetEntityEventManager.cs +++ b/Subsurface/Source/Networking/NetEntityEvent/NetEntityEventManager.cs @@ -45,9 +45,11 @@ namespace Barotrauma.Networking tempBuffer.LengthBytes < 128, "Maximum EntityEvent size exceeded when serializing \""+e.Entity+"\"!"); + //the ID has been taken by another entity (the original entity has been removed) -> write an empty event if (Entity.FindEntityByID(e.Entity.ID) != e.Entity) { - //DebugConsole.ThrowError("Error in NetEntityEventManager.Write (FindEntityByID(e.Entity.ID) != e.Entity)"); + //technically the clients don't have any use for these, but removing events and shifting the IDs of all + //consecutive ones is so error-prone that I think this is a safer option msg.Write((UInt16)0); msg.WritePadBits(); }