diff --git a/Subsurface/Source/Networking/GameClient.cs b/Subsurface/Source/Networking/GameClient.cs index dcbda50f0..e5ebaa5fa 100644 --- a/Subsurface/Source/Networking/GameClient.cs +++ b/Subsurface/Source/Networking/GameClient.cs @@ -570,6 +570,7 @@ namespace Barotrauma.Networking case "You have been banned from the server": case "You have been kicked from the server": case "You have been disconnected because of excessive desync": + case "You have been disconnected because syncing your client with the server took too long.": var msgBox = new GUIMessageBox("CONNECTION LOST", disconnectMsg); msgBox.Buttons[0].OnClicked += ReturnToServerList; break; diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs index 9931b4029..eca34753f 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -684,7 +684,7 @@ namespace Barotrauma.Networking //last msgs we've created/sent, the client IDs should never be higher than these UInt16 lastEntityEventID = entityEventManager.Events.Count == 0 ? (UInt16)0 : entityEventManager.Events.Last().ID; - + if (c.NeedsMidRoundSync) { //received all the old events -> client in sync, we can switch to normal behavior @@ -1628,9 +1628,11 @@ namespace Barotrauma.Networking { log.LogFrame.Draw(spriteBatch); } - + if (!ShowNetStats) return; + GUI.Font.DrawString(spriteBatch, "Unique Events: " + entityEventManager.UniqueEvents.Count, new Vector2(10, 50), Color.White); + int width = 200, height = 300; int x = GameMain.GraphicsWidth - width, y = (int)(GameMain.GraphicsHeight * 0.3f); @@ -1643,7 +1645,7 @@ namespace Barotrauma.Networking GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black * 0.7f, true); GUI.Font.DrawString(spriteBatch, "Network statistics:", new Vector2(x + 10, y + 10), Color.White); - + GUI.SmallFont.DrawString(spriteBatch, "Connections: "+server.ConnectionsCount, new Vector2(x + 10, y + 30), Color.White); GUI.SmallFont.DrawString(spriteBatch, "Received bytes: " + MathUtils.GetBytesReadable(server.Statistics.ReceivedBytes), new Vector2(x + 10, y + 45), Color.White); GUI.SmallFont.DrawString(spriteBatch, "Received packets: " + server.Statistics.ReceivedPackets, new Vector2(x + 10, y + 60), Color.White); diff --git a/Subsurface/Source/Networking/NetEntityEvent/ClientEntityEventManager.cs b/Subsurface/Source/Networking/NetEntityEvent/ClientEntityEventManager.cs index 8aac6cf7b..c4a9d7a2b 100644 --- a/Subsurface/Source/Networking/NetEntityEvent/ClientEntityEventManager.cs +++ b/Subsurface/Source/Networking/NetEntityEvent/ClientEntityEventManager.cs @@ -136,7 +136,7 @@ namespace Barotrauma.Networking { if (thisEventID != lastReceivedID + 1) { - DebugConsole.NewMessage("received msg " + thisEventID, Microsoft.Xna.Framework.Color.Red); + DebugConsole.NewMessage("received msg " + thisEventID + " (waiting for "+ (lastReceivedID+1) + ")", thisEventID UniqueEvents + { + get { return uniqueEvents; } + } + private class BufferedEvent { public readonly Client Sender; @@ -208,12 +213,14 @@ namespace Barotrauma.Networking { msg.Write((byte)ServerNetObject.ENTITY_EVENT_INITIAL); //how many (unique) events the clients had missed before joining + client.UnreceivedEntityEventCount = (UInt16)uniqueEvents.Count; msg.Write(client.UnreceivedEntityEventCount); //ID of the first event sent after the client joined //(after the client has been synced they'll switch their lastReceivedID //to the one before this, and the eventmanagers will start to function "normally") msg.Write(events.Count == 0 ? (UInt16)0 : events[events.Count - 1].ID); + Write(msg, eventsToSync, client); } else