diff --git a/RageCoop.Client/Main.cs b/RageCoop.Client/Main.cs index d81469d..bbe23b4 100644 --- a/RageCoop.Client/Main.cs +++ b/RageCoop.Client/Main.cs @@ -139,10 +139,9 @@ namespace RageCoop.Client { _lastDebugData = time; - _debugBytesReceived = Networking.BytesReceived; - Networking.BytesReceived = 0; - _debugBytesSend = Networking.BytesSend; - Networking.BytesSend = 0; + _debugBytesReceived = Networking.Client.Statistics.ReceivedBytes; + _debugBytesSend = Networking.Client.Statistics.SentBytes; + Networking.Client.Statistics.Reset(); } new LemonUI.Elements.ScaledText(new PointF(Screen.PrimaryScreen.Bounds.Width / 2, 0), $"L: {Networking.Latency * 1000:N0}ms", 0.5f) { Alignment = GTA.UI.Alignment.Center }.Draw(); diff --git a/RageCoop.Client/Menus/Sub/SettingsMenu.cs b/RageCoop.Client/Menus/Sub/SettingsMenu.cs index c3f77e7..98b6f07 100644 --- a/RageCoop.Client/Menus/Sub/SettingsMenu.cs +++ b/RageCoop.Client/Menus/Sub/SettingsMenu.cs @@ -118,11 +118,6 @@ namespace RageCoop.Client.Menus { Networking.ShowNetworkInfo = _showNetworkInfoItem.Checked; - if (!Networking.ShowNetworkInfo) - { - Networking.BytesReceived = 0; - Networking.BytesSend = 0; - } } } } diff --git a/RageCoop.Client/Networking/Networking.cs b/RageCoop.Client/Networking/Networking.cs index 88596c6..aa9fdfa 100644 --- a/RageCoop.Client/Networking/Networking.cs +++ b/RageCoop.Client/Networking/Networking.cs @@ -16,8 +16,6 @@ namespace RageCoop.Client public static NetClient Client; public static float Latency = 0; public static bool ShowNetworkInfo = false; - public static int BytesReceived = 0; - public static int BytesSend = 0; static Networking() { diff --git a/RageCoop.Client/Networking/Receive.cs b/RageCoop.Client/Networking/Receive.cs index 46c475f..b0ac4b1 100644 --- a/RageCoop.Client/Networking/Receive.cs +++ b/RageCoop.Client/Networking/Receive.cs @@ -17,8 +17,6 @@ namespace RageCoop.Client { if(message == null) { return; } - BytesReceived += message.LengthBytes; - switch (message.MessageType) { case NetIncomingMessageType.StatusChanged: diff --git a/RageCoop.Client/Networking/Send.cs b/RageCoop.Client/Networking/Send.cs index 03e0013..ff0d62e 100644 --- a/RageCoop.Client/Networking/Send.cs +++ b/RageCoop.Client/Networking/Send.cs @@ -156,10 +156,6 @@ namespace RageCoop.Client Client.FlushSendQueue(); #if DEBUG - if (ShowNetworkInfo) - { - BytesSend += outgoingMessage.LengthBytes; - } #endif } public static void SendDownloadFinish(int id) @@ -172,10 +168,6 @@ namespace RageCoop.Client Client.FlushSendQueue(); #if DEBUG - if (ShowNetworkInfo) - { - BytesSend += outgoingMessage.LengthBytes; - } #endif } #endregion diff --git a/RageCoop.Client/Sync/EntityPool.cs b/RageCoop.Client/Sync/EntityPool.cs index d1bd930..9c9b5f7 100644 --- a/RageCoop.Client/Sync/EntityPool.cs +++ b/RageCoop.Client/Sync/EntityPool.cs @@ -277,6 +277,14 @@ namespace RageCoop.Client return ID_Projectiles.ContainsKey(id); } #endregion + static int vehStateIndex; + static int pedStateIndex; + static int vehStatesPerFrame; + static int pedStatesPerFrame; + static int i; + public static Ped[] allPeds=new Ped[0]; + public static Vehicle[] allVehicles=new Vehicle[0]; + public static Projectile[] allProjectiles=new Projectile[0]; public static void DoSync() { @@ -284,9 +292,12 @@ namespace RageCoop.Client PerfCounter.Restart(); Debug.TimeStamps[TimeStamp.CheckProjectiles]=PerfCounter.ElapsedTicks; #endif - var allPeds = World.GetAllPeds(); - var allVehicles=World.GetAllVehicles(); - var allProjectiles=World.GetAllProjectiles(); + allPeds = World.GetAllPeds(); + allVehicles=World.GetAllVehicles(); + allProjectiles=World.GetAllProjectiles(); + vehStatesPerFrame=allVehicles.Length*5/(int)Game.FPS+1; + pedStatesPerFrame=allPeds.Length*5/(int)Game.FPS+1; + if (Main.Settings.WorldVehicleSoftLimit>-1) { if (Main.Ticked%100==0) { if (allVehicles.Length>Main.Settings.WorldVehicleSoftLimit) { SetBudget(0); } else { SetBudget(1); } } @@ -347,6 +358,7 @@ namespace RageCoop.Client } + i=-1; lock (PedsLock) { @@ -369,9 +381,15 @@ namespace RageCoop.Client Debug.TimeStamps[TimeStamp.AddPeds]=PerfCounter.ElapsedTicks; #endif - - foreach (SyncedPed c in ID_Peds.Values.ToArray()) + var ps = ID_Peds.Values.ToArray(); + pedStateIndex+=pedStatesPerFrame; + if (pedStateIndex>=ps.Length) { + pedStateIndex=0; + } + foreach (SyncedPed c in ps) + { + i++; if ((c.MainPed!=null)&&(!c.MainPed.Exists())) { EntityPool.RemovePed(c.ID, "non-existent"); @@ -387,15 +405,13 @@ namespace RageCoop.Client // event check SyncEvents.Check(c); - if (Main.Ticked%20==0) + Networking.SendPed(c); + + // Send state + if ((i-pedStateIndex)=vs.Length) { + vehStateIndex=0; + } + foreach (SyncedVehicle v in vs) + { + i++; if ((v.MainVehicle!=null)&&(!v.MainVehicle.Exists())) { EntityPool.RemoveVehicle(v.ID,"non-existent"); @@ -452,15 +478,14 @@ namespace RageCoop.Client if (v.IsMine) { SyncEvents.Check(v); - if (Main.Ticked%20==0) + + Networking.SendVehicle(v); + + // Send state + if ((i-vehStateIndex)=EntityPool.allVehicles.Length) + { + current=0; + } + Networking.SendVehicleState(EntityPool.allVehicles[current]) + } + } + } +} +*/ \ No newline at end of file