From e82854fb09160c1806b992fe34f022a69437882e Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 7 Jul 2006 15:40:11 +0000 Subject: 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 --- src/mode.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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'); } + -- cgit v1.2.3