Client communicates event syncing errors to the server
This should help
This commit is contained in:
@@ -590,6 +590,9 @@ namespace Barotrauma.Networking
|
||||
fileSender.ReadFileRequest(inc);
|
||||
}
|
||||
break;
|
||||
case ClientPacketHeader.ERROR:
|
||||
HandleClientError(inc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,6 +611,47 @@ namespace Barotrauma.Networking
|
||||
return userID;
|
||||
}
|
||||
|
||||
private void HandleClientError(NetIncomingMessage inc)
|
||||
{
|
||||
Client c = ConnectedClients.Find(x => x.Connection == inc.SenderConnection);
|
||||
|
||||
string errorStr = "Unhandled error report";
|
||||
|
||||
ClientNetError error = (ClientNetError)inc.ReadByte();
|
||||
switch (error)
|
||||
{
|
||||
case ClientNetError.MISSING_EVENT:
|
||||
UInt16 expectedID = inc.ReadUInt16();
|
||||
UInt16 receivedID = inc.ReadUInt16();
|
||||
errorStr = "Expecting event id " + expectedID.ToString() + ", received " + receivedID.ToString();
|
||||
break;
|
||||
case ClientNetError.MISSING_ENTITY:
|
||||
UInt16 eventID = inc.ReadUInt16();
|
||||
UInt16 entityID = inc.ReadUInt16();
|
||||
Entity entity = Entity.FindEntityByID(entityID);
|
||||
if (entity == null)
|
||||
{
|
||||
errorStr = "Received an update for an entity that doesn't exist (event id " + eventID.ToString() + ", entity id " + entityID.ToString() + ")";
|
||||
}
|
||||
else if (entity is Character character)
|
||||
{
|
||||
errorStr = "Missing character " + character.Name + " (event id " + eventID.ToString() + ", entity id " + entityID.ToString() + ")";
|
||||
}
|
||||
else if (entity is Item item)
|
||||
{
|
||||
errorStr = "Missing item " + item.Name + " (event id " + eventID.ToString() + ", entity id " + entityID.ToString() + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
errorStr = "Missing entity " + entity.ToString() + " (event id " + eventID.ToString() + ", entity id " + entityID.ToString() + ")";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
GameServer.Log(c.Name+" has reported an error: "+errorStr, ServerLog.MessageType.Error);
|
||||
KickClient(c, errorStr);
|
||||
}
|
||||
|
||||
private void ClientReadLobby(NetIncomingMessage inc)
|
||||
{
|
||||
Client c = ConnectedClients.Find(x => x.Connection == inc.SenderConnection);
|
||||
|
||||
@@ -17,7 +17,9 @@ namespace Barotrauma.Networking
|
||||
FILE_REQUEST, //request a (submarine) file from the server
|
||||
|
||||
RESPONSE_STARTGAME, //tell the server whether you're ready to start
|
||||
SERVER_COMMAND //tell the server to end a round or kick/ban someone (special permissions required)
|
||||
SERVER_COMMAND, //tell the server to end a round or kick/ban someone (special permissions required)
|
||||
|
||||
ERROR //tell the server that an error occurred
|
||||
}
|
||||
enum ClientNetObject
|
||||
{
|
||||
@@ -29,6 +31,12 @@ namespace Barotrauma.Networking
|
||||
ENTITY_STATE
|
||||
}
|
||||
|
||||
enum ClientNetError
|
||||
{
|
||||
MISSING_EVENT, //client was expecting a previous event
|
||||
MISSING_ENTITY //client can't find an entity of a certain ID
|
||||
}
|
||||
|
||||
enum ServerPacketHeader
|
||||
{
|
||||
AUTH_RESPONSE, //tell the player if they require a password to log in
|
||||
|
||||
Reference in New Issue
Block a user