diff --git a/RageCoop.Client/Networking/Receive.cs b/RageCoop.Client/Networking/Receive.cs
index e1c2321..b92c6d4 100644
--- a/RageCoop.Client/Networking/Receive.cs
+++ b/RageCoop.Client/Networking/Receive.cs
@@ -159,6 +159,7 @@ namespace RageCoop.Client
Main.Logger.Error(ex);
Peer.Shutdown($"Packet Error [{packetType}]");
#endif
+ _recycle = false;
}
break;
}
@@ -305,7 +306,9 @@ namespace RageCoop.Client
if (c == null)
{
// Main.Logger.Debug($"Creating character for incoming sync:{packet.ID}");
- EntityPool.ThreadSafe.Add(c = new SyncedPed(packet.ID));
+ if (EntityPool.allPeds.Length < Main.Settings.GlobalPedSoftLimit)
+ EntityPool.ThreadSafe.Add(c = new SyncedPed(packet.ID));
+ else return;
}
PedDataFlags flags = packet.Flags;
c.ID = packet.ID;
@@ -353,7 +356,9 @@ namespace RageCoop.Client
SyncedVehicle v = EntityPool.GetVehicleByID(packet.ID);
if (v == null)
{
- EntityPool.ThreadSafe.Add(v = new SyncedVehicle(packet.ID));
+ if (EntityPool.allVehicles.Length < Main.Settings.GlobalVehicleSoftLimit)
+ EntityPool.ThreadSafe.Add(v = new SyncedVehicle(packet.ID));
+ else return;
}
if (v.IsLocal) { return; }
v.ID = packet.ID;
@@ -393,7 +398,9 @@ namespace RageCoop.Client
{
if (packet.Flags.HasProjDataFlag(ProjectileDataFlags.Exploded)) { return; }
// Main.Logger.Debug($"Creating new projectile: {(WeaponHash)packet.WeaponHash}");
- EntityPool.ThreadSafe.Add(p = new SyncedProjectile(packet.ID));
+ if (EntityPool.allProjectiles.Length < Main.Settings.GlobalProjectileSoftLimit)
+ EntityPool.ThreadSafe.Add(p = new SyncedProjectile(packet.ID));
+ else return;
}
p.Flags = packet.Flags;
p.Position = packet.Position;
diff --git a/RageCoop.Client/Settings.cs b/RageCoop.Client/Settings.cs
index 6da3868..b60e91e 100644
--- a/RageCoop.Client/Settings.cs
+++ b/RageCoop.Client/Settings.cs
@@ -67,6 +67,22 @@ namespace RageCoop.Client
/// The game won't spawn more NPC traffic if the limit is exceeded. -1 for unlimited (not recommended).
///
public int WorldPedSoftLimit { get; set; } = 30;
+
+ ///
+ /// The mod won't sync more vehicles if the limit is exceeded.
+ ///
+ public int GlobalVehicleSoftLimit { get; set; } = 100;
+
+ ///
+ /// The mod won't sync more peds if the limit is exceeded.
+ ///
+ public int GlobalPedSoftLimit { get; set; } = 100;
+
+ ///
+ /// The mod won't sync more projectiles if the limit is exceeded.
+ ///
+ public int GlobalProjectileSoftLimit { get; set; } = 100;
+
///
/// The directory where log and resources downloaded from server will be placed.
///