summaryrefslogtreecommitdiff
path: root/src/modes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modes.cpp')
-rw-r--r--src/modes.cpp51
1 files changed, 48 insertions, 3 deletions
diff --git a/src/modes.cpp b/src/modes.cpp
index 624023e66..ce34e461c 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -13,7 +13,7 @@
std::list<std::pair<void *, StackerInfo *> > ModeManager::StackerObjects;
/* List of all modes Anope knows about */
-std::list<Mode *> ModeManager::Modes;
+std::map<Anope::string, Mode *> ModeManager::Modes;
/* User modes */
std::map<char, UserMode *> ModeManager::UserModesByChar;
@@ -91,6 +91,37 @@ void SetDefaultMLock(ServerConfig *config)
}
}
+Anope::string ChannelStatus::BuildCharPrefixList() const
+{
+ Anope::string ret;
+
+ for (std::map<char, ChannelMode *>::const_iterator it = ModeManager::ChannelModesByChar.begin(), it_end = ModeManager::ChannelModesByChar.end(); it != it_end; ++it)
+ {
+ if (this->HasFlag(it->second->Name))
+ {
+ ret += it->second->ModeChar;
+ }
+ }
+
+ return ret;
+}
+
+Anope::string ChannelStatus::BuildModePrefixList() const
+{
+ Anope::string ret;
+
+ for (std::map<char, ChannelMode *>::const_iterator it = ModeManager::ChannelModesByChar.begin(), it_end = ModeManager::ChannelModesByChar.end(); it != it_end; ++it)
+ {
+ if (this->HasFlag(it->second->Name))
+ {
+ ChannelModeStatus *cm = debug_cast<ChannelModeStatus *>(it->second);
+ ret += cm->Symbol;
+ }
+ }
+
+ return ret;
+}
+
/** Default constructor
* @param mClass The type of mode this is
* @param mNameAsString The mode name as a string
@@ -607,7 +638,7 @@ bool ModeManager::AddUserMode(UserMode *um)
Alog() << "ModeManager: Added generic support for user mode " << um->ModeChar;
}
ModeManager::UserModesByName.insert(std::make_pair(um->Name, um));
- ModeManager::Modes.push_back(um);
+ ModeManager::Modes.insert(std::make_pair(um->NameAsString, um));
FOREACH_MOD(I_OnUserModeAdd, OnUserModeAdd(um));
@@ -631,7 +662,7 @@ bool ModeManager::AddChannelMode(ChannelMode *cm)
Alog() << "ModeManager: Added generic support for channel mode " << cm->ModeChar;
}
ModeManager::ChannelModesByName.insert(std::make_pair(cm->Name, cm));
- ModeManager::Modes.push_back(cm);
+ ModeManager::Modes.insert(std::make_pair(cm->NameAsString, cm));
/* Apply this mode to the new default mlock if its used */
SetDefaultMLock(Config);
@@ -671,6 +702,20 @@ UserMode *ModeManager::FindUserModeByChar(char Mode)
return NULL;
}
+/** Find a mode by name
+ * @param name The mode name
+ * @return The mode
+ */
+Mode *ModeManager::FindModeByName(const Anope::string &name)
+{
+ std::map<Anope::string, Mode *>::const_iterator it = ModeManager::Modes.find(name);
+
+ if (it != ModeManager::Modes.end())
+ return it->second;
+
+ return NULL;
+}
+
/** Find a channel mode
* @param Mode The modename
* @return The mode class