[ioquake3] g_client.c weapon init question

Ben Millwood thebenmachine at googlemail.com
Thu May 29 08:50:59 PDT 2008


It's an enum, in bg_public.h (about halfway down
http://svn.icculus.org/quake3/trunk/code/game/bg_public.h?revision=726&view=markup)

so client->ps.stats[STAT_WEAPONS] = (1 << WP_PLASMAGUN) | (1 << WP_BFG); is
right
WP_PLASMAGUN is 8 and WP_BFG is 9, by the way.

On Thu, May 29, 2008 at 4:25 PM, Patrick Baggett <baggett.patrick at gmail.com>
wrote:

> If WP_XXXXXXX constants are bit flags (i.e. 0x01, 0x02, 0x04, 0x08, 0x10,
> 0x20, ...) then doing a bitwise OR will select multiple, and
>
> client->ps.stats[STAT_WEAPONS] = WP_PLASMAGUN | WP_BFG; //With bitflags
>
> would be correct. However, if they are enumerations (i.e. sequential values
> such as 0x00, 0x01, 0x02, 0x03, ....) then ORing them will give improper
> results. You have to think of each enumerant's value as the BIT position it
> covers. To set that bit however, you need to do a left-shift with 1, so that
> the single bit is set.
>
> client->ps.stats[STAT_WEAPONS] = (1<<WP_PLASMAGUN)| (1<<WP_BFG); //With
> enumeration
>
> Can someone just please go to the definition of the code and look it up?
>
>
> On Thu, May 29, 2008 at 8:49 AM, Edson Alves Pereira <lottalava at gmail.com>
> wrote:
>
>> Wouldn´t  be correct do that fashion?
>>
>> client->ps.stats[STAT_WEAPONS] = WP_PLASMAGUN | WP_BFG;
>>
>>
>>
>> On Thu, May 29, 2008 at 10:37 AM, Matt Turner <mattst88 at gmail.com> wrote:
>>
>>> On Thu, May 29, 2008 at 9:07 AM, Tyler Schwend <tylerschwend at gmail.com>
>>> wrote:
>>> > Likely, you could change:
>>> >
>>> >        client->ps.stats[STAT_WEAPONS] = ( 1 << WP_PLASMAGUN );
>>> >
>>> > to
>>> >
>>> >        client->ps.stats[STAT_WEAPONS] = ( 1 << WP_PLASMAGUN << WP_BFG);
>>> >
>>> > The << is a bit shifter, and you should be able to stack on whatever
>>> you
>>> > want there...
>>>
>>> No. It would rather be
>>>
>>> client->ps.stats[STAT_WEAPONS] = (1 << WP_PLASMAGUN) | (1 << WP_BFG);
>>>
>>> Matt
>>> _______________________________________________
>>> ioquake3 mailing list
>>> ioquake3 at lists.ioquake.org
>>> http://lists.ioquake.org/listinfo.cgi/ioquake3-ioquake.org
>>> By sending this message I agree to love ioquake3 and libsdl.
>>>
>>
>>
>> _______________________________________________
>> ioquake3 mailing list
>> ioquake3 at lists.ioquake.org
>> http://lists.ioquake.org/listinfo.cgi/ioquake3-ioquake.org
>> By sending this message I agree to love ioquake3 and libsdl.
>>
>
>
> _______________________________________________
> ioquake3 mailing list
> ioquake3 at lists.ioquake.org
> http://lists.ioquake.org/listinfo.cgi/ioquake3-ioquake.org
> By sending this message I agree to love ioquake3 and libsdl.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ioquake.org/pipermail/ioquake3-ioquake.org/attachments/20080529/dc73f00f/attachment.htm>


More information about the ioquake3 mailing list