]> jfr.im git - irc/gameservirc.git/blob - gameserv/flags.h
updated the TODO
[irc/gameservirc.git] / gameserv / flags.h
1 #ifndef FLAGS_H
2 #define FLAGS_H
3
4 /* This file contains all the flags used in the aClient and Player classes.
5 * More flags can be added simply by going up in multiples of 2.
6 * ie. 0001 0002 0004 0008 0010 0020 0040 0080 0100 0200 0400 0800 1000 2000 4000
7 * 8000 10000 20000 40000 80000 100000 200000 400000 800000 1000000 2000000 4000000
8 * 8000000 10000000 20000000 40000000 80000000 (32 bit)
9 * This method was taken from my experience in working with various
10 * IRCD packages. Most of them use this for their modes along with
11 * corresponding letter representations.
12 * Theoretically, each flag is 32 bit (long int), and each place in a flag
13 * is one hexadecimal digit (four bits). So, technically each flag variable
14 * can hold 8 spaces for flags. 8 spaces at 4 flags per space makes for
15 * 32 possible flags for each long int. That means there are 32 flags available
16 * for the aClient class, and 32 for the player class.
17 *
18 * Basically if you are having problems visualizing how flags work, think of them in
19 * binary terms:
20 * Hex Binary
21 * 0x0001 0001
22 * 0x0002 0010
23 * 0x0004 0100
24 * 0x0008 1000
25 * Basically, each flag represents a 1. When you add the different flags, you are just
26 * adding a 1 in the given position. So 1001 would be 0x0009 or flags 0001 and 0008.
27 */
28
29 // aClient FLAGS ONLY
30 #define FLAG_ADMIN 0x0001
31 #define FLAG_IGNORE 0x0002
32 #define FLAG_PLAYING 0x0004
33
34 // PLAYER FLAGS ONLY
35 #define FLAG_MASTER 0x0001
36 #define FLAG_ALIVE 0x0002
37 #define FLAG_YOURTURN 0x0004
38 #define FLAG_WONGAME 0x0008
39
40
41 // aClient flags
42 // #define ADMIN_FLAGS(FLAG_ONE | FLAG_TWO | FLAG_ETC)
43 #define ADMIN_FLAGS (FLAG_ADMIN)
44
45 #define setAdmin(x) ((x)->addFlag(FLAG_ADMIN))
46 #define clearAdmin(x) ((x)->remFlag(FLAG_ADMIN))
47 #define isAdmin(x) ((x)->getFlags() & FLAG_ADMIN)
48
49 #define clearAdminFlags(x) ((x)->remFlag(ADMIN_FLAGS))
50
51 #define setIgnore(x) ((x)->addFlag(FLAG_IGNORE))
52 #define clearIgnore(x) ((x)->remFlag(FLAG_IGNORE))
53 #define isIgnore(x) ((x)->getFlags() & FLAG_IGNORE) && !isAdmin(x)
54
55 #define setPlaying(x) ((x)->addFlag(FLAG_PLAYING))
56 #define clearPlaying(x) ((x)->remFlag(FLAG_IGNORE))
57 #define FL_is_playing(x) ((x)->getFlags() & FLAG_PLAYING)
58
59 // Player Flags
60 #define seenMaster(x) ((x)->getFlags() & FLAG_MASTER)
61 #define setMaster(x) ((x)->addFlag(FLAG_MASTER))
62 #define clearMaster(x) ((x)->remFlag(FLAG_MASTER))
63
64 #define isAlive(x) ((x)->getFlags() & FLAG_ALIVE)
65 #define setAlive(x) ((x)->addFlag(FLAG_ALIVE))
66 #define clearAlive(x) ((x)->remFlag(FLAG_ALIVE))
67
68 #define isYourTurn(x) ((x)->getFlags() & FLAG_YOURTURN)
69 #define setYourTurn(x) ((x)->addFlag(FLAG_YOURTURN))
70 #define clearYourTurn(x) ((x)->remFlag(FLAG_YOURTURN))
71
72 #define hasWonGame(x) ((x)->getFlags() & FLAG_WONGAME)
73 #define setWonGame(x) ((x)->addFlag(FLAG_WONGAME))
74 #define clearWonGame(x) ((x)->remFlag(FLAG_WONGAME))
75
76 #endif