summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mode.h14
-rw-r--r--src/modules.cpp19
-rw-r--r--src/modules/m_namedmodes.cpp7
-rw-r--r--src/modules/m_spanningtree/fjoin.cpp8
4 files changed, 30 insertions, 18 deletions
diff --git a/include/mode.h b/include/mode.h
index d71423ecf..c257226c9 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -491,15 +491,15 @@ class CoreExport ModeParser
public:
static const ModeHandler::Id MODEID_MAX = 64;
+ /** Type of the container that maps mode names to ModeHandlers
+ */
+ typedef TR1NS::unordered_map<std::string, ModeHandler*, irc::insensitive, irc::StrHashComp> ModeHandlerMap;
+
private:
/** Last item in the ModeType enum
*/
static const unsigned int MODETYPE_LAST = 2;
- /** Type of the container that maps mode names to ModeHandlers
- */
- typedef TR1NS::unordered_map<std::string, ModeHandler*, irc::insensitive, irc::StrHashComp> ModeHandlerMap;
-
/** Mode handlers for each mode, to access a handler subtract
* 65 from the ascii value of the mode letter.
* The upper bit of the value indicates if its a usermode
@@ -733,6 +733,12 @@ class CoreExport ModeParser
* @return A list containing all prefix modes
*/
const PrefixModeList& GetPrefixModes() const { return mhlist.prefix; }
+
+ /** Get a mode name -> ModeHandler* map containing all modes of the given type
+ * @param mt Type of modes to return, MODETYPE_USER or MODETYPE_CHANNEL
+ * @return A map of mode handlers of the given type
+ */
+ const ModeHandlerMap& GetModes(ModeType mt) const { return modehandlersbyname[mt]; }
};
inline const std::string& ModeParser::GetModeListFor004Numeric()
diff --git a/src/modules.cpp b/src/modules.cpp
index cbb8661ae..88d89a35b 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -408,16 +408,23 @@ void ModuleManager::DoSafeUnload(Module* mod)
mod->OnCleanup(TYPE_USER, user);
user->doUnhookExtensions(items);
}
- for(char m='A'; m <= 'z'; m++)
+
+ const ModeParser::ModeHandlerMap& usermodes = ServerInstance->Modes->GetModes(MODETYPE_USER);
+ for (ModeParser::ModeHandlerMap::const_iterator i = usermodes.begin(); i != usermodes.end(); ++i)
{
- ModeHandler* mh;
- mh = ServerInstance->Modes->FindMode(m, MODETYPE_USER);
- if (mh && mh->creator == mod)
+ ModeHandler* mh = i->second;
+ if (mh->creator == mod)
this->DelService(*mh);
- mh = ServerInstance->Modes->FindMode(m, MODETYPE_CHANNEL);
- if (mh && mh->creator == mod)
+ }
+
+ const ModeParser::ModeHandlerMap& chanmodes = ServerInstance->Modes->GetModes(MODETYPE_CHANNEL);
+ for (ModeParser::ModeHandlerMap::const_iterator i = chanmodes.begin(); i != chanmodes.end(); ++i)
+ {
+ ModeHandler* mh = i->second;
+ if (mh->creator == mod)
this->DelService(*mh);
}
+
for(std::multimap<std::string, ServiceProvider*>::iterator i = DataProviders.begin(); i != DataProviders.end(); )
{
std::multimap<std::string, ServiceProvider*>::iterator curr = i++;
diff --git a/src/modules/m_namedmodes.cpp b/src/modules/m_namedmodes.cpp
index e8b90caa3..5c0ffeea5 100644
--- a/src/modules/m_namedmodes.cpp
+++ b/src/modules/m_namedmodes.cpp
@@ -22,11 +22,10 @@
static void DisplayList(User* user, Channel* channel)
{
std::stringstream items;
- for(char letter = 'A'; letter <= 'z'; letter++)
+ const ModeParser::ModeHandlerMap& mhs = ServerInstance->Modes->GetModes(MODETYPE_CHANNEL);
+ for (ModeParser::ModeHandlerMap::const_iterator i = mhs.begin(); i != mhs.end(); ++i)
{
- ModeHandler* mh = ServerInstance->Modes->FindMode(letter, MODETYPE_CHANNEL);
- if (!mh || mh->IsListMode())
- continue;
+ ModeHandler* mh = i->second;
if (!channel->IsModeSet(mh))
continue;
items << " +" << mh->name;
diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp
index d697af63d..ea7711332 100644
--- a/src/modules/m_spanningtree/fjoin.cpp
+++ b/src/modules/m_spanningtree/fjoin.cpp
@@ -214,16 +214,16 @@ void CommandFJoin::RemoveStatus(Channel* c)
{
irc::modestacker stack(false);
- for (char modeletter = 'A'; modeletter <= 'z'; ++modeletter)
+ const ModeParser::ModeHandlerMap& mhs = ServerInstance->Modes->GetModes(MODETYPE_CHANNEL);
+ for (ModeParser::ModeHandlerMap::const_iterator i = mhs.begin(); i != mhs.end(); ++i)
{
- ModeHandler* mh = ServerInstance->Modes->FindMode(modeletter, MODETYPE_CHANNEL);
+ ModeHandler* mh = i->second;
/* Passing a pointer to a modestacker here causes the mode to be put onto the mode stack,
* rather than applied immediately. Module unloads require this to be done immediately,
* for this function we require tidyness instead. Fixes bug #493
*/
- if (mh)
- mh->RemoveMode(c, stack);
+ mh->RemoveMode(c, stack);
}
ApplyModeStack(ServerInstance->FakeClient, c, stack);