edict_t
Jump to navigation
Jump to search
edict_t
("entity dictionary") is an interface struct used to refer to entities across DLL boundaries, including the client/server divide. In each location it provides a pointer to the local representation of its assigned entity.

CHandle
for long-term storage.
edict_t
or CBaseEdict
. If the memory footprint of either changes, engine DLLs will start accessing invalid addresses.Todo: Is the dictionary synced between client and server even for non-networked ents?
Edict limit
Source can have up to 2048 edicts allocated at any one time, and going over that will cause the engine to exit with an error message. This is commonly referred to as the entity limit, which is inaccurate; there is an entity limit, but it is 4096 and hitting it will cause only console errors.
Avoiding
Edicts are automatically assigned by CBaseEntity::PostConstructor()
. To prevent this, construct your entity like so:
CMyEntity() : CBaseEntity(true) { /*...*/ }

CServerOnlyEntity
already does this. CLogicalEntity
inherits, and as such none of Valve's logic entities or VPhysics constraints have edicts.Edict-less entities still count toward the overall entity limit, which is 4096.
Getting
edict_t* CBaseEntity::edict()
- Simple accessor. Returns null if there is no edict.
edict_t* PEntityOfEntIndex(int iEntIndex)
- Given an entity index, returns a pointer to the corresponding edict.
int GetEntityCount()
- Returns the current number of assigned edicts (not entities).
Setting
void CBaseEntity::NetworkProp()->AttachEdict(edict_t* pRequiredEdict);
- Assigns an edict via the entity's
CServerNetworkProperty
object. Pass NULL unless a specific edict is required. void CBaseEntity::NetworkProp()->DetachEdict()
- Detaches the entity's assigned edict. It will go back into the edict pool for re-use.
Notable members
CBaseEntity* GetUnknown()->GetBaseEntity()
- Pointer to the entity's local representation.
char* GetClassName()
- The classname of the assigned entity.
bool IsFree()
- Whether there is currently an entity assigned to this edict.
float freetime
- The server timestamp at which the edict was last freed. Can be used to avoid reallocating the edict immediately.
IServerEntity* GetIServerEntity()
IServerNetworkable* GetNetworkable()
ICollideable* GetCollideable()
- Accessors to various interfaces.
See also
- Entity index
- Entity limit
CHandle
- Discussion on GoldSrc edicts
- Quake 2's edict_t. Storing so many disparate variables in an engine interface was a bad idea!