]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/flags.h
Almost done the player code
[irc/gameservirc.git] / gameserv / flags.h
index b8d7851113b270d543852a6dfe100de19bcb1c78..64a57305bc5cf26feb77031b5262b79e1c609dcf 100644 (file)
 #ifndef FLAGS_H
 #define FLAGS_H
 
-/* This file contains all the flags used in the aClient structure
+#include "extern.h"
+
+/* This file contains all the flags used in the aClient and Player classes.
  * More flags can be added simply by going up in multiples of 2.
- * ie. 0001 0002 0004 0008 0010 0020 0040 0080 0100 0200 0400 0800
+ * ie. 0001 0002 0004 0008 0010 0020 0040 0080 0100 0200 0400 0800 1000 2000 4000
+ *     8000 10000 20000 40000 80000 100000 200000 400000 800000 1000000 2000000 4000000
+ *     8000000 10000000 20000000 40000000 80000000 (32 bit)
  * This method was taken from my experience in working with various
  * IRCD packages. Most of them use this for their modes along with
  * corresponding letter representations.
+ * Theoretically, each flag is 32 bit (long int), and each place in a flag
+ * is one hexadecimal digit (four bits). So, technically each flag variable
+ * can hold 8 spaces for flags. 8 spaces at 4 flags per space makes for
+ * 32 possible flags for each long int. That means there are 32 flags available
+ * for the aClient class, and 32 for the player class.
+ *
+ * Basically if you are having problems visualizing how flags work, think of them in
+ * binary terms:
+ *     Hex     Binary
+ *     0x0001  0001
+ *     0x0002  0010
+ *     0x0004  0100
+ *     0x0008  1000
+ *     Basically, each flag represents a 1. When you add the different flags, you are just
+ *     adding a 1 in the given position. So 1001 would be 0x0009 or flags 0001 and 0008.
  */
 
-#define FLAG_ADMIN 0x0001
+// aClient FLAGS ONLY
+#define FLAG_ADMIN     0x00000001
+#define FLAG_IGNORE    0x00000002
+#define FLAG_PLAYING   0x00000004
+
+// PLAYER FLAGS ONLY
+#define FLAG_MASTER            0x00000001
+#define FLAG_ALIVE             0x00000002
+#define FLAG_YOURTURN          0x00000004
+#define FLAG_WONGAME           0x00000008
+#define FLAG_DRAGONFIGHT       0x00000010
+#define FLAG_TIMEDOUT       0x00000020
+
+// Config File flags
+#define CFLAG_LISTENONCF               0x00000001
+#define CFLAG_USEPRIVMSG               0x00000002
+#define CFLAG_BOPER                    0x00000004
+#define CFLAG_WELCOME                  0x00000008
+#define CFLAG_SAVEDNOTICE              0x00000010
+#define CFLAG_USENICKSERV              0x00000020
+#define CFLAG_ROLLOVERFORESTFIGHTS      0x00000040
+#define CFLAG_FAIRFIGHTS               0x00000080
+
+#define setFairFights()                        (configflags |= CFLAG_FAIRFIGHTS)
+#define clearFairFights()              (configflags &= ~CFLAG_FAIRFIGHTS)
+#define isFairFights()                 (configflags & CFLAG_FAIRFIGHTS)
 
+#define setRolloverForestFights()       (configflags |= CFLAG_ROLLOVERFORESTFIGHTS)
+#define clearRolloverForestFights()     (configflags &= ~CFLAG_ROLLOVERFORESTFIGHTS)
+#define isRolloverForestFights()        (configflags & CFLAG_ROLLOVERFORESTFIGHTS)
 
+#define setUseNickServ()               (configflags |= CFLAG_USENICKSERV)
+#define clearUseNickServ()             (configflags &= ~CFLAG_USENICKSERV)
+#define isUseNickServ()                        (configflags & CFLAG_USENICKSERV)
 
+#define setSavedNotice()               (configflags |= CFLAG_SAVEDNOTICE)
+#define clearSavedNotice()             (configflags &= ~CFLAG_SAVEDNOTICE)
+#define isSavedNotice()                        (configflags & CFLAG_SAVEDNOTICE)
 
+#define setWelcome()                   (configflags |= CFLAG_WELCOME)
+#define clearWelcome()                 (configflags &= ~CFLAG_WELCOME)
+#define isWelcome()                    (configflags & CFLAG_WELCOME)
 
+#define setListenOnCF()                        (configflags |= CFLAG_LISTENONCF)
+#define clearListenOnCF()              (configflags &= ~CFLAG_LISTENONCF)
+#define isListenOnCF()                 (configflags & CFLAG_LISTENONCF)
 
+#define setUsePrivmsg()                        (configflags |= CFLAG_USEPRIVMSG)
+#define clearUsePrivmsg()              (configflags &= ~CFLAG_USEPRIVMSG)
+#define isUsePrivmsg()                 (configflags & CFLAG_USEPRIVMSG)
+
+#define setBOper()                     (configflags |= CFLAG_BOPER)
+#define clearBOPer()                   (configflags &= ~CFLAG_BOPER)
+#define isBOper()                      (configflags & CFLAG_BOPER)
+
+// aClient flags
+// #define ADMIN_FLAGS(FLAG_ONE | FLAG_TWO | FLAG_ETC)
+#define ADMIN_FLAGS (FLAG_ADMIN)
 
 #define setAdmin(x)    ((x)->addFlag(FLAG_ADMIN))
 #define clearAdmin(x)  ((x)->remFlag(FLAG_ADMIN))
 #define isAdmin(x)     ((x)->getFlags() & FLAG_ADMIN)
 
+#define clearAdminFlags(x)     ((x)->remFlag(ADMIN_FLAGS))
+
+#define setIgnore(x)   ((x)->addFlag(FLAG_IGNORE))
+#define clearIgnore(x) ((x)->remFlag(FLAG_IGNORE))
+#define isIgnore(x)    ((x)->getFlags() & FLAG_IGNORE) && !isAdmin(x)
+
+#define setPlaying(x)          ((x)->addFlag(FLAG_PLAYING))
+#define clearPlaying(x)                ((x)->remFlag(FLAG_IGNORE))
+#define FL_is_playing(x)       ((x)->getFlags() & FLAG_PLAYING)
+
+// Player Flags
+#define PF_timedout(x)      ((x)->getFlags() & FLAG_TIMEDOUT)
+#define PF_settimedout(x)   ((x)->addFlag(FLAG_TIMEDOUT))
+#define PF_cleartimedout(x) ((x)->remFlag(FLAG_TIMEDOUT))
+                                                        
+#define seenMaster(x)          ((x)->getFlags() & FLAG_MASTER)
+#define setMaster(x)           ((x)->addFlag(FLAG_MASTER))
+#define clearMaster(x)         ((x)->remFlag(FLAG_MASTER))
+
+#define isAlive(x)             ((x)->getFlags() & FLAG_ALIVE)
+#define setAlive(x)            ((x)->addFlag(FLAG_ALIVE))
+#define clearAlive(x)          ((x)->remFlag(FLAG_ALIVE))
+
+#define isYourTurn(x)          ((x)->getFlags() & FLAG_YOURTURN)
+#define setYourTurn(x)         ((x)->addFlag(FLAG_YOURTURN))
+#define clearYourTurn(x)       ((x)->remFlag(FLAG_YOURTURN))
+
+#define hasWonGame(x)          ((x)->getFlags() & FLAG_WONGAME)
+#define setWonGame(x)          ((x)->addFlag(FLAG_WONGAME))
+#define clearWonGame(x)                ((x)->remFlag(FLAG_WONGAME))
+
+#define isDragonFight(x)       ((x)->getFlags() & FLAG_DRAGONFIGHT)
+#define setDragonFight(x)      ((x)->addFlag(FLAG_DRAGONFIGHT))
+#define clearDragonFight(x)    ((x)->remFlag(FLAG_DRAGONFIGHT))
+
 #endif