About Store Forum Documentation Contact



Post Reply 
Another FlagTest
Author Message
Zervox Offline
Source Licensee

Post: #1
Another FlagTest
Thought I'd just snippet in another FlagTest for packed enums.

Code:
T2(TA,TB) inline Bool FlagMulTest   (TA  flags, TB f      ) {return (flags&f)==f;}                                   // check if all passed TB 'f' flags are enabled in TA flags

Code:
enum Ailment{
    Ailment_None      = 0,
    Ailment_Stone     = 1<<0,
    Ailment_Freeze    = 1<<1,
    Ailment_Stun      = 1<<2,
    Ailment_Sleep     = 1<<3,
    Ailment_Darkness  = 1<<4,

    Ailment_Poison    = 1<<5,
    Ailment_Curse     = 1<<6,
    Ailment_Silence   = 1<<7,
    Ailment_Confusion = 1<<8,
};
Code:
UInt test = (Ailment_Stone|Ailment_Freeze|Ailment_Stun|Ailment_Sleep|Ailment_Darkness|Ailmen​t_Poison|Ailment_Curse|Ailment_Silence|Ailment_Confusion);

Meaning this
Code:
if(FlagMulTest(test, (Ailment_Stone | Ailment_Curse))){

}

Will only return true if both flags are enabled.

EE::FlagTest will return if either flags are true.
02-26-2013 04:03 PM
Find all posts by this user Quote this message in a reply
Post Reply