Entity limit: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(i've verified that spawning too many things can crash the game)
 
(71 intermediate revisions by 22 users not shown)
Line 1: Line 1:
For reasons of memory allocation, there is a limit to the number of [[entity|entities]] Source can manage at once.
{{LanguageBar|title = Entity Limit}}
 
For reasons of memory allocation, there is a limit to the number of [[entity|entities]] {{gldsrc|4}}/{{source|4}}/{{source2|4}} can manage at once.


The combined size (in bytes) of a map's entity data should also be considered, even if the number of entities is within safe limits. Large amounts of [[Source BSP File Format#Entity|entdata]] can take a noticeably long time to transmit from server to client, and may lead to crashes.
The combined size (in bytes) of a map's entity data should also be considered, even if the number of entities is within safe limits. Large amounts of [[Source BSP File Format#Entity|entdata]] can take a noticeably long time to transmit from server to client, and may lead to crashes.
Line 5: Line 7:
{{tip|When creating very large or detailed maps, remember that more entities will exist at runtime than were compiled in. Things like weapons held by characters, projectiles and death ragdolls are all entities too. If you see "no free edicts" errors then you need to start cutting!}}
{{tip|When creating very large or detailed maps, remember that more entities will exist at runtime than were compiled in. Things like weapons held by characters, projectiles and death ragdolls are all entities too. If you see "no free edicts" errors then you need to start cutting!}}


== Engine limits ==
== {{gldsrc|4}} limits ==
{{stub}}
The default [[edict]] limit is 1200, but this can be raised to 2048 by editing the mod's [[liblist.gam]] to include {{code|edicts "2048"}}.<br>This can safely be done for singleplayer mods, but should not be relied upon for multiplayer maps for existing games, as the server and all clients must agree upon the edict limit.


There can be up to 4096 entities. This total is split into two groups of 2048:
In {{svencoop|4.1}}, the limit has been raised to 8192.


# Non-networked entities, which exist only on the client or server (e.g. death ragdolls on client, [[CLogicalEntity|logicals]] on server).
Prior to {{hl|4.1}}'s 25th-anniversary update, aswell as some standalone GoldSrc games, the default edict limit was 900.
# Entities with associated [[edict]]s, which can cross the client/server divide.


If the game tries to assign a 2049th edict it will exit with an error message, but if it tries to create a 2049th non-networked entity it will merely refuse and print a warning to the console. The logic behind this may be that an entity spawned dynamically (i.e. not present in the map) but not assigned an edict probably isn't too important.
All entities on the server are [[edict]]s, and are networked to clients. Intangible entities can be made clientside-only using {{cmd|MAKE_STATIC}}, but they will be removed upon loading a saved game.
 
== {{source|4}} limits ==
There is 2 groups of entities:
# Non-networked entities are entities which exist only on the client or server (e.g. death ragdolls on client, [[CLogicalEntity|logicals]] on server). There can be 2048 of these in pre-[[VScript]] branches and {{left4dead2}}, 6144 otherwise ({{tf2branch}}, {{asw}}, {{portal2}}, {{csgo}})
# Networked entities are associated [[edict]]s, which can cross the client/server divide. There can be 2048 of these.
 
* In {{gmod|4.1}}, there can be up 8192 networked entities, and 8192 non-networked entities.
* In {{mapbase|4.1}}, there can be up to 16384  "clientside renderable" entities. (Internal point entities, like {{ent|prop_static}}'s) {{ref|1}}
 
If the game tries to assign an edict past the limit it will exit with an error message, but if it tries to create a non-networked entity past the limit it will merely refuse and print a warning to the console. The logic behind this may be that an entity spawned dynamically (i.e. not present in the map) but not assigned an edict probably isn't too important.


The two entity lists are created by <code>CBaseEntityList::CBaseEntityList()</code> using <code>NUM_ENT_ENTRIES</code> and <code>MAX_EDICTS</code>. Neither of those values can be changed without breaking compatibility with the engine.
The two entity lists are created by <code>CBaseEntityList::CBaseEntityList()</code> using <code>NUM_ENT_ENTRIES</code> and <code>MAX_EDICTS</code>. Neither of those values can be changed without breaking compatibility with the engine.
In [[VScript]] games, non-networked entities have 2 extra bits reserved compared to edicts. Since the pool of entities is shared between entities and non-entities, this is why non-networked entities have a higher limit.


{{tip|[[Temporary Entity|Temporary entities]] and [[prop_static|static]] or [[prop_detail|detail]] props do not count toward either limit.}}
{{tip|{{clr}}
* [[Temporary Entity|Temporary entities]] and {{ent|prop_static}}'s, {{ent|env_sprite_clientside}}, or {{ent|prop_detail}} props do not count toward either limit. [[VBSP]] enforces limits for these, but these can be raised with a modified VBSP.
* If you're creating lots of individual objects all the time, consider rolling them all into a single manager entity.
* In-game, use console commands like {{command|report_entities}} and {{command|cl_showents}} to get an idea of how many entities are present at that current state.
* Prop entities that use a model with {{ent|$collisionjoints}} will generate one {{ent|phys_bone_follower}} for every convex piece of their [[collision model]]. These can quickly eat up the edict count! Enabling the "Disable Bone Followers" keyvalue on the prop will disable bone followers, although the prop will no longer have a functioning collision model, and the model will not be able to [[ragdoll]].}}


{{tip|If you're creating lots of individual objects all the time, consider rolling them all into a single manager entity. This is how [[Left 4 Dead]] handles huge numbers of infected: they are all "finger puppets" of the director.}}
=== VMF Limits ===
Hammer itself has no entity limit, but {{vbsp|4.1}}'s is dependent on the game:
* 8192 in {{src07|4.1}}/{{src13|4.1}}/{{tf2branch|4.1}}
* 16384 in {{as|4.1}}/{{portal2|4.1}}
* 20480 in {{csgo|4.1}}
* 65536 in {{mapbase|4.1}}/{{gmod|4.1}}, since March 2024.
{{note|The limit is set by MAX_MAP_ENTITIES variable in {{file|public/bspfile|h}}. This is a soft limit; a modded [[VBSP]] is capable of compiling as many entities as memory allows.}}
This is double the combined total accepted by the engine, which may be because it at first treats [[internal entity|internal entities]] (such as {{ent|prop_static}} and {{ent|env_cubemap}}) like normal entities, or perhaps because it generates a lot of [[detail props]].


{{tip|In-game, use console commands like <code>report_entities</code> and <code>cl_showents</code> to get an idea of how many entities are present at that current state.}}
VBSP also recommends an [[Source BSP File Format#Entity|entdata]] size limit of 384KB, but this is in no way enforced.


{{tip|The infodecal entity requires an edict since it can be activated to toggle it on and off. If you mod map has heavy use of infodecals, you can change the infodecal entity to a server only entity. This will require the removal of the toggle ability. To do this modify the CDecal parent from CPointEntity to CServerOnlyPointEntity. You will need to comment out the TriggerDecal, and InputActivate functions. Alternatively, you could create a infodecal_toggle entity to preserve both features.}}
== {{source2|4}} limits ==
In {{source2|4.1}}, specifically {{S&box|4.1}}, the networked entity limit is 16384 [[edicts]].


== Hammer limits ==
{{cs2|4}} - max 16384 edicts and 16384 server-only entities


Hammer itself has no entity limit, but [[VBSP]]'s is 8192. This is double the combined total accepted by the engine, which may be because it at first treats [[internal entity|internal entities]] (such as [[prop_static]] and [[env_cubemap]]) like normal entities, or perhaps because it generates a lot of [[detail props]].
There appears to be no limit for map compiles, or it is tied to the networked entity limit.


VBSP also recommends an [[Source BSP File Format#Entity|entdata]] size limit of 384KB, but this is in no way enforced.
== See also ==
* [[Internal entity]]
* {{ent|edict_t}}
 
== External links ==
* [https://rafuron.wordpress.com/category/mapping-tricks/ mapping tricks to get around the Entity limit]
 
== References ==
<ol>
<li> Mapbase 3.1 Release Notes https://www.moddb.com/mods/mapbase/news/mapbase-v3-1-released ''ModDB'' Retrieved ''Wednesday, March 6, 2024''
</ol>
 
[[Category:GoldSrc]]
[[Category:Source]]
[[Category:Source 2]]


[[Category:Level Design]]
[[Category:Level Design]]
[[Category:Programming]]
[[Category:Programming]]
[[Category:Glossary]]

Latest revision as of 02:31, 27 April 2025

English (en)Esperanto (eo)Русский (ru)中文 (zh)Translate (Translate)

For reasons of memory allocation, there is a limit to the number of entities GoldSrc GoldSrc/Source Source/Source 2 Source 2 can manage at once.

The combined size (in bytes) of a map's entity data should also be considered, even if the number of entities is within safe limits. Large amounts of entdata can take a noticeably long time to transmit from server to client, and may lead to crashes.

Tip.pngTip:When creating very large or detailed maps, remember that more entities will exist at runtime than were compiled in. Things like weapons held by characters, projectiles and death ragdolls are all entities too. If you see "no free edicts" errors then you need to start cutting!

GoldSrc GoldSrc limits

Stub

This article or section is a stub. You can help by expanding it.

The default edict limit is 1200, but this can be raised to 2048 by editing the mod's liblist.gam to include edicts "2048".
This can safely be done for singleplayer mods, but should not be relied upon for multiplayer maps for existing games, as the server and all clients must agree upon the edict limit.

In Sven Co-op Sven Co-op, the limit has been raised to 8192.

Prior to Half-Life Half-Life's 25th-anniversary update, aswell as some standalone GoldSrc games, the default edict limit was 900.

All entities on the server are edicts, and are networked to clients. Intangible entities can be made clientside-only using MAKE_STATIC, but they will be removed upon loading a saved game.

Source Source limits

There is 2 groups of entities:

  1. Non-networked entities are entities which exist only on the client or server (e.g. death ragdolls on client, logicals on server). There can be 2048 of these in pre-VScript branches and Left 4 Dead 2, 6144 otherwise (Team Fortress 2 branch, Alien Swarm, Portal 2, Counter-Strike: Global Offensive)
  2. Networked entities are associated edicts, which can cross the client/server divide. There can be 2048 of these.
  • In Garry's Mod Garry's Mod, there can be up 8192 networked entities, and 8192 non-networked entities.
  • In Mapbase Mapbase, there can be up to 16384 "clientside renderable" entities. (Internal point entities, like prop_static's) [1]

If the game tries to assign an edict past the limit it will exit with an error message, but if it tries to create a non-networked entity past the limit it will merely refuse and print a warning to the console. The logic behind this may be that an entity spawned dynamically (i.e. not present in the map) but not assigned an edict probably isn't too important.

The two entity lists are created by CBaseEntityList::CBaseEntityList() using NUM_ENT_ENTRIES and MAX_EDICTS. Neither of those values can be changed without breaking compatibility with the engine. In VScript games, non-networked entities have 2 extra bits reserved compared to edicts. Since the pool of entities is shared between entities and non-entities, this is why non-networked entities have a higher limit.

Tip.pngTip:
  • Temporary entities and prop_static's, env_sprite_clientside, or prop_detail props do not count toward either limit. VBSP enforces limits for these, but these can be raised with a modified VBSP.
  • If you're creating lots of individual objects all the time, consider rolling them all into a single manager entity.
  • In-game, use console commands like report_entities and cl_showents to get an idea of how many entities are present at that current state.
  • Prop entities that use a model with $collisionjoints will generate one phys_bone_follower for every convex piece of their collision model. These can quickly eat up the edict count! Enabling the "Disable Bone Followers" keyvalue on the prop will disable bone followers, although the prop will no longer have a functioning collision model, and the model will not be able to ragdoll.

VMF Limits

Hammer itself has no entity limit, but VBSP VBSP's is dependent on the game:

Note.pngNote:The limit is set by MAX_MAP_ENTITIES variable in 🖿public/bspfile.h. This is a soft limit; a modded VBSP is capable of compiling as many entities as memory allows.

This is double the combined total accepted by the engine, which may be because it at first treats internal entities (such as prop_static and env_cubemap) like normal entities, or perhaps because it generates a lot of detail props.

VBSP also recommends an entdata size limit of 384KB, but this is in no way enforced.

Source 2 Source 2 limits

In Source 2 Source 2, specifically S&box S&box, the networked entity limit is 16384 edicts.

Counter-Strike 2 Counter-Strike 2 - max 16384 edicts and 16384 server-only entities

There appears to be no limit for map compiles, or it is tied to the networked entity limit.

See also

External links

References

  1. Mapbase 3.1 Release Notes https://www.moddb.com/mods/mapbase/news/mapbase-v3-1-released ModDB Retrieved Wednesday, March 6, 2024