Entity index: Difference between revisions
Jump to navigation
Jump to search
Tip:Worldspawn is always entity 0, while indices 1 to <maxplayers> are reserved for players.
Note: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
Confirm:An existing entity's index cannot be changed.
TomEdwards (talk | contribs) No edit summary |
TomEdwards (talk | contribs) 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 library boundaries, but will be different on the client and server unless an [[edict]] is used. Within | An '''entity index''' is a unique [[integer]] given to every entity by the engine. It allows the same entity to be referred to across library boundaries, but will be different on the client and server unless an [[edict]] is used. Within the client and server, [[pointer]]s to <code>[[CBaseEntity]]</code> are 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. | ||
{{tip|[[Worldspawn]] is always entity 0, while indices 1 to <[[maxplayers]]> are reserved for players.}} | |||
{{note|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 <code>[[CHandle]]</code> for long-term storage.}} | {{note|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 <code>[[CHandle]]</code> for long-term storage.}} | ||
Line 7: | Line 9: | ||
== Usage == | == Usage == | ||
* [[Entity]]: <code>entindex()</code> | * [[CBaseEntity|Entity]]: <code>entindex()</code> | ||
* [[Edict]]: <code>[[IVEngineServer|engine]]->IndexOfEdict()</code> | * [[Edict]]: <code>[[IVEngineServer|engine]]->IndexOfEdict()</code> | ||
{{confirm|An existing entity's index cannot be changed.}} | {{confirm|An existing entity's index cannot be changed.}} |
Revision as of 09:00, 20 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 library boundaries, but will be different on the client and server unless an edict is used. Within the client and server, pointers to CBaseEntity
are 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.


CHandle
for long-term storage.Usage
