Say I have the following:
#define A 1 #define ACT_IS_NPC (A) /* Auto set for mobs */Now, say further that all mobs have a variable EFFECTS. How would I:
A) Set the ACT_IS_NPC flag in EFFECTS
B) Check to see if that flag is set for a mob
C) Clear that flag for a mob
Thanks for the help!
-James
mob.EFFECTS |= ACT_IS_NPC
if(mob.EFFECTS&ACT_IS_NPC)
...
mob.EFFECTS &= ~ACT_IS_NPC
There is an explanation of bit vectors in the old DUNG board somewhere (I think the topic is "bit fields"). That might help.
This all said, it would probably be wiser just to use a list to store effects. Bit fields, while efficient, are limiting (since you can only use up to 32 different fields (2^32 = sizeof(int)) and are also hard to read in the code.