summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-02-20 13:20:21 +0100
committerAttila Molnar <attilamolnar@hush.com>2014-02-20 13:20:21 +0100
commitf66d05dbda78c44b9af40e3e6f4e1a50f802d054 (patch)
treeee3b9d0ee3e574b93d284f526baac49b398d94ef /src
parent7bcb703bca4af019e94b87bc6a6b4ecb52424485 (diff)
Create a name -> ModeHandler* map
Diffstat (limited to 'src')
-rw-r--r--src/mode.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index a2a0790b8..e70df5479 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -635,6 +635,9 @@ bool ModeParser::AddMode(ModeHandler* mh)
if (slot)
return false;
+ if (!modehandlersbyname[mh->GetModeType()].insert(std::make_pair(mh->name, mh)).second)
+ return false;
+
// Everything is fine, add the mode
slot = mh;
if (pm)
@@ -651,6 +654,11 @@ bool ModeParser::DelMode(ModeHandler* mh)
if ((mh->GetModeChar() < 'A') || (mh->GetModeChar() > 'z'))
return false;
+ ModeHandlerMap& mhmap = modehandlersbyname[mh->GetModeType()];
+ ModeHandlerMap::iterator mhmapit = mhmap.find(mh->name);
+ if ((mhmapit == mhmap.end()) || (mhmapit->second != mh))
+ return false;
+
ModeHandler*& slot = modehandlers[mh->GetModeType()][mh->GetModeChar()-65];
if (slot != mh)
return false;
@@ -689,6 +697,7 @@ bool ModeParser::DelMode(ModeHandler* mh)
break;
}
+ mhmap.erase(mhmapit);
slot = NULL;
if (mh->IsPrefixMode())
mhlist.prefix.erase(std::find(mhlist.prefix.begin(), mhlist.prefix.end(), mh->IsPrefixMode()));