summaryrefslogtreecommitdiff
path: root/src/modes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modes.cpp')
-rw-r--r--src/modes.cpp63
1 files changed, 21 insertions, 42 deletions
diff --git a/src/modes.cpp b/src/modes.cpp
index 5f950df57..6c46302de 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -46,9 +46,7 @@ struct StackerInfo
/* Modes to be deleted */
std::list<std::pair<Mode *, Anope::string> > DelModes;
/* Bot this is sent from */
- BotInfo *bi;
-
- StackerInfo() : bi(NULL) { }
+ BotInfo *bi = nullptr;
/** Add a mode to this object
* @param mode The mode
@@ -58,10 +56,6 @@ struct StackerInfo
void AddMode(Mode *mode, bool set, const Anope::string &param);
};
-ChannelStatus::ChannelStatus()
-{
-}
-
ChannelStatus::ChannelStatus(const Anope::string &m) : modes(m)
{
}
@@ -101,9 +95,9 @@ Anope::string ChannelStatus::BuildModePrefixList() const
{
Anope::string ret;
- for (size_t i = 0; i < modes.length(); ++i)
+ for (auto mode : modes)
{
- ChannelMode *cm = ModeManager::FindChannelModeByChar(modes[i]);
+ ChannelMode *cm = ModeManager::FindChannelModeByChar(mode);
if (cm != NULL && cm->type == MODE_STATUS)
{
ChannelModeStatus *cms = anope_dynamic_static_cast<ChannelModeStatus *>(cm);
@@ -118,10 +112,6 @@ Mode::Mode(const Anope::string &mname, ModeClass mcl, char mch, ModeType mt) : n
{
}
-Mode::~Mode()
-{
-}
-
bool Mode::CanSet(User *u) const
{
return true;
@@ -154,9 +144,9 @@ ChannelMode *ChannelMode::Wrap(Anope::string &param)
ChannelMode *ChannelMode::Unwrap(Anope::string &param)
{
- for (unsigned i = 0; i < listeners.size(); ++i)
+ for (auto *listener : listeners)
{
- ChannelMode *cm = listeners[i]->Unwrap(this, param);
+ ChannelMode *cm = listener->Unwrap(this, param);
if (cm != this)
return cm;
}
@@ -307,13 +297,13 @@ void StackerInfo::AddMode(Mode *mode, bool set, const Anope::string &param)
}
/* Add this mode and its param to our list */
- list->push_back(std::make_pair(mode, param));
+ list->emplace_back(mode, param);
}
static class ModePipe : public Pipe
{
public:
- void OnNotify()
+ void OnNotify() override
{
ModeManager::ProcessModes();
}
@@ -456,8 +446,8 @@ bool ModeManager::AddChannelMode(ChannelMode *cm)
FOREACH_MOD(OnChannelModeAdd, (cm));
- for (unsigned int i = 0; i < ChannelModes.size(); ++i)
- ChannelModes[i]->Check();
+ for (auto *cmode : ChannelModes)
+ cmode->Check();
return true;
}
@@ -600,10 +590,8 @@ static struct StatusSort
void ModeManager::RebuildStatusModes()
{
ChannelModesByStatus.clear();
- for (unsigned j = 0; j < ChannelModesIdx.size(); ++j)
+ for (auto *cm : ChannelModesIdx)
{
- ChannelMode *cm = ChannelModesIdx[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));
}
@@ -640,30 +628,22 @@ void ModeManager::ProcessModes()
{
if (!UserStackerObjects.empty())
{
- for (std::map<User *, StackerInfo *>::const_iterator it = UserStackerObjects.begin(), it_end = UserStackerObjects.end(); it != it_end; ++it)
+ for (const auto &[u, s] : UserStackerObjects)
{
- User *u = it->first;
- StackerInfo *s = it->second;
-
- std::list<Anope::string> ModeStrings = BuildModeStrings(s);
- for (std::list<Anope::string>::iterator lit = ModeStrings.begin(), lit_end = ModeStrings.end(); lit != lit_end; ++lit)
- IRCD->SendMode(s->bi, u, "%s", lit->c_str());
- delete it->second;
+ for (const auto &modestr : BuildModeStrings(s))
+ IRCD->SendMode(s->bi, u, "%s", modestr.c_str());
+ delete s;
}
UserStackerObjects.clear();
}
if (!ChannelStackerObjects.empty())
{
- for (std::map<Channel *, StackerInfo *>::const_iterator it = ChannelStackerObjects.begin(), it_end = ChannelStackerObjects.end(); it != it_end; ++it)
+ for (const auto &[c, s] : ChannelStackerObjects)
{
- Channel *c = it->first;
- StackerInfo *s = it->second;
-
- std::list<Anope::string> ModeStrings = BuildModeStrings(s);
- for (std::list<Anope::string>::iterator lit = ModeStrings.begin(), lit_end = ModeStrings.end(); lit != lit_end; ++lit)
- IRCD->SendMode(s->bi, c, "%s", lit->c_str());
- delete it->second;
+ for (const auto &modestr : BuildModeStrings(s))
+ IRCD->SendMode(s->bi, c, "%s", modestr.c_str());
+ delete s;
}
ChannelStackerObjects.clear();
}
@@ -676,9 +656,8 @@ static void StackerDel(std::map<T *, StackerInfo *> &map, T *obj)
if (it != map.end())
{
StackerInfo *si = it->second;
- std::list<Anope::string> ModeStrings = BuildModeStrings(si);
- for (std::list<Anope::string>::iterator lit = ModeStrings.begin(), lit_end = ModeStrings.end(); lit != lit_end; ++lit)
- IRCD->SendMode(si->bi, obj, "%s", lit->c_str());
+ for (const auto &modestr : BuildModeStrings(si))
+ IRCD->SendMode(si->bi, obj, "%s", modestr.c_str());
delete si;
map.erase(it);
@@ -742,7 +721,7 @@ void ModeManager::StackerDel(Mode *m)
}
}
-Entry::Entry(const Anope::string &m, const Anope::string &fh) : name(m), mask(fh), cidr_len(0), family(0)
+Entry::Entry(const Anope::string &m, const Anope::string &fh) : name(m), mask(fh)
{
Anope::string n, u, h;