Client communicates event syncing errors to the server

This should help
This commit is contained in:
juanjp600
2018-10-16 17:11:20 -03:00
parent 6bad59dfba
commit 13dc008cb5
4 changed files with 80 additions and 4 deletions
@@ -1646,5 +1646,23 @@ namespace Barotrauma.Networking
Vote(VoteType.EndRound, tickBox.Selected);
return false;
}
public void ReportError(ClientNetError error,UInt16 expectedID=0,UInt16 eventID=0,UInt16 entityID=0)
{
NetOutgoingMessage outMsg = client.CreateMessage();
outMsg.Write((byte)error);
switch (error)
{
case ClientNetError.MISSING_EVENT:
outMsg.Write(expectedID);
outMsg.Write(eventID);
break;
case ClientNetError.MISSING_ENTITY:
outMsg.Write(eventID);
outMsg.Write(entityID);
break;
}
client.SendMessage(outMsg, NetDeliveryMethod.ReliableUnordered);
}
}
}
@@ -170,9 +170,14 @@ namespace Barotrauma.Networking
{
DebugConsole.NewMessage(
"Received msg " + thisEventID + " (waiting for " + (lastReceivedID + 1) + ")",
thisEventID < lastReceivedID + 1
? Microsoft.Xna.Framework.Color.Yellow
: Microsoft.Xna.Framework.Color.Red);
NetIdUtils.IdMoreRecent(thisEventID, (UInt16)(lastReceivedID + 1))
? Microsoft.Xna.Framework.Color.Red
: Microsoft.Xna.Framework.Color.Yellow);
}
if (NetIdUtils.IdMoreRecent(thisEventID, (UInt16)(lastReceivedID + 1)))
{
GameMain.Client.ReportError(ClientNetError.MISSING_EVENT, expectedID: (UInt16)(lastReceivedID + 1), eventID: thisEventID);
}
}
else if (entity == null)
@@ -180,6 +185,7 @@ namespace Barotrauma.Networking
DebugConsole.NewMessage(
"Received msg " + thisEventID + ", entity " + entityID + " not found",
Microsoft.Xna.Framework.Color.Red);
GameMain.Client.ReportError(ClientNetError.MISSING_ENTITY, eventID: thisEventID, entityID: entityID);
}
msg.Position += msgLength * 8;