diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-02-09 20:28:09 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-02-09 20:28:09 +0000 |
commit | 2e59ae625ecfe45b4d1d8bfb7cb7a6da701df9a3 (patch) | |
tree | b3b2ba5487dd18c33bce6ef16400cfdd38da81d2 /src/mode.cpp | |
parent | 936dbf7a8e0dd7aeacb2f32a938bd023110eb291 (diff) |
Change the constructor of ModeParser, make it just a tiny bit prettier.
Rather than calling AddMode like 25 times, put them in a nice looking array and call it in a loop, doesnt look as craqy (although its exactly the same thing with makeup on)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6555 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/mode.cpp')
-rw-r--r-- | src/mode.cpp | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/src/mode.cpp b/src/mode.cpp index a7effa642..ef3801ab6 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -967,6 +967,33 @@ void ModeHandler::RemoveMode(chanrec* channel) ModeParser::ModeParser(InspIRCd* Instance) : ServerInstance(Instance) { + struct Initializer + { + char modechar; + ModeHandler* handler; + }; + + Initializer modes[] = { + { 's', new ModeChannelSecret(Instance) }, + { 'p', new ModeChannelPrivate(Instance) }, + { 'm', new ModeChannelModerated(Instance) }, + { 't', new ModeChannelTopicOps(Instance) }, + { 'n', new ModeChannelNoExternal(Instance) }, + { 'i', new ModeChannelInviteOnly(Instance) }, + { 'k', new ModeChannelKey(Instance) }, + { 'l', new ModeChannelLimit(Instance) }, + { 'b', new ModeChannelBan(Instance) }, + { 'o', new ModeChannelOp(Instance) }, + { 'h', new ModeChannelHalfOp(Instance) }, + { 'v', new ModeChannelVoice(Instance) }, + { 's', new ModeUserServerNotice(Instance) }, + { 'w', new ModeUserWallops(Instance) }, + { 'i', new ModeUserInvisible(Instance) }, + { 'o', new ModeUserOperator(Instance) }, + { 'n', new ModeUserServerNoticeMask(Instance) }, + { 0, NULL } + }; + /* Clear mode list */ memset(modehandlers, 0, sizeof(modehandlers)); memset(modewatchers, 0, sizeof(modewatchers)); @@ -975,29 +1002,6 @@ ModeParser::ModeParser(InspIRCd* Instance) : ServerInstance(Instance) LastParse = ""; /* Initialise the RFC mode letters */ - - /* Start with channel simple modes, no params */ - this->AddMode(new ModeChannelSecret(Instance), 's'); - this->AddMode(new ModeChannelPrivate(Instance), 'p'); - this->AddMode(new ModeChannelModerated(Instance), 'm'); - this->AddMode(new ModeChannelTopicOps(Instance), 't'); - this->AddMode(new ModeChannelNoExternal(Instance), 'n'); - this->AddMode(new ModeChannelInviteOnly(Instance), 'i'); - - /* Cannel modes with params */ - this->AddMode(new ModeChannelKey(Instance), 'k'); - this->AddMode(new ModeChannelLimit(Instance), 'l'); - - /* Channel listmodes */ - this->AddMode(new ModeChannelBan(Instance), 'b'); - this->AddMode(new ModeChannelOp(Instance), 'o'); - this->AddMode(new ModeChannelHalfOp(Instance), 'h'); - this->AddMode(new ModeChannelVoice(Instance), 'v'); - - /* Now for usermodes */ - this->AddMode(new ModeUserServerNotice(Instance), 's'); - this->AddMode(new ModeUserWallops(Instance), 'w'); - this->AddMode(new ModeUserInvisible(Instance), 'i'); - this->AddMode(new ModeUserOperator(Instance), 'o'); - this->AddMode(new ModeUserServerNoticeMask(Instance), 'n'); + for (int index = 0; modes[index].modechar; index++) + this->AddMode(modes[index].handler, modes[index].modechar); } |