summaryrefslogtreecommitdiff
path: root/include/mode.h
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-07 15:27:05 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-07 15:27:05 +0000
commita1af610ac1916bc3a4f09962ac86a58883514e51 (patch)
tree2e83871b3d8cee1910edaf90b71e18ef7a3e2519 /include/mode.h
parent6b9d3c568d5c13353dab4aad657310a0ed933730 (diff)
Added masking stuff.
Basically, so that we can hold user modes and channel modes in the same list, we use bitwise masking. We have a list of handlers, 256 in size 0 through 255, and to work out where a mode handler is dependent on WHAT it is, we use this simple hashing algorithm (no collisions can occur): (modeletter - 65) | mask Where mask is 128 (10000000b) if its a user mode, or 0 (00000000b, duh) if its a channel mode. Smart, and much faster than using a map of pairs. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4128 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include/mode.h')
-rw-r--r--include/mode.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/include/mode.h b/include/mode.h
index f0efdf1d2..1c30d26e1 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -45,6 +45,11 @@ enum ModeAction {
MODEACTION_ALLOW = 1 /* Allow the mode */
};
+enum ModeMasks {
+ MASK_USER = 128, /* A user mode */
+ MASK_CHANNEL = 0 /* A channel mode */
+};
+
class ModeHandler
{
char mode;
@@ -93,12 +98,14 @@ class ModeParser
/**
* Mode handlers for each mode, to access a handler subtract
* 65 from the ascii value of the mode letter.
+ * The upper bit of the value indicates if its a usermode
+ * or a channel mode, so we have 255 of them not 64.
*/
- ModeHandler* modehandlers[64];
+ ModeHandler* modehandlers[256];
/**
* Mode watcher classes
*/
- std::vector<ModeWatcher*> modewatchers[64];
+ std::vector<ModeWatcher*> modewatchers[256];
char* GiveOps(userrec *user,char *dest,chanrec *chan,int status);
char* GiveHops(userrec *user,char *dest,chanrec *chan,int status);