Author | Message | Time |
---|---|---|
LoRd | For some odd reason, my bitwize flag comparison always returns false when checking for USER_FLAG_B (0x04), but returns properly for all of the other flags and I can't figure out why. [code]// User Flags #define USER_FLAG_A 0x01 // A - Access Management #define USER_FLAG_a 0x02 // a - Restricted Access Management #define USER_FLAG_B 0x04 // B - Auto-Banned #define USER_FLAG_C 0x08 // C - Connection #define USER_FLAG_D 0x10 // D - Connection #define USER_FLAG_G 0x20 // G - General Function Control #define USER_FLAG_J 0x40 // J - Join #define USER_FLAG_M 0x80 // M - Bot Master #define USER_FLAG_O 0x100 // O - Channel Operator #define USER_FLAG_o 0x200 // o - Restricted Channel Operator #define USER_FLAG_P 0x400 // P - Protected #define USER_FLAG_S 0x800 // S - Safe #define USER_FLAG_s 0x1000 // s - Low-Level Safe #define USER_FLAG_T 0x2000 // T - Talk[/code] [code] dbuUsers[0].Flags = (USER_FLAG_A| USER_FLAG_B| USER_FLAG_C| USER_FLAG_D| USER_FLAG_G| USER_FLAG_J| USER_FLAG_M| USER_FLAG_O| USER_FLAG_S| USER_FLAG_T);[/code] [code]inline void CBNCS::OnJoin(const DWORD *dwFlags, const DWORD *dwPing, const char *sUsername, const char *sStatstring) { #ifdef DEBUG AppendConsole("%s:%i:%X has joined the channel.\n", sUsername, *dwPing, *dwFlags); #endif unsigned int iUsrBFlags = Database.GetUserFlags(sUsername); if (iUsrBFlags != 0xFFFFFFFF) { if ((iUsrBFlags & USER_FLAG_B) == USER_FLAG_B) SendChatCommand("/ban %s Autoban", sUsername); } }[/code] | November 21, 2004, 5:57 AM |
drivehappy | What does iUsrBFlags equal when it's supposed to SendChatCommand() ? BTW, it's not called bitwise, rather bit masking. | November 21, 2004, 8:05 AM |
LoRd | [quote author=drivehappy link=topic=9628.msg89600#msg89600 date=1101024313] What does iUsrBFlags equal when it's supposed to SendChatCommand() ? BTW, it's not called bitwise, rather bit masking. [/quote] 0x14F9 (5369) Edit: Problem solved. For some odd reason, the entry being loaded from the database was incorrect. | November 21, 2004, 8:27 AM |
Mephisto | if ((iUsrBFlags & USER_FLAG_B) == USER_FLAG_B) That's a bit redundant. Just use if ((iUsrBFlags & FLAG_B) { ... } | November 21, 2004, 6:26 PM |
LoRd | [quote author=Mephisto link=topic=9628.msg89633#msg89633 date=1101061618] if ((iUsrBFlags & USER_FLAG_B) == USER_FLAG_B) That's a bit redundant. Just use if ((iUsrBFlags & FLAG_B) { ... } [/quote] It helps to give me a more visual perspective. | November 21, 2004, 9:07 PM |
Eibro | Also note that if you're ANDing with a mask rather than a flag you need the extra == to check if the entire mask was set. | November 21, 2004, 9:42 PM |