]>
Commit | Line | Data |
---|---|---|
1 | #ifndef FLAGS_H | |
2 | #define FLAGS_H | |
3 | ||
4 | #include "extern.h" | |
5 | ||
6 | /* This file contains all the flags used in the aClient and Player classes. | |
7 | * More flags can be added simply by going up in multiples of 2. | |
8 | * ie. 0001 0002 0004 0008 0010 0020 0040 0080 0100 0200 0400 0800 1000 2000 4000 | |
9 | * 8000 10000 20000 40000 80000 100000 200000 400000 800000 1000000 2000000 4000000 | |
10 | * 8000000 10000000 20000000 40000000 80000000 (32 bit) | |
11 | * This method was taken from my experience in working with various | |
12 | * IRCD packages. Most of them use this for their modes along with | |
13 | * corresponding letter representations. | |
14 | * Theoretically, each flag is 32 bit (long int), and each place in a flag | |
15 | * is one hexadecimal digit (four bits). So, technically each flag variable | |
16 | * can hold 8 spaces for flags. 8 spaces at 4 flags per space makes for | |
17 | * 32 possible flags for each long int. That means there are 32 flags available | |
18 | * for the aClient class, and 32 for the player class. | |
19 | * | |
20 | * Basically if you are having problems visualizing how flags work, think of them in | |
21 | * binary terms: | |
22 | * Hex Binary | |
23 | * 0x0001 0001 | |
24 | * 0x0002 0010 | |
25 | * 0x0004 0100 | |
26 | * 0x0008 1000 | |
27 | * Basically, each flag represents a 1. When you add the different flags, you are just | |
28 | * adding a 1 in the given position. So 1001 would be 0x0009 or flags 0001 and 0008. | |
29 | */ | |
30 | ||
31 | // aClient FLAGS ONLY | |
32 | #define FLAG_ADMIN 0x00000001 | |
33 | #define FLAG_IGNORE 0x00000002 | |
34 | #define FLAG_PLAYING 0x00000004 | |
35 | ||
36 | // PLAYER FLAGS ONLY | |
37 | #define FLAG_MASTER 0x00000001 | |
38 | #define FLAG_ALIVE 0x00000002 | |
39 | #define FLAG_YOURTURN 0x00000004 | |
40 | #define FLAG_WONGAME 0x00000008 | |
41 | #define FLAG_DRAGONFIGHT 0x00000010 | |
42 | #define FLAG_TIMEDOUT 0x00000020 | |
43 | ||
44 | // Config File flags | |
45 | #define CFLAG_LISTENONCF 0x00000001 | |
46 | #define CFLAG_USEPRIVMSG 0x00000002 | |
47 | #define CFLAG_BOPER 0x00000004 | |
48 | #define CFLAG_WELCOME 0x00000008 | |
49 | #define CFLAG_SAVEDNOTICE 0x00000010 | |
50 | #define CFLAG_USENICKSERV 0x00000020 | |
51 | #define CFLAG_ROLLOVERFORESTFIGHTS 0x00000040 | |
52 | #define CFLAG_FAIRFIGHTS 0x00000080 | |
53 | ||
54 | #define setFairFights() (configflags |= CFLAG_FAIRFIGHTS) | |
55 | #define clearFairFights() (configflags &= ~CFLAG_FAIRFIGHTS) | |
56 | #define isFairFights() (configflags & CFLAG_FAIRFIGHTS) | |
57 | ||
58 | #define setRolloverForestFights() (configflags |= CFLAG_ROLLOVERFORESTFIGHTS) | |
59 | #define clearRolloverForestFights() (configflags &= ~CFLAG_ROLLOVERFORESTFIGHTS) | |
60 | #define isRolloverForestFights() (configflags & CFLAG_ROLLOVERFORESTFIGHTS) | |
61 | ||
62 | #define setUseNickServ() (configflags |= CFLAG_USENICKSERV) | |
63 | #define clearUseNickServ() (configflags &= ~CFLAG_USENICKSERV) | |
64 | #define isUseNickServ() (configflags & CFLAG_USENICKSERV) | |
65 | ||
66 | #define setSavedNotice() (configflags |= CFLAG_SAVEDNOTICE) | |
67 | #define clearSavedNotice() (configflags &= ~CFLAG_SAVEDNOTICE) | |
68 | #define isSavedNotice() (configflags & CFLAG_SAVEDNOTICE) | |
69 | ||
70 | #define setWelcome() (configflags |= CFLAG_WELCOME) | |
71 | #define clearWelcome() (configflags &= ~CFLAG_WELCOME) | |
72 | #define isWelcome() (configflags & CFLAG_WELCOME) | |
73 | ||
74 | #define setListenOnCF() (configflags |= CFLAG_LISTENONCF) | |
75 | #define clearListenOnCF() (configflags &= ~CFLAG_LISTENONCF) | |
76 | #define isListenOnCF() (configflags & CFLAG_LISTENONCF) | |
77 | ||
78 | #define setUsePrivmsg() (configflags |= CFLAG_USEPRIVMSG) | |
79 | #define clearUsePrivmsg() (configflags &= ~CFLAG_USEPRIVMSG) | |
80 | #define isUsePrivmsg() (configflags & CFLAG_USEPRIVMSG) | |
81 | ||
82 | #define setBOper() (configflags |= CFLAG_BOPER) | |
83 | #define clearBOPer() (configflags &= ~CFLAG_BOPER) | |
84 | #define isBOper() (configflags & CFLAG_BOPER) | |
85 | ||
86 | // aClient flags | |
87 | // #define ADMIN_FLAGS(FLAG_ONE | FLAG_TWO | FLAG_ETC) | |
88 | #define ADMIN_FLAGS (FLAG_ADMIN) | |
89 | ||
90 | #define setAdmin(x) ((x)->addFlag(FLAG_ADMIN)) | |
91 | #define clearAdmin(x) ((x)->remFlag(FLAG_ADMIN)) | |
92 | #define isAdmin(x) ((x)->getFlags() & FLAG_ADMIN) | |
93 | ||
94 | #define clearAdminFlags(x) ((x)->remFlag(ADMIN_FLAGS)) | |
95 | ||
96 | #define setIgnore(x) ((x)->addFlag(FLAG_IGNORE)) | |
97 | #define clearIgnore(x) ((x)->remFlag(FLAG_IGNORE)) | |
98 | #define isIgnore(x) ((x)->getFlags() & FLAG_IGNORE) && !isAdmin(x) | |
99 | ||
100 | #define setPlaying(x) ((x)->addFlag(FLAG_PLAYING)) | |
101 | #define clearPlaying(x) ((x)->remFlag(FLAG_IGNORE)) | |
102 | #define FL_is_playing(x) ((x)->getFlags() & FLAG_PLAYING) | |
103 | ||
104 | // Player Flags | |
105 | #define PF_timedout(x) ((x)->getFlags() & FLAG_TIMEDOUT) | |
106 | #define PF_settimedout(x) ((x)->addFlag(FLAG_TIMEDOUT)) | |
107 | #define PF_cleartimedout(x) ((x)->remFlag(FLAG_TIMEDOUT)) | |
108 | ||
109 | #define seenMaster(x) ((x)->getFlags() & FLAG_MASTER) | |
110 | #define setMaster(x) ((x)->addFlag(FLAG_MASTER)) | |
111 | #define clearMaster(x) ((x)->remFlag(FLAG_MASTER)) | |
112 | ||
113 | #define isAlive(x) ((x)->getFlags() & FLAG_ALIVE) | |
114 | #define setAlive(x) ((x)->addFlag(FLAG_ALIVE)) | |
115 | #define clearAlive(x) ((x)->remFlag(FLAG_ALIVE)) | |
116 | ||
117 | #define isYourTurn(x) ((x)->getFlags() & FLAG_YOURTURN) | |
118 | #define setYourTurn(x) ((x)->addFlag(FLAG_YOURTURN)) | |
119 | #define clearYourTurn(x) ((x)->remFlag(FLAG_YOURTURN)) | |
120 | ||
121 | #define hasWonGame(x) ((x)->getFlags() & FLAG_WONGAME) | |
122 | #define setWonGame(x) ((x)->addFlag(FLAG_WONGAME)) | |
123 | #define clearWonGame(x) ((x)->remFlag(FLAG_WONGAME)) | |
124 | ||
125 | #define isDragonFight(x) ((x)->getFlags() & FLAG_DRAGONFIGHT) | |
126 | #define setDragonFight(x) ((x)->addFlag(FLAG_DRAGONFIGHT)) | |
127 | #define clearDragonFight(x) ((x)->remFlag(FLAG_DRAGONFIGHT)) | |
128 | ||
129 | #endif |