Articles:
OpenGL:
GL : Mouse Position to 3d Space

JA/JO:
JA : Getting Started
All : Qboolean
All : Bit Flags
All : Vector Math
JKA : Saber Cycle BugFix
JK2 : Classes
JK2 : Ladders
All : FontDat File Info
JK2 : Breakdown
JK2 : PM_ Anim

Dox:
JK2 : Source
JKA : Source

Related:
LF : JA Coding
LF : OJP Forum
LF : General Editing
Code3Arena
Stanford CS Library

Ancient
3.2004
2.2004
1.2004
12.2003

You are visitor #141738.
(since 11/01/2005).
You are unique visitor #33280.
(since 11/01/2005).
Your Friend, QBoolean - Wudan

Qboolean - the word is literally all over the source code, but you can't even pronounce it. Well, a qboolean is really just a 'boolean', literally. If you wanted to use them in regular programming you could do:
#define qboolean boolean
And it would work out fine. A function that is defined as type 'qboolean' will return either a '1' (qtrue) or a '0' (qfalse).

If you've ever used an 'if(stuff)' in your code, this is essentially a qboolean check - all sorts of things evaluate to true or false!

The basic idea behind a qboolean check is consistency - you only write the check once, and can use it many times without going mad - for example, if you know you're going to be writing what could be a nasty mess of 'if/else' conditions, you'll want to keep it as clean as possible.

So, if you know how to ask for an evaluation using an 'if' statement, then you should be able to grasp the concept of making qboolean statements.

Take for instance:
//check to see if the client is using
if( ent->client->ps.weapon == WP_SABER )
{
   
//do stuff if the statement evaluated qtrue
}
Now, you'll still use the 'if' statement, but this new function can be re-used a TON, and is (to me at least), more aesthetically desirable:
qboolean WP_Is( gentity_t *ent, int weapon )
{
    if( ent->client->ps.weapon == weapon )
    {
        return qtrue;
    }
    return qfalse;
}
And it's usage example:
//check to see if the client is using if( WP_Is( ent, WP_SABER ) )
{
   
//do stuff if the statement evaluated qtrue
}
It should be noted that this example only checks to see what weapon the player is currently using - because it's cool to have more usefulness, I'll include another function to check to see if the player *has* a weapon in his inventory:
qboolean WP_Has( gentity_t *ent, int weapon )
{
    if( ent->client->ps.stats[STAT_WEAPONS] == ( 1 << weapon ) )
    {
        return qtrue;
    }
    return qfalse;
}
And it's usage is conditionally identical:
//check to see if the client is using if( WP_Has( ent, WP_SABER ) )
{
   
//do stuff if the statement evaluated qtrue
}
The second function makes use of some trickyness that I'll cover in another article.
Comments and Suggestions Follow: