Add global limits

This commit is contained in:
oldnapalm
2023-10-18 10:41:34 -03:00
parent 92e1a970a8
commit 4e6fde129d
2 changed files with 26 additions and 3 deletions

View File

@ -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}");
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)
{
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}");
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;

View File

@ -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).
/// </summary>
public int WorldPedSoftLimit { get; set; } = 30;
/// <summary>
/// The mod won't sync more vehicles if the limit is exceeded.
/// </summary>
public int GlobalVehicleSoftLimit { get; set; } = 100;
/// <summary>
/// The mod won't sync more peds if the limit is exceeded.
/// </summary>
public int GlobalPedSoftLimit { get; set; } = 100;
/// <summary>
/// The mod won't sync more projectiles if the limit is exceeded.
/// </summary>
public int GlobalProjectileSoftLimit { get; set; } = 100;
/// <summary>
/// The directory where log and resources downloaded from server will be placed.
/// </summary>