Add global limits
This commit is contained in:
@ -159,6 +159,7 @@ namespace RageCoop.Client
|
|||||||
Main.Logger.Error(ex);
|
Main.Logger.Error(ex);
|
||||||
Peer.Shutdown($"Packet Error [{packetType}]");
|
Peer.Shutdown($"Packet Error [{packetType}]");
|
||||||
#endif
|
#endif
|
||||||
|
_recycle = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -305,7 +306,9 @@ namespace RageCoop.Client
|
|||||||
if (c == null)
|
if (c == null)
|
||||||
{
|
{
|
||||||
// Main.Logger.Debug($"Creating character for incoming sync:{packet.ID}");
|
// 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));
|
EntityPool.ThreadSafe.Add(c = new SyncedPed(packet.ID));
|
||||||
|
else return;
|
||||||
}
|
}
|
||||||
PedDataFlags flags = packet.Flags;
|
PedDataFlags flags = packet.Flags;
|
||||||
c.ID = packet.ID;
|
c.ID = packet.ID;
|
||||||
@ -353,7 +356,9 @@ namespace RageCoop.Client
|
|||||||
SyncedVehicle v = EntityPool.GetVehicleByID(packet.ID);
|
SyncedVehicle v = EntityPool.GetVehicleByID(packet.ID);
|
||||||
if (v == null)
|
if (v == null)
|
||||||
{
|
{
|
||||||
|
if (EntityPool.allVehicles.Length < Main.Settings.GlobalVehicleSoftLimit)
|
||||||
EntityPool.ThreadSafe.Add(v = new SyncedVehicle(packet.ID));
|
EntityPool.ThreadSafe.Add(v = new SyncedVehicle(packet.ID));
|
||||||
|
else return;
|
||||||
}
|
}
|
||||||
if (v.IsLocal) { return; }
|
if (v.IsLocal) { return; }
|
||||||
v.ID = packet.ID;
|
v.ID = packet.ID;
|
||||||
@ -393,7 +398,9 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
if (packet.Flags.HasProjDataFlag(ProjectileDataFlags.Exploded)) { return; }
|
if (packet.Flags.HasProjDataFlag(ProjectileDataFlags.Exploded)) { return; }
|
||||||
// Main.Logger.Debug($"Creating new projectile: {(WeaponHash)packet.WeaponHash}");
|
// Main.Logger.Debug($"Creating new projectile: {(WeaponHash)packet.WeaponHash}");
|
||||||
|
if (EntityPool.allProjectiles.Length < Main.Settings.GlobalProjectileSoftLimit)
|
||||||
EntityPool.ThreadSafe.Add(p = new SyncedProjectile(packet.ID));
|
EntityPool.ThreadSafe.Add(p = new SyncedProjectile(packet.ID));
|
||||||
|
else return;
|
||||||
}
|
}
|
||||||
p.Flags = packet.Flags;
|
p.Flags = packet.Flags;
|
||||||
p.Position = packet.Position;
|
p.Position = packet.Position;
|
||||||
|
@ -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).
|
/// The game won't spawn more NPC traffic if the limit is exceeded. -1 for unlimited (not recommended).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int WorldPedSoftLimit { get; set; } = 30;
|
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>
|
/// <summary>
|
||||||
/// The directory where log and resources downloaded from server will be placed.
|
/// The directory where log and resources downloaded from server will be placed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Reference in New Issue
Block a user