diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-05 20:18:45 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-05 20:18:45 +0000 |
commit | a082f5a3234bc9f3225824001d8bcae9e56cf189 (patch) | |
tree | 92b2e8270b1b5ff1f4472812f28943cbb9e9d58e /src | |
parent | b4a39a0cf7f27c62cb4a262bafde405e917e2d02 (diff) |
Make builtin modes static to eliminate confusing destructor exception
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11801 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/mode.cpp | 87 |
1 files changed, 48 insertions, 39 deletions
diff --git a/src/mode.cpp b/src/mode.cpp index 069f2ea48..5bb1dab8e 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -981,58 +981,67 @@ void ModeHandler::RemoveMode(Channel* channel, irc::modestacker* stack) } } -ModeParser::ModeParser() +struct builtin_modes { - ModeHandler* modes[] = + ModeChannelSecret s; + ModeChannelPrivate p; + ModeChannelModerated m; + ModeChannelTopicOps t; + + ModeChannelNoExternal n; + ModeChannelInviteOnly i; + ModeChannelKey k; + ModeChannelLimit l; + + ModeChannelBan b; + ModeChannelOp o; + // halfop is added by configreader + ModeChannelVoice v; + + ModeUserWallops uw; + ModeUserInvisible ui; + ModeUserOperator uo; + ModeUserServerNoticeMask us; + + void init(ModeParser* modes) { - new ModeChannelSecret, - new ModeChannelPrivate, - new ModeChannelModerated, - new ModeChannelTopicOps, - - new ModeChannelNoExternal, - new ModeChannelInviteOnly, - new ModeChannelKey, - new ModeChannelLimit, - - new ModeChannelBan, - new ModeChannelOp, - new ModeChannelHalfOp, - new ModeChannelVoice, - - new ModeUserWallops, - new ModeUserInvisible, - new ModeUserOperator, - new ModeUserServerNoticeMask, -#define BUILTIN_MODE_COUNT 16 - }; + modes->AddMode(&s); + modes->AddMode(&p); + modes->AddMode(&m); + modes->AddMode(&t); + modes->AddMode(&n); + modes->AddMode(&i); + modes->AddMode(&k); + modes->AddMode(&l); + modes->AddMode(&b); + modes->AddMode(&o); + modes->AddMode(&v); + modes->AddMode(&uw); + modes->AddMode(&ui); + modes->AddMode(&uo); + modes->AddMode(&us); + } +}; +static builtin_modes static_modes; + +ModeParser::ModeParser() +{ /* Clear mode handler list */ memset(modehandlers, 0, sizeof(modehandlers)); /* Last parse string */ LastParse.clear(); - /* Initialise the RFC mode letters */ - for (int index = 0; index < BUILTIN_MODE_COUNT; index++) - this->AddMode(modes[index]); - seq = 0; memset(&sent, 0, sizeof(sent)); + + static_modes.init(this); } ModeParser::~ModeParser() { - int count = 0; - for(int i=0; i < 256; i++) - { - ModeHandler* mh = modehandlers[i]; - if (mh && mh->creator == NULL) - { - count++; - delete mh; - } - } - if (count != BUILTIN_MODE_COUNT) - throw CoreException("Mode handler found non-core modes remaining at deallocation"); + ModeHandler* mh = ServerInstance->Modes->FindMode('h', MODETYPE_CHANNEL); + if (mh) + delete mh; } |