summaryrefslogtreecommitdiff
path: root/src/modes.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-04-08 00:19:07 -0500
committerAdam <Adam@anope.org>2013-04-08 00:19:07 -0500
commit1a37e1c0480f8bd11f57dfba514069a4e9c7d8de (patch)
tree41798df9056ef555f00c4a6c0964f1219c357dc3 /src/modes.cpp
parentfb7fef7a849342ab8463743497e781c5c3e6ae88 (diff)
Made auto* chanserv privileges not hard coded.
Made cs_statusupdate not remove status on users if they still match other entries. Move privilege descriptions out of the config
Diffstat (limited to 'src/modes.cpp')
-rw-r--r--src/modes.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/modes.cpp b/src/modes.cpp
index a1ecdbfee..6cdeb6565 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -25,6 +25,9 @@ std::vector<UserMode *> ModeManager::UserModes;
static std::map<Anope::string, ChannelMode *> ChannelModesByName;
static std::map<Anope::string, UserMode *> UserModesByName;
+/* Sorted by status */
+static std::vector<ChannelModeStatus *> ChannelModesByStatus;
+
/* Number of generic modes we support */
unsigned ModeManager::GenericChannelModes = 0, ModeManager::GenericUserModes = 0;
@@ -349,6 +352,8 @@ bool ModeManager::AddChannelMode(ChannelMode *cm)
if (want >= ModeManager::ChannelModes.size())
ModeManager::ChannelModes.resize(want + 1);
ModeManager::ChannelModes[want] = cms;
+
+ RebuildStatusModes();
}
ChannelModesByName[cm->name] = cm;
@@ -406,6 +411,8 @@ void ModeManager::RemoveChannelMode(ChannelMode *cm)
return;
ModeManager::ChannelModes[want] = NULL;
+
+ RebuildStatusModes();
}
ChannelModesByName.erase(cm->name);
@@ -470,6 +477,32 @@ const std::vector<UserMode *> &ModeManager::GetUserModes()
return UserModes;
}
+const std::vector<ChannelModeStatus *> &ModeManager::GetStatusChannelModesByRank()
+{
+ return ChannelModesByStatus;
+}
+
+static struct StatusSort
+{
+ bool operator()(ChannelModeStatus *cm1, ChannelModeStatus *cm2) const
+ {
+ return cm1->level > cm2->level;
+ }
+} statuscmp;
+
+void ModeManager::RebuildStatusModes()
+{
+ ChannelModesByStatus.clear();
+ for (unsigned j = 0; j < ModeManager::GetChannelModes().size(); ++j)
+ {
+ ChannelMode *cm = ModeManager::GetChannelModes()[j];
+
+ if (cm && cm->type == MODE_STATUS && std::find(ChannelModesByStatus.begin(), ChannelModesByStatus.end(), cm) == ChannelModesByStatus.end())
+ ChannelModesByStatus.push_back(anope_dynamic_static_cast<ChannelModeStatus *>(cm));
+ }
+ std::sort(ChannelModesByStatus.begin(), ChannelModesByStatus.end(), statuscmp);
+}
+
void ModeManager::StackerAdd(const BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, const Anope::string &Param)
{
StackerInfo *s = GetInfo(ChannelStackerObjects, c);