In the end, I think it comes down to a simple profiling decision.
The question being: Which method is more economical?

If you're handling an event that happens often...like player_death, my guess is 
the extra 64
bits ("depending on the compiler") per player might be worth the amount of 
function calls if
you're doing it often. It'll certainly prevent sudden choppiness; replacing it 
with negligible(?)
sluggishness.

Of course, I base this on absolutely nothing as I haven't profiled the 
difference.

-- Roy "Kylratix" Laurie

On 20 Dec 2004 at 18:51, Marcelo Bezerra wrote:

> You can code the loop so it looks up both pEntities on a single pass.
> (You will be special casing this one to speed things up).
>
> Copy and paste from my plugin:
> -------------------------------------------
>         for(i=1;i<=maxplayers && (!pVictim || !pAttacker;i++)) {
>             edict_t *pEntity = engine->PEntityOfEntIndex(i);
>             if(!pEntity || pEntity->IsFree()) {
>                 continue;
>             }
>             int this_uid = engine->GetPlayerUserId(pEntity);
>             if(this_uid>=0) {
>                 if(uid == this_uid) {
>                     pVictim = pEntity;
>                 }
>                 if(attacker == this_uid) {
>                     pAttacker = pEntity;
>                 }
>             }
>         }
> -------------------------------------------
> I am generating an attacked logline to be used on my tk prevention system :)
> (It runs remotely, parsing log from multiple servers)
>
> Josh wrote:
>
> >Yea that's what I was thinking :(  I was really hoping to not do that, as a
> >LOT of functions will need to call that function. (I'm working on a war3 mod
> >for CSS, just building the groundwork).  So every time someone is shot /
> >died that will be called twice.  Doesn't that seem intensive? Do you think
> >valve could create an easier way?
> >
> >Josh
> >
> >-----Original Message-----
> >From: [EMAIL PROTECTED]
> >[mailto:[EMAIL PROTECTED] On Behalf Of Marcelo Bezerra
> >Sent: Monday, December 20, 2004 2:46 PM
> >To: [EMAIL PROTECTED]
> >Subject: Re: [hlcoders] Finding the entity based on the userid
> >
> >
> >for(int i=1;i<=maxplayers;i++) {
> >    edict_t *pEntity =  engine->PEntityOfEntIndex(i);
> >    if(!pEntity || pEntity->IsFree()) {
> >         continue;
> >    }
> >    int uid = engine->GetPlayerUserId(pEntity);
> >}
> >
> >Josh wrote:
> >
> >
> >
> >>OK all I have is the playerid (userid).  How do I get a pointer to the
> >>entity having this userid?  And I CANNOT use IndexOfEdict b/c that is a
> >>different number.
> >>
> >>For example, I join a game then I call the iplayerinfo on myself and find
> >>out that my userid is 2.  But IndexOfEdict is 1.  They are different.
> >>
> >>Josh
> >>
> >>
> >>-----Original Message-----
> >>From: [EMAIL PROTECTED]
> >>[mailto:[EMAIL PROTECTED] On Behalf Of Marcelo Bezerra
> >>Sent: Monday, December 20, 2004 12:36 PM
> >>To: [EMAIL PROTECTED]
> >>Subject: Re: [hlcoders] Finding the entity based on the userid
> >>
> >>You can look from 1 to maxplayers, get the pEntity and use:
> >>engine->GetPlayerUserId(pEntity);
> >>
> >>Loop from
> >>Josh wrote:
> >>
> >>
> >>
> >>
> >>
> >>>This is a multi-part message in MIME format.
> >>>--
> >>>[ Picked text/plain from multipart/alternative ]
> >>>I was just wondering how I can get an entity or an index of the entity
> >>>
> >>>
> >that
> >
> >
> >>>is "fired".
> >>>
> >>>
> >>>
> >>>Meaning the player_hurt event is fired and I get a userid of 2.  Will this
> >>>is different than the IndexOfEdict function in engine.  How can I
> >>>
> >>>
> >determine
> >
> >
> >>>the IndexOfEdict or get the pointer to the entity of a userid?
> >>>
> >>>
> >>>
> >>>Thanks,
> >>>
> >>>Josh
> >>>
> >>>--
> >>>
> >>>
> >>>_______________________________________________
> >>>To unsubscribe, edit your list preferences, or view the list archives,
> >>>
> >>>
> >>>
> >>>
> >>please visit:
> >>
> >>
> >>
> >>
> >>>http://list.valvesoftware.com/mailman/listinfo/hlcoders
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>_______________________________________________
> >>To unsubscribe, edit your list preferences, or view the list archives,
> >>please visit:
> >>http://list.valvesoftware.com/mailman/listinfo/hlcoders
> >>
> >>
> >>
> >>_______________________________________________
> >>To unsubscribe, edit your list preferences, or view the list archives,
> >>
> >>
> >please visit:
> >
> >
> >>http://list.valvesoftware.com/mailman/listinfo/hlcoders
> >>
> >>
> >>
> >>
> >>
> >
> >
> >_______________________________________________
> >To unsubscribe, edit your list preferences, or view the list archives,
> >please visit:
> >http://list.valvesoftware.com/mailman/listinfo/hlcoders
> >
> >
> >
> >_______________________________________________
> >To unsubscribe, edit your list preferences, or view the list archives, 
> >please visit:
> >http://list.valvesoftware.com/mailman/listinfo/hlcoders
> >
> >
> >
>
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives, please 
> visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>
>



_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to