You cannot assume that it is not evaluated. Maybe the compiler compiles the
code is such a way both get checked anyways. Or maybe the compiler copiles
it so the second statement gets checked first. You -never- know for sure, so
you should be explicit about it. I would do it this way (please note I use
NULL instead of using !, because strictly taken, you should always check
pointers with NULL. I think gcc even complains about it.)

if (pPlayer == NULL)
{
    // Do the code
}
else
{
    if (!pPlayer->IsNetClient())
    {
        // Do the code here too
    }
}

This structure is a bit odd, beacouse you have the code twice. So you should
use a function there. If you want to avoid using a function, just figure out
a different way to write the check (there always is a way to do it). Just
make sure you never try "pPlayer->IsNetClient()" if pPlayer is NULL.

Jeroen "ShadowLord" Bogers


----- Original Message -----
From: "Persuter" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, June 08, 2003 22:28
Subject: Re: [hlcoders] SDK line crashing linux servers


If pPlayer is NULL, then !pPlayer will return true, in which case the
second part of the or statement will not get evaluated, so that's not the
problem.

Persuter

At 10:02 PM 6/8/2003 +0200, you wrote:
>hmm, if pPlayer = NULL then you can�t do pPlayer->IsNetClient()..
>
>
>----- Original Message -----
>From: "James Couzens" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Saturday, June 07, 2003 9:22 PM
>Subject: [hlcoders] SDK line crashing linux servers
>
>
> > if (!pPlayer || !pPlayer->IsNetClient())
> >
> > Why does this logic crash a linux dedicated server?
> >
> > Cheers,
> >
> > James
> >
> > ---
> > James Couzens
> > ClanMod Dev Team
> > WWW: http://unitedadmins.com/clanmod.php
> > UA LISTS: http://list.unitedadmins.com/mailman/listinfo
> >
> > _______________________________________________
> > 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