EHANDLE: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
m (revert)
Line 1: Line 1:
[http://despretinemid.demogen.info/ despre tine mid] [http://weisshorn.etotest.info/ weisshorn] [http://decoderstrongparabole.skains.info/ decoder strong parabole] [http://scrivereconlaluce.demogen.info/ scrivere con la luce] [http://casaeditrice.etotest.info/ casa editrice] [http://calendarioeva.enlard.info/ calendario eva henger] [http://stevenkingheroes.demogen.info/ steven king heroes] [http://luf.wedged.info/ luf] [http://evalongoria.alient.info/ eva longoria] [http://ivanhoewalter.etotest.info/ ivanhoe walter scott] [http://britishcouncil.wedged.info/ british council] [http://schaeharrison.wedged.info/ schae harrison] [http://laperlakimono.wedged.info/ la perla kimono] [http://radiomodem.demogen.info/ radio modem] [http://beiragazzi.wedged.info/ bei ragazzi] [http://dirittoumano.behav.info/ diritto umano] [http://exopereoperantis.demogen.info/ ex opere operantis] [http://sonata.wedged.info/ sonata] [http://ammabunton.behav.info/ amma bunton] [http://lq-630sepson.enlard.info/ lq-630s epson] [http://monitorlcd21pollici.enlard.info/ monitor lcd 21 pollici] [http://carloverdonefoto.etotest.info/ carlo verdone foto] [http://giardinaggiofai.enlard.info/ giardinaggio fai da te] [http://amplificatori.demogen.info/ amplificatori per cuffie] [http://liljonetheeastside.wedged.info/ lil jon e the eastside boyz] [http://allevamento.etotest.info/ allevamento cucciolo] [http://viaggibarcellona.enlard.info/ viaggi barcellona] [http://batteriapixo.alient.info/ batteria pixo] [http://girautoguiraut.etotest.info/ giraut o guiraut de bornelh] [http://seilamiadonna.demogen.info/ sei la mia donna] [http://unimiit.alient.info/ unimi it] [http://lavaggiocartuccia.alient.info/ lavaggio cartuccia stampante] [http://carmelaragusa.etotest.info/ carmela ragusa] [http://doveilmondo.enlard.info/ dove il mondo] [http://enlard.info/index2_500.html page] [http://tatuaggicon.skains.info/ tatuaggi con fate] [http://tarantelladelgaragano.enlard.info/ tarantella del garagano] [http://zuccheroindaco.behav.info/ zucchero indaco] [http://flyfishingoutfitters.etotest.info/ fly fishing outfitters] [http://grandvoyager2.enlard.info/ grand voyager 2 8] [http://etienneperier.wedged.info/ etienne perier] [http://c480olympus.enlard.info/ c480 olympus] [http://enlard.info/index6_250.html map] [http://tarotgratis.alient.info/ tarot gratis] [http://gefara.alient.info/ gefara] [http://pensavofosse.enlard.info/ pensavo fosse amore e invece era un] [http://noanda.skains.info/ noanda] [http://peliculaaladino.alient.info/ pelicula aladino] [http://asesino.wedged.info/ asesino] [http://finalenad.enlard.info/ finale nad] [http://rayban3243.behav.info/ ray ban 3243] [http://ozonedintei.enlard.info/ ozone din tei] [http://canon300dreflex.enlard.info/ canon 300d reflex fotocamere] [http://demirussos.etotest.info/ demi russos] [http://woodlark.etotest.info/ woodlark] [http://ot10ibanez.demogen.info/ ot 10 ibanez] [http://netware.wedged.info/ netware] [http://bagliorinel.demogen.info/ bagliori nel buio] [http://barbiedivertimento.skains.info/ barbie divertimento] [http://imageporno.etotest.info/ image porno] [http://wwwaltavillait.enlard.info/ www altavilla it] [http://voyagercrd.demogen.info/ voyager crd] [http://ballrevamped2.skains.info/ ball revamped 2] [http://zipsp.demogen.info/ zip sp] [http://venuteinfaccia.enlard.info/ venute in faccia] [http://navigatoresatellitare.behav.info/ navigatore satellitare gps quest] [http://lesoldatesse.enlard.info/ le soldatesse] [http://hotelradda.wedged.info/ hotel radda] [http://behav.info/index3_250.html home] [http://fotorapiti.behav.info/ foto rapiti] [http://coricatania.etotest.info/ cori catania] [http://ba.etotest.info/ ba] [http://almeglio.wedged.info/ al meglio] [http://skains.info/index7_250.html map] [http://trust600ups600va.alient.info/ trust 600 ups 600va] [http://traduzioneonline.enlard.info/ traduzione online] [http://videocameragrdjvc.alient.info/ videocamera grd jvc] [http://kalashnikov.demogen.info/ kalashnikov] [http://historiadelfutbol.enlard.info/ historia del futbol] [http://nokiabatterialitio.wedged.info/ nokia batteria litio 3310 3330] [http://pancapro-form.enlard.info/ panca pro-form] [http://dimm256mb.behav.info/ dimm 256mb] [http://samsungml2550.etotest.info/ samsung ml 2550] [http://ewanmcgregor.enlard.info/ ewan mcgregor] [http://ilcasomaurizius.etotest.info/ il caso maurizius] [http://calcioolandese.skains.info/ calcio olandese] [http://peperoportocervo.demogen.info/ pepero porto cervo] [http://screensavergatto.wedged.info/ screensaver gatto] [http://wwwitaliaunocom.demogen.info/ www italiauno com] [http://norman.wedged.info/ norman] [http://redhatwsbasic.behav.info/ redhat ws basic] [http://serie7bmw.alient.info/ serie 7 bmw] [http://batteriepanasonic.wedged.info/ batterie panasonic x70] [http://pixcisco.behav.info/ pix cisco] [http://rundeletecrack.wedged.info/ r undelete crack] [http://losceiccobianco.etotest.info/ lo sceicco bianco di fellini] [http://crissymoranvideo.etotest.info/ crissy moran video] [http://uncadaverein.alient.info/ un cadavere in fuga] [http://nessunacome.etotest.info/ nessuna come te] [http://checkforupdate.wedged.info/ check for update]
Entities in the Source Engine are created and deleted all the time. Each time a new entity is instantiated, the engine looks up an unused entity-index and assigns this to the new entity. Once the entity is destroyed, its entity index becomes available again and may be reused for a different entity.
Entities in the Source Engine are created and deleted all the time. Each time a new entity is instantiated, the engine looks up an unused entity-index and assigns this to the new entity. Once the entity is destroyed, its entity index becomes available again and may be reused for a different entity.



Revision as of 06:43, 24 October 2007

Entities in the Source Engine are created and deleted all the time. Each time a new entity is instantiated, the engine looks up an unused entity-index and assigns this to the new entity. Once the entity is destroyed, its entity index becomes available again and may be reused for a different entity.

It's often nessary to keep track of an entity. This done mostly with pointers and entindex (index of the entity). However, when the entity is destroyed, using the pointer crashes (because it still points to a non-NULL location) and the entindex is not suitable because it may point to an other entity.

A better and safer way is to use an EHANDLE (or CBaseHandle) to keep track of entities. An EHANDLE encapsulate a 32-bit ID that is unique for an entity instance during the whole game and can be used on both server and client to refer to entity objects (An EHANDLE is a combination of an entity index and an increasing serial number). An EHANDLE can be transformed to CBaseEntity and vice versa just by using its overloaded operators. If an EHANDLE resolves to NULL, the entity is not valid anymore.

Example

// Find a player, if no player is available pPlayer and hPlayer are NULL
CBasePlayer* pPlayer = gEntList.FindEntityByClassname( NULL, "player" );

// Store it in a EHANDLE
EHANDLE hPlayer = pPlayer;

// Convert back to CBasePlayer
pPlayer = dynamic_cast<CBasePlayer*>((CBaseEntity*)hPlayer);

EHANDLEs must always be converted to the class CBaseEntity first, before casting to a derived class.

Related content

Networking Entities