Entity index: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Created page with 'An '''entity index''' is a unique integer given to every entity by the engine. It allows the same entity to be referred to across DLL boundaries. [[Entity limit|There can be…')
 
No edit summary
Line 1: Line 1:
An '''entity index''' is a unique [[integer]] given to every entity by the engine. It allows the same entity to be referred to across DLL boundaries.
An '''entity index''' is a unique [[integer]] given to every entity by the engine. It allows the same entity to be referred to across DLL boundaries; elsewhere a [[pointer]] is more useful.


[[Entity limit|There can be up to 4096 entities in the index]]. The first 2048 entries are reserved for entities with [[edict]]s, which cross the client/server divide.
[[Entity limit|There can be up to 4096 entities in the index]]. The first 2048 entries are reserved for entities with [[edict]]s, which cross the client/server divide.
Line 7: Line 7:
== Usage ==
== Usage ==


To get an entity's index, call <code>entindex()</code>. When programming mods this is only useful for comparison with another entity index: most of the time a [[pointer]] can be used instead.
* [[Entity]]: <code>entindex()</code>.
* [[Edict]]: <code>[[IVEngineServer|engine]]->IndexOfEdict()</code>.
 
{{confirm|An existing entity's index cannot be changed.}}


== See also ==
== See also ==

Revision as of 05:36, 19 October 2010

An entity index is a unique integer given to every entity by the engine. It allows the same entity to be referred to across DLL boundaries; elsewhere a pointer is more useful.

There can be up to 4096 entities in the index. The first 2048 entries are reserved for entities with edicts, which cross the client/server divide.

Note.pngNote:An entity index is not reliable between frames, as it can be freed from one entity and and reallocated to another at any time. Use CHandle for long-term storage.

Usage

Confirm:An existing entity's index cannot be changed.

See also