]> jfr.im git - irc/gameservirc.git/blame - gameserv/flags.h
Added a couple new directives to the config file
[irc/gameservirc.git] / gameserv / flags.h
CommitLineData
108f1888 1#ifndef FLAGS_H
2#define FLAGS_H
3
6f727d4c 4#include "extern.h"
5
1af35752 6/* This file contains all the flags used in the aClient and Player classes.
108f1888 7 * More flags can be added simply by going up in multiples of 2.
1af35752 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)
108f1888 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.
1af35752 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.
0d012394 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.
108f1888 29 */
30
1af35752 31// aClient FLAGS ONLY
108f1888 32#define FLAG_ADMIN 0x0001
448a1531 33#define FLAG_IGNORE 0x0002
3f243b0b 34#define FLAG_PLAYING 0x0004
108f1888 35
1af35752 36// PLAYER FLAGS ONLY
ee38284f 37#define FLAG_MASTER 0x0001
38#define FLAG_ALIVE 0x0002
39#define FLAG_YOURTURN 0x0004
9ea839ce 40#define FLAG_WONGAME 0x0008
108f1888 41
9bafc40d 42// Config File flags
43#define CFLAG_LISTENONCF 0x0001
44#define CFLAG_USEPRIVMSG 0x0002
6f727d4c 45#define CFLAG_BOPER 0x0004
46
47#define setListenOnCF() (configflags |= CFLAG_LISTENONCF)
48#define clearListenOnCF() (configflags &= ~CFLAG_LISTENONCF)
49#define isListenonCF() (configflags & CFLAG_LISTENONCF)
9bafc40d 50
6f727d4c 51#define setUsePrivmsg() (configflags |= CFLAG_USEPRIVMSG)
52#define clearUsePrivmsg() (configflags &= ~CFLAG_USEPRIVMSG)
53#define isUsePrivmsg() (configflags & CFLAG_USEPRIVMSG)
9bafc40d 54
6f727d4c 55#define setBOper() (configflags |= CFLAG_BOPER)
56#define clearBOPer() (configflags &= ~CFLAG_BOPER)
57#define isBOper() (configflags & CFLAG_BOPER)
108f1888 58
1af35752 59// aClient flags
60// #define ADMIN_FLAGS(FLAG_ONE | FLAG_TWO | FLAG_ETC)
61#define ADMIN_FLAGS (FLAG_ADMIN)
108f1888 62
63#define setAdmin(x) ((x)->addFlag(FLAG_ADMIN))
64#define clearAdmin(x) ((x)->remFlag(FLAG_ADMIN))
65#define isAdmin(x) ((x)->getFlags() & FLAG_ADMIN)
66
1af35752 67#define clearAdminFlags(x) ((x)->remFlag(ADMIN_FLAGS))
68
448a1531 69#define setIgnore(x) ((x)->addFlag(FLAG_IGNORE))
70#define clearIgnore(x) ((x)->remFlag(FLAG_IGNORE))
71#define isIgnore(x) ((x)->getFlags() & FLAG_IGNORE) && !isAdmin(x)
72
3f243b0b 73#define setPlaying(x) ((x)->addFlag(FLAG_PLAYING))
74#define clearPlaying(x) ((x)->remFlag(FLAG_IGNORE))
75#define FL_is_playing(x) ((x)->getFlags() & FLAG_PLAYING)
1af35752 76
77// Player Flags
ee38284f 78#define seenMaster(x) ((x)->getFlags() & FLAG_MASTER)
79#define setMaster(x) ((x)->addFlag(FLAG_MASTER))
80#define clearMaster(x) ((x)->remFlag(FLAG_MASTER))
81
82#define isAlive(x) ((x)->getFlags() & FLAG_ALIVE)
83#define setAlive(x) ((x)->addFlag(FLAG_ALIVE))
84#define clearAlive(x) ((x)->remFlag(FLAG_ALIVE))
1af35752 85
ee38284f 86#define isYourTurn(x) ((x)->getFlags() & FLAG_YOURTURN)
87#define setYourTurn(x) ((x)->addFlag(FLAG_YOURTURN))
88#define clearYourTurn(x) ((x)->remFlag(FLAG_YOURTURN))
1af35752 89
9ea839ce 90#define hasWonGame(x) ((x)->getFlags() & FLAG_WONGAME)
91#define setWonGame(x) ((x)->addFlag(FLAG_WONGAME))
92#define clearWonGame(x) ((x)->remFlag(FLAG_WONGAME))
93
108f1888 94#endif