Raised This Month: $ Target: $400
 0% 

Adding, removing, checking bitsums


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 05-27-2007 , 18:09   Adding, removing, checking bitsums
Reply With Quote #1

I was just wondering if I did this the correct way.

PHP Code:
#define FLAG_A (1<<0)
#define FLAG_B (1<<1)
#define FLAG_C (1<<2)
 
stock get_player_flags(idflags)
 return (
g_user_flags[id] & flags)
 
stock set_player_flags(idflags)
 return 
g_user_flags[id] |= flags
 
// add
set_player_flags(idFLAG_A)
 
// remove
set_player_flags(id, ~FLAG_B)
 
// check
if(!get_player_flags(idFLAG_C))
  return 
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.

Last edited by Cheap_Suit; 05-27-2007 at 21:32.
Cheap_Suit is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 05-27-2007 , 21:28   Re: Adding, removing, checking bitsums
Reply With Quote #2

Quote:
Originally Posted by Cheap_Suit View Post
I was just wondering if I did this the correct way.

PHP Code:
#define FLAG_A (1<<0)
#define FLAG_B (1<<1)
#define FLAG_B (1<<2)
 
stock get_player_flags(idflags)
 return (
g_user_flags[id] & flags)
 
stock set_player_flags(idflags)
 return 
g_user_flags[id] |= flags
 
// add
set_player_flags(idFLAG_A)
 
// remove
set_player_flags(id, ~FLAG_B)
 
// check
if(!get_player_flags(idFLAG_C))
  return 
Sorry i don't know anything about bitsum stuff the only flaw is a typo because you define 2 times FLAG_B
But it looks correct..0o

greetz regalis
__________________
regalis is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 05-27-2007 , 23:58   Re: Adding, removing, checking bitsums
Reply With Quote #3

Everything else is right except for removing.

Code:
var &= ~FLAG_C
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 05-28-2007 , 00:27   Re: Adding, removing, checking bitsums
Reply With Quote #4

Ah thanks
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.
Cheap_Suit is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:41.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode