summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-07 15:40:11 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-07 15:40:11 +0000
commite82854fb09160c1806b992fe34f022a69437882e (patch)
tree8e155d3bb28a43ebd2ed3fc275ff346feca3343c
parent2d27d1f9f4fe54f9935a53e68b320e345c2cc1b1 (diff)
Tidied up checking in ModeParser::AddMode() and added a humorous comment about modes like '^' and '_'.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4132 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/mode.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index 7575e2b0e..8125f07b3 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -669,8 +669,22 @@ void cmd_mode::Handle (char **parameters, int pcnt, userrec *user)
bool ModeParser::AddMode(ModeHandler* mh, unsigned const char modeletter)
{
unsigned char mask = 0;
+ unsigned char pos = 0;
+
+ /* Yes, i know, this might let people declare modes like '_' or '^'.
+ * If they do that, thats their problem, and if i ever EVER see an
+ * official InspIRCd developer do that, i'll beat them with a paddle!
+ */
+ if ((modeletter < 'A') || (modeletter > 'z'))
+ return false;
+
mh->GetModeType() == MODETYPE_USER ? mask = MASK_USER : mask = MASK_CHANNEL;
- modehandlers[(modeletter-65) | mask] = mh;
+ pos = (modeletter-65) | mask;
+
+ if (modehandlers[pos])
+ return false;
+
+ modehandlers[pos] = mh;
return true;
}
@@ -684,3 +698,4 @@ ModeParser::ModeParser()
this->AddMode(new ModeChannelSecret, 's');
this->AddMode(new ModeChannelPrivate, 'p');
}
+