Allow the server to skip over EntityEvents sent by clients if the entity does not exist. The clients may create events for removed entities if they for example use an item repeatedly and cause events to be created before the client is notified of the item being removed. Closes #973

This commit is contained in:
Joonas Rikkonen
2018-12-25 21:24:45 +02:00
parent 35e22d3e66
commit 12aebf3cc9

View File

@@ -349,24 +349,29 @@ namespace Barotrauma.Networking
IClientSerializable entity = Entity.FindEntityByID(entityID) as IClientSerializable;
//skip the event if we've already received it or if the entity isn't found
if (thisEventID != (UInt16)(sender.LastSentEntityEventID + 1) || entity == null)
//skip the event if we've already received it
if (thisEventID != (UInt16)(sender.LastSentEntityEventID + 1))
{
if (GameSettings.VerboseLogging)
{
if (thisEventID != (UInt16) (sender.LastSentEntityEventID + 1))
{
DebugConsole.NewMessage("received msg " + thisEventID, Microsoft.Xna.Framework.Color.Red);
}
else if (entity == null)
{
DebugConsole.NewMessage(
"received msg " + thisEventID + ", entity " + entityID + " not found",
Microsoft.Xna.Framework.Color.Red);
}
DebugConsole.NewMessage("received msg " + thisEventID, Microsoft.Xna.Framework.Color.Red);
}
msg.Position += msgLength * 8;
}
else if (entity == null)
{
//entity not found -> consider the even read and skip over it
//(can happen, for example, when a client uses a medical item repeatedly
//and creates an event for it before receiving the event about it being removed)
if (GameSettings.VerboseLogging)
{
DebugConsole.NewMessage(
"received msg " + thisEventID + ", entity " + entityID + " not found",
Microsoft.Xna.Framework.Color.Orange);
}
sender.LastSentEntityEventID++;
msg.Position += msgLength * 8;
}
else
{
if (GameSettings.VerboseLogging)