aboutsummaryrefslogtreecommitdiffstats
path: root/src/mode.cpp
diff options
context:
space:
mode:
authorGravatar Daniel De Graaf2010-02-19 09:25:10 -0600
committerGravatar Daniel De Graaf2010-08-03 17:32:36 -0400
commitf9ad09a3fcb2c84b818e4ede4e6e182bd64f6139 (patch)
treef3033f3c8d01366c9a534822fdafcfccb43b00b9 /src/mode.cpp
parentAllow named modes to be disabled with <disabled:modes> (diff)
Allow digits 0-9 to be used as mode characters
Diffstat (limited to 'src/mode.cpp')
-rw-r--r--src/mode.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index 5cdc9baed..c13f4b8cb 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -701,13 +701,6 @@ void ModeParser::CleanMask(std::string &mask)
bool ModeParser::AddMode(ModeHandler* mh)
{
- /* 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 (mh->GetModeChar() && ((mh->GetModeChar() < 'A') || (mh->GetModeChar() > 'z')))
- return false;
-
/* A mode prefix of ',' is not acceptable, it would fuck up server to server.
* A mode prefix of ':' will fuck up both server to server, and client to server.
* A mode prefix of '#' will mess up /whois and /privmsg
@@ -715,18 +708,30 @@ bool ModeParser::AddMode(ModeHandler* mh)
if ((mh->GetPrefix() == ',') || (mh->GetPrefix() == ':') || (mh->GetPrefix() == '#'))
return false;
- if (FindMode(mh->name))
- return false;
-
std::string myletter = ServerInstance->Config->ConfValue("modeletters")->getString(mh->name, std::string(1,mh->GetModeChar()));
mh->AdjustModeChar(myletter.c_str()[0]);
+ // names can't be duplicated
+ if (FindMode(mh->name))
+ return false;
+
+ // prefixes can't be duplicated
if (mh->GetPrefix() && FindPrefix(mh->GetPrefix()))
return false;
+ // user modes have to be alpha (can't be null either)
+ if (mh->GetModeType() == MODETYPE_USER && !isalpha(mh->GetModeChar()))
+ return false;
+
+ // all modes have to be alphanumeric or null
+ if (mh->GetModeChar() && !isalnum(mh->GetModeChar()))
+ return false;
+
+ // mode letters can't be duplicated
if (mh->GetModeChar() && FindMode(mh->GetModeChar(), mh->GetModeType()))
return false;
+ // find a free ID, and add it
for(int id = 1; id < MODE_ID_MAX; id++)
{
if (handlers[id])
@@ -735,6 +740,7 @@ bool ModeParser::AddMode(ModeHandler* mh)
handlers[id] = mh;
return true;
}
+ // whoops, you need to increase MODE_ID_MAX
return false;
}