diff options
Diffstat (limited to 'modules/commands')
105 files changed, 1269 insertions, 1527 deletions
diff --git a/modules/commands/bs_assign.cpp b/modules/commands/bs_assign.cpp index edfff1c59..53d616e33 100644 --- a/modules/commands/bs_assign.cpp +++ b/modules/commands/bs_assign.cpp @@ -20,7 +20,7 @@ class CommandBSAssign : public Command this->SetSyntax(_("\037channel\037 \037nick\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &chan = params[0]; const Anope::string &nick = params[1]; @@ -71,7 +71,7 @@ class CommandBSAssign : public Command source.Reply(_("Bot \002%s\002 has been assigned to %s."), bi->nick.c_str(), ci->name.c_str()); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -91,7 +91,7 @@ class CommandBSUnassign : public Command this->SetSyntax(_("\037channel\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -132,7 +132,7 @@ class CommandBSUnassign : public Command source.Reply(_("There is no bot assigned to %s anymore."), ci->name.c_str()); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -154,7 +154,7 @@ class CommandBSSetNoBot : public Command this->SetSyntax(_("\037channel\037 {\037ON|OFF\037}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci = ChannelInfo::Find(params[0]); const Anope::string &value = params[1]; @@ -191,7 +191,7 @@ class CommandBSSetNoBot : public Command this->OnSyntaxError(source, source.command); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(_(" \n" @@ -217,7 +217,7 @@ class BSAssign : public Module { } - void OnInvite(User *source, Channel *c, User *targ) anope_override + void OnInvite(User *source, Channel *c, User *targ) override { BotInfo *bi; if (Anope::ReadOnly || !c->ci || targ->server != Me || !(bi = dynamic_cast<BotInfo *>(targ))) @@ -246,7 +246,7 @@ class BSAssign : public Module targ->SendMessage(bi, _("Bot \002%s\002 has been assigned to %s."), bi->nick.c_str(), c->name.c_str()); } - void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) anope_override + void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) override { if (nobot.HasExt(ci)) info.AddOption(_("No bot")); diff --git a/modules/commands/bs_badwords.cpp b/modules/commands/bs_badwords.cpp index 5ceba9fb3..72e8c60f3 100644 --- a/modules/commands/bs_badwords.cpp +++ b/modules/commands/bs_badwords.cpp @@ -15,9 +15,9 @@ struct BadWordImpl : BadWord, Serializable { BadWordImpl() : Serializable("BadWord") { } - ~BadWordImpl(); + ~BadWordImpl() override; - void Serialize(Serialize::Data &data) const anope_override + void Serialize(Serialize::Data &data) const override { data["ci"] << this->chan; data["word"] << this->word; @@ -35,9 +35,9 @@ struct BadWordsImpl : BadWords BadWordsImpl(Extensible *obj) : ci(anope_dynamic_static_cast<ChannelInfo *>(obj)), badwords("BadWord") { } - ~BadWordsImpl(); + ~BadWordsImpl() override; - BadWord* AddBadWord(const Anope::string &word, BadWordType type) anope_override + BadWord* AddBadWord(const Anope::string &word, BadWordType type) override { BadWordImpl *bw = new BadWordImpl(); bw->chan = ci->name; @@ -51,7 +51,7 @@ struct BadWordsImpl : BadWords return bw; } - BadWord* GetBadWord(unsigned index) const anope_override + BadWord* GetBadWord(unsigned index) const override { if (this->badwords->empty() || index >= this->badwords->size()) return NULL; @@ -61,12 +61,12 @@ struct BadWordsImpl : BadWords return bw; } - unsigned GetBadWordCount() const anope_override + unsigned GetBadWordCount() const override { return this->badwords->size(); } - void EraseBadWord(unsigned index) anope_override + void EraseBadWord(unsigned index) override { if (this->badwords->empty() || index >= this->badwords->size()) return; @@ -76,13 +76,13 @@ struct BadWordsImpl : BadWords delete this->badwords->at(index); } - void ClearBadWords() anope_override + void ClearBadWords() override { while (!this->badwords->empty()) delete this->badwords->back(); } - void Check() anope_override + void Check() override { if (this->badwords->empty()) ci->Shrink<BadWords>("badwords"); @@ -150,17 +150,17 @@ class BadwordsDelCallback : public NumberList ChannelInfo *ci; BadWords *bw; Command *c; - unsigned deleted; - bool override; + unsigned deleted = 0; + bool override = false; public: - BadwordsDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), deleted(0), override(false) + BadwordsDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c) { if (!source.AccessFor(ci).HasPriv("BADWORDS") && source.HasPriv("botserv/administration")) this->override = true; bw = ci->Require<BadWords>("badwords"); } - ~BadwordsDelCallback() + ~BadwordsDelCallback() override { if (!deleted) source.Reply(_("No matching entries on %s bad words list."), ci->name.c_str()); @@ -170,7 +170,7 @@ class BadwordsDelCallback : public NumberList source.Reply(_("Deleted %d entries from %s bad words list."), deleted, ci->name.c_str()); } - void HandleNumber(unsigned Number) anope_override + void HandleNumber(unsigned Number) override { if (!bw || !Number || Number > bw->GetBadWordCount()) return; @@ -209,7 +209,7 @@ class CommandBSBadwords : public Command { } - void HandleNumber(unsigned Number) anope_override + void HandleNumber(unsigned Number) override { if (!Number || Number > bw->GetBadWordCount()) return; @@ -251,8 +251,8 @@ class CommandBSBadwords : public Command source.Reply(_("Bad words list for %s:"), ci->name.c_str()); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); source.Reply(_("End of bad words list.")); } @@ -374,7 +374,7 @@ class CommandBSBadwords : public Command this->SetSyntax(_("\037channel\037 CLEAR")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &cmd = params[1]; const Anope::string &word = params.size() > 2 ? params[2] : ""; @@ -417,7 +417,7 @@ class CommandBSBadwords : public Command this->OnSyntaxError(source, ""); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/bs_bot.cpp b/modules/commands/bs_bot.cpp index 547dca06e..ee44437dd 100644 --- a/modules/commands/bs_bot.cpp +++ b/modules/commands/bs_bot.cpp @@ -272,7 +272,7 @@ class CommandBSBot : public Command this->SetSyntax(_("\002DEL \037nick\037\002")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &cmd = params[0]; @@ -345,7 +345,7 @@ class CommandBSBot : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/bs_botlist.cpp b/modules/commands/bs_botlist.cpp index 71d8ee3ee..b124aa2ce 100644 --- a/modules/commands/bs_botlist.cpp +++ b/modules/commands/bs_botlist.cpp @@ -19,17 +19,15 @@ class CommandBSBotList : public Command this->SetDesc(_("Lists available bots")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { unsigned count = 0; ListFormatter list(source.GetAccount()); list.AddColumn(_("Nick")).AddColumn(_("Mask")); - for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it) + for (const auto &[_, bi] : *BotListByNick) { - BotInfo *bi = it->second; - if (source.HasPriv("botserv/administration") || !bi->oper_only) { ++count; @@ -50,14 +48,14 @@ class CommandBSBotList : public Command { source.Reply(_("Bot list:")); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); source.Reply(_("%d bots available."), count); } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/bs_control.cpp b/modules/commands/bs_control.cpp index 7cbcd9d0a..8bb93327b 100644 --- a/modules/commands/bs_control.cpp +++ b/modules/commands/bs_control.cpp @@ -20,7 +20,7 @@ class CommandBSSay : public Command this->SetSyntax(_("\037channel\037 \037text\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &text = params[1]; @@ -62,7 +62,7 @@ class CommandBSSay : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to say: " << text; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -80,7 +80,7 @@ class CommandBSAct : public Command this->SetSyntax(_("\037channel\037 \037text\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { Anope::string message = params[1]; @@ -120,7 +120,7 @@ class CommandBSAct : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to say: " << message; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/bs_info.cpp b/modules/commands/bs_info.cpp index 22ae3d31b..d9b3afe1d 100644 --- a/modules/commands/bs_info.cpp +++ b/modules/commands/bs_info.cpp @@ -17,10 +17,8 @@ class CommandBSInfo : public Command void send_bot_channels(std::vector<Anope::string> &buffers, const BotInfo *bi) { Anope::string buf; - for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it) + for (const auto &[_, ci] : *RegisteredChannelList) { - const ChannelInfo *ci = it->second; - if (ci->bi == bi) { buf += " " + ci->name + " "; @@ -41,7 +39,7 @@ class CommandBSInfo : public Command this->SetSyntax(_("{\037channel\037 | \037nickname\037}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &query = params[0]; @@ -63,15 +61,15 @@ class CommandBSInfo : public Command std::vector<Anope::string> replies; info.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); if (source.HasPriv("botserv/administration")) { std::vector<Anope::string> buf; this->send_bot_channels(buf, bi); - for (unsigned i = 0; i < buf.size(); ++i) - source.Reply(buf[i]); + for (const auto &line : buf) + source.Reply(line); } } @@ -94,14 +92,14 @@ class CommandBSInfo : public Command std::vector<Anope::string> replies; info.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); } else source.Reply(_("\002%s\002 is not a valid bot or registered channel."), query.c_str()); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -113,7 +111,7 @@ class CommandBSInfo : public Command return true; } - const Anope::string GetDesc(CommandSource &source) const anope_override + const Anope::string GetDesc(CommandSource &source) const override { return Anope::printf(Language::Translate(source.GetAccount(), _("Allows you to see %s information about a channel or a bot")), source.service->nick.c_str()); } diff --git a/modules/commands/bs_kick.cpp b/modules/commands/bs_kick.cpp index eeeaf4b22..051400d16 100644 --- a/modules/commands/bs_kick.cpp +++ b/modules/commands/bs_kick.cpp @@ -20,8 +20,8 @@ struct KickerDataImpl : KickerData KickerDataImpl(Extensible *obj) { amsgs = badwords = bolds = caps = colors = flood = italics = repeat = reverses = underlines = false; - for (int16_t i = 0; i < TTB_SIZE; ++i) - ttb[i] = 0; + for (auto &ttbtype : ttb) + ttbtype = 0; capsmin = capspercent = 0; floodlines = floodsecs = 0; repeattimes = 0; @@ -29,7 +29,7 @@ struct KickerDataImpl : KickerData dontkickops = dontkickvoices = false; } - void Check(ChannelInfo *ci) anope_override + void Check(ChannelInfo *ci) override { if (amsgs || badwords || bolds || caps || colors || flood || italics || repeat || reverses || underlines || dontkickops || dontkickvoices) return; @@ -41,7 +41,7 @@ struct KickerDataImpl : KickerData { ExtensibleItem(Module *m, const Anope::string &ename) : ::ExtensibleItem<KickerDataImpl>(m, ename) { } - void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const anope_override + void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const override { if (s->GetSerializableType()->GetName() != "ChannelInfo") return; @@ -69,11 +69,11 @@ struct KickerDataImpl : KickerData data.SetType("repeattimes", Serialize::Data::DT_INT); data["repeattimes"] << kd->repeattimes; data.SetType("dontkickops", Serialize::Data::DT_INT); data["dontkickops"] << kd->dontkickops; data.SetType("dontkickvoices", Serialize::Data::DT_INT); data["dontkickvoices"] << kd->dontkickvoices; - for (int16_t i = 0; i < TTB_SIZE; ++i) - data["ttb"] << kd->ttb[i] << " "; + for (auto ttbtype : kd->ttb) + data["ttb"] << ttbtype << " "; } - void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) anope_override + void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override { if (s->GetSerializableType()->GetName() != "ChannelInfo") return; @@ -124,23 +124,20 @@ class CommandBSKick : public Command this->SetSyntax(_("\037option\037 \037channel\037 {\037ON|OFF\037} [\037settings\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->OnSyntaxError(source, ""); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); source.Reply(_("Configures bot kickers. \037option\037 can be one of:")); Anope::string this_name = source.command; - for (CommandInfo::map::const_iterator it = source.service->commands.begin(), it_end = source.service->commands.end(); it != it_end; ++it) + for (const auto &[c_name, info] : source.service->commands) { - const Anope::string &c_name = it->first; - const CommandInfo &info = it->second; - if (c_name.find_ci(this_name + " ") == 0) { ServiceReference<Command> command("Command", info.name); @@ -169,9 +166,9 @@ class CommandBSKickBase : public Command { } - virtual void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override = 0; + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override = 0; - virtual bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override = 0; + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override = 0; protected: bool CheckArguments(CommandSource &source, const std::vector<Anope::string> ¶ms, ChannelInfo* &ci) @@ -256,7 +253,7 @@ class CommandBSKickAMSG : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (CheckArguments(source, params, ci)) @@ -267,7 +264,7 @@ class CommandBSKickAMSG : public CommandBSKickBase } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -292,7 +289,7 @@ class CommandBSKickBadwords : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (CheckArguments(source, params, ci)) @@ -304,7 +301,7 @@ class CommandBSKickBadwords : public CommandBSKickBase } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -331,7 +328,7 @@ class CommandBSKickBolds : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (CheckArguments(source, params, ci)) @@ -342,7 +339,7 @@ class CommandBSKickBolds : public CommandBSKickBase } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -365,7 +362,7 @@ class CommandBSKickCaps : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037 [\037min\037 [\037percent\037]]]\002")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (!CheckArguments(source, params, ci)) @@ -433,7 +430,7 @@ class CommandBSKickCaps : public CommandBSKickBase kd->Check(ci); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -461,7 +458,7 @@ class CommandBSKickColors : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (CheckArguments(source, params, ci)) @@ -472,7 +469,7 @@ class CommandBSKickColors : public CommandBSKickBase } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -495,7 +492,7 @@ class CommandBSKickFlood : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037 [\037ln\037 [\037secs\037]]]\002")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (!CheckArguments(source, params, ci)) @@ -568,7 +565,7 @@ class CommandBSKickFlood : public CommandBSKickBase kd->Check(ci); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -593,7 +590,7 @@ class CommandBSKickItalics : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (CheckArguments(source, params, ci)) @@ -604,7 +601,7 @@ class CommandBSKickItalics : public CommandBSKickBase } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -627,7 +624,7 @@ class CommandBSKickRepeat : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037 [\037num\037]]\002")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (!CheckArguments(source, params, ci)) @@ -703,7 +700,7 @@ class CommandBSKickRepeat : public CommandBSKickBase kd->Check(ci); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -728,7 +725,7 @@ class CommandBSKickReverses : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (CheckArguments(source, params, ci)) @@ -739,7 +736,7 @@ class CommandBSKickReverses : public CommandBSKickBase } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -762,7 +759,7 @@ class CommandBSKickUnderlines : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (CheckArguments(source, params, ci)) @@ -773,7 +770,7 @@ class CommandBSKickUnderlines : public CommandBSKickBase } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -796,7 +793,7 @@ class CommandBSSetDontKickOps : public Command this->SetSyntax(_("\037channel\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) @@ -841,7 +838,7 @@ class CommandBSSetDontKickOps : public Command kd->Check(ci); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(_(" \n" @@ -861,7 +858,7 @@ class CommandBSSetDontKickVoices : public Command this->SetSyntax(_("\037channel\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) @@ -906,7 +903,7 @@ class CommandBSSetDontKickVoices : public Command kd->Check(ci); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(_(" \n" @@ -928,8 +925,8 @@ struct BanData Data() { last_use = 0; - for (int i = 0; i < TTB_SIZE; ++i) - this->ttb[i] = 0; + for (auto &ttbtype : this->ttb) + ttbtype = 0; } }; @@ -993,14 +990,12 @@ class BanDataPurger : public Timer public: BanDataPurger(Module *o) : Timer(o, 300, Anope::CurTime, true) { } - void Tick(time_t) anope_override + void Tick(time_t) override { Log(LOG_DEBUG) << "bs_main: Running bandata purger"; - for (channel_map::iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it) + for (auto &[_, c] : ChannelList) { - Channel *c = it->second; - BanData *bd = c->GetExt<BanData>("bandata"); if (bd != NULL) { @@ -1049,7 +1044,7 @@ class BSKick : public Module UserData *ud = userdata.Require(uc); return ud; - } + } void check_ban(ChannelInfo *ci, User *u, KickerData *kd, int ttbtype) { @@ -1110,7 +1105,7 @@ class BSKick : public Module } - void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) anope_override + void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) override { if (!ci) return; @@ -1225,7 +1220,7 @@ class BSKick : public Module info.AddOption(_("Voices protection")); } - void OnPrivmsg(User *u, Channel *c, Anope::string &msg) anope_override + void OnPrivmsg(User *u, Channel *c, Anope::string &msg) override { /* Now we can make kicker stuff. We try to order the checks * from the fastest one to the slowest one, since there's @@ -1308,11 +1303,11 @@ class BSKick : public Module { int i = 0, l = 0; - for (unsigned j = 0, end = realbuf.length(); j < end; ++j) + for (auto chr : realbuf) { - if (isupper(realbuf[j])) + if (isupper(chr)) ++i; - else if (islower(realbuf[j])) + else if (islower(chr)) ++l; } diff --git a/modules/commands/bs_set.cpp b/modules/commands/bs_set.cpp index 74e614075..0670b537f 100644 --- a/modules/commands/bs_set.cpp +++ b/modules/commands/bs_set.cpp @@ -20,12 +20,12 @@ class CommandBSSet : public Command this->SetSyntax(_("\037option\037 \037(channel | bot)\037 \037settings\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->OnSyntaxError(source, ""); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -35,10 +35,8 @@ class CommandBSSet : public Command bool hide_privileged_commands = Config->GetBlock("options")->Get<bool>("hideprivilegedcommands"), hide_registered_commands = Config->GetBlock("options")->Get<bool>("hideregisteredcommands"); Anope::string this_name = source.command; - for (CommandInfo::map::const_iterator it = source.service->commands.begin(), it_end = source.service->commands.end(); it != it_end; ++it) + for (const auto &[c_name, info] : source.service->commands) { - const Anope::string &c_name = it->first; - const CommandInfo &info = it->second; if (c_name.find_ci(this_name + " ") == 0) { if (info.hide) @@ -54,7 +52,7 @@ class CommandBSSet : public Command if (hide_privileged_commands && !info.permission.empty() && !source.HasCommand(info.permission)) continue; - source.command = it->first; + source.command = c_name; command->OnServHelp(source); } } @@ -77,7 +75,7 @@ class CommandBSSetBanExpire : public Command public: UnbanTimer(Module *creator, const Anope::string &ch, const Anope::string &bmask, time_t t) : Timer(creator, t), chname(ch), mask(bmask) { } - void Tick(time_t) anope_override + void Tick(time_t) override { Channel *c = Channel::Find(chname); if (c) @@ -91,7 +89,7 @@ class CommandBSSetBanExpire : public Command this->SetSyntax(_("\037channel\037 \037time\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &chan = params[0]; const Anope::string &arg = params[1]; @@ -141,7 +139,7 @@ class CommandBSSetBanExpire : public Command source.Reply(_("Bot bans will automatically expire after %s."), Anope::Duration(ci->banexpire, source.GetAccount()).c_str()); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(_(" \n" @@ -162,7 +160,7 @@ class CommandBSSetPrivate : public Command this->SetSyntax(_("\037botname\037 {\037ON|OFF\037}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { BotInfo *bi = BotInfo::Find(params[0], true); const Anope::string &value = params[1]; @@ -193,7 +191,7 @@ class CommandBSSetPrivate : public Command this->OnSyntaxError(source, source.command); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(_(" \n" @@ -216,7 +214,7 @@ class BSSet : public Module { } - void OnBotBan(User *u, ChannelInfo *ci, const Anope::string &mask) anope_override + void OnBotBan(User *u, ChannelInfo *ci, const Anope::string &mask) override { if (!ci->banexpire) return; diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index 1a6c93514..f1d132963 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -16,30 +16,30 @@ static std::map<Anope::string, int16_t, ci::less> defaultLevels; static inline void reset_levels(ChannelInfo *ci) { ci->ClearLevels(); - for (std::map<Anope::string, int16_t, ci::less>::iterator it = defaultLevels.begin(), it_end = defaultLevels.end(); it != it_end; ++it) - ci->SetLevel(it->first, it->second); + for (auto &[priv, level] : defaultLevels) + ci->SetLevel(priv, level); } class AccessChanAccess : public ChanAccess { public: - int level; + int level = 0; - AccessChanAccess(AccessProvider *p) : ChanAccess(p), level(0) + AccessChanAccess(AccessProvider *p) : ChanAccess(p) { } - bool HasPriv(const Anope::string &name) const anope_override + bool HasPriv(const Anope::string &name) const override { return this->ci->GetLevel(name) != ACCESS_INVALID && this->level >= this->ci->GetLevel(name); } - Anope::string AccessSerialize() const anope_override + Anope::string AccessSerialize() const override { return stringify(this->level); } - void AccessUnserialize(const Anope::string &data) anope_override + void AccessUnserialize(const Anope::string &data) override { try { @@ -50,7 +50,7 @@ class AccessChanAccess : public ChanAccess } } - bool operator>(const ChanAccess &other) const anope_override + bool operator>(const ChanAccess &other) const override { if (this->provider != other.provider) return ChanAccess::operator>(other); @@ -58,7 +58,7 @@ class AccessChanAccess : public ChanAccess return this->level > anope_dynamic_static_cast<const AccessChanAccess *>(&other)->level; } - bool operator<(const ChanAccess &other) const anope_override + bool operator<(const ChanAccess &other) const override { if (this->provider != other.provider) return ChanAccess::operator<(other); @@ -77,7 +77,7 @@ class AccessAccessProvider : public AccessProvider me = this; } - ChanAccess *Create() anope_override + ChanAccess *Create() override { return new AccessChanAccess(this); } @@ -214,6 +214,7 @@ class CommandCSAccess : public Command access->level = level; access->last_seen = 0; access->created = Anope::CurTime; + access->description = params.size() > 4 ? params[4] : ""; ci->AddAccess(access); FOREACH_MOD(OnAccessAdd, (ci, source, access)); @@ -250,18 +251,18 @@ class CommandCSAccess : public Command CommandSource &source; ChannelInfo *ci; Command *c; - unsigned deleted; + unsigned deleted = 0; Anope::string Nicks; - bool denied; - bool override; + bool denied = false; + bool override = false; public: - AccessDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), deleted(0), denied(false), override(false) + AccessDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c) { if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && source.HasPriv("chanserv/access/modify")) this->override = true; } - ~AccessDelCallback() + ~AccessDelCallback() override { if (denied && !deleted) source.Reply(ACCESS_DENIED); @@ -278,7 +279,7 @@ class CommandCSAccess : public Command } } - void HandleNumber(unsigned Number) anope_override + void HandleNumber(unsigned Number) override { if (!Number || Number > ci->GetAccessCount()) return; @@ -359,7 +360,7 @@ class CommandCSAccess : public Command { } - void HandleNumber(unsigned number) anope_override + void HandleNumber(unsigned number) override { if (!number || number > ci->GetAccessCount()) return; @@ -368,12 +369,14 @@ class CommandCSAccess : public Command Anope::string timebuf; if (ci->c) - for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end; ++cit) + { + for (const auto &[_, cuc] : ci->c->users) { ChannelInfo *p; - if (access->Matches(cit->second->user, cit->second->user->Account(), p)) + if (access->Matches(cuc->user, cuc->user->Account(), p)) timebuf = "Now"; } + } if (timebuf.empty()) { if (access->last_seen == 0) @@ -388,6 +391,7 @@ class CommandCSAccess : public Command entry["Mask"] = access->Mask(); entry["By"] = access->creator; entry["Last seen"] = timebuf; + entry["Description"] = access->description; this->list.AddEntry(entry); } } @@ -405,12 +409,14 @@ class CommandCSAccess : public Command Anope::string timebuf; if (ci->c) - for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end; ++cit) + { + for (auto &[_, cuc] : ci->c->users) { ChannelInfo *p; - if (access->Matches(cit->second->user, cit->second->user->Account(), p)) + if (access->Matches(cuc->user, cuc->user->Account(), p)) timebuf = "Now"; } + } if (timebuf.empty()) { if (access->last_seen == 0) @@ -425,6 +431,7 @@ class CommandCSAccess : public Command entry["Mask"] = access->Mask(); entry["By"] = access->creator; entry["Last seen"] = timebuf; + entry["Description"] = access->description; list.AddEntry(entry); } } @@ -438,8 +445,8 @@ class CommandCSAccess : public Command source.Reply(_("Access list for %s:"), ci->name.c_str()); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); source.Reply(_("End of access list")); } @@ -456,7 +463,7 @@ class CommandCSAccess : public Command } ListFormatter list(source.GetAccount()); - list.AddColumn(_("Number")).AddColumn(_("Level")).AddColumn(_("Mask")); + list.AddColumn(_("Number")).AddColumn(_("Level")).AddColumn(_("Mask")).AddColumn(_("Description")); this->ProcessList(source, ci, params, list); } @@ -469,7 +476,7 @@ class CommandCSAccess : public Command } ListFormatter list(source.GetAccount()); - list.AddColumn(_("Number")).AddColumn(_("Level")).AddColumn(_("Mask")).AddColumn(_("By")).AddColumn(_("Last seen")); + list.AddColumn(_("Number")).AddColumn(_("Level")).AddColumn(_("Mask")).AddColumn(_("By")).AddColumn(_("Last seen")).AddColumn(_("Description")); this->ProcessList(source, ci, params, list); } @@ -493,17 +500,17 @@ class CommandCSAccess : public Command } public: - CommandCSAccess(Module *creator) : Command(creator, "chanserv/access", 2, 4) + CommandCSAccess(Module *creator) : Command(creator, "chanserv/access", 2, 5) { this->SetDesc(_("Modify the list of privileged users")); - this->SetSyntax(_("\037channel\037 ADD \037mask\037 \037level\037")); + this->SetSyntax(_("\037channel\037 ADD \037mask\037 \037level\037 [\037description\037]")); this->SetSyntax(_("\037channel\037 DEL {\037mask\037 | \037entry-num\037 | \037list\037}")); this->SetSyntax(_("\037channel\037 LIST [\037mask\037 | \037list\037]")); this->SetSyntax(_("\037channel\037 VIEW [\037mask\037 | \037list\037]")); this->SetSyntax(_("\037channel\037 CLEAR")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &cmd = params[1]; const Anope::string &nick = params.size() > 2 ? params[2] : ""; @@ -561,7 +568,7 @@ class CommandCSAccess : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -698,9 +705,8 @@ class CommandCSLevels : public Command const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges(); - for (unsigned i = 0; i < privs.size(); ++i) + for (const auto &p : privs) { - const Privilege &p = privs[i]; int16_t j = ci->GetLevel(p.name); ListFormatter::ListEntry entry; @@ -719,8 +725,8 @@ class CommandCSLevels : public Command std::vector<Anope::string> replies; list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); } void DoReset(CommandSource &source, ChannelInfo *ci) @@ -745,7 +751,7 @@ class CommandCSLevels : public Command this->SetSyntax(_("\037channel\037 RESET")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &cmd = params[1]; const Anope::string &what = params.size() > 2 ? params[2] : ""; @@ -789,7 +795,7 @@ class CommandCSLevels : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { if (subcommand.equals_ci("DESC")) { @@ -798,10 +804,8 @@ class CommandCSLevels : public Command ListFormatter list(source.GetAccount()); list.AddColumn(_("Name")).AddColumn(_("Description")); - const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges(); - for (unsigned i = 0; i < privs.size(); ++i) + for (const auto &p : PrivilegeManager::GetPrivileges()) { - const Privilege &p = privs[i]; ListFormatter::ListEntry entry; entry["Name"] = p.name; entry["Description"] = Language::Translate(source.nc, p.desc.c_str()); @@ -811,8 +815,8 @@ class CommandCSLevels : public Command std::vector<Anope::string> replies; list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); } else { @@ -856,7 +860,7 @@ class CSAccess : public Module } - void OnReload(Configuration::Conf *conf) anope_override + void OnReload(Configuration::Conf *conf) override { defaultLevels.clear(); @@ -882,12 +886,12 @@ class CSAccess : public Module } } - void OnCreateChan(ChannelInfo *ci) anope_override + void OnCreateChan(ChannelInfo *ci) override { reset_levels(ci); } - EventReturn OnGroupCheckPriv(const AccessGroup *group, const Anope::string &priv) anope_override + EventReturn OnGroupCheckPriv(const AccessGroup *group, const Anope::string &priv) override { if (group->ci == NULL) return EVENT_CONTINUE; diff --git a/modules/commands/cs_akick.cpp b/modules/commands/cs_akick.cpp index 4ccf2a3b4..78215dacd 100644 --- a/modules/commands/cs_akick.cpp +++ b/modules/commands/cs_akick.cpp @@ -96,10 +96,9 @@ class CommandCSAKick : public Command /* Check excepts BEFORE we get this far */ if (ci->c) { - std::vector<Anope::string> modes = ci->c->GetModeList("EXCEPT"); - for (unsigned int i = 0; i < modes.size(); ++i) + for (const auto &mode : ci->c->GetModeList("EXCEPT")) { - if (Anope::Match(modes[i], mask)) + if (Anope::Match(mode, mask)) { source.Reply(CHAN_EXCEPTED, mask.c_str(), ci->name.c_str()); return; @@ -129,10 +128,8 @@ class CommandCSAKick : public Command { /* Match against all currently online users with equal or * higher access. - Viper */ - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) + for (const auto &[_, u2] : UserListByNick) { - User *u2 = it->second; - AccessGroup nc_access = ci->AccessFor(nc), u_access = source.AccessFor(ci); Entry entry_mask("", mask); @@ -145,9 +142,9 @@ class CommandCSAKick : public Command /* Match against the lastusermask of all nickalias's with equal * or higher access. - Viper */ - for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it) + for (const auto &[_, na2] : *NickAliasList) { - na = it->second; + na = na2; AccessGroup nc_access = ci->AccessFor(na->nc), u_access = source.AccessFor(ci); if (na->nc && (na->nc == ci->GetFounder() || nc_access >= u_access)) @@ -211,14 +208,14 @@ class CommandCSAKick : public Command CommandSource &source; ChannelInfo *ci; Command *c; - unsigned deleted; + unsigned deleted = 0; AccessGroup ag; public: - AkickDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), deleted(0), ag(source.AccessFor(ci)) + AkickDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), ag(source.AccessFor(ci)) { } - ~AkickDelCallback() + ~AkickDelCallback() override { if (!deleted) source.Reply(_("No matching entries on %s autokick list."), ci->name.c_str()); @@ -228,7 +225,7 @@ class CommandCSAKick : public Command source.Reply(_("Deleted %d entries from %s autokick list."), deleted, ci->name.c_str()); } - void HandleNumber(unsigned number) anope_override + void HandleNumber(unsigned number) override { if (!number || number > ci->GetAkickCount()) return; @@ -293,7 +290,7 @@ class CommandCSAKick : public Command { } - void HandleNumber(unsigned number) anope_override + void HandleNumber(unsigned number) override { if (!number || number > ci->GetAkickCount()) return; @@ -373,8 +370,8 @@ class CommandCSAKick : public Command source.Reply(_("Autokick list for %s:"), ci->name.c_str()); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); source.Reply(_("End of autokick list")); } @@ -440,7 +437,7 @@ class CommandCSAKick : public Command this->SetSyntax(_("\037channel\037 CLEAR")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { Anope::string chan = params[0]; Anope::string cmd = params[1]; @@ -485,7 +482,7 @@ class CommandCSAKick : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { BotInfo *bi = Config->GetClient("NickServ"); this->SendSyntax(source); @@ -538,7 +535,7 @@ class CSAKick : public Module { } - EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) anope_override + EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) override { if (!c->ci || c->MatchesList(u, "EXCEPT")) return EVENT_CONTINUE; diff --git a/modules/commands/cs_ban.cpp b/modules/commands/cs_ban.cpp index 88b0c5168..51e124948 100644 --- a/modules/commands/cs_ban.cpp +++ b/modules/commands/cs_ban.cpp @@ -23,7 +23,7 @@ class TempBan : public Timer public: TempBan(time_t seconds, Channel *c, const Anope::string &banmask, const Anope::string &mod) : Timer(me, seconds), channel(c->name), mask(banmask), mode(mod) { } - void Tick(time_t ctime) anope_override + void Tick(time_t ctime) override { Channel *c = Channel::Find(this->channel); if (c) @@ -40,7 +40,7 @@ class CommandCSBan : public Command this->SetSyntax(_("\037channel\037 [+\037expiry\037] {\037nick\037 | \037mask\037} [\037reason\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { Configuration::Block *block = Config->GetCommand(source); const Anope::string &mode = block->Get<Anope::string>("mode", "BAN"); @@ -223,7 +223,7 @@ class CommandCSBan : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/cs_clone.cpp b/modules/commands/cs_clone.cpp index 3074d13ec..c287f6a0b 100644 --- a/modules/commands/cs_clone.cpp +++ b/modules/commands/cs_clone.cpp @@ -44,6 +44,7 @@ class CommandCSClone : public Command ChanAccess *newaccess = provider->Create(); newaccess->SetMask(taccess->Mask(), target_ci); newaccess->creator = taccess->creator; + newaccess->description = taccess->description; newaccess->last_seen = taccess->last_seen; newaccess->created = taccess->created; newaccess->AccessUnserialize(taccess->AccessSerialize()); @@ -98,11 +99,9 @@ class CommandCSClone : public Command void CopyLevels(CommandSource &source, ChannelInfo *ci, ChannelInfo *target_ci) { - const Anope::map<int16_t> &cilevels = ci->GetLevelEntries(); - - for (Anope::map<int16_t>::const_iterator it = cilevels.begin(); it != cilevels.end(); ++it) + for (const auto &[priv, level] : ci->GetLevelEntries()) { - target_ci->SetLevel(it->first, it->second); + target_ci->SetLevel(priv, level); } source.Reply(_("All level entries from \002%s\002 have been cloned into \002%s\002."), ci->name.c_str(), target_ci->name.c_str()); @@ -115,7 +114,7 @@ public: this->SetSyntax(_("\037channel\037 \037target\037 [\037what\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &channel = params[0]; const Anope::string &target = params[1]; @@ -198,8 +197,8 @@ public: const Anope::string settings[] = { "NOAUTOOP", "CS_KEEP_MODES", "PEACE", "PERSIST", "RESTRICTED", "CS_SECURE", "SECUREFOUNDER", "SECUREOPS", "SIGNKICK", "SIGNKICK_LEVEL", "CS_NO_EXPIRE" }; - for (unsigned int i = 0; i < sizeof(settings) / sizeof(Anope::string); ++i) - CopySetting(ci, target_ci, settings[i]); + for (const auto &setting : settings) + CopySetting(ci, target_ci, setting); CopyAccess(source, ci, target_ci); CopyAkick(source, ci, target_ci); @@ -235,7 +234,7 @@ public: Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clone " << (what.empty() ? "everything from it" : what) << " to " << target_ci->name; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/cs_drop.cpp b/modules/commands/cs_drop.cpp index a0e3311a4..86fd3256a 100644 --- a/modules/commands/cs_drop.cpp +++ b/modules/commands/cs_drop.cpp @@ -20,7 +20,7 @@ class CommandCSDrop : public Command this->SetSyntax(_("\037channel\037 \037channel\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &chan = params[0]; @@ -66,7 +66,7 @@ class CommandCSDrop : public Command c->CheckModes(); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/cs_enforce.cpp b/modules/commands/cs_enforce.cpp index 2a8c43478..eca2d0651 100644 --- a/modules/commands/cs_enforce.cpp +++ b/modules/commands/cs_enforce.cpp @@ -29,10 +29,8 @@ class CommandCSEnforce : public Command bool hadsecureops = ci->HasExt("SECUREOPS"); ci->Extend<bool>("SECUREOPS"); - for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) + for (const auto &[_, uc] : ci->c->users) { - ChanUserContainer *uc = it->second; - ci->c->SetCorrectModes(uc->user, false); } @@ -48,9 +46,9 @@ class CommandCSEnforce : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce restricted"; std::vector<User *> users; - for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) + + for (const auto &[_, uc] : ci->c->users) { - ChanUserContainer *uc = it->second; User *user = uc->user; if (user->IsProtected()) @@ -60,10 +58,8 @@ class CommandCSEnforce : public Command users.push_back(user); } - for (unsigned i = 0; i < users.size(); ++i) + for (auto *user : users) { - User *user = users[i]; - Anope::string mask = ci->GetIdealBan(user); Anope::string reason = Language::Translate(user, _("RESTRICTED enforced by ")) + source.GetNick(); ci->c->SetMode(NULL, "BAN", mask); @@ -79,9 +75,8 @@ class CommandCSEnforce : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce registered only"; std::vector<User *> users; - for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) + for (const auto &[_, uc] : ci->c->users) { - ChanUserContainer *uc = it->second; User *user = uc->user; if (user->IsProtected()) @@ -91,10 +86,8 @@ class CommandCSEnforce : public Command users.push_back(user); } - for (unsigned i = 0; i < users.size(); ++i) + for (auto *user : users) { - User *user = users[i]; - Anope::string mask = ci->GetIdealBan(user); Anope::string reason = Language::Translate(user, _("REGONLY enforced by ")) + source.GetNick(); if (!ci->c->HasMode("REGISTEREDONLY")) @@ -111,22 +104,19 @@ class CommandCSEnforce : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce SSL only"; std::vector<User *> users; - for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) + for (auto &[_, uc] : ci->c->users) { - ChanUserContainer *uc = it->second; User *user = uc->user; if (user->IsProtected()) continue; - if (!user->HasMode("SSL") && !user->HasExt("ssl")) + if (!user->IsSecurelyConnected()) users.push_back(user); } - for (unsigned i = 0; i < users.size(); ++i) + for (auto *user : users) { - User *user = users[i]; - Anope::string mask = ci->GetIdealBan(user); Anope::string reason = Language::Translate(user, _("SSLONLY enforced by ")) + source.GetNick(); if (!ci->c->HasMode("SSL")) @@ -143,9 +133,8 @@ class CommandCSEnforce : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce bans"; std::vector<User *> users; - for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) + for (const auto &[_, uc] : ci->c->users) { - ChanUserContainer *uc = it->second; User *user = uc->user; if (user->IsProtected()) @@ -155,10 +144,8 @@ class CommandCSEnforce : public Command users.push_back(user); } - for (unsigned i = 0; i < users.size(); ++i) + for (auto *user : users) { - User *user = users[i]; - Anope::string reason = Language::Translate(user, _("BANS enforced by ")) + source.GetNick(); ci->c->Kick(NULL, user, "%s", reason.c_str()); } @@ -210,10 +197,8 @@ class CommandCSEnforce : public Command users.push_back(user); } - for (unsigned i = 0; i < users.size(); ++i) + for (auto *user : users) { - User *user = users[i]; - Anope::string reason = Language::Translate(user, _("LIMIT enforced by ")) + source.GetNick(); ci->c->Kick(NULL, user, "%s", reason.c_str()); } @@ -228,7 +213,7 @@ class CommandCSEnforce : public Command this->SetSyntax(_("\037channel\037 \037what\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &what = params.size() > 1 ? params[1] : ""; @@ -256,7 +241,7 @@ class CommandCSEnforce : public Command this->OnSyntaxError(source, ""); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/cs_entrymsg.cpp b/modules/commands/cs_entrymsg.cpp index 1817b9c44..0b6fdcbfe 100644 --- a/modules/commands/cs_entrymsg.cpp +++ b/modules/commands/cs_entrymsg.cpp @@ -26,9 +26,9 @@ struct EntryMsgImpl : EntryMsg, Serializable this->when = ct; } - ~EntryMsgImpl(); + ~EntryMsgImpl() override; - void Serialize(Serialize::Data &data) const anope_override + void Serialize(Serialize::Data &data) const override { data["ci"] << this->chan; data["creator"] << this->creator; @@ -43,7 +43,7 @@ struct EntryMessageListImpl : EntryMessageList { EntryMessageListImpl(Extensible *) { } - EntryMsg* Create() anope_override + EntryMsg* Create() override { return new EntryMsgImpl(); } @@ -128,8 +128,8 @@ class CommandEntryMessage : public Command std::vector<Anope::string> replies; list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); source.Reply(_("End of entry message list.")); } @@ -197,7 +197,7 @@ class CommandEntryMessage : public Command this->SetSyntax(_("\037channel\037 CLEAR")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) @@ -232,7 +232,7 @@ class CommandEntryMessage : public Command this->OnSyntaxError(source, ""); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -273,15 +273,15 @@ class CSEntryMessage : public Module { } - void OnJoinChannel(User *u, Channel *c) anope_override + void OnJoinChannel(User *u, Channel *c) override { if (u && c && c->ci && u->server->IsSynced()) { EntryMessageList *messages = c->ci->GetExt<EntryMessageList>("entrymsg"); if (messages != NULL) - for (unsigned i = 0; i < (*messages)->size(); ++i) - u->SendMessage(c->ci->WhoSends(), "[%s] %s", c->ci->name.c_str(), (*messages)->at(i)->message.c_str()); + for (const auto &message : *(*messages)) + u->SendMessage(c->ci->WhoSends(), "[%s] %s", c->ci->name.c_str(), message->message.c_str()); } } }; diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp index 47a18242e..54a99d7b6 100644 --- a/modules/commands/cs_flags.cpp +++ b/modules/commands/cs_flags.cpp @@ -22,7 +22,7 @@ class FlagsChanAccess : public ChanAccess { } - bool HasPriv(const Anope::string &priv) const anope_override + bool HasPriv(const Anope::string &priv) const override { std::map<Anope::string, char>::iterator it = defaultFlags.find(priv); if (it != defaultFlags.end() && this->flags.count(it->second) > 0) @@ -30,12 +30,12 @@ class FlagsChanAccess : public ChanAccess return false; } - Anope::string AccessSerialize() const anope_override + Anope::string AccessSerialize() const override { return Anope::string(this->flags.begin(), this->flags.end()); } - void AccessUnserialize(const Anope::string &data) anope_override + void AccessUnserialize(const Anope::string &data) override { for (unsigned i = data.length(); i > 0; --i) this->flags.insert(data[i - 1]); @@ -48,9 +48,9 @@ class FlagsChanAccess : public ChanAccess std::set<char> buffer; - for (std::map<Anope::string, char>::iterator it = defaultFlags.begin(), it_end = defaultFlags.end(); it != it_end; ++it) - if (access->HasPriv(it->first)) - buffer.insert(it->second); + for (auto &[priv, flag] : defaultFlags) + if (access->HasPriv(priv)) + buffer.insert(flag); if (buffer.empty()) return "(none)"; @@ -69,7 +69,7 @@ class FlagsAccessProvider : public AccessProvider ap = this; } - ChanAccess *Create() anope_override + ChanAccess *Create() override { return new FlagsChanAccess(this); } @@ -78,7 +78,7 @@ FlagsAccessProvider* FlagsAccessProvider::ap; class CommandCSFlags : public Command { - void DoModify(CommandSource &source, ChannelInfo *ci, Anope::string mask, const Anope::string &flags) + void DoModify(CommandSource &source, ChannelInfo *ci, Anope::string mask, const Anope::string &flags, const Anope::string &description) { if (flags.empty()) { @@ -189,14 +189,14 @@ class CommandCSFlags : public Command add = false; break; case '*': - for (std::map<Anope::string, char>::iterator it = defaultFlags.begin(), it_end = defaultFlags.end(); it != it_end; ++it) + for (const auto &[priv, flag] : defaultFlags) { - bool has = current_flags.count(it->second); + bool has = current_flags.count(flag); // If we are adding a flag they already have or removing one they don't have, don't bother if (add == has) continue; - if (!u_access.HasPriv(it->first) && !u_access.founder) + if (!u_access.HasPriv(priv) && !u_access.founder) { if (source.HasPriv("chanserv/access/modify")) override = true; @@ -205,9 +205,9 @@ class CommandCSFlags : public Command } if (add) - current_flags.insert(it->second); + current_flags.insert(flag); else - current_flags.erase(it->second); + current_flags.erase(flag); } break; default: @@ -218,11 +218,11 @@ class CommandCSFlags : public Command i = flags.length(); } - for (std::map<Anope::string, char>::iterator it = defaultFlags.begin(), it_end = defaultFlags.end(); it != it_end; ++it) + for (const auto &[priv, flag] : defaultFlags) { - if (f != it->second) + if (f != flag) continue; - else if (!u_access.HasPriv(it->first) && !u_access.founder) + else if (!u_access.HasPriv(priv) && !u_access.founder) { if (source.HasPriv("chanserv/access/modify")) override = true; @@ -262,7 +262,8 @@ class CommandCSFlags : public Command return; FlagsChanAccess *access = anope_dynamic_static_cast<FlagsChanAccess *>(provider->Create()); access->SetMask(mask, ci); - access->creator = source.GetNick(); + access->creator = source.GetNick(); + access->description = current ? current->description : description; access->last_seen = current ? current->last_seen : 0; access->created = Anope::CurTime; access->flags = current_flags; @@ -298,7 +299,7 @@ class CommandCSFlags : public Command ListFormatter list(source.GetAccount()); - list.AddColumn(_("Number")).AddColumn(_("Mask")).AddColumn(_("Flags")).AddColumn(_("Creator")).AddColumn(_("Created")); + list.AddColumn(_("Number")).AddColumn(_("Mask")).AddColumn(_("Flags")).AddColumn(_("Creator")).AddColumn(_("Created")).AddColumn(_("Description")); unsigned count = 0; for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i) @@ -328,6 +329,7 @@ class CommandCSFlags : public Command entry["Flags"] = flags; entry["Creator"] = access->creator; entry["Created"] = Anope::strftime(access->created, source.nc, true); + entry["Description"] = access->description; list.AddEntry(entry); } @@ -339,8 +341,8 @@ class CommandCSFlags : public Command list.Process(replies); source.Reply(_("Flags list for %s"), ci->name.c_str()); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); if (count == ci->GetAccessCount()) source.Reply(_("End of access list.")); else @@ -368,15 +370,15 @@ class CommandCSFlags : public Command } public: - CommandCSFlags(Module *creator) : Command(creator, "chanserv/flags", 1, 4) + CommandCSFlags(Module *creator) : Command(creator, "chanserv/flags", 1, 5) { this->SetDesc(_("Modify the list of privileged users")); - this->SetSyntax(_("\037channel\037 [MODIFY] \037mask\037 \037changes\037")); + this->SetSyntax(_("\037channel\037 [MODIFY] \037mask\037 \037changes\037 [\037description\037]")); this->SetSyntax(_("\037channel\037 LIST [\037mask\037 | +\037flags\037]")); this->SetSyntax(_("\037channel\037 CLEAR")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &chan = params[0]; const Anope::string &cmd = params.size() > 1 ? params[1] : ""; @@ -409,23 +411,25 @@ class CommandCSFlags : public Command this->DoClear(source, ci); else { - Anope::string mask, flags; + Anope::string mask, flags, description; if (cmd.equals_ci("MODIFY")) { mask = params.size() > 2 ? params[2] : ""; flags = params.size() > 3 ? params[3] : ""; + description = params.size() > 4 ? params[4] : ""; } else { mask = cmd; flags = params.size() > 2 ? params[2] : ""; + description = params.size() > 3 ? params[3] : ""; } - this->DoModify(source, ci, mask, flags); + this->DoModify(source, ci, mask, flags, description); } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -450,15 +454,15 @@ class CommandCSFlags : public Command typedef std::multimap<char, Anope::string, ci::less> reverse_map; reverse_map reverse; - for (std::map<Anope::string, char>::iterator it = defaultFlags.begin(), it_end = defaultFlags.end(); it != it_end; ++it) - reverse.insert(std::make_pair(it->second, it->first)); + for (auto &[priv, flag] : defaultFlags) + reverse.emplace(flag, priv); - for (reverse_map::iterator it = reverse.begin(), it_end = reverse.end(); it != it_end; ++it) + for (auto &[flag, priv] : reverse) { - Privilege *p = PrivilegeManager::FindPrivilege(it->second); + Privilege *p = PrivilegeManager::FindPrivilege(priv); if (p == NULL) continue; - source.Reply(" %c - %s", it->first, Language::Translate(source.nc, p->desc.c_str())); + source.Reply(" %c - %s", flag, Language::Translate(source.nc, p->desc.c_str())); } return true; @@ -478,7 +482,7 @@ class CSFlags : public Module } - void OnReload(Configuration::Conf *conf) anope_override + void OnReload(Configuration::Conf *conf) override { defaultFlags.clear(); diff --git a/modules/commands/cs_getkey.cpp b/modules/commands/cs_getkey.cpp index 678bf41d6..c184ecac2 100644 --- a/modules/commands/cs_getkey.cpp +++ b/modules/commands/cs_getkey.cpp @@ -20,7 +20,7 @@ class CommandCSGetKey : public Command this->SetSyntax(_("\037channel\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &chan = params[0]; @@ -50,7 +50,7 @@ class CommandCSGetKey : public Command source.Reply(_("Key for channel \002%s\002 is \002%s\002."), chan.c_str(), key.c_str()); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/cs_info.cpp b/modules/commands/cs_info.cpp index f9d565bc9..d47f9f8c1 100644 --- a/modules/commands/cs_info.cpp +++ b/modules/commands/cs_info.cpp @@ -21,7 +21,7 @@ class CommandCSInfo : public Command this->AllowUnregistered(true); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &chan = params[0]; @@ -65,11 +65,11 @@ class CommandCSInfo : public Command std::vector<Anope::string> replies; info.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/cs_invite.cpp b/modules/commands/cs_invite.cpp index d95c954a1..91c98673f 100644 --- a/modules/commands/cs_invite.cpp +++ b/modules/commands/cs_invite.cpp @@ -20,7 +20,7 @@ class CommandCSInvite : public Command this->SetSyntax(_("\037channel\037 [\037nick\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &chan = params[0]; @@ -84,7 +84,7 @@ class CommandCSInvite : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/cs_kick.cpp b/modules/commands/cs_kick.cpp index a3c84ee87..5d2bce871 100644 --- a/modules/commands/cs_kick.cpp +++ b/modules/commands/cs_kick.cpp @@ -21,7 +21,7 @@ class CommandCSKick : public Command this->SetSyntax(_("\037channel\037 \037mask\037 [\037reason\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &chan = params[0]; const Anope::string &target = params[1]; @@ -121,7 +121,7 @@ class CommandCSKick : public Command source.Reply(NICK_X_NOT_IN_USE, target.c_str()); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/cs_list.cpp b/modules/commands/cs_list.cpp index a3892090c..8323b6adb 100644 --- a/modules/commands/cs_list.cpp +++ b/modules/commands/cs_list.cpp @@ -21,7 +21,7 @@ class CommandCSList : public Command this->SetSyntax(_("\037pattern\037 [SUSPENDED] [NOEXPIRE]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { Anope::string pattern = params[0]; unsigned nchans; @@ -75,13 +75,11 @@ class CommandCSList : public Command list.AddColumn(_("Name")).AddColumn(_("Description")); Anope::map<ChannelInfo *> ordered_map; - for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it) - ordered_map[it->first] = it->second; + for (const auto &[cname, ci] : *RegisteredChannelList) + ordered_map[cname] = ci; - for (Anope::map<ChannelInfo *>::const_iterator it = ordered_map.begin(), it_end = ordered_map.end(); it != it_end; ++it) + for (const auto &[_, ci] : ordered_map) { - const ChannelInfo *ci = it->second; - if (!is_servadmin) { if (ci->HasExt("CS_PRIVATE") || ci->HasExt("CS_SUSPENDED")) @@ -124,13 +122,13 @@ class CommandCSList : public Command std::vector<Anope::string> replies; list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); source.Reply(_("End of list - %d/%d matches shown."), nchans > listmax ? listmax : nchans, nchans); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -181,7 +179,7 @@ class CommandCSSetPrivate : public Command this->SetSyntax(_("\037channel\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -225,7 +223,7 @@ class CommandCSSetPrivate : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -253,7 +251,7 @@ class CSList : public Module { } - void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) anope_override + void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) override { if (!show_all) return; diff --git a/modules/commands/cs_log.cpp b/modules/commands/cs_log.cpp index 67d08e4e6..2a6f2d0ec 100644 --- a/modules/commands/cs_log.cpp +++ b/modules/commands/cs_log.cpp @@ -18,7 +18,7 @@ struct LogSettingImpl : LogSetting, Serializable { } - ~LogSettingImpl() + ~LogSettingImpl() override { ChannelInfo *ci = ChannelInfo::Find(chan); if (ci) @@ -33,7 +33,7 @@ struct LogSettingImpl : LogSetting, Serializable } } - void Serialize(Serialize::Data &data) const anope_override + void Serialize(Serialize::Data &data) const override { data["ci"] << chan; data["service_name"] << service_name; @@ -81,7 +81,7 @@ struct LogSettingsImpl : LogSettings { LogSettingsImpl(Extensible *) { } - ~LogSettingsImpl() + ~LogSettingsImpl() override { for (iterator it = (*this)->begin(); it != (*this)->end();) { @@ -91,7 +91,7 @@ struct LogSettingsImpl : LogSettings } } - LogSetting *Create() anope_override + LogSetting *Create() override { return new LogSettingImpl(); } @@ -107,7 +107,7 @@ public: this->SetSyntax(_("\037channel\037 \037command\037 \037method\037 [\037status\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &channel = params[0]; @@ -144,8 +144,8 @@ public: std::vector<Anope::string> replies; list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); } } else if (params.size() > 2) @@ -199,12 +199,14 @@ public: return; } - for (unsigned i = 0; i < extra.length(); ++i) - if (ModeManager::GetStatusChar(extra[i]) == 0) + for (auto chr : extra) + { + if (ModeManager::GetStatusChar(chr) == 0) { - source.Reply(_("%c is an unknown status mode."), extra[i]); + source.Reply(_("%c is an unknown status mode."), chr); return; } + } bool override = !source.AccessFor(ci).HasPriv("SET"); @@ -251,7 +253,7 @@ public: this->OnSyntaxError(source, ""); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -301,7 +303,7 @@ class CSLog : public Module } - void OnReload(Configuration::Conf *conf) anope_override + void OnReload(Configuration::Conf *conf) override { Configuration::Block *block = conf->GetModule(this); defaults.clear(); @@ -320,16 +322,14 @@ class CSLog : public Module } } - void OnChanRegistered(ChannelInfo *ci) anope_override + void OnChanRegistered(ChannelInfo *ci) override { if (defaults.empty()) return; LogSettings *ls = logsettings.Require(ci); - for (unsigned i = 0; i < defaults.size(); ++i) + for (auto &d : defaults) { - LogDefault &d = defaults[i]; - LogSetting *log = new LogSettingImpl(); log->chan = ci->name; @@ -353,18 +353,17 @@ class CSLog : public Module } } - void OnLog(Log *l) anope_override + void OnLog(Log *l) override { if (l->type != LOG_COMMAND || l->u == NULL || l->c == NULL || l->ci == NULL || !Me || !Me->IsSynced()) return; LogSettings *ls = logsettings.Get(l->ci); if (ls) - for (unsigned i = 0; i < (*ls)->size(); ++i) + { + for (auto *log : *(*ls)) { - const LogSetting *log = (*ls)->at(i); - - /* wrong command */ + /* wrong command */ if (log->service_name != l->c->name) continue; @@ -393,6 +392,7 @@ class CSLog : public Module else if (log->method.equals_ci("NOTICE") && l->ci->c) IRCD->SendNotice(l->ci->WhoSends(), log->extra + l->ci->c->name, "%s", buffer.c_str()); } + } } }; diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp index 313dfe636..69e2247ba 100644 --- a/modules/commands/cs_mode.cpp +++ b/modules/commands/cs_mode.cpp @@ -18,7 +18,7 @@ struct ModeLockImpl : ModeLock, Serializable { } - ~ModeLockImpl() + ~ModeLockImpl() override { ChannelInfo *chan = ChannelInfo::Find(ci); if (chan) @@ -29,7 +29,7 @@ struct ModeLockImpl : ModeLock, Serializable } } - void Serialize(Serialize::Data &data) const anope_override; + void Serialize(Serialize::Data &data) const override; static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); }; @@ -42,26 +42,23 @@ struct ModeLocksImpl : ModeLocks { } - ~ModeLocksImpl() + ~ModeLocksImpl() override { ModeList modelist; mlocks->swap(modelist); - for (ModeList::iterator it = modelist.begin(); it != modelist.end(); ++it) + for (auto *ml : modelist) { - ModeLock *ml = *it; delete ml; } } - bool HasMLock(ChannelMode *mode, const Anope::string ¶m, bool status) const anope_override + bool HasMLock(ChannelMode *mode, const Anope::string ¶m, bool status) const override { if (!mode) return false; - for (ModeList::const_iterator it = this->mlocks->begin(); it != this->mlocks->end(); ++it) + for (auto *ml : *this->mlocks) { - const ModeLock *ml = *it; - if (ml->name == mode->name && ml->set == status && ml->param == param) return true; } @@ -69,7 +66,7 @@ struct ModeLocksImpl : ModeLocks return false; } - bool SetMLock(ChannelMode *mode, bool status, const Anope::string ¶m, Anope::string setter, time_t created = Anope::CurTime) anope_override + bool SetMLock(ChannelMode *mode, bool status, const Anope::string ¶m, Anope::string setter, time_t created = Anope::CurTime) override { if (!mode) return false; @@ -99,15 +96,13 @@ struct ModeLocksImpl : ModeLocks return true; } - bool RemoveMLock(ChannelMode *mode, bool status, const Anope::string ¶m = "") anope_override + bool RemoveMLock(ChannelMode *mode, bool status, const Anope::string ¶m = "") override { if (!mode) return false; - for (ModeList::iterator it = this->mlocks->begin(); it != this->mlocks->end(); ++it) + for (auto *m : *this->mlocks) { - ModeLock *m = *it; - if (m->name == mode->name) { // For list or status modes, we must check the parameter @@ -128,44 +123,41 @@ struct ModeLocksImpl : ModeLocks return false; } - void RemoveMLock(ModeLock *mlock) anope_override + void RemoveMLock(ModeLock *mlock) override { ModeList::iterator it = std::find(this->mlocks->begin(), this->mlocks->end(), mlock); if (it != this->mlocks->end()) this->mlocks->erase(it); } - void ClearMLock() anope_override + void ClearMLock() override { ModeList ml; this->mlocks->swap(ml); - for (unsigned i = 0; i < ml.size(); ++i) - delete ml[i]; + for (const auto *lock : ml) + delete lock; } - const ModeList &GetMLock() const anope_override + const ModeList &GetMLock() const override { return this->mlocks; } - std::list<ModeLock *> GetModeLockList(const Anope::string &name) anope_override + std::list<ModeLock *> GetModeLockList(const Anope::string &name) override { std::list<ModeLock *> mlist; - for (ModeList::const_iterator it = this->mlocks->begin(); it != this->mlocks->end(); ++it) + for (auto *m : *this->mlocks) { - ModeLock *m = *it; - if (m->name == name) + if (m->name == name) mlist.push_back(m); } return mlist; } - const ModeLock *GetMLock(const Anope::string &mname, const Anope::string ¶m = "") anope_override + const ModeLock *GetMLock(const Anope::string &mname, const Anope::string ¶m = "") override { - for (ModeList::const_iterator it = this->mlocks->begin(); it != this->mlocks->end(); ++it) + for (auto *m : *this->mlocks) { - ModeLock *m = *it; - if (m->name == mname && m->param == param) return m; } @@ -173,13 +165,12 @@ struct ModeLocksImpl : ModeLocks return NULL; } - Anope::string GetMLockAsString(bool complete) const anope_override + Anope::string GetMLockAsString(bool complete) const override { Anope::string pos = "+", neg = "-", params; - for (ModeList::const_iterator it = this->mlocks->begin(); it != this->mlocks->end(); ++it) + for (auto *ml : *this->mlocks) { - const ModeLock *ml = *it; ChannelMode *cm = ModeManager::FindChannelModeByName(ml->name); if (!cm || cm->type == MODE_LIST || cm->type == MODE_STATUS) @@ -202,7 +193,7 @@ struct ModeLocksImpl : ModeLocks return pos + neg + params; } - void Check() anope_override + void Check() override { if (this->mlocks->empty()) ci->Shrink<ModeLocks>("modelocks"); @@ -281,9 +272,8 @@ class CommandCSMode : public Command if (subcommand.equals_ci("SET")) { const ModeLocks::ModeList mlocks = modelocks->GetMLock(); - for (ModeLocks::ModeList::const_iterator it = mlocks.begin(); it != mlocks.end(); ++it) + for (auto *ml : mlocks) { - const ModeLock *ml = *it; ChannelMode *cm = ModeManager::FindChannelModeByName(ml->name); if (cm && cm->CanSet(source.GetUser())) modelocks->RemoveMLock(cm, ml->set, ml->param); @@ -299,9 +289,9 @@ class CommandCSMode : public Command int adding = 1; bool needreply = true; - for (size_t i = 0; i < modes.length(); ++i) + for (auto mode : modes) { - switch (modes[i]) + switch (mode) { case '+': adding = 1; @@ -311,15 +301,15 @@ class CommandCSMode : public Command break; default: needreply = false; - ChannelMode *cm = ModeManager::FindChannelModeByChar(modes[i]); + ChannelMode *cm = ModeManager::FindChannelModeByChar(mode); if (!cm) { - source.Reply(_("Unknown mode character %c ignored."), modes[i]); + source.Reply(_("Unknown mode character %c ignored."), mode); break; } else if (u && !cm->CanSet(u)) { - source.Reply(_("You may not (un)lock mode %c."), modes[i]); + source.Reply(_("You may not (un)lock mode %c."), mode); break; } @@ -391,9 +381,9 @@ class CommandCSMode : public Command int adding = 1; bool needreply = true; - for (size_t i = 0; i < modes.length(); ++i) + for (auto mode : modes) { - switch (modes[i]) + switch (mode) { case '+': adding = 1; @@ -403,15 +393,15 @@ class CommandCSMode : public Command break; default: needreply = false; - ChannelMode *cm = ModeManager::FindChannelModeByChar(modes[i]); + ChannelMode *cm = ModeManager::FindChannelModeByChar(mode); if (!cm) { - source.Reply(_("Unknown mode character %c ignored."), modes[i]); + source.Reply(_("Unknown mode character %c ignored."), mode); break; } else if (u && !cm->CanSet(u)) { - source.Reply(_("You may not (un)lock mode %c."), modes[i]); + source.Reply(_("You may not (un)lock mode %c."), mode); break; } @@ -448,9 +438,8 @@ class CommandCSMode : public Command ListFormatter list(source.GetAccount()); list.AddColumn(_("Mode")).AddColumn(_("Param")).AddColumn(_("Creator")).AddColumn(_("Created")); - for (ModeLocks::ModeList::const_iterator it = mlocks.begin(), it_end = mlocks.end(); it != it_end; ++it) + for (auto *ml : mlocks) { - const ModeLock *ml = *it; ChannelMode *cm = ModeManager::FindChannelModeByName(ml->name); if (!cm) continue; @@ -468,8 +457,8 @@ class CommandCSMode : public Command std::vector<Anope::string> replies; list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); } } else @@ -489,9 +478,9 @@ class CommandCSMode : public Command bool override = !source.AccessFor(ci).HasPriv("MODE") && source.HasPriv("chanserv/administration"); int adding = -1; - for (size_t i = 0; i < modes.length(); ++i) + for (auto mode : modes) { - switch (modes[i]) + switch (mode) { case '+': adding = 1; @@ -521,7 +510,7 @@ class CommandCSMode : public Command default: if (adding == -1) break; - ChannelMode *cm = ModeManager::FindChannelModeByChar(modes[i]); + ChannelMode *cm = ModeManager::FindChannelModeByChar(mode); if (!cm || (u && !cm->CanSet(u) && !can_override)) continue; switch (cm->type) @@ -665,10 +654,11 @@ class CommandCSMode : public Command } else { - std::vector<Anope::string> v = ci->c->GetModeList(cm->name); - for (unsigned j = 0; j < v.size(); ++j) - if (Anope::Match(v[j], param)) - ci->c->RemoveMode(NULL, cm, v[j]); + for (const auto &mode : ci->c->GetModeList(cm->name)) + { + if (Anope::Match(mode, param)) + ci->c->RemoveMode(NULL, cm, mode); + } } } } // switch @@ -685,8 +675,8 @@ class CommandCSMode : public Command { std::vector<Anope::string> new_params; new_params.push_back(params[0]); - new_params.push_back("SET"); - new_params.push_back("-*"); + new_params.emplace_back("SET"); + new_params.emplace_back("-*"); this->DoSet(source, ci, new_params); return; } @@ -721,9 +711,9 @@ class CommandCSMode : public Command std::vector<Anope::string> new_params; new_params.push_back(params[0]); - new_params.push_back("SET"); + new_params.emplace_back("SET"); new_params.push_back("-" + stringify(cm->mchar)); - new_params.push_back("*"); + new_params.emplace_back("*"); this->DoSet(source, ci, new_params); } @@ -736,7 +726,7 @@ class CommandCSMode : public Command this->SetSyntax(_("\037channel\037 CLEAR [\037what\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &subcommand = params[1]; @@ -766,7 +756,7 @@ class CommandCSMode : public Command this->OnSyntaxError(source, ""); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -807,7 +797,7 @@ class CommandCSModes : public Command this->SetSyntax(_("\037channel\037 [\037user\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { User *u = source.GetUser(), *targ = params.size() > 1 ? User::Find(params[1], true) : u; @@ -879,7 +869,7 @@ class CommandCSModes : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "on " << targ->nick; } - const Anope::string GetDesc(CommandSource &source) const anope_override + const Anope::string GetDesc(CommandSource &source) const override { const std::pair<bool, Anope::string> &m = modes[source.command]; if (!m.second.empty()) @@ -893,7 +883,7 @@ class CommandCSModes : public Command return ""; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { const std::pair<bool, Anope::string> &m = modes[source.command]; if (m.second.empty()) @@ -932,7 +922,7 @@ class CSMode : public Module } - void OnReload(Configuration::Conf *conf) anope_override + void OnReload(Configuration::Conf *conf) override { modes.clear(); @@ -956,17 +946,17 @@ class CSMode : public Module } } - void OnCheckModes(Reference<Channel> &c) anope_override + void OnCheckModes(Reference<Channel> &c) override { if (!c || !c->ci) return; ModeLocks *locks = modelocks.Get(c->ci); if (locks) - for (ModeLocks::ModeList::const_iterator it = locks->GetMLock().begin(), it_end = locks->GetMLock().end(); it != it_end; ++it) + { + for (auto *ml : locks->GetMLock()) { - const ModeLock *ml = *it; - ChannelMode *cm = ModeManager::FindChannelModeByName(ml->name); + ChannelMode *cm = ModeManager::FindChannelModeByName(ml->name); if (!cm) continue; @@ -1003,9 +993,10 @@ class CSMode : public Module c->RemoveMode(NULL, cm, ml->param, false); } } + } } - void OnChanRegistered(ChannelInfo *ci) anope_override + void OnChanRegistered(ChannelInfo *ci) override { ModeLocks *ml = modelocks.Require(ci); Anope::string mlock; @@ -1013,21 +1004,21 @@ class CSMode : public Module if (sep.GetToken(mlock)) { bool add = true; - for (unsigned i = 0; i < mlock.length(); ++i) + for (auto mode : mlock) { - if (mlock[i] == '+') + if (mode == '+') { add = true; continue; } - if (mlock[i] == '-') + if (mode == '-') { add = false; continue; } - ChannelMode *cm = ModeManager::FindChannelModeByChar(mlock[i]); + ChannelMode *cm = ModeManager::FindChannelModeByChar(mode); if (!cm) continue; @@ -1055,7 +1046,7 @@ class CSMode : public Module ml->Check(); } - void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) anope_override + void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) override { if (!show_hidden) return; diff --git a/modules/commands/cs_register.cpp b/modules/commands/cs_register.cpp index e69d83526..76066349e 100644 --- a/modules/commands/cs_register.cpp +++ b/modules/commands/cs_register.cpp @@ -20,7 +20,7 @@ class CommandCSRegister : public Command this->SetSyntax(_("\037channel\037 [\037description\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &chan = params[0]; const Anope::string &chdesc = params.size() > 1 ? params[1] : ""; @@ -79,7 +79,7 @@ class CommandCSRegister : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp index 84ca102dd..6bdb85bbf 100644 --- a/modules/commands/cs_seen.cpp +++ b/modules/commands/cs_seen.cpp @@ -36,14 +36,14 @@ struct SeenInfo : Serializable { } - ~SeenInfo() + ~SeenInfo() override { database_map::iterator iter = database.find(nick); if (iter != database.end() && iter->second == this) database.erase(iter); } - void Serialize(Serialize::Data &data) const anope_override + void Serialize(Serialize::Data &data) const override { data["nick"] << nick; data["vhost"] << vhost; @@ -119,20 +119,20 @@ class CommandOSSeen : public Command this->SetSyntax(_("CLEAR \037time\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (params[0].equals_ci("STATS")) { size_t mem_counter; mem_counter = sizeof(database_map); - for (database_map::iterator it = database.begin(), it_end = database.end(); it != it_end; ++it) + for (auto &[nick, si] : database) { mem_counter += (5 * sizeof(Anope::string)) + sizeof(TypeInfo) + sizeof(time_t); - mem_counter += it->first.capacity(); - mem_counter += it->second->vhost.capacity(); - mem_counter += it->second->nick2.capacity(); - mem_counter += it->second->channel.capacity(); - mem_counter += it->second->message.capacity(); + mem_counter += nick.capacity(); + mem_counter += si->vhost.capacity(); + mem_counter += si->nick2.capacity(); + mem_counter += si->channel.capacity(); + mem_counter += si->message.capacity(); } source.Reply(_("%lu nicks are stored in the database, using %.2Lf kB of memory."), database.size(), static_cast<long double>(mem_counter) / 1024); } @@ -165,7 +165,7 @@ class CommandOSSeen : public Command this->SendSyntax(source); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -222,9 +222,8 @@ class CommandSeen : public Command return; } - for (Channel::ChanUserList::const_iterator it = source.c->users.begin(), it_end = source.c->users.end(); it != it_end; ++it) + for (const auto &[_, uc] : source.c->users) { - ChanUserContainer *uc = it->second; User *u = uc->user; if (u->Account() == na->nc) @@ -236,10 +235,8 @@ class CommandSeen : public Command AccessGroup ag = source.c->ci->AccessFor(na->nc); time_t last = 0; - for (unsigned int i = 0; i < ag.paths.size(); ++i) + for (const auto &p : ag.paths) { - ChanAccess::Path &p = ag.paths[i]; - if (p.empty()) continue; @@ -263,7 +260,7 @@ class CommandSeen : public Command this->AllowUnregistered(true); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &target = params[0]; @@ -360,7 +357,7 @@ class CommandSeen : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -381,12 +378,12 @@ class CSSeen : public Module { } - void OnReload(Configuration::Conf *conf) anope_override + void OnReload(Configuration::Conf *conf) override { simple = conf->GetModule(this)->Get<bool>("simple"); } - void OnExpireTick() anope_override + void OnExpireTick() override { size_t previous_size = database.size(); time_t purgetime = Config->GetModule(this)->Get<time_t>("purgetime"); @@ -406,34 +403,34 @@ class CSSeen : public Module Log(LOG_DEBUG) << "cs_seen: Purged database, checked " << previous_size << " nicks and removed " << (previous_size - database.size()) << " old entries."; } - void OnUserConnect(User *u, bool &exempt) anope_override + void OnUserConnect(User *u, bool &exempt) override { if (!u->Quitting()) UpdateUser(u, NEW, u->nick, "", "", ""); } - void OnUserNickChange(User *u, const Anope::string &oldnick) anope_override + void OnUserNickChange(User *u, const Anope::string &oldnick) override { UpdateUser(u, NICK_TO, oldnick, u->nick, "", ""); UpdateUser(u, NICK_FROM, u->nick, oldnick, "", ""); } - void OnUserQuit(User *u, const Anope::string &msg) anope_override + void OnUserQuit(User *u, const Anope::string &msg) override { UpdateUser(u, QUIT, u->nick, "", "", msg); } - void OnJoinChannel(User *u, Channel *c) anope_override + void OnJoinChannel(User *u, Channel *c) override { UpdateUser(u, JOIN, u->nick, "", c->name, ""); } - void OnPartChannel(User *u, Channel *c, const Anope::string &channel, const Anope::string &msg) anope_override + void OnPartChannel(User *u, Channel *c, const Anope::string &channel, const Anope::string &msg) override { UpdateUser(u, PART, u->nick, "", channel, msg); } - void OnPreUserKicked(const MessageSource &source, ChanUserContainer *cu, const Anope::string &msg) anope_override + void OnPreUserKicked(const MessageSource &source, ChanUserContainer *cu, const Anope::string &msg) override { UpdateUser(cu->user, KICK, cu->user->nick, source.GetSource(), cu->chan->name, msg); } diff --git a/modules/commands/cs_set.cpp b/modules/commands/cs_set.cpp index 73fa9f4a0..0456f56b8 100644 --- a/modules/commands/cs_set.cpp +++ b/modules/commands/cs_set.cpp @@ -21,12 +21,12 @@ class CommandCSSet : public Command this->SetSyntax(_("\037option\037 \037channel\037 \037parameters\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->OnSyntaxError(source, ""); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -37,10 +37,8 @@ class CommandCSSet : public Command Anope::string this_name = source.command; bool hide_privileged_commands = Config->GetBlock("options")->Get<bool>("hideprivilegedcommands"), hide_registered_commands = Config->GetBlock("options")->Get<bool>("hideregisteredcommands"); - for (CommandInfo::map::const_iterator it = source.service->commands.begin(), it_end = source.service->commands.end(); it != it_end; ++it) + for (const auto &[c_name, info] : source.service->commands) { - const Anope::string &c_name = it->first; - const CommandInfo &info = it->second; if (c_name.find_ci(this_name + " ") == 0) { if (info.hide) @@ -56,7 +54,7 @@ class CommandCSSet : public Command else if (hide_privileged_commands && !info.permission.empty() && !source.HasCommand(info.permission)) continue; - source.command = it->first; + source.command = c_name; c->OnServHelp(source); } } @@ -75,7 +73,7 @@ class CommandCSSetAutoOp : public Command this->SetSyntax(_("\037channel\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -117,7 +115,7 @@ class CommandCSSetAutoOp : public Command this->OnSyntaxError(source, "AUTOOP"); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -134,11 +132,11 @@ class CommandCSSetBanType : public Command public: CommandCSSetBanType(Module *creator, const Anope::string &cname = "chanserv/set/bantype") : Command(creator, cname, 2, 2) { - this->SetDesc(_("Set how Services make bans on the channel")); + this->SetDesc(_("Set how services make bans on the channel")); this->SetSyntax(_("\037channel\037 \037bantype\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -179,7 +177,7 @@ class CommandCSSetBanType : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -205,7 +203,7 @@ class CommandCSSetDescription : public Command this->SetSyntax(_("\037channel\037 [\037description\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -248,7 +246,7 @@ class CommandCSSetDescription : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -267,7 +265,7 @@ class CommandCSSetFounder : public Command this->SetSyntax(_("\037channel\037 \037nick\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -317,7 +315,7 @@ class CommandCSSetFounder : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -336,7 +334,7 @@ class CommandCSSetKeepModes : public Command this->SetSyntax(_("\037channel\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -381,7 +379,7 @@ class CommandCSSetKeepModes : public Command this->OnSyntaxError(source, "KEEPMODES"); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -401,7 +399,7 @@ class CommandCSSetPeace : public Command this->SetSyntax(_("\037channel\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -445,7 +443,7 @@ class CommandCSSetPeace : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -473,7 +471,7 @@ class CommandCSSetPersist : public Command this->SetSyntax(_("\037channel\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -583,7 +581,7 @@ class CommandCSSetPersist : public Command this->OnSyntaxError(source, "PERSIST"); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { BotInfo *BotServ = Config->GetClient("BotServ"); BotInfo *ChanServ = Config->GetClient("ChanServ"); @@ -622,7 +620,7 @@ class CommandCSSetRestricted : public Command this->SetSyntax(_("\037channel\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -664,7 +662,7 @@ class CommandCSSetRestricted : public Command this->OnSyntaxError(source, "RESTRICTED"); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -684,7 +682,7 @@ class CommandCSSetSecure : public Command this->SetSyntax(_("\037channel\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -726,7 +724,7 @@ class CommandCSSetSecure : public Command this->OnSyntaxError(source, "SECURE"); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -747,7 +745,7 @@ class CommandCSSetSecureFounder : public Command this->SetSyntax(_("\037channel\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -789,7 +787,7 @@ class CommandCSSetSecureFounder : public Command this->OnSyntaxError(source, "SECUREFOUNDER"); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -811,7 +809,7 @@ class CommandCSSetSecureOps : public Command this->SetSyntax(_("\037channel\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -853,7 +851,7 @@ class CommandCSSetSecureOps : public Command this->OnSyntaxError(source, "SECUREOPS"); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -873,7 +871,7 @@ class CommandCSSetSignKick : public Command this->SetSyntax(_("\037channel\037 {ON | LEVEL | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -925,7 +923,7 @@ class CommandCSSetSignKick : public Command this->OnSyntaxError(source, "SIGNKICK"); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -950,7 +948,7 @@ class CommandCSSetSuccessor : public Command this->SetSyntax(_("\037channel\037 [\037nick\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -1010,7 +1008,7 @@ class CommandCSSetSuccessor : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -1044,7 +1042,7 @@ class CommandCSSetNoexpire : public Command this->SetSyntax(_("\037channel\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -1083,7 +1081,7 @@ class CommandCSSetNoexpire : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -1103,7 +1101,7 @@ class CSSet : public Module { KeepModes(Module *m, const Anope::string &n) : SerializableExtensibleItem<bool>(m, n) { } - void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const anope_override + void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const override { SerializableExtensibleItem<bool>::ExtensibleSerialize(e, s, data); @@ -1112,18 +1110,18 @@ class CSSet : public Module const ChannelInfo *ci = anope_dynamic_static_cast<const ChannelInfo *>(s); Anope::string modes; - for (Channel::ModeList::const_iterator it = ci->last_modes.begin(); it != ci->last_modes.end(); ++it) + for (const auto &[last_mode, last_value] : ci->last_modes) { if (!modes.empty()) modes += " "; - modes += it->first; - if (!it->second.empty()) - modes += "," + it->second; + modes += last_mode; + if (!last_value.empty()) + modes += "," + last_value; } data["last_modes"] << modes; } - void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) anope_override + void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override { SerializableExtensibleItem<bool>::ExtensibleUnserialize(e, s, data); @@ -1138,9 +1136,9 @@ class CSSet : public Module { size_t c = modes.find(','); if (c == Anope::string::npos) - ci->last_modes.insert(std::make_pair(modes, "")); + ci->last_modes.emplace(modes, ""); else - ci->last_modes.insert(std::make_pair(modes.substr(0, c), modes.substr(c + 1))); + ci->last_modes.emplace(modes.substr(0, c), modes.substr(c + 1)); } } } keep_modes; @@ -1184,27 +1182,27 @@ class CSSet : public Module { } - void OnReload(Configuration::Conf *conf) anope_override + void OnReload(Configuration::Conf *conf) override { persist_lower_ts = conf->GetModule(this)->Get<bool>("persist_lower_ts"); } - void OnCreateChan(ChannelInfo *ci) anope_override + void OnCreateChan(ChannelInfo *ci) override { ci->bantype = Config->GetModule(this)->Get<int>("defbantype", "2"); } - void OnChannelSync(Channel *c) anope_override + void OnChannelSync(Channel *c) override { if (c->ci && keep_modes.HasExt(c->ci)) { Channel::ModeList ml = c->ci->last_modes; - for (Channel::ModeList::iterator it = ml.begin(); it != ml.end(); ++it) - c->SetMode(c->ci->WhoSends(), it->first, it->second); + for (const auto &[last_mode, last_value] : c->ci->last_modes) + c->SetMode(c->ci->WhoSends(), last_mode, last_value); } } - EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) anope_override + EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) override { if (!c->ci || !restricted.HasExt(c->ci) || c->MatchesList(u, "EXCEPT")) return EVENT_CONTINUE; @@ -1215,14 +1213,14 @@ class CSSet : public Module return EVENT_CONTINUE; } - void OnDelChan(ChannelInfo *ci) anope_override + void OnDelChan(ChannelInfo *ci) override { if (ci->c && persist.HasExt(ci)) ci->c->RemoveMode(ci->WhoSends(), "PERM", "", false); persist.Unset(ci); } - EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string ¶m) anope_override + EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string ¶m) override { if (c->ci) { @@ -1237,7 +1235,7 @@ class CSSet : public Module return EVENT_CONTINUE; } - EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string ¶m) anope_override + EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string ¶m) override { if (mode->name == "PERM") { @@ -1251,7 +1249,7 @@ class CSSet : public Module return EVENT_CONTINUE; } - void OnJoinChannel(User *u, Channel *c) anope_override + void OnJoinChannel(User *u, Channel *c) override { if (u->server != Me && persist_lower_ts && c->ci && persist.HasExt(c->ci) && c->creation_time > c->ci->time_registered) { @@ -1262,7 +1260,7 @@ class CSSet : public Module } } - void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) anope_override + void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) override { if (chan->ci) { @@ -1274,13 +1272,13 @@ class CSSet : public Module } } - void OnPreChanExpire(ChannelInfo *ci, bool &expire) anope_override + void OnPreChanExpire(ChannelInfo *ci, bool &expire) override { if (noexpire.HasExt(ci)) expire = false; } - void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) anope_override + void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) override { if (!show_all) return; diff --git a/modules/commands/cs_set_misc.cpp b/modules/commands/cs_set_misc.cpp index 9c75f72e2..86233c97a 100644 --- a/modules/commands/cs_set_misc.cpp +++ b/modules/commands/cs_set_misc.cpp @@ -42,7 +42,7 @@ struct CSMiscData : MiscData, Serializable data = d; } - void Serialize(Serialize::Data &sdata) const anope_override + void Serialize(Serialize::Data &sdata) const override { sdata["ci"] << this->object; sdata["name"] << this->name; @@ -96,7 +96,7 @@ class CommandCSSetMisc : public Command this->SetSyntax(_("\037channel\037 [\037parameters\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -143,7 +143,7 @@ class CommandCSSetMisc : public Command } } - void OnServHelp(CommandSource &source) anope_override + void OnServHelp(CommandSource &source) override { if (descriptions.count(source.command)) { @@ -152,7 +152,7 @@ class CommandCSSetMisc : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { if (descriptions.count(source.command)) { @@ -176,13 +176,13 @@ class CSSetMisc : public Module me = this; } - ~CSSetMisc() + ~CSSetMisc() override { - for (Anope::map<ExtensibleItem<CSMiscData> *>::iterator it = items.begin(); it != items.end(); ++it) - delete it->second; + for (const auto &[_, item] : items) + delete item; } - void OnReload(Configuration::Conf *conf) anope_override + void OnReload(Configuration::Conf *conf) override { descriptions.clear(); @@ -203,11 +203,10 @@ class CSSetMisc : public Module } } - void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool) anope_override + void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool) override { - for (Anope::map<ExtensibleItem<CSMiscData> *>::iterator it = items.begin(); it != items.end(); ++it) + for (const auto &[_, e] : items) { - ExtensibleItem<CSMiscData> *e = it->second; MiscData *data = e->Get(ci); if (data != NULL) diff --git a/modules/commands/cs_status.cpp b/modules/commands/cs_status.cpp index 7404cce5d..9d5f856f8 100644 --- a/modules/commands/cs_status.cpp +++ b/modules/commands/cs_status.cpp @@ -20,7 +20,7 @@ public: this->SetSyntax(_("\037channel\037 [\037user\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &channel = params[0]; @@ -57,11 +57,9 @@ public: { source.Reply(_("Access for \002%s\002 on \002%s\002:"), nick.c_str(), ci->name.c_str()); - for (unsigned i = 0; i < ag.paths.size(); ++i) + for (const auto &p : ag.paths) { - ChanAccess::Path &p = ag.paths[i]; - - if (p.empty()) + if (p.empty()) continue; if (p.size() == 1) @@ -99,7 +97,7 @@ public: } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp index 839fe74de..ca8dfce56 100644 --- a/modules/commands/cs_suspend.cpp +++ b/modules/commands/cs_suspend.cpp @@ -16,7 +16,7 @@ struct CSSuspendInfo : SuspendInfo, Serializable { CSSuspendInfo(Extensible *) : Serializable("CSSuspendInfo") { } - void Serialize(Serialize::Data &data) const anope_override + void Serialize(Serialize::Data &data) const override { data["chan"] << what; data["by"] << by; @@ -59,7 +59,7 @@ class CommandCSSuspend : public Command this->SetSyntax(_("\037channel\037 [+\037expiry\037] [\037reason\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &chan = params[0]; Anope::string expiry = params[1]; @@ -109,16 +109,15 @@ class CommandCSSuspend : public Command { std::vector<User *> users; - for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) + for (const auto &[_, uc] : ci->c->users) { - ChanUserContainer *uc = it->second; User *user = uc->user; if (!user->HasMode("OPER") && user->server != Me) users.push_back(user); } - for (unsigned i = 0; i < users.size(); ++i) - ci->c->Kick(NULL, users[i], "%s", !reason.empty() ? reason.c_str() : Language::Translate(users[i], _("This channel has been suspended."))); + for (auto *user : users) + ci->c->Kick(NULL, user, "%s", !reason.empty() ? reason.c_str() : Language::Translate(user, _("This channel has been suspended."))); } Log(LOG_ADMIN, source, this, ci) << "(" << (!reason.empty() ? reason : "No reason") << "), expires on " << (expiry_secs ? Anope::strftime(Anope::CurTime + expiry_secs) : "never"); @@ -127,7 +126,7 @@ class CommandCSSuspend : public Command FOREACH_MOD(OnChanSuspend, (ci)); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -152,7 +151,7 @@ class CommandCSUnSuspend : public Command this->SetSyntax(_("\037channel\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) @@ -184,7 +183,7 @@ class CommandCSUnSuspend : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -222,7 +221,7 @@ class CSSuspend : public Module { } - void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) anope_override + void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) override { CSSuspendInfo *si = suspend.Get(ci); if (!si) @@ -240,7 +239,7 @@ class CSSuspend : public Module info[_("Suspension expires")] = Anope::strftime(si->expires, source.GetAccount()); } - void OnPreChanExpire(ChannelInfo *ci, bool &expire) anope_override + void OnPreChanExpire(ChannelInfo *ci, bool &expire) override { CSSuspendInfo *si = suspend.Get(ci); if (!si) @@ -260,7 +259,7 @@ class CSSuspend : public Module } } - EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) anope_override + EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) override { if (u->HasMode("OPER") || !c->ci || !suspend.HasExt(c->ci)) return EVENT_CONTINUE; @@ -269,7 +268,7 @@ class CSSuspend : public Module return EVENT_STOP; } - EventReturn OnChanDrop(CommandSource &source, ChannelInfo *ci) anope_override + EventReturn OnChanDrop(CommandSource &source, ChannelInfo *ci) override { CSSuspendInfo *si = suspend.Get(ci); if (si && !source.HasCommand("chanserv/drop")) diff --git a/modules/commands/cs_sync.cpp b/modules/commands/cs_sync.cpp index af76c47f7..2610f521c 100644 --- a/modules/commands/cs_sync.cpp +++ b/modules/commands/cs_sync.cpp @@ -20,7 +20,7 @@ class CommandCSSync : public Command this->SetSyntax(_("\037channel\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci = ChannelInfo::Find(params[0]); @@ -35,14 +35,14 @@ class CommandCSSync : public Command bool override = !source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && source.HasPriv("chanserv/administration"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci); - for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) - ci->c->SetCorrectModes(it->second->user, true); + for (const auto &[_, uc] : ci->c->users) + ci->c->SetCorrectModes(uc->user, true); source.Reply(_("All user modes on \002%s\002 have been synced."), ci->name.c_str()); } } - bool OnHelp(CommandSource &source, const Anope::string ¶ms) anope_override + bool OnHelp(CommandSource &source, const Anope::string ¶ms) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/cs_topic.cpp b/modules/commands/cs_topic.cpp index 28c821104..7e71020a1 100644 --- a/modules/commands/cs_topic.cpp +++ b/modules/commands/cs_topic.cpp @@ -21,7 +21,7 @@ class CommandCSSetKeepTopic : public Command this->SetSyntax(_("\037channel\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -63,7 +63,7 @@ class CommandCSSetKeepTopic : public Command this->OnSyntaxError(source, "KEEPTOPIC"); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -152,7 +152,7 @@ class CommandCSTopic : public Command this->SetSyntax(_("\037channel\037 [UNLOCK|LOCK]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &subcmd = params[1]; @@ -186,7 +186,7 @@ class CommandCSTopic : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -216,7 +216,7 @@ class CSTopic : public Module } - void OnChannelSync(Channel *c) anope_override + void OnChannelSync(Channel *c) override { if (c->ci) { @@ -228,7 +228,7 @@ class CSTopic : public Module } } - void OnTopicUpdated(User *source, Channel *c, const Anope::string &user, const Anope::string &topic) anope_override + void OnTopicUpdated(User *source, Channel *c, const Anope::string &user, const Anope::string &topic) override { if (!c->ci) return; @@ -250,7 +250,7 @@ class CSTopic : public Module } } - void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) anope_override + void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) override { if (keeptopic.HasExt(ci)) info.AddOption(_("Topic retention")); diff --git a/modules/commands/cs_unban.cpp b/modules/commands/cs_unban.cpp index 177a1a101..fec777cc0 100644 --- a/modules/commands/cs_unban.cpp +++ b/modules/commands/cs_unban.cpp @@ -20,7 +20,7 @@ class CommandCSUnban : public Command this->SetSyntax(_("\037channel\037 [\037nick\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelMode *cm = ModeManager::FindChannelModeByName("BAN"); if (!cm) @@ -38,17 +38,15 @@ class CommandCSUnban : public Command source.GetAccount()->GetChannelReferences(queue); unsigned count = 0; - for (unsigned i = 0; i < queue.size(); ++i) + for (auto *ci : queue) { - ChannelInfo *ci = queue[i]; - if (!ci->c || !source.AccessFor(ci).HasPriv("UNBAN")) continue; - + FOREACH_MOD(OnChannelUnban, (source.GetUser(), ci)); - for (unsigned j = 0; j < modes.size(); ++j) - if (ci->c->Unban(source.GetUser(), modes[j]->name, true)) + for (const auto *mode : modes) + if (ci->c->Unban(source.GetUser(), mode->name, true)) ++count; } @@ -92,15 +90,15 @@ class CommandCSUnban : public Command FOREACH_MOD(OnChannelUnban, (u2, ci)); - for (unsigned i = 0; i < modes.size(); ++i) - ci->c->Unban(u2, modes[i]->name, source.GetUser() == u2); + for (const auto *mode : modes) + ci->c->Unban(u2, mode->name, source.GetUser() == u2); if (u2 == source.GetUser()) source.Reply(_("You have been unbanned from \002%s\002."), ci->c->name.c_str()); else source.Reply(_("\002%s\002 has been unbanned from \002%s\002."), u2->nick.c_str(), ci->c->name.c_str()); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/cs_updown.cpp b/modules/commands/cs_updown.cpp index 5ebc3e8cc..59bd19660 100644 --- a/modules/commands/cs_updown.cpp +++ b/modules/commands/cs_updown.cpp @@ -24,9 +24,8 @@ class CommandCSUp : public Command bool given = false; AccessGroup u_access = c->ci->AccessFor(u); - for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i) + for (auto *cm : ModeManager::GetStatusChannelModesByRank()) { - ChannelModeStatus *cm = ModeManager::GetStatusChannelModesByRank()[i]; bool has_priv = u_access.HasPriv("AUTO" + cm->name) || u_access.HasPriv(cm->name); if (has_priv) @@ -49,7 +48,7 @@ class CommandCSUp : public Command this->SetSyntax(_("[\037channel\037 [\037nick\037]]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (params.empty()) { @@ -119,7 +118,7 @@ class CommandCSUp : public Command } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -147,7 +146,7 @@ class CommandCSDown : public Command this->SetSyntax(_("[\037channel\037 [\037nick\037]]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (params.empty()) { @@ -216,7 +215,7 @@ class CommandCSDown : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/cs_xop.cpp b/modules/commands/cs_xop.cpp index 33b2f564e..5bd9de696 100644 --- a/modules/commands/cs_xop.cpp +++ b/modules/commands/cs_xop.cpp @@ -26,7 +26,7 @@ class XOPChanAccess : public ChanAccess { } - bool HasPriv(const Anope::string &priv) const anope_override + bool HasPriv(const Anope::string &priv) const override { for (std::vector<Anope::string>::iterator it = std::find(order.begin(), order.end(), this->type); it != order.end(); ++it) { @@ -37,12 +37,12 @@ class XOPChanAccess : public ChanAccess return false; } - Anope::string AccessSerialize() const anope_override + Anope::string AccessSerialize() const override { return this->type; } - void AccessUnserialize(const Anope::string &data) anope_override + void AccessUnserialize(const Anope::string &data) override { this->type = data; } @@ -58,25 +58,28 @@ class XOPChanAccess : public ChanAccess { std::map<Anope::string, int> count; - for (std::map<Anope::string, std::vector<Anope::string> >::const_iterator it = permissions.begin(), it_end = permissions.end(); it != it_end; ++it) + for (const auto &[name, perms] : permissions) { - int &c = count[it->first]; - const std::vector<Anope::string> &perms = it->second; - for (unsigned i = 0; i < perms.size(); ++i) - if (access->HasPriv(perms[i])) + int &c = count[name]; + for (const auto &perm : perms) + { + if (access->HasPriv(perm)) ++c; + } } - Anope::string max; - int maxn = 0; - for (std::map<Anope::string, int>::iterator it = count.begin(), it_end = count.end(); it != it_end; ++it) - if (it->second > maxn) + Anope::string maxname; + int maxpriv = 0; + for (const auto &[name, priv] : count) + { + if (priv > maxpriv) { - maxn = it->second; - max = it->first; + maxname = name; + maxpriv = priv; } + } - return max; + return maxname; } } }; @@ -88,7 +91,7 @@ class XOPAccessProvider : public AccessProvider { } - ChanAccess *Create() anope_override + ChanAccess *Create() override { return new XOPChanAccess(this); } @@ -100,6 +103,7 @@ class CommandCSXOP : public Command void DoAdd(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { Anope::string mask = params.size() > 2 ? params[2] : ""; + Anope::string description = params.size() > 3 ? params[3] : ""; if (mask.empty()) { @@ -208,6 +212,7 @@ class CommandCSXOP : public Command XOPChanAccess *acc = anope_dynamic_static_cast<XOPChanAccess *>(provider->Create()); acc->SetMask(mask, ci); acc->creator = source.GetNick(); + acc->description = description; acc->type = source.command.upper(); acc->last_seen = 0; acc->created = Anope::CurTime; @@ -280,15 +285,15 @@ class CommandCSXOP : public Command CommandSource &source; ChannelInfo *ci; Command *c; - unsigned deleted; + unsigned deleted = 0; Anope::string nicks; bool override; public: - XOPDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, bool _override, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), deleted(0), override(_override) + XOPDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, bool _override, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), override(_override) { } - ~XOPDelCallback() + ~XOPDelCallback() override { if (!deleted) source.Reply(_("No matching entries on %s %s list."), ci->name.c_str(), source.command.c_str()); @@ -303,7 +308,7 @@ class CommandCSXOP : public Command } } - void HandleNumber(unsigned number) anope_override + void HandleNumber(unsigned number) override { if (!number || number > ci->GetAccessCount()) return; @@ -374,7 +379,7 @@ class CommandCSXOP : public Command } ListFormatter list(source.GetAccount()); - list.AddColumn(_("Number")).AddColumn(_("Mask")); + list.AddColumn(_("Number")).AddColumn(_("Mask")).AddColumn(_("Description")); if (!nick.empty() && nick.find_first_not_of("1234567890,-") == Anope::string::npos) { @@ -388,7 +393,7 @@ class CommandCSXOP : public Command { } - void HandleNumber(unsigned Number) anope_override + void HandleNumber(unsigned Number) override { if (!Number || Number > ci->GetAccessCount()) return; @@ -401,6 +406,7 @@ class CommandCSXOP : public Command ListFormatter::ListEntry entry; entry["Number"] = stringify(Number); entry["Mask"] = a->Mask(); + entry["Description"] = a->description; this->list.AddEntry(entry); } } nl_list(list, ci, nick, source); @@ -420,6 +426,7 @@ class CommandCSXOP : public Command ListFormatter::ListEntry entry; entry["Number"] = stringify(i + 1); entry["Mask"] = a->Mask(); + entry["Description"] = a->description; list.AddEntry(entry); } } @@ -432,8 +439,8 @@ class CommandCSXOP : public Command list.Process(replies); source.Reply(_("%s list for %s"), source.command.c_str(), ci->name.c_str()); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); } } @@ -478,18 +485,18 @@ class CommandCSXOP : public Command public: CommandCSXOP(Module *modname) : Command(modname, "chanserv/xop", 2, 4) { - this->SetSyntax(_("\037channel\037 ADD \037mask\037")); + this->SetSyntax(_("\037channel\037 ADD \037mask\037 [\037description\037]")); this->SetSyntax(_("\037channel\037 DEL {\037mask\037 | \037entry-num\037 | \037list\037}")); this->SetSyntax(_("\037channel\037 LIST [\037mask\037 | \037list\037]")); this->SetSyntax(_("\037channel\037 CLEAR")); } - const Anope::string GetDesc(CommandSource &source) const anope_override + const Anope::string GetDesc(CommandSource &source) const override { return Anope::printf(Language::Translate(source.GetAccount(), _("Modify the list of %s users")), source.command.upper().c_str()); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) @@ -513,7 +520,7 @@ class CommandCSXOP : public Command } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { const Anope::string &cmd = source.command.upper(); @@ -524,9 +531,9 @@ class CommandCSXOP : public Command " "), cmd.c_str(), cmd.c_str()); Anope::string buf; - for (unsigned i = 0; i < permissions[cmd].size(); ++i) + for (const auto &permission : permissions[cmd]) { - buf += ", " + permissions[cmd][i]; + buf += ", " + permission; if (buf.length() > 75) { source.Reply(" %s\n", buf.substr(2).c_str()); @@ -590,7 +597,7 @@ class CSXOP : public Module } - void OnReload(Configuration::Conf *conf) anope_override + void OnReload(Configuration::Conf *conf) override { order.clear(); permissions.clear(); diff --git a/modules/commands/gl_global.cpp b/modules/commands/gl_global.cpp index 07d3c111a..072b786dc 100644 --- a/modules/commands/gl_global.cpp +++ b/modules/commands/gl_global.cpp @@ -22,7 +22,7 @@ class CommandGLGlobal : public Command this->SetSyntax(_("\037message\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &msg = params[0]; @@ -35,7 +35,7 @@ class CommandGLGlobal : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { Reference<BotInfo> sender; if (GService) diff --git a/modules/commands/greet.cpp b/modules/commands/greet.cpp index 864c8d3dc..0ebad1864 100644 --- a/modules/commands/greet.cpp +++ b/modules/commands/greet.cpp @@ -20,7 +20,7 @@ class CommandBSSetGreet : public Command this->SetSyntax(_("\037channel\037 {\037ON|OFF\037}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci = ChannelInfo::Find(params[0]); const Anope::string &value = params[1]; @@ -63,7 +63,7 @@ class CommandBSSetGreet : public Command this->OnSyntaxError(source, source.command); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(_(" \n" @@ -119,12 +119,12 @@ class CommandNSSetGreet : public Command } } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, source.nc->display, params.size() > 0 ? params[0] : ""); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -145,12 +145,12 @@ class CommandNSSASetGreet : public CommandNSSetGreet this->SetSyntax(_("\037nickname\037 \037message\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, params[0], params.size() > 1 ? params[1] : ""); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -182,7 +182,7 @@ class Greet : public Module { } - void OnJoinChannel(User *user, Channel *c) anope_override + void OnJoinChannel(User *user, Channel *c) override { /* Only display the greet if the main uplink we're connected * to has synced, or we'll get greet-floods when the net @@ -199,14 +199,14 @@ class Greet : public Module } } - void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) anope_override + void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) override { Anope::string *greet = ns_greet.Get(na->nc); if (greet != NULL) info[_("Greet")] = *greet; } - void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) anope_override + void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) override { if (bs_greet.HasExt(ci)) info.AddOption(_("Greet")); diff --git a/modules/commands/help.cpp b/modules/commands/help.cpp index f4271620d..071161fcd 100644 --- a/modules/commands/help.cpp +++ b/modules/commands/help.cpp @@ -17,9 +17,8 @@ class CommandHelp : public Command static CommandGroup *FindGroup(const Anope::string &name) { - for (unsigned i = 0; i < Config->CommandGroups.size(); ++i) + for (auto &gr : Config->CommandGroups) { - CommandGroup &gr = Config->CommandGroups[i]; if (gr.name == name) return &gr; } @@ -34,7 +33,7 @@ class CommandHelp : public Command this->AllowUnregistered(true); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { EventReturn MOD_RESULT; FOREACH_RESULT(OnPreHelp, MOD_RESULT, (source, params)); @@ -56,18 +55,15 @@ class CommandHelp : public Command if (all) source.Reply(_("All available commands for \002%s\002:"), source.service->nick.c_str()); - for (CommandInfo::map::const_iterator it = map.begin(), it_end = map.end(); it != it_end; ++it) + for (const auto &[c_name, info] : map) { - const Anope::string &c_name = it->first; - const CommandInfo &info = it->second; - if (info.hide) continue; // Smaller command exists Anope::string cmd; spacesepstream(c_name).GetToken(cmd, 0); - if (cmd != it->first && map.count(cmd)) + if (cmd != c_name && map.count(cmd)) continue; ServiceReference<Command> c("Command", info.name); @@ -95,18 +91,14 @@ class CommandHelp : public Command } - for (GroupInfo::iterator it = groups.begin(), it_end = groups.end(); it != it_end; ++it) + for (auto &[gr, cmds] : groups) { - CommandGroup *gr = it->first; - source.Reply(" "); source.Reply("%s", gr->description.c_str()); Anope::string buf; - for (std::list<Anope::string>::iterator it2 = it->second.begin(), it2_end = it->second.end(); it2 != it2_end; ++it2) + for (const auto &c_name : cmds) { - const Anope::string &c_name = *it2; - buf += ", " + c_name; if (buf.length() > help_wrap_len) diff --git a/modules/commands/hs_del.cpp b/modules/commands/hs_del.cpp index ea5e4a222..9d4514907 100644 --- a/modules/commands/hs_del.cpp +++ b/modules/commands/hs_del.cpp @@ -20,7 +20,7 @@ class CommandHSDel : public Command this->SetSyntax(_("\037nick\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -41,7 +41,7 @@ class CommandHSDel : public Command source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -60,7 +60,7 @@ class CommandHSDelAll : public Command this->SetSyntax(_("\037nick\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -74,9 +74,9 @@ class CommandHSDelAll : public Command { FOREACH_MOD(OnDeleteVhost, (na)); const NickCore *nc = na->nc; - for (unsigned i = 0; i < nc->aliases->size(); ++i) + for (auto *alias : *nc->aliases) { - na = nc->aliases->at(i); + na = alias; na->RemoveVhost(); } Log(LOG_ADMIN, source, this) << "for all nicks in group " << nc->display; @@ -86,7 +86,7 @@ class CommandHSDelAll : public Command source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/hs_group.cpp b/modules/commands/hs_group.cpp index 46f2f1a9d..03e1dc333 100644 --- a/modules/commands/hs_group.cpp +++ b/modules/commands/hs_group.cpp @@ -13,7 +13,7 @@ class CommandHSGroup : public Command { - bool setting; + bool setting = false; public: void Sync(const NickAlias *na) @@ -25,9 +25,8 @@ class CommandHSGroup : public Command return; setting = true; - for (unsigned i = 0; i < na->nc->aliases->size(); ++i) + for (auto *nick : *na->nc->aliases) { - NickAlias *nick = na->nc->aliases->at(i); if (nick) { nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator()); @@ -37,12 +36,12 @@ class CommandHSGroup : public Command setting = false; } - CommandHSGroup(Module *creator) : Command(creator, "hostserv/group", 0, 0), setting(false) + CommandHSGroup(Module *creator) : Command(creator, "hostserv/group", 0, 0) { this->SetDesc(_("Syncs the vhost for all nicks in a group")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -65,7 +64,7 @@ class CommandHSGroup : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -90,7 +89,7 @@ class HSGroup : public Module throw ModuleException("Your IRCd does not support vhosts"); } - void OnSetVhost(NickAlias *na) anope_override + void OnSetVhost(NickAlias *na) override { if (!synconset) return; @@ -98,7 +97,7 @@ class HSGroup : public Module commandhsgroup.Sync(na); } - void OnNickGroup(User *u, NickAlias *na) anope_override + void OnNickGroup(User *u, NickAlias *na) override { if (!syncongroup) return; @@ -106,7 +105,7 @@ class HSGroup : public Module commandhsgroup.Sync(na); } - void OnReload(Configuration::Conf *conf) anope_override + void OnReload(Configuration::Conf *conf) override { Configuration::Block *block = conf->GetModule(this); syncongroup = block->Get<bool>("syncongroup"); diff --git a/modules/commands/hs_list.cpp b/modules/commands/hs_list.cpp index dbf76d1d6..00f2915d1 100644 --- a/modules/commands/hs_list.cpp +++ b/modules/commands/hs_list.cpp @@ -20,7 +20,7 @@ class CommandHSList : public Command this->SetSyntax(_("[\037key\037|\037#X-Y\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &key = !params.empty() ? params[0] : ""; int from = 0, to = 0, counter = 1; @@ -57,10 +57,8 @@ class CommandHSList : public Command ListFormatter list(source.GetAccount()); list.AddColumn(_("Number")).AddColumn(_("Nick")).AddColumn(_("Vhost")).AddColumn(_("Creator")).AddColumn(_("Created")); - for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it) + for (const auto &[_, na] : *NickAliasList) { - const NickAlias *na = it->second; - if (!na->HasVhost()) continue; @@ -125,11 +123,11 @@ class CommandHSList : public Command std::vector<Anope::string> replies; list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/hs_off.cpp b/modules/commands/hs_off.cpp index d1f7dc4de..e2325bb45 100644 --- a/modules/commands/hs_off.cpp +++ b/modules/commands/hs_off.cpp @@ -20,7 +20,7 @@ class CommandHSOff : public Command this->RequireUser(true); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { User *u = source.GetUser(); @@ -42,7 +42,7 @@ class CommandHSOff : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/hs_on.cpp b/modules/commands/hs_on.cpp index 714fb4410..a3feffbaf 100644 --- a/modules/commands/hs_on.cpp +++ b/modules/commands/hs_on.cpp @@ -20,7 +20,7 @@ class CommandHSOn : public Command this->RequireUser(true); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (!IRCD->CanSetVHost) return; // HostServ wouldn't even be loaded at this point @@ -48,7 +48,7 @@ class CommandHSOn : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp index 0177d0d58..c626deca2 100644 --- a/modules/commands/hs_request.cpp +++ b/modules/commands/hs_request.cpp @@ -29,7 +29,7 @@ struct HostRequest : Serializable HostRequest(Extensible *) : Serializable("HostRequest") { } - void Serialize(Serialize::Data &data) const anope_override + void Serialize(Serialize::Data &data) const override { data["nick"] << this->nick; data["ident"] << this->ident; @@ -79,7 +79,7 @@ class CommandHSRequest : public Command this->SetSyntax(_("vhost")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -132,12 +132,14 @@ class CommandHSRequest : public Command source.Reply(HOST_NO_VIDENT); return; } - for (Anope::string::iterator s = user.begin(), s_end = user.end(); s != s_end; ++s) - if (!isvalidchar(*s)) + for (const auto &chr : user) + { + if (!isvalidchar(chr)) { source.Reply(HOST_SET_IDENT_ERROR); return; } + } } if (host.length() > Config->GetBlock("networkinfo")->Get<unsigned>("hostlen")) @@ -172,7 +174,7 @@ class CommandHSRequest : public Command Log(LOG_COMMAND, source, this) << "to request new vhost " << (!user.empty() ? user + "@" : "") << host; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -192,7 +194,7 @@ class CommandHSActivate : public Command this->SetSyntax(_("\037nick\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -220,7 +222,7 @@ class CommandHSActivate : public Command source.Reply(_("No request for nick %s found."), nick.c_str()); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -241,7 +243,7 @@ class CommandHSReject : public Command this->SetSyntax(_("\037nick\037 [\037reason\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -276,7 +278,7 @@ class CommandHSReject : public Command source.Reply(_("No request for nick %s found."), nick.c_str()); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -296,7 +298,7 @@ class CommandHSWaiting : public Command this->SetDesc(_("Retrieves the vhost requests")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { unsigned counter = 0; unsigned display_counter = 0, listmax = Config->GetModule(this->owner)->Get<unsigned>("listmax"); @@ -304,9 +306,8 @@ class CommandHSWaiting : public Command list.AddColumn(_("Number")).AddColumn(_("Nick")).AddColumn(_("Vhost")).AddColumn(_("Created")); - for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it) + for (const auto &[nick, na] : *NickAliasList) { - const NickAlias *na = it->second; HostRequest *hr = na->GetExt<HostRequest>("hostrequest"); if (!hr) continue; @@ -317,7 +318,7 @@ class CommandHSWaiting : public Command ListFormatter::ListEntry entry; entry["Number"] = stringify(display_counter); - entry["Nick"] = it->first; + entry["Nick"] = nick; if (!hr->ident.empty()) entry["Vhost"] = hr->ident + "@" + hr->host; else @@ -331,13 +332,13 @@ class CommandHSWaiting : public Command std::vector<Anope::string> replies; list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); source.Reply(_("Displayed \002%d\002 records (\002%d\002 total)."), display_counter, counter); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -369,18 +370,15 @@ class HSRequest : public Module static void req_send_memos(Module *me, CommandSource &source, const Anope::string &vIdent, const Anope::string &vHost) { Anope::string host; - std::list<std::pair<Anope::string, Anope::string> >::iterator it, it_end; - if (!vIdent.empty()) host = vIdent + "@" + vHost; else host = vHost; if (Config->GetModule(me)->Get<bool>("memooper") && memoserv) - for (unsigned i = 0; i < Oper::opers.size(); ++i) + { + for (auto *o : Oper::opers) { - Oper *o = Oper::opers[i]; - const NickAlias *na = NickAlias::Find(o->name); if (!na) continue; @@ -389,6 +387,7 @@ static void req_send_memos(Module *me, CommandSource &source, const Anope::strin memoserv->Send(source.service->nick, na->nick, message, true); } + } } MODULE_INIT(HSRequest) diff --git a/modules/commands/hs_set.cpp b/modules/commands/hs_set.cpp index b506bfa60..926dc3bfe 100644 --- a/modules/commands/hs_set.cpp +++ b/modules/commands/hs_set.cpp @@ -20,7 +20,7 @@ class CommandHSSet : public Command this->SetSyntax(_("\037nick\037 \037hostmask\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -92,7 +92,7 @@ class CommandHSSet : public Command source.Reply(_("VHost for \002%s\002 set to \002%s\002."), nick.c_str(), host.c_str()); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -111,9 +111,8 @@ class CommandHSSetAll : public Command if (!na || !na->HasVhost()) return; - for (unsigned i = 0; i < na->nc->aliases->size(); ++i) + for (auto *nick : *na->nc->aliases) { - NickAlias *nick = na->nc->aliases->at(i); if (nick) nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator()); } @@ -126,7 +125,7 @@ class CommandHSSetAll : public Command this->SetSyntax(_("\037nick\037 \037hostmask\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -199,7 +198,7 @@ class CommandHSSetAll : public Command source.Reply(_("VHost for group \002%s\002 set to \002%s\002."), nick.c_str(), host.c_str()); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ms_cancel.cpp b/modules/commands/ms_cancel.cpp index f915457fe..d9f10b104 100644 --- a/modules/commands/ms_cancel.cpp +++ b/modules/commands/ms_cancel.cpp @@ -20,7 +20,7 @@ class CommandMSCancel : public Command this->SetSyntax(_("{\037nick\037 | \037channel\037}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -77,7 +77,7 @@ class CommandMSCancel : public Command source.Reply(_("No memo was cancelable.")); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ms_check.cpp b/modules/commands/ms_check.cpp index f6f5d663b..a0b50eeb9 100644 --- a/modules/commands/ms_check.cpp +++ b/modules/commands/ms_check.cpp @@ -20,7 +20,7 @@ class CommandMSCheck : public Command this->SetSyntax(_("\037nick\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &recipient = params[0]; @@ -62,7 +62,7 @@ class CommandMSCheck : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ms_del.cpp b/modules/commands/ms_del.cpp index dc8ac330f..eefd7add7 100644 --- a/modules/commands/ms_del.cpp +++ b/modules/commands/ms_del.cpp @@ -22,7 +22,7 @@ class MemoDelCallback : public NumberList { } - void HandleNumber(unsigned number) anope_override + void HandleNumber(unsigned number) override { if (!number || number > mi->memos->size()) return; @@ -45,7 +45,7 @@ class CommandMSDel : public Command this->SetSyntax(_("[\037channel\037] {\037num\037 | \037list\037 | LAST | ALL}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -122,7 +122,7 @@ class CommandMSDel : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ms_ignore.cpp b/modules/commands/ms_ignore.cpp index f4121ec16..ca6e1ae86 100644 --- a/modules/commands/ms_ignore.cpp +++ b/modules/commands/ms_ignore.cpp @@ -22,7 +22,7 @@ class CommandMSIgnore : public Command this->SetSyntax(_("[\037channel\037] LIST")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -58,7 +58,7 @@ class CommandMSIgnore : public Command if (std::find(mi->ignores.begin(), mi->ignores.end(), param.ci_str()) == mi->ignores.end()) { - mi->ignores.push_back(param.ci_str()); + mi->ignores.emplace_back(param.ci_str()); source.Reply(_("\002%s\002 added to ignore list."), param.c_str()); } else @@ -84,10 +84,10 @@ class CommandMSIgnore : public Command { ListFormatter list(source.GetAccount()); list.AddColumn(_("Mask")); - for (unsigned i = 0; i < mi->ignores.size(); ++i) + for (const auto &ignore : mi->ignores) { ListFormatter::ListEntry entry; - entry["Mask"] = mi->ignores[i]; + entry["Mask"] = ignore; list.AddEntry(entry); } @@ -96,8 +96,8 @@ class CommandMSIgnore : public Command std::vector<Anope::string> replies; list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); } } else @@ -106,7 +106,7 @@ class CommandMSIgnore : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ms_info.cpp b/modules/commands/ms_info.cpp index 34533b9cb..f9dd20740 100644 --- a/modules/commands/ms_info.cpp +++ b/modules/commands/ms_info.cpp @@ -20,7 +20,7 @@ class CommandMSInfo : public Command this->SetSyntax(_("[\037nick\037 | \037channel\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { NickCore *nc = source.nc; const MemoInfo *mi; @@ -197,7 +197,7 @@ class CommandMSInfo : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ms_list.cpp b/modules/commands/ms_list.cpp index 2bc25e0d2..728fe1a71 100644 --- a/modules/commands/ms_list.cpp +++ b/modules/commands/ms_list.cpp @@ -20,7 +20,7 @@ class CommandMSList : public Command this->SetSyntax(_("[\037channel\037] [\037list\037 | NEW]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { Anope::string param = !params.empty() ? params[0] : "", chan; @@ -75,7 +75,7 @@ class CommandMSList : public Command { } - void HandleNumber(unsigned number) anope_override + void HandleNumber(unsigned number) override { if (!number || number > mi->memos->size()) return; @@ -129,13 +129,13 @@ class CommandMSList : public Command list.Process(replies); source.Reply(_("Memos for %s:"), ci ? ci->name.c_str() : source.GetNick().c_str()); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); } return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ms_read.cpp b/modules/commands/ms_read.cpp index 1bfe86437..0fee45e31 100644 --- a/modules/commands/ms_read.cpp +++ b/modules/commands/ms_read.cpp @@ -59,13 +59,13 @@ class MemoListCallback : public NumberList found = false; } - ~MemoListCallback() + ~MemoListCallback() override { if (!found) source.Reply(_("No memos to display.")); } - void HandleNumber(unsigned number) anope_override + void HandleNumber(unsigned number) override { if (!number || number > mi->memos->size()) return; @@ -113,7 +113,7 @@ class CommandMSRead : public Command this->SetSyntax(_("[\037channel\037] {\037num\037 | \037list\037 | LAST | NEW | ALL}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { MemoInfo *mi; @@ -192,7 +192,7 @@ class CommandMSRead : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ms_rsend.cpp b/modules/commands/ms_rsend.cpp index f7f64b725..bd88749a4 100644 --- a/modules/commands/ms_rsend.cpp +++ b/modules/commands/ms_rsend.cpp @@ -25,7 +25,7 @@ class CommandMSRSend : public Command this->SetSyntax(_("{\037nick\037 | \037channel\037} \037memo-text\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (!memoserv) return; @@ -73,7 +73,7 @@ class CommandMSRSend : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ms_send.cpp b/modules/commands/ms_send.cpp index 7a1edd039..71d4cc7e4 100644 --- a/modules/commands/ms_send.cpp +++ b/modules/commands/ms_send.cpp @@ -25,7 +25,7 @@ class CommandMSSend : public Command this->SetSyntax(_("{\037nick\037 | \037channel\037} \037memo-text\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (!memoserv) return; @@ -59,7 +59,7 @@ class CommandMSSend : public Command source.Reply(_("Sorry, %s currently has too many memos and cannot receive more."), nick.c_str()); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ms_sendall.cpp b/modules/commands/ms_sendall.cpp index 60f93cd87..904e5e161 100644 --- a/modules/commands/ms_sendall.cpp +++ b/modules/commands/ms_sendall.cpp @@ -25,7 +25,7 @@ class CommandMSSendAll : public Command this->SetSyntax(_("\037memo-text\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (!memoserv) return; @@ -34,10 +34,8 @@ class CommandMSSendAll : public Command Log(LOG_ADMIN, source, this) << "to send " << text; - for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it) + for (const auto &[_, nc] : *NickCoreList) { - const NickCore *nc = it->second; - if (nc != source.nc) memoserv->Send(source.GetNick(), nc->display, text); } @@ -45,7 +43,7 @@ class CommandMSSendAll : public Command source.Reply(_("A massmemo has been sent to all registered users.")); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ms_set.cpp b/modules/commands/ms_set.cpp index fc87b9b61..f1d2ebba6 100644 --- a/modules/commands/ms_set.cpp +++ b/modules/commands/ms_set.cpp @@ -207,7 +207,7 @@ class CommandMSSet : public Command this->SetSyntax(_("\037option\037 \037parameters\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &cmd = params[0]; MemoInfo *mi = &source.nc->memos; @@ -226,7 +226,7 @@ class CommandMSSet : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { if (subcommand.empty()) { diff --git a/modules/commands/ms_staff.cpp b/modules/commands/ms_staff.cpp index fba892467..2b0efae6d 100644 --- a/modules/commands/ms_staff.cpp +++ b/modules/commands/ms_staff.cpp @@ -25,23 +25,21 @@ class CommandMSStaff : public Command this->SetSyntax(_("\037memo-text\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (!memoserv) return; const Anope::string &text = params[0]; - for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it) + for (const auto &[_, nc] : *NickCoreList) { - const NickCore *nc = it->second; - if (source.nc != nc && nc->IsServicesOper()) memoserv->Send(source.GetNick(), nc->display, text, true); } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ns_access.cpp b/modules/commands/ns_access.cpp index 73f760121..d85277a51 100644 --- a/modules/commands/ns_access.cpp +++ b/modules/commands/ns_access.cpp @@ -104,7 +104,7 @@ class CommandNSAccess : public Command this->SetSyntax(_("LIST [\037nickname\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &cmd = params[0]; Anope::string nick, mask; @@ -159,7 +159,7 @@ class CommandNSAccess : public Command this->OnSyntaxError(source, ""); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -196,7 +196,7 @@ class NSAccess : public Module { } - void OnNickRegister(User *u, NickAlias *na, const Anope::string &) anope_override + void OnNickRegister(User *u, NickAlias *na, const Anope::string &) override { if (u && Config->GetModule(this)->Get<bool>("addaccessonreg")) na->nc->AddAccess(u->Mask()); diff --git a/modules/commands/ns_ajoin.cpp b/modules/commands/ns_ajoin.cpp index fef32094f..a783708a9 100644 --- a/modules/commands/ns_ajoin.cpp +++ b/modules/commands/ns_ajoin.cpp @@ -27,7 +27,7 @@ struct AJoinEntry : Serializable AJoinEntry(Extensible *) : Serializable("AJoinEntry") { } - ~AJoinEntry() + ~AJoinEntry() override { AJoinList *channels = owner->GetExt<AJoinList>("ajoinlist"); if (channels) @@ -38,7 +38,7 @@ struct AJoinEntry : Serializable } } - void Serialize(Serialize::Data &sd) const anope_override + void Serialize(Serialize::Data &sd) const override { if (!this->owner) return; @@ -82,8 +82,8 @@ struct AJoinEntry : Serializable AJoinList::~AJoinList() { - for (unsigned i = 0; i < (*this)->size(); ++i) - delete (*this)->at(i); + for (const auto *ajoin : *(*this)) + delete ajoin; } class CommandNSAJoin : public Command @@ -113,8 +113,8 @@ class CommandNSAJoin : public Command std::vector<Anope::string> replies; list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); } } @@ -233,7 +233,7 @@ class CommandNSAJoin : public Command this->SetSyntax(_("LIST [\037nickname\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &cmd = params[0]; Anope::string nick, param, param2; @@ -285,7 +285,7 @@ class CommandNSAJoin : public Command this->OnSyntaxError(source, ""); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -314,7 +314,7 @@ class NSAJoin : public Module } - void OnUserLogin(User *u) anope_override + void OnUserLogin(User *u) override { BotInfo *NickServ = Config->GetClient("NickServ"); if (!NickServ) @@ -327,9 +327,8 @@ class NSAJoin : public Module /* Set +r now, so we can ajoin users into +R channels */ ModeManager::ProcessModes(); - for (unsigned i = 0; i < (*channels)->size(); ++i) + for (auto *entry : *(*channels)) { - AJoinEntry *entry = (*channels)->at(i); Channel *c = Channel::Find(entry->channel); ChannelInfo *ci; @@ -356,7 +355,7 @@ class NSAJoin : public Module continue; else if (c->HasMode("ADMINONLY") && !u->HasMode("ADMIN")) continue; - else if (c->HasMode("SSL") && !(u->HasMode("SSL") || u->HasExt("ssl"))) + else if (c->HasMode("SSL") && !u->IsSecurelyConnected()) continue; else if (c->MatchesList(u, "BAN") == true && c->MatchesList(u, "EXCEPT") == false) need_invite = true; diff --git a/modules/commands/ns_alist.cpp b/modules/commands/ns_alist.cpp index dc4a0a19e..e0f160aa2 100644 --- a/modules/commands/ns_alist.cpp +++ b/modules/commands/ns_alist.cpp @@ -25,7 +25,7 @@ class CommandNSAList : public Command this->SetSyntax(_("[\037nickname\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { Anope::string nick = source.GetNick(); NickCore *nc = source.nc; @@ -51,9 +51,8 @@ class CommandNSAList : public Command nc->GetChannelReferences(queue); std::sort(queue.begin(), queue.end(), ChannelSort); - for (unsigned i = 0; i < queue.size(); ++i) + for (auto *ci : queue) { - ChannelInfo *ci = queue[i]; ListFormatter::ListEntry entry; if (ci->GetFounder() == nc) @@ -86,10 +85,8 @@ class CommandNSAList : public Command entry["Number"] = stringify(chan_count); entry["Channel"] = (ci->HasExt("CS_NO_EXPIRE") ? "!" : "") + ci->name; - for (unsigned j = 0; j < access.paths.size(); ++j) + for (auto &p : access.paths) { - ChanAccess::Path &p = access.paths[j]; - // not interested in indirect access if (p.size() != 1) continue; @@ -113,14 +110,14 @@ class CommandNSAList : public Command { source.Reply(_("Channels that \002%s\002 has access on:"), nc->display.c_str()); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); source.Reply(_("End of list - %d channels shown."), chan_count); } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ns_cert.cpp b/modules/commands/ns_cert.cpp index a9674df67..4e42d9fb5 100644 --- a/modules/commands/ns_cert.cpp +++ b/modules/commands/ns_cert.cpp @@ -18,7 +18,7 @@ struct CertServiceImpl : CertService { CertServiceImpl(Module *o) : CertService(o) { } - NickCore* FindAccountFromCert(const Anope::string &cert) anope_override + NickCore* FindAccountFromCert(const Anope::string &cert) override { Anope::hash_map<NickCore *>::iterator it = certmap.find(cert); if (it != certmap.end()) @@ -35,7 +35,7 @@ struct NSCertListImpl : NSCertList public: NSCertListImpl(Extensible *obj) : nc(anope_dynamic_static_cast<NickCore *>(obj)) { } - ~NSCertListImpl() + ~NSCertListImpl() override { ClearCert(); } @@ -46,7 +46,7 @@ struct NSCertListImpl : NSCertList * * Adds a new entry into the cert list. */ - void AddCert(const Anope::string &entry) anope_override + void AddCert(const Anope::string &entry) override { this->certs.push_back(entry); certmap[entry] = nc; @@ -60,14 +60,14 @@ struct NSCertListImpl : NSCertList * * Retrieves an entry from the certificate list corresponding to the given index. */ - Anope::string GetCert(unsigned entry) const anope_override + Anope::string GetCert(unsigned entry) const override { if (entry >= this->certs.size()) return ""; return this->certs[entry]; } - unsigned GetCertCount() const anope_override + unsigned GetCertCount() const override { return this->certs.size(); } @@ -79,7 +79,7 @@ struct NSCertListImpl : NSCertList * * Search for an fingerprint within the cert list. */ - bool FindCert(const Anope::string &entry) const anope_override + bool FindCert(const Anope::string &entry) const override { return std::find(this->certs.begin(), this->certs.end(), entry) != this->certs.end(); } @@ -90,7 +90,7 @@ struct NSCertListImpl : NSCertList * * Removes the specified fingerprint from the cert list. */ - void EraseCert(const Anope::string &entry) anope_override + void EraseCert(const Anope::string &entry) override { std::vector<Anope::string>::iterator it = std::find(this->certs.begin(), this->certs.end(), entry); if (it != this->certs.end()) @@ -105,15 +105,15 @@ struct NSCertListImpl : NSCertList * * Deletes all the memory allocated in the certificate list vector and then clears the vector. */ - void ClearCert() anope_override + void ClearCert() override { FOREACH_MOD(OnNickClearCert, (this->nc)); - for (unsigned i = 0; i < certs.size(); ++i) - certmap.erase(certs[i]); + for (const auto &cert : certs) + certmap.erase(cert); this->certs.clear(); } - void Check() anope_override + void Check() override { if (this->certs.empty()) nc->Shrink<NSCertList>("certificates"); @@ -123,7 +123,7 @@ struct NSCertListImpl : NSCertList { ExtensibleItem(Module *m, const Anope::string &ename) : ::ExtensibleItem<NSCertListImpl>(m, ename) { } - void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const anope_override + void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const override { if (s->GetSerializableType()->GetName() != "NickCore") return; @@ -137,7 +137,7 @@ struct NSCertListImpl : NSCertList data["cert"] << c->GetCert(i) << " "; } - void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) anope_override + void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override { if (s->GetSerializableType()->GetName() != "NickCore") return; @@ -148,8 +148,8 @@ struct NSCertListImpl : NSCertList Anope::string buf; data["cert"] >> buf; spacesepstream sep(buf); - for (unsigned i = 0; i < c->certs.size(); ++i) - certmap.erase(c->certs[i]); + for (const auto &cert : c->certs) + certmap.erase(cert); c->certs.clear(); while (sep.GetToken(buf)) { @@ -260,7 +260,7 @@ class CommandNSCert : public Command this->SetSyntax(_("LIST [\037nickname\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &cmd = params[0]; Anope::string nick, certfp; @@ -312,7 +312,7 @@ class CommandNSCert : public Command this->OnSyntaxError(source, ""); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -352,7 +352,7 @@ class NSCert : public Module throw ModuleException("Your IRCd does not support ssl client certificates"); } - void OnFingerprint(User *u) anope_override + void OnFingerprint(User *u) override { BotInfo *NickServ = Config->GetClient("NickServ"); if (!NickServ || u->IsIdentified()) @@ -379,7 +379,7 @@ class NSCert : public Module Log(NickServ) << u->GetMask() << " automatically identified for account " << nc->display << " via SSL certificate fingerprint"; } - EventReturn OnNickValidate(User *u, NickAlias *na) anope_override + EventReturn OnNickValidate(User *u, NickAlias *na) override { NSCertList *cl = certs.Get(na->nc); if (!u->fingerprint.empty() && cl && cl->FindCert(u->fingerprint)) diff --git a/modules/commands/ns_drop.cpp b/modules/commands/ns_drop.cpp index bb4c95dff..3cf9c9bb0 100644 --- a/modules/commands/ns_drop.cpp +++ b/modules/commands/ns_drop.cpp @@ -20,7 +20,7 @@ class CommandNSDrop : public Command this->SetDesc(_("Cancel the registration of a nickname")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &nick = params[0]; @@ -54,7 +54,7 @@ class CommandNSDrop : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ns_getemail.cpp b/modules/commands/ns_getemail.cpp index 685431fe9..de418cd0c 100644 --- a/modules/commands/ns_getemail.cpp +++ b/modules/commands/ns_getemail.cpp @@ -24,17 +24,15 @@ class CommandNSGetEMail : public Command this->SetSyntax(_("\037email\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &email = params[0]; int j = 0; Log(LOG_ADMIN, source, this) << "on " << email; - for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it) + for (const auto &[_, nc] : *NickCoreList) { - const NickCore *nc = it->second; - if (!nc->email.empty() && Anope::Match(nc->email, email)) { ++j; @@ -51,7 +49,7 @@ class CommandNSGetEMail : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ns_getpass.cpp b/modules/commands/ns_getpass.cpp deleted file mode 100644 index 0605a3078..000000000 --- a/modules/commands/ns_getpass.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* NickServ core functions - * - * (C) 2003-2023 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - */ - -#include "module.h" - -class CommandNSGetPass : public Command -{ - public: - CommandNSGetPass(Module *creator) : Command(creator, "nickserv/getpass", 1, 1) - { - this->SetDesc(_("Retrieve the password for a nickname")); - this->SetSyntax(_("\037nickname\037")); - } - - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - const Anope::string &nick = params[0]; - Anope::string tmp_pass; - const NickAlias *na; - - if (!(na = NickAlias::Find(nick))) - source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); - else if (Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && na->nc->IsServicesOper()) - source.Reply(_("You may not get the password of other Services Operators.")); - else - { - if (Anope::Decrypt(na->nc->pass, tmp_pass) == 1) - { - Log(LOG_ADMIN, source, this) << "for " << nick; - source.Reply(_("Password for %s is \002%s\002."), nick.c_str(), tmp_pass.c_str()); - } - else - source.Reply(_("GETPASS command unavailable because encryption is in use.")); - } - return; - } - - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override - { - this->SendSyntax(source); - source.Reply(" "); - source.Reply(_("Returns the password for the given nickname. \002Note\002 that\n" - "whenever this command is used, a message including the\n" - "person who issued the command and the nickname it was used\n" - "on will be logged and sent out as a WALLOPS/GLOBOPS.")); - return true; - } -}; - -class NSGetPass : public Module -{ - CommandNSGetPass commandnsgetpass; - - public: - NSGetPass(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnsgetpass(this) - { - - Anope::string tmp_pass = "plain:tmp"; - if (!Anope::Decrypt(tmp_pass, tmp_pass)) - throw ModuleException("Incompatible with the encryption module being used"); - - } -}; - -MODULE_INIT(NSGetPass) diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp index 6830b7cd1..af9b71584 100644 --- a/modules/commands/ns_group.cpp +++ b/modules/commands/ns_group.cpp @@ -22,7 +22,7 @@ class NSGroupRequest : public IdentifyRequest public: NSGroupRequest(Module *o, CommandSource &src, Command *c, const Anope::string &n, NickAlias *targ, const Anope::string &pass) : IdentifyRequest(o, targ->nc->display, pass), source(src), cmd(c), nick(n), target(targ) { } - void OnSuccess() anope_override + void OnSuccess() override { User *u = source.GetUser(); @@ -67,7 +67,7 @@ class NSGroupRequest : public IdentifyRequest u->lastnickreg = Anope::CurTime; } - void OnFail() anope_override + void OnFail() override { User *u = source.GetUser(); @@ -93,7 +93,7 @@ class CommandNSGroup : public Command this->AllowUnregistered(true); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { User *user = source.GetUser(); @@ -128,16 +128,16 @@ class CommandNSGroup : public Command } if (Config->GetModule("nickserv")->Get<bool>("restrictopernicks")) - for (unsigned i = 0; i < Oper::opers.size(); ++i) + { + for (auto *o : Oper::opers) { - Oper *o = Oper::opers[i]; - if (user != NULL && !user->HasMode("OPER") && user->nick.find_ci(o->name) != Anope::string::npos) { source.Reply(NICK_CANNOT_BE_REGISTERED, user->nick.c_str()); return; } } + } NickAlias *target, *na = NickAlias::Find(source.GetNick()); const Anope::string &guestnick = Config->GetModule("nickserv")->Get<const Anope::string>("guestnickprefix", "Guest"); @@ -194,7 +194,7 @@ class CommandNSGroup : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -237,7 +237,7 @@ class CommandNSUngroup : public Command this->SetSyntax(_("[\037nick\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { Anope::string nick = !params.empty() ? params[0] : ""; NickAlias *na = NickAlias::Find(!nick.empty() ? nick : source.GetNick()); @@ -278,7 +278,7 @@ class CommandNSUngroup : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -299,7 +299,7 @@ class CommandNSGList : public Command this->SetDesc(_("Lists all nicknames in your group")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &nick = !params.empty() ? params[0] : ""; const NickCore *nc; @@ -325,12 +325,10 @@ class CommandNSGList : public Command ListFormatter list(source.GetAccount()); list.AddColumn(_("Nick")).AddColumn(_("Expires")); - time_t nickserv_expire = Config->GetModule("nickserv")->Get<time_t>("expire", "21d"), + time_t nickserv_expire = Config->GetModule("nickserv")->Get<time_t>("expire", "90d"), unconfirmed_expire = Config->GetModule("ns_register")->Get<time_t>("unconfirmedexpire", "1d"); - for (unsigned i = 0; i < nc->aliases->size(); ++i) + for (auto *na2 : *nc->aliases) { - const NickAlias *na2 = nc->aliases->at(i); - Anope::string expires; if (na2->HasExt("NS_NO_EXPIRE")) expires = NO_EXPIRE; @@ -351,13 +349,13 @@ class CommandNSGList : public Command std::vector<Anope::string> replies; list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); source.Reply(_("%d nickname(s) in the group."), nc->aliases->size()); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { if (source.IsServicesOper()) source.Reply(_("Syntax: \002%s [\037nickname\037]\002\n" diff --git a/modules/commands/ns_identify.cpp b/modules/commands/ns_identify.cpp index 8608a11e6..edab989e2 100644 --- a/modules/commands/ns_identify.cpp +++ b/modules/commands/ns_identify.cpp @@ -19,7 +19,7 @@ class NSIdentifyRequest : public IdentifyRequest public: NSIdentifyRequest(Module *o, CommandSource &s, Command *c, const Anope::string &acc, const Anope::string &pass) : IdentifyRequest(o, acc, pass), source(s), cmd(c) { } - void OnSuccess() anope_override + void OnSuccess() override { if (!source.GetUser()) return; @@ -40,7 +40,7 @@ class NSIdentifyRequest : public IdentifyRequest } } - void OnFail() anope_override + void OnFail() override { if (source.GetUser()) { @@ -68,7 +68,7 @@ class CommandNSIdentify : public Command this->RequireUser(true); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { User *u = source.GetUser(); @@ -100,7 +100,7 @@ class CommandNSIdentify : public Command req->Dispatch(); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ns_info.cpp b/modules/commands/ns_info.cpp index b65106ba5..abe423acb 100644 --- a/modules/commands/ns_info.cpp +++ b/modules/commands/ns_info.cpp @@ -21,7 +21,7 @@ class CommandNSInfo : public Command this->AllowUnregistered(true); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &nick = params.size() ? params[0] : (source.nc ? source.nc->display : source.GetNick()); @@ -114,12 +114,12 @@ class CommandNSInfo : public Command std::vector<Anope::string> replies; info.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -212,12 +212,12 @@ class CommandNSSetHide : public Command this->OnSyntaxError(source, "HIDE"); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, source.nc->display, params[0], params[1]); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -240,13 +240,13 @@ class CommandNSSASetHide : public CommandNSSetHide this->SetSyntax(_("\037nickname\037 {EMAIL | STATUS | USERMASK | QUIT} {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->ClearSyntax(); this->Run(source, params[0], params[1], params[2]); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ns_list.cpp b/modules/commands/ns_list.cpp index af29d8658..3c690984e 100644 --- a/modules/commands/ns_list.cpp +++ b/modules/commands/ns_list.cpp @@ -20,7 +20,7 @@ class CommandNSList : public Command this->SetSyntax(_("\037pattern\037 [SUSPENDED] [NOEXPIRE] [UNCONFIRMED]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { Anope::string pattern = params[0]; @@ -75,13 +75,11 @@ class CommandNSList : public Command list.AddColumn(_("Nick")).AddColumn(_("Last usermask")); Anope::map<NickAlias *> ordered_map; - for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it) - ordered_map[it->first] = it->second; + for (const auto &[nick, na] : *NickAliasList) + ordered_map[nick] = na; - for (Anope::map<NickAlias *>::const_iterator it = ordered_map.begin(), it_end = ordered_map.end(); it != it_end; ++it) + for (const auto &[_, na] : ordered_map) { - const NickAlias *na = it->second; - /* Don't show private nicks to non-services admins. */ if (na->nc->HasExt("NS_PRIVATE") && !is_servadmin && na->nc != mync) continue; @@ -125,14 +123,14 @@ class CommandNSList : public Command std::vector<Anope::string> replies; list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); source.Reply(_("End of list - %d/%d matches shown."), nnicks > listmax ? listmax : nnicks, nnicks); return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -224,12 +222,12 @@ class CommandNSSetPrivate : public Command this->OnSyntaxError(source, "PRIVATE"); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, source.nc->display, params[0]); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -252,12 +250,12 @@ class CommandNSSASetPrivate : public CommandNSSetPrivate this->SetSyntax(_("\037nickname\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, params[0], params[1]); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -288,7 +286,7 @@ class NSList : public Module { } - void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_all) anope_override + void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_all) override { if (!show_all) return; diff --git a/modules/commands/ns_logout.cpp b/modules/commands/ns_logout.cpp index 74e2e59f9..e281a9708 100644 --- a/modules/commands/ns_logout.cpp +++ b/modules/commands/ns_logout.cpp @@ -22,7 +22,7 @@ class CommandNSLogout : public Command this->SetSyntax(_("[\037nickname\037 [REVALIDATE]]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &nick = !params.empty() ? params[0] : ""; @@ -59,7 +59,7 @@ class CommandNSLogout : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -69,7 +69,7 @@ class CommandNSLogout : public Command "yourself.\n" " \n" "With a parameter, does the same for the given nick. If you\n" - "specify \002REVALIDATE\002 as well, Services will ask the given nick\n" + "specify \002REVALIDATE\002 as well, services will ask the given nick\n" "to re-identify. This is limited to \002Services Operators\002.")); return true; diff --git a/modules/commands/ns_recover.cpp b/modules/commands/ns_recover.cpp index 67994a983..f8ca00329 100644 --- a/modules/commands/ns_recover.cpp +++ b/modules/commands/ns_recover.cpp @@ -32,7 +32,7 @@ class NSRecoverRequest : public IdentifyRequest public: NSRecoverRequest(Module *o, CommandSource &src, Command *c, const Anope::string &nick, const Anope::string &pass) : IdentifyRequest(o, nick, pass), source(src), cmd(c), user(nick) { } - void OnSuccess() anope_override + void OnSuccess() override { User *u = User::Find(user, true); if (!source.GetUser() || !source.service) @@ -69,8 +69,8 @@ class NSRecoverRequest : public IdentifyRequest if (!u->chans.empty()) { NSRecoverInfo *ei = source.GetUser()->Extend<NSRecoverInfo>("recover"); - for (User::ChanUserList::iterator it = u->chans.begin(), it_end = u->chans.end(); it != it_end; ++it) - (*ei)[it->first->name] = it->second->status; + for (auto &[chan, cuc] : u->chans) + (*ei)[chan->name] = cuc->status; } } @@ -124,7 +124,7 @@ class NSRecoverRequest : public IdentifyRequest } } - void OnFail() anope_override + void OnFail() override { if (NickAlias::Find(GetAccount()) != NULL) { @@ -151,7 +151,7 @@ class CommandNSRecover : public Command this->AllowUnregistered(true); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &nick = params[0]; const Anope::string &pass = params.size() > 1 ? params[1] : ""; @@ -207,7 +207,7 @@ class CommandNSRecover : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -237,7 +237,7 @@ class NSRecover : public Module } - void OnUserNickChange(User *u, const Anope::string &oldnick) anope_override + void OnUserNickChange(User *u, const Anope::string &oldnick) override { if (Config->GetModule(this)->Get<bool>("restoreonrecover")) { @@ -272,7 +272,7 @@ class NSRecover : public Module } } - void OnJoinChannel(User *u, Channel *c) anope_override + void OnJoinChannel(User *u, Channel *c) override { if (Config->GetModule(this)->Get<bool>("restoreonrecover")) { @@ -283,8 +283,8 @@ class NSRecover : public Module NSRecoverInfo::iterator it = ei->find(c->name); if (it != ei->end()) { - for (size_t i = 0; i < it->second.Modes().length(); ++i) - c->SetMode(c->WhoSends(), ModeManager::FindChannelModeByChar(it->second.Modes()[i]), u->GetUID()); + for (auto mode : it->second.Modes()) + c->SetMode(c->WhoSends(), ModeManager::FindChannelModeByChar(mode), u->GetUID()); ei->erase(it); if (ei->empty()) diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp index bd188637c..6fd47ad38 100644 --- a/modules/commands/ns_register.cpp +++ b/modules/commands/ns_register.cpp @@ -23,7 +23,7 @@ class CommandNSConfirm : public Command this->AllowUnregistered(true); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &passcode = params[0]; @@ -88,7 +88,7 @@ class CommandNSConfirm : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -106,7 +106,7 @@ class CommandNSConfirm : public Command return true; } - void OnSyntaxError(CommandSource &source, const Anope::string &subcommand) anope_override + void OnSyntaxError(CommandSource &source, const Anope::string &subcommand) override { source.Reply(NICK_CONFIRM_INVALID); } @@ -125,7 +125,7 @@ class CommandNSRegister : public Command this->AllowUnregistered(true); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { User *u = source.GetUser(); Anope::string u_nick = source.GetNick(); @@ -180,10 +180,8 @@ class CommandNSRegister : public Command if (Config->GetModule("nickserv")->Get<bool>("restrictopernicks")) { - for (unsigned i = 0; i < Oper::opers.size(); ++i) + for (auto *o : Oper::opers) { - Oper *o = Oper::opers[i]; - if (!source.IsOper() && u_nick.find_ci(o->name) != Anope::string::npos) { source.Reply(NICK_CANNOT_BE_REGISTERED, u_nick.c_str()); @@ -192,7 +190,8 @@ class CommandNSRegister : public Command } } - unsigned int passlen = Config->GetModule("nickserv")->Get<unsigned>("passlen", "32"); + unsigned int minpasslen = Config->GetModule("nickserv")->Get<unsigned>("minpasslen", "8"); + unsigned int maxpasslen = Config->GetModule("nickserv")->Get<unsigned>("maxpasslen", "32"); if (Config->GetModule("nickserv")->Get<bool>("forceemail", "yes") && email.empty()) this->OnSyntaxError(source, ""); @@ -200,10 +199,12 @@ class CommandNSRegister : public Command source.Reply(_("Please wait %d seconds before using the REGISTER command again."), (u->lastnickreg + reg_delay) - Anope::CurTime); else if (NickAlias::Find(u_nick) != NULL) source.Reply(NICK_ALREADY_REGISTERED, u_nick.c_str()); - else if (pass.equals_ci(u_nick) || (Config->GetBlock("options")->Get<bool>("strictpasswords") && pass.length() < 5)) + else if (pass.equals_ci(u_nick)) source.Reply(MORE_OBSCURE_PASSWORD); - else if (pass.length() > passlen) - source.Reply(PASSWORD_TOO_LONG, passlen); + else if (pass.length() < minpasslen) + source.Reply(PASSWORD_TOO_SHORT, minpasslen); + else if (pass.length() > maxpasslen) + source.Reply(PASSWORD_TOO_LONG, maxpasslen); else if (!email.empty() && !Mail::Validate(email)) source.Reply(MAIL_X_INVALID, email.c_str()); else @@ -229,10 +230,6 @@ class CommandNSRegister : public Command else source.Reply(_("Nickname \002%s\002 registered."), u_nick.c_str()); - Anope::string tmp_pass; - if (Anope::Decrypt(na->nc->pass, tmp_pass) == 1) - source.Reply(_("Your password is \002%s\002 - remember this for later use."), tmp_pass.c_str()); - if (nsregister.equals_ci("admin")) { nc->Extend<bool>("UNCONFIRMED"); @@ -264,7 +261,7 @@ class CommandNSRegister : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -314,7 +311,7 @@ class CommandNSResend : public Command this->SetDesc(_("Resend registration confirmation email")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (!Config->GetModule(this->owner)->Get<const Anope::string>("registration").equals_ci("mail")) { @@ -345,7 +342,7 @@ class CommandNSResend : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { if (!Config->GetModule(this->owner)->Get<const Anope::string>("registration").equals_ci("mail")) return false; @@ -356,7 +353,7 @@ class CommandNSResend : public Command return true; } - void OnServHelp(CommandSource &source) anope_override + void OnServHelp(CommandSource &source) override { if (Config->GetModule(this->owner)->Get<const Anope::string>("registration").equals_ci("mail")) Command::OnServHelp(source); @@ -381,7 +378,7 @@ class NSRegister : public Module throw ModuleException("Module " + this->name + " will not load with registration disabled."); } - void OnNickIdentify(User *u) anope_override + void OnNickIdentify(User *u) override { BotInfo *NickServ; if (unconfirmed.HasExt(u->Account()) && (NickServ = Config->GetClient("NickServ"))) @@ -399,7 +396,7 @@ class NSRegister : public Module } } - void OnPreNickExpire(NickAlias *na, bool &expire) anope_override + void OnPreNickExpire(NickAlias *na, bool &expire) override { if (unconfirmed.HasExt(na->nc)) { diff --git a/modules/commands/ns_resetpass.cpp b/modules/commands/ns_resetpass.cpp index bf5f30230..c0001cbe4 100644 --- a/modules/commands/ns_resetpass.cpp +++ b/modules/commands/ns_resetpass.cpp @@ -23,7 +23,7 @@ class CommandNSResetPass : public Command this->AllowUnregistered(true); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const NickAlias *na; @@ -43,7 +43,7 @@ class CommandNSResetPass : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -73,7 +73,7 @@ class NSResetPass : public Module throw ModuleException("Not using mail."); } - EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) anope_override + EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) override { if (command->name == "nickserv/confirm" && params.size() > 1) { @@ -106,7 +106,7 @@ class NSResetPass : public Module { source.GetUser()->Identify(na); } - + source.Reply(_("You are now identified for your nick. Change your password now.")); } else diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp index 62dd51180..b18bb9cff 100644 --- a/modules/commands/ns_set.cpp +++ b/modules/commands/ns_set.cpp @@ -20,13 +20,13 @@ class CommandNSSet : public Command this->SetSyntax(_("\037option\037 \037parameters\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->OnSyntaxError(source, ""); return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -35,11 +35,8 @@ class CommandNSSet : public Command Anope::string this_name = source.command; bool hide_privileged_commands = Config->GetBlock("options")->Get<bool>("hideprivilegedcommands"), hide_registered_commands = Config->GetBlock("options")->Get<bool>("hideregisteredcommands"); - for (CommandInfo::map::const_iterator it = source.service->commands.begin(), it_end = source.service->commands.end(); it != it_end; ++it) + for (const auto &[c_name, info] : source.service->commands) { - const Anope::string &c_name = it->first; - const CommandInfo &info = it->second; - if (c_name.find_ci(this_name + " ") == 0) { if (info.hide) @@ -75,24 +72,21 @@ class CommandNSSASet : public Command this->SetSyntax(_("\037option\037 \037nickname\037 \037parameters\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->OnSyntaxError(source, ""); return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); source.Reply(_("Sets various nickname options. \037option\037 can be one of:")); Anope::string this_name = source.command; - for (CommandInfo::map::const_iterator it = source.service->commands.begin(), it_end = source.service->commands.end(); it != it_end; ++it) + for (const auto &[c_name, info] : source.service->commands) { - const Anope::string &c_name = it->first; - const CommandInfo &info = it->second; - if (c_name.find_ci(this_name + " ") == 0) { ServiceReference<Command> command("Command", info.name); @@ -120,7 +114,7 @@ class CommandNSSetPassword : public Command this->SetSyntax(_("\037new-password\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string ¶m = params[0]; unsigned len = param.length(); @@ -131,30 +125,33 @@ class CommandNSSetPassword : public Command return; } - if (source.GetNick().equals_ci(param) || (Config->GetBlock("options")->Get<bool>("strictpasswords") && len < 5)) + if (source.GetNick().equals_ci(param)) { source.Reply(MORE_OBSCURE_PASSWORD); return; } - unsigned int passlen = Config->GetModule("nickserv")->Get<unsigned>("passlen", "32"); - if (len > passlen) + unsigned int minpasslen = Config->GetModule("nickserv")->Get<unsigned>("minpasslen", "8"); + if (len < minpasslen) { - source.Reply(PASSWORD_TOO_LONG, passlen); + source.Reply(PASSWORD_TOO_SHORT, minpasslen); + return; + } + + unsigned int maxpasslen = Config->GetModule("nickserv")->Get<unsigned>("maxpasslen", "32"); + if (len > maxpasslen) + { + source.Reply(PASSWORD_TOO_LONG, maxpasslen); return; } Log(LOG_COMMAND, source, this) << "to change their password"; Anope::Encrypt(param, source.nc->pass); - Anope::string tmp_pass; - if (Anope::Decrypt(source.nc->pass, tmp_pass) == 1) - source.Reply(_("Password for \002%s\002 changed to \002%s\002."), source.nc->display.c_str(), tmp_pass.c_str()); - else - source.Reply(_("Password for \002%s\002 changed."), source.nc->display.c_str()); + source.Reply(_("Password for \002%s\002 changed."), source.nc->display.c_str()); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -173,7 +170,7 @@ class CommandNSSASetPassword : public Command this->SetSyntax(_("\037nickname\037 \037new-password\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -197,16 +194,23 @@ class CommandNSSASetPassword : public Command return; } - if (nc->display.equals_ci(params[1]) || (Config->GetBlock("options")->Get<bool>("strictpasswords") && len < 5)) + if (nc->display.equals_ci(params[1])) { source.Reply(MORE_OBSCURE_PASSWORD); return; } - unsigned int passlen = Config->GetModule("nickserv")->Get<unsigned>("passlen", "32"); - if (len > passlen) + unsigned int minpasslen = Config->GetModule("nickserv")->Get<unsigned>("minpasslen", "8"); + if (len < minpasslen) + { + source.Reply(PASSWORD_TOO_SHORT, minpasslen); + return; + } + + unsigned int maxpasslen = Config->GetModule("nickserv")->Get<unsigned>("maxpasslen", "32"); + if (len > maxpasslen) { - source.Reply(PASSWORD_TOO_LONG, passlen); + source.Reply(PASSWORD_TOO_LONG, maxpasslen); return; } @@ -214,13 +218,10 @@ class CommandNSSASetPassword : public Command Anope::Encrypt(params[1], nc->pass); Anope::string tmp_pass; - if (Anope::Decrypt(nc->pass, tmp_pass) == 1) - source.Reply(_("Password for \002%s\002 changed to \002%s\002."), nc->display.c_str(), tmp_pass.c_str()); - else - source.Reply(_("Password for \002%s\002 changed."), nc->display.c_str()); + source.Reply(_("Password for \002%s\002 changed."), nc->display.c_str()); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -275,12 +276,12 @@ class CommandNSSetAutoOp : public Command this->OnSyntaxError(source, "AUTOOP"); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, source.nc->display, params[0]); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { BotInfo *bi = Config->GetClient("ChanServ"); this->SendSyntax(source); @@ -302,12 +303,12 @@ class CommandNSSASetAutoOp : public CommandNSSetAutoOp this->SetSyntax(_("\037nickname\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, params[0], params[1]); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { BotInfo *bi = Config->GetClient("ChanServ"); this->SendSyntax(source); @@ -375,12 +376,12 @@ class CommandNSSetDisplay : public Command source.Reply(NICK_SET_DISPLAY_CHANGED, user_na->nc->display.c_str()); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, source.nc->display, params[0]); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -399,12 +400,12 @@ class CommandNSSASetDisplay : public CommandNSSetDisplay this->SetSyntax(_("\037nickname\037 \037new-display\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, params[0], params[1]); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -521,12 +522,12 @@ class CommandNSSetEmail : public Command } } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, source.nc->display, params.size() ? params[0] : ""); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -546,12 +547,12 @@ class CommandNSSASetEmail : public CommandNSSetEmail this->SetSyntax(_("\037nickname\037 \037address\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, params[0], params.size() > 1 ? params[1] : ""); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -606,12 +607,12 @@ class CommandNSSetKeepModes : public Command this->OnSyntaxError(source, ""); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, source.nc->display, params[0]); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -631,12 +632,12 @@ class CommandNSSASetKeepModes : public CommandNSSetKeepModes this->SetSyntax(_("\037nickname\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, params[0], params[1]); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -726,12 +727,12 @@ class CommandNSSetKill : public Command return; } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, source.nc->display, params[0]); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -760,12 +761,12 @@ class CommandNSSASetKill : public CommandNSSetKill this->SetSyntax(_("\037nickname\037 {ON | QUICK | IMMED | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, params[0], params[1]); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -790,7 +791,7 @@ class CommandNSSetLanguage : public Command public: CommandNSSetLanguage(Module *creator, const Anope::string &sname = "nickserv/set/language", size_t min = 1) : Command(creator, sname, min, min + 1) { - this->SetDesc(_("Set the language Services will use when messaging you")); + this->SetDesc(_("Set the language services will use when messaging you")); this->SetSyntax(_("\037language\037")); } @@ -836,27 +837,27 @@ class CommandNSSetLanguage : public Command source.Reply(_("Language for \002%s\002 changed to \002%s\002."), nc->display.c_str(), Language::Translate(param.c_str(), _("English"))); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶m) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶m) override { this->Run(source, source.nc->display, param[0]); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); - source.Reply(_("Changes the language Services uses when sending messages to\n" + source.Reply(_("Changes the language services uses when sending messages to\n" "you (for example, when responding to a command you send).\n" "\037language\037 should be chosen from the following list of\n" "supported languages:")); source.Reply(" en_US (English)"); - for (unsigned j = 0; j < Language::Languages.size(); ++j) + for (const auto &language : Language::Languages) { - const Anope::string &langname = Language::Translate(Language::Languages[j].c_str(), _("English")); + const Anope::string &langname = Language::Translate(language.c_str(), _("English")); if (langname == "English") continue; - source.Reply(" %s (%s)", Language::Languages[j].c_str(), langname.c_str()); + source.Reply(" %s (%s)", language.c_str(), langname.c_str()); } return true; @@ -872,26 +873,26 @@ class CommandNSSASetLanguage : public CommandNSSetLanguage this->SetSyntax(_("\037nickname\037 \037language\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, params[0], params[1]); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); - source.Reply(_("Changes the language Services uses when sending messages to\n" + source.Reply(_("Changes the language services uses when sending messages to\n" "the given user (for example, when responding to a command they send).\n" "\037language\037 should be chosen from the following list of\n" "supported languages:")); source.Reply(" en (English)"); - for (unsigned j = 0; j < Language::Languages.size(); ++j) + for (const auto &language : Language::Languages) { - const Anope::string &langname = Language::Translate(Language::Languages[j].c_str(), _("English")); + const Anope::string &langname = Language::Translate(language.c_str(), _("English")); if (langname == "English") continue; - source.Reply(" %s (%s)", Language::Languages[j].c_str(), langname.c_str()); + source.Reply(" %s (%s)", language.c_str(), langname.c_str()); } return true; } @@ -902,7 +903,7 @@ class CommandNSSetMessage : public Command public: CommandNSSetMessage(Module *creator, const Anope::string &sname = "nickserv/set/message", size_t min = 1) : Command(creator, sname, min, min + 1) { - this->SetDesc(_("Change the communication method of Services")); + this->SetDesc(_("Change the communication method of services")); this->SetSyntax("{ON | OFF}"); } @@ -949,12 +950,12 @@ class CommandNSSetMessage : public Command this->OnSyntaxError(source, "MSG"); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, source.nc->display, params[0]); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { Anope::string cmd = source.command; size_t i = cmd.find_last_of(' '); @@ -963,13 +964,13 @@ class CommandNSSetMessage : public Command this->SendSyntax(source); source.Reply(" "); - source.Reply(_("Allows you to choose the way Services are communicating with\n" - "you. With \002%s\002 set, Services will use messages, else they'll\n" + source.Reply(_("Allows you to choose the way services are communicating with\n" + "you. With \002%s\002 set, services will use messages, else they'll\n" "use notices."), cmd.upper().c_str()); return true; } - void OnServHelp(CommandSource &source) anope_override + void OnServHelp(CommandSource &source) override { if (Config->GetBlock("options")->Get<bool>("useprivmsg")) Command::OnServHelp(source); @@ -985,17 +986,17 @@ class CommandNSSASetMessage : public CommandNSSetMessage this->SetSyntax(_("\037nickname\037 {ON | OFF}")); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); - source.Reply(_("Allows you to choose the way Services are communicating with\n" - "the given user. With \002MSG\002 set, Services will use messages,\n" + source.Reply(_("Allows you to choose the way services are communicating with\n" + "the given user. With \002MSG\002 set, services will use messages,\n" "else they'll use notices.")); return true; } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, params[0], params[1]); } @@ -1047,12 +1048,12 @@ class CommandNSSetSecure : public Command this->OnSyntaxError(source, "SECURE"); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, source.nc->display, params[0]); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -1076,12 +1077,12 @@ class CommandNSSASetSecure : public CommandNSSetSecure this->SetSyntax(_("\037nickname\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, params[0], params[1]); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -1105,7 +1106,7 @@ class CommandNSSASetNoexpire : public Command this->SetSyntax(_("\037nickname\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { @@ -1138,7 +1139,7 @@ class CommandNSSASetNoexpire : public Command this->OnSyntaxError(source, "NOEXPIRE"); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); @@ -1189,7 +1190,7 @@ class NSSet : public Module { KeepModes(Module *m, const Anope::string &n) : SerializableExtensibleItem<bool>(m, n) { } - void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const anope_override + void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const override { SerializableExtensibleItem<bool>::ExtensibleSerialize(e, s, data); @@ -1198,18 +1199,18 @@ class NSSet : public Module const NickCore *nc = anope_dynamic_static_cast<const NickCore *>(s); Anope::string modes; - for (User::ModeList::const_iterator it = nc->last_modes.begin(); it != nc->last_modes.end(); ++it) + for (const auto &[last_mode, last_value] : nc->last_modes) { if (!modes.empty()) modes += " "; - modes += it->first; - if (!it->second.empty()) - modes += "," + it->second; + modes += last_mode; + if (!last_value.empty()) + modes += "," + last_value; } data["last_modes"] << modes; } - void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) anope_override + void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override { SerializableExtensibleItem<bool>::ExtensibleUnserialize(e, s, data); @@ -1224,9 +1225,9 @@ class NSSet : public Module { size_t c = modes.find(','); if (c == Anope::string::npos) - nc->last_modes.insert(std::make_pair(modes, "")); + nc->last_modes.emplace(modes, ""); else - nc->last_modes.insert(std::make_pair(modes.substr(0, c), modes.substr(c + 1))); + nc->last_modes.emplace(modes.substr(0, c), modes.substr(c + 1)); } } } keep_modes; @@ -1258,7 +1259,7 @@ class NSSet : public Module } - EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) anope_override + EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) override { NickCore *uac = source.nc; @@ -1281,7 +1282,7 @@ class NSSet : public Module return EVENT_CONTINUE; } - void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) anope_override + void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) override { if (chan->ci) { @@ -1290,13 +1291,13 @@ class NSSet : public Module } } - void OnPreNickExpire(NickAlias *na, bool &expire) anope_override + void OnPreNickExpire(NickAlias *na, bool &expire) override { if (noexpire.HasExt(na)) expire = false; } - void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) anope_override + void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) override { if (!show_hidden) return; @@ -1319,29 +1320,28 @@ class NSSet : public Module info.AddOption(_("Keep modes")); } - void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) anope_override + void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) override { if (u->Account() && setter.GetUser() == u) u->Account()->last_modes = u->GetModeList(); } - void OnUserModeUnset(const MessageSource &setter, User *u, const Anope::string &mname) anope_override + void OnUserModeUnset(const MessageSource &setter, User *u, const Anope::string &mname) override { if (u->Account() && setter.GetUser() == u) u->Account()->last_modes = u->GetModeList(); } - void OnUserLogin(User *u) anope_override + void OnUserLogin(User *u) override { if (keep_modes.HasExt(u->Account())) { - User::ModeList modes = u->Account()->last_modes; - for (User::ModeList::iterator it = modes.begin(); it != modes.end(); ++it) + for (const auto &[last_mode, last_value] : u->Account()->last_modes) { - UserMode *um = ModeManager::FindUserModeByName(it->first); + UserMode *um = ModeManager::FindUserModeByName(last_mode); /* if the null user can set the mode, then it's probably safe */ if (um && um->CanSet(NULL)) - u->SetMode(NULL, it->first, it->second); + u->SetMode(NULL, last_mode, last_value); } } } diff --git a/modules/commands/ns_set_misc.cpp b/modules/commands/ns_set_misc.cpp index b8f098443..be2804f04 100644 --- a/modules/commands/ns_set_misc.cpp +++ b/modules/commands/ns_set_misc.cpp @@ -42,7 +42,7 @@ struct NSMiscData : MiscData, Serializable data = d; } - void Serialize(Serialize::Data &sdata) const anope_override + void Serialize(Serialize::Data &sdata) const override { sdata["nc"] << this->object; sdata["name"] << this->name; @@ -135,12 +135,12 @@ class CommandNSSetMisc : public Command } } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, source.nc->display, !params.empty() ? params[0] : ""); } - void OnServHelp(CommandSource &source) anope_override + void OnServHelp(CommandSource &source) override { if (descriptions.count(source.command)) { @@ -149,7 +149,7 @@ class CommandNSSetMisc : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { if (descriptions.count(source.command)) { @@ -170,7 +170,7 @@ class CommandNSSASetMisc : public CommandNSSetMisc this->SetSyntax(_("\037nickname\037 [\037parameter\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->Run(source, params[0], params.size() > 1 ? params[1] : ""); } @@ -189,13 +189,13 @@ class NSSetMisc : public Module me = this; } - ~NSSetMisc() + ~NSSetMisc() override { - for (Anope::map<ExtensibleItem<NSMiscData> *>::iterator it = items.begin(); it != items.end(); ++it) - delete it->second; + for (const auto &[_, data] : items) + delete data; } - void OnReload(Configuration::Conf *conf) anope_override + void OnReload(Configuration::Conf *conf) override { descriptions.clear(); @@ -218,11 +218,10 @@ class NSSetMisc : public Module } } - void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool) anope_override + void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool) override { - for (Anope::map<ExtensibleItem<NSMiscData> *>::iterator it = items.begin(); it != items.end(); ++it) + for (const auto &[_, e] : items) { - ExtensibleItem<NSMiscData> *e = it->second; NSMiscData *data = e->Get(na->nc); if (data != NULL) diff --git a/modules/commands/ns_status.cpp b/modules/commands/ns_status.cpp index a1041be28..017da171d 100644 --- a/modules/commands/ns_status.cpp +++ b/modules/commands/ns_status.cpp @@ -21,7 +21,7 @@ class CommandNSStatus : public Command this->AllowUnregistered(true); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &nick = !params.empty() ? params[0] : source.GetNick(); const NickAlias *na = NickAlias::Find(nick); @@ -48,7 +48,7 @@ class CommandNSStatus : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ns_suspend.cpp b/modules/commands/ns_suspend.cpp index 8db57e532..28ca99b68 100644 --- a/modules/commands/ns_suspend.cpp +++ b/modules/commands/ns_suspend.cpp @@ -18,7 +18,7 @@ struct NSSuspendInfo : SuspendInfo, Serializable { NSSuspendInfo(Extensible *) : Serializable("NSSuspendInfo") { } - void Serialize(Serialize::Data &data) const anope_override + void Serialize(Serialize::Data &data) const override { data["nick"] << what; data["by"] << by; @@ -61,7 +61,7 @@ class CommandNSSuspend : public Command this->SetSyntax(_("\037nickname\037 [+\037expiry\037] [\037reason\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &nick = params[0]; @@ -116,10 +116,8 @@ class CommandNSSuspend : public Command si->when = Anope::CurTime; si->expires = expiry_secs ? expiry_secs + Anope::CurTime : 0; - for (unsigned i = 0; i < nc->aliases->size(); ++i) + for (auto *na2 : *nc->aliases) { - NickAlias *na2 = nc->aliases->at(i); - if (na2 && *na2->nc == *na->nc) { na2->last_quit = reason; @@ -140,7 +138,7 @@ class CommandNSSuspend : public Command FOREACH_MOD(OnNickSuspend, (na)); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -161,7 +159,7 @@ class CommandNSUnSuspend : public Command this->SetSyntax(_("\037nickname\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &nick = params[0]; @@ -192,7 +190,7 @@ class CommandNSUnSuspend : public Command FOREACH_MOD(OnNickUnsuspended, (na)); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -229,14 +227,14 @@ class NSSuspend : public Module { } - void OnReload(Configuration::Conf *conf) anope_override + void OnReload(Configuration::Conf *conf) override { Anope::string s = conf->GetModule(this)->Get<Anope::string>("show"); commasepstream(s).GetTokens(show); std::transform(show.begin(), show.end(), show.begin(), trim()); } - void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) anope_override + void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) override { NSSuspendInfo *s = suspend.Get(na->nc); if (!s) @@ -254,7 +252,7 @@ class NSSuspend : public Module info[_("Suspension expires")] = Anope::strftime(s->expires, source.GetAccount()); } - void OnPreNickExpire(NickAlias *na, bool &expire) anope_override + void OnPreNickExpire(NickAlias *na, bool &expire) override { NSSuspendInfo *s = suspend.Get(na->nc); if (!s) @@ -274,7 +272,7 @@ class NSSuspend : public Module } } - EventReturn OnNickValidate(User *u, NickAlias *na) anope_override + EventReturn OnNickValidate(User *u, NickAlias *na) override { NSSuspendInfo *s = suspend.Get(na->nc); if (!s) diff --git a/modules/commands/ns_update.cpp b/modules/commands/ns_update.cpp index 86a862a2a..0d6a1f4c0 100644 --- a/modules/commands/ns_update.cpp +++ b/modules/commands/ns_update.cpp @@ -20,7 +20,7 @@ class CommandNSUpdate : public Command this->RequireUser(true); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { User *u = source.GetUser(); NickAlias *na = NickAlias::Find(u->nick); @@ -36,7 +36,7 @@ class CommandNSUpdate : public Command source.Reply(_("Status updated (memos, vhost, chmodes, flags).")); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/os_akill.cpp b/modules/commands/os_akill.cpp index 899c2410e..31f96b507 100644 --- a/modules/commands/os_akill.cpp +++ b/modules/commands/os_akill.cpp @@ -16,14 +16,14 @@ static ServiceReference<XLineManager> akills("XLineManager", "xlinemanager/sglin class AkillDelCallback : public NumberList { CommandSource &source; - unsigned deleted; + unsigned deleted = 0; Command *cmd; public: - AkillDelCallback(CommandSource &_source, const Anope::string &numlist, Command *c) : NumberList(numlist, true), source(_source), deleted(0), cmd(c) + AkillDelCallback(CommandSource &_source, const Anope::string &numlist, Command *c) : NumberList(numlist, true), source(_source), cmd(c) { } - ~AkillDelCallback() + ~AkillDelCallback() override { if (!deleted) source.Reply(_("No matching entries on the AKILL list.")); @@ -33,7 +33,7 @@ class AkillDelCallback : public NumberList source.Reply(_("Deleted %d entries from the AKILL list."), deleted); } - void HandleNumber(unsigned number) anope_override + void HandleNumber(unsigned number) override { if (!number) return; @@ -172,8 +172,8 @@ class CommandOSAKill : public Command x->id = XLineManager::GenerateUID(); unsigned int affected = 0; - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) - if (akills->Check(it->second, x)) + for (const auto &[_, user] : UserListByNick) + if (akills->Check(user, x)) ++affected; float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0; @@ -271,7 +271,7 @@ class CommandOSAKill : public Command { } - void HandleNumber(unsigned number) anope_override + void HandleNumber(unsigned number) override { if (!number) return; @@ -325,8 +325,8 @@ class CommandOSAKill : public Command std::vector<Anope::string> replies; list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); source.Reply(_("End of AKILL list.")); } @@ -390,7 +390,7 @@ class CommandOSAKill : public Command this->SetSyntax("CLEAR"); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &cmd = params[0]; @@ -413,7 +413,7 @@ class CommandOSAKill : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/os_chankill.cpp b/modules/commands/os_chankill.cpp index e53f17629..a22eae178 100644 --- a/modules/commands/os_chankill.cpp +++ b/modules/commands/os_chankill.cpp @@ -22,7 +22,7 @@ class CommandOSChanKill : public Command this->SetSyntax(_("[+\037expiry\037] \037channel\037 \037reason\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (!akills) return; @@ -69,10 +69,8 @@ class CommandOSChanKill : public Command if ((c = Channel::Find(channel))) { - for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) + for (const auto &[_, uc] : c->users) { - ChanUserContainer *uc = it->second; - if (uc->user->server == Me || uc->user->HasMode("OPER")) continue; @@ -93,7 +91,7 @@ class CommandOSChanKill : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/os_config.cpp b/modules/commands/os_config.cpp index d54730462..3f211d695 100644 --- a/modules/commands/os_config.cpp +++ b/modules/commands/os_config.cpp @@ -20,7 +20,7 @@ class CommandOSConfig : public Command this->SetSyntax(_("{\037MODIFY\037|\037VIEW\037} [\037block name\037 \037item name\037 \037item value\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &what = params[0]; @@ -57,19 +57,16 @@ class CommandOSConfig : public Command for (unsigned i = 0; !show_blocks[i].empty(); ++i) { Configuration::Block *block = Config->GetBlock(show_blocks[i]); - const Configuration::Block::item_map *items = block->GetItems(); - - if (!items) - continue; + const Configuration::Block::item_map &items = block->GetItems(); ListFormatter lflist(source.GetAccount()); lflist.AddColumn(_("Name")).AddColumn(_("Value")); - for (Configuration::Block::item_map::const_iterator it = items->begin(), it_end = items->end(); it != it_end; ++it) + for (const auto &[name, value] : items) { ListFormatter::ListEntry entry; - entry["Name"] = it->first; - entry["Value"] = it->second; + entry["Name"] = name; + entry["Value"] = value; lflist.AddEntry(entry); } @@ -78,8 +75,8 @@ class CommandOSConfig : public Command source.Reply(_("%s settings:"), block->GetName().c_str()); - for (unsigned j = 0; j < replies.size(); ++j) - source.Reply(replies[j]); + for (const auto &reply : replies) + source.Reply(reply); source.Reply(" "); } @@ -90,18 +87,18 @@ class CommandOSConfig : public Command for (int i = 0; i < Config->CountBlock("module"); ++i) { Configuration::Block *block = Config->GetBlock("module", i); - const Configuration::Block::item_map *items = block->GetItems(); + const Configuration::Block::item_map &items = block->GetItems(); - if (!items || items->size() <= 1) + if (items.size() <= 1) continue; ListFormatter::ListEntry entry; entry["Module Name"] = block->Get<Anope::string>("name"); - for (Configuration::Block::item_map::const_iterator it = items->begin(), it_end = items->end(); it != it_end; ++it) + for (const auto &[name, value] : items) { - entry["Name"] = it->first; - entry["Value"] = it->second; + entry["Name"] = name; + entry["Value"] = value; lflist.AddEntry(entry); } } @@ -111,8 +108,8 @@ class CommandOSConfig : public Command source.Reply(_("Module settings:")); - for (unsigned j = 0; j < replies.size(); ++j) - source.Reply(replies[j]); + for (const auto &reply : replies) + source.Reply(reply); source.Reply(_("End of configuration.")); } @@ -120,7 +117,7 @@ class CommandOSConfig : public Command this->OnSyntaxError(source, what); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/os_defcon.cpp b/modules/commands/os_defcon.cpp index 7b89e6957..8a93a7f7b 100644 --- a/modules/commands/os_defcon.cpp +++ b/modules/commands/os_defcon.cpp @@ -72,7 +72,7 @@ struct DefconConfig bool SetDefConParam(const Anope::string &name, const Anope::string &buf) { - return DefConModesOnParams.insert(std::make_pair(name, buf)).second; + return DefConModesOnParams.emplace(name, buf).second; } void UnsetDefConParam(const Anope::string &name) @@ -115,12 +115,12 @@ class DefConTimeout : public Timer timeout = this; } - ~DefConTimeout() + ~DefConTimeout() override { timeout = NULL; } - void Tick(time_t) anope_override + void Tick(time_t) override { if (DConfig.defaultlevel != level) { @@ -177,7 +177,7 @@ class CommandOSDefcon : public Command this->SetSyntax(_("[\0021\002|\0022\002|\0023\002|\0024\002|\0025\002]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &lvl = params[0]; @@ -233,7 +233,7 @@ class CommandOSDefcon : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -253,7 +253,6 @@ class OSDefcon : public Module void ParseModeString() { int add = -1; /* 1 if adding, 0 if deleting, -1 if neither */ - unsigned char mode; ChannelMode *cm; ChannelModeParam *cmp; Anope::string modes, param; @@ -265,10 +264,8 @@ class OSDefcon : public Module ss.GetToken(modes); /* Loop while there are modes to set */ - for (unsigned i = 0, end = modes.length(); i < end; ++i) + for (auto mode : modes) { - mode = modes[i]; - switch (mode) { case '+': @@ -335,7 +332,7 @@ class OSDefcon : public Module } - void OnReload(Configuration::Conf *conf) anope_override + void OnReload(Configuration::Conf *conf) override { Configuration::Block *block = conf->GetModule(this); DefconConfig dconfig; @@ -406,7 +403,7 @@ class OSDefcon : public Module this->ParseModeString(); } - EventReturn OnChannelModeSet(Channel *c, MessageSource &source, ChannelMode *mode, const Anope::string ¶m) anope_override + EventReturn OnChannelModeSet(Channel *c, MessageSource &source, ChannelMode *mode, const Anope::string ¶m) override { if (DConfig.Check(DEFCON_FORCE_CHAN_MODES) && DConfig.DefConModesOff.count(mode->name) && source.GetUser() && !source.GetBot()) { @@ -418,7 +415,7 @@ class OSDefcon : public Module return EVENT_CONTINUE; } - EventReturn OnChannelModeUnset(Channel *c, MessageSource &source, ChannelMode *mode, const Anope::string &) anope_override + EventReturn OnChannelModeUnset(Channel *c, MessageSource &source, ChannelMode *mode, const Anope::string &) override { if (DConfig.Check(DEFCON_FORCE_CHAN_MODES) && DConfig.DefConModesOn.count(mode->name) && source.GetUser() && !source.GetBot()) { @@ -436,7 +433,7 @@ class OSDefcon : public Module return EVENT_CONTINUE; } - EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) anope_override + EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) override { if (DConfig.Check(DEFCON_OPER_ONLY) && !source.IsOper()) { @@ -483,7 +480,7 @@ class OSDefcon : public Module return EVENT_CONTINUE; } - void OnUserConnect(User *u, bool &exempt) anope_override + void OnUserConnect(User *u, bool &exempt) override { if (exempt || u->Quitting() || !u->server->IsSynced() || u->server->IsULined()) return; @@ -535,13 +532,13 @@ class OSDefcon : public Module } } - void OnChannelModeAdd(ChannelMode *cm) anope_override + void OnChannelModeAdd(ChannelMode *cm) override { if (DConfig.chanmodes.find(cm->mchar) != Anope::string::npos) this->ParseModeString(); } - void OnChannelSync(Channel *c) anope_override + void OnChannelSync(Channel *c) override { if (DConfig.Check(DEFCON_FORCE_CHAN_MODES)) c->SetModes(Config->GetClient("OperServ"), false, "%s", DConfig.chanmodes.c_str()); @@ -559,8 +556,8 @@ static void runDefCon() { Log(OperServ, "operserv/defcon") << "DEFCON: setting " << DConfig.chanmodes << " on all channels"; DefConModesSet = true; - for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it) - it->second->SetModes(OperServ, false, "%s", DConfig.chanmodes.c_str()); + for (const auto &[_, chan] : ChannelList) + chan->SetModes(OperServ, false, "%s", DConfig.chanmodes.c_str()); } } } @@ -575,8 +572,8 @@ static void runDefCon() if (!newmodes.empty()) { Log(OperServ, "operserv/defcon") << "DEFCON: setting " << newmodes << " on all channels"; - for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it) - it->second->SetModes(OperServ, true, "%s", newmodes.c_str()); + for (const auto &[_, chan] : ChannelList) + chan->SetModes(OperServ, true, "%s", newmodes.c_str()); } } } @@ -588,14 +585,14 @@ static Anope::string defconReverseModes(const Anope::string &modes) if (modes.empty()) return ""; Anope::string newmodes; - for (unsigned i = 0, end = modes.length(); i < end; ++i) + for (auto mode : modes) { - if (modes[i] == '+') + if (mode == '+') newmodes += '-'; - else if (modes[i] == '-') + else if (mode == '-') newmodes += '+'; else - newmodes += modes[i]; + newmodes += mode; } return newmodes; } diff --git a/modules/commands/os_dns.cpp b/modules/commands/os_dns.cpp index b01690577..c297ec062 100644 --- a/modules/commands/os_dns.cpp +++ b/modules/commands/os_dns.cpp @@ -29,19 +29,19 @@ struct DNSZone : Serializable zones->push_back(this); } - ~DNSZone() + ~DNSZone() override { std::vector<DNSZone *>::iterator it = std::find(zones->begin(), zones->end(), this); if (it != zones->end()) zones->erase(it); } - void Serialize(Serialize::Data &data) const anope_override + void Serialize(Serialize::Data &data) const override { data["name"] << name; unsigned count = 0; - for (std::set<Anope::string, ci::less>::iterator it = servers.begin(), it_end = servers.end(); it != it_end; ++it) - data["server" + stringify(count++)] << *it; + for (const auto &server : servers) + data["server" + stringify(count++)] << server; } static Serializable* Unserialize(Serializable *obj, Serialize::Data &data) @@ -74,13 +74,14 @@ struct DNSZone : Serializable static DNSZone *Find(const Anope::string &name) { - for (unsigned i = 0; i < zones->size(); ++i) - if (zones->at(i)->name.equals_ci(name)) + for (auto *zone : *zones) + { + if (zone->name.equals_ci(name)) { - DNSZone *z = zones->at(i); - z->QueueUpdate(); - return z; + zone->QueueUpdate(); + return zone; } + } return NULL; } }; @@ -89,22 +90,22 @@ class DNSServer : public Serializable { Anope::string server_name; std::vector<Anope::string> ips; - unsigned limit; + unsigned limit = 0; /* wants to be in the pool */ - bool pooled; + bool pooled = false; /* is actually in the pool */ - bool active; + bool active = false; public: std::set<Anope::string, ci::less> zones; - time_t repool; + time_t repool = 0; - DNSServer(const Anope::string &sn) : Serializable("DNSServer"), server_name(sn), limit(0), pooled(false), active(false), repool(0) + DNSServer(const Anope::string &sn) : Serializable("DNSServer"), server_name(sn) { dns_servers->push_back(this); } - ~DNSServer() + ~DNSServer() override { std::vector<DNSServer *>::iterator it = std::find(dns_servers->begin(), dns_servers->end(), this); if (it != dns_servers->end()) @@ -134,12 +135,12 @@ class DNSServer : public Serializable if (dnsmanager) { dnsmanager->UpdateSerial(); - for (std::set<Anope::string, ci::less>::iterator it = zones.begin(), it_end = zones.end(); it != it_end; ++it) - dnsmanager->Notify(*it); + for (const auto &zone : zones) + dnsmanager->Notify(zone); } } - void Serialize(Serialize::Data &data) const anope_override + void Serialize(Serialize::Data &data) const override { data["server_name"] << server_name; for (unsigned i = 0; i < ips.size(); ++i) @@ -147,8 +148,8 @@ class DNSServer : public Serializable data["limit"] << limit; data["pooled"] << pooled; unsigned count = 0; - for (std::set<Anope::string, ci::less>::iterator it = zones.begin(), it_end = zones.end(); it != it_end; ++it) - data["zone" + stringify(count++)] << *it; + for (const auto &zone : zones) + data["zone" + stringify(count++)] << zone; } static Serializable* Unserialize(Serializable *obj, Serialize::Data &data) @@ -193,10 +194,9 @@ class DNSServer : public Serializable static DNSServer *Find(const Anope::string &s) { - for (unsigned i = 0; i < dns_servers->size(); ++i) - if (dns_servers->at(i)->GetName().equals_ci(s)) + for (auto *serv : *dns_servers) + if (serv->GetName().equals_ci(s)) { - DNSServer *serv = dns_servers->at(i); serv->QueueUpdate(); return serv; } @@ -216,9 +216,8 @@ class CommandOSDNS : public Command ListFormatter lf(source.GetAccount()); lf.AddColumn(_("Server")).AddColumn(_("IP")).AddColumn(_("Limit")).AddColumn(_("State")); - for (unsigned i = 0; i < dns_servers->size(); ++i) + for (auto *s : *dns_servers) { - DNSServer *s = dns_servers->at(i); Server *srv = Server::Find(s->GetName(), true); ListFormatter::ListEntry entry; @@ -226,8 +225,8 @@ class CommandOSDNS : public Command entry["Limit"] = s->GetLimit() ? stringify(s->GetLimit()) : Language::Translate(source.GetAccount(), _("None")); Anope::string ip_str; - for (unsigned j = 0; j < s->GetIPs().size(); ++j) - ip_str += s->GetIPs()[j] + " "; + for (const auto &ip : s->GetIPs()) + ip_str += ip + " "; ip_str.trim(); if (ip_str.empty()) ip_str = "None"; @@ -254,16 +253,14 @@ class CommandOSDNS : public Command ListFormatter lf2(source.GetAccount()); lf2.AddColumn(_("Zone")).AddColumn(_("Servers")); - for (unsigned i = 0; i < zones->size(); ++i) + for (auto *z : *zones) { - const DNSZone *z = zones->at(i); - ListFormatter::ListEntry entry; entry["Zone"] = z->name; Anope::string server_str; - for (std::set<Anope::string, ci::less>::iterator it = z->servers.begin(), it_end = z->servers.end(); it != it_end; ++it) - server_str += *it + " "; + for (const auto &server : z->servers) + server_str += server + " "; server_str.trim(); if (server_str.empty()) @@ -277,8 +274,8 @@ class CommandOSDNS : public Command lf2.Process(replies); } - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); } void AddZone(CommandSource &source, const std::vector<Anope::string> ¶ms) @@ -316,9 +313,9 @@ class CommandOSDNS : public Command Log(LOG_ADMIN, source, this) << "to delete zone " << z->name; - for (std::set<Anope::string, ci::less>::iterator it = z->servers.begin(), it_end = z->servers.end(); it != it_end; ++it) + for (const auto &server : z->servers) { - DNSServer *s = DNSServer::Find(*it); + DNSServer *s = DNSServer::Find(server); if (s) s->zones.erase(z->name); } @@ -466,9 +463,9 @@ class CommandOSDNS : public Command return; } - for (std::set<Anope::string, ci::less>::iterator it = s->zones.begin(), it_end = s->zones.end(); it != it_end; ++it) + for (const auto &zone : s->zones) { - DNSZone *z = DNSZone::Find(*it); + DNSZone *z = DNSZone::Find(zone); if (z) z->servers.erase(s->GetName()); } @@ -494,12 +491,14 @@ class CommandOSDNS : public Command return; } - for (unsigned i = 0; i < s->GetIPs().size(); ++i) - if (params[2].equals_ci(s->GetIPs()[i])) + for (const auto &ip : s->GetIPs()) + { + if (params[2].equals_ci(ip)) { - source.Reply(_("IP %s already exists for %s."), s->GetIPs()[i].c_str(), s->GetName().c_str()); + source.Reply(_("IP %s already exists for %s."), ip.c_str(), s->GetName().c_str()); return; } + } sockaddrs addr(params[2]); if (!addr.valid()) @@ -518,8 +517,8 @@ class CommandOSDNS : public Command if (s->Active() && dnsmanager) { dnsmanager->UpdateSerial(); - for (std::set<Anope::string, ci::less>::iterator it = s->zones.begin(), it_end = s->zones.end(); it != it_end; ++it) - dnsmanager->Notify(*it); + for (const auto &zone : s->zones) + dnsmanager->Notify(zone); } } @@ -552,8 +551,8 @@ class CommandOSDNS : public Command if (s->Active() && dnsmanager) { dnsmanager->UpdateSerial(); - for (std::set<Anope::string, ci::less>::iterator it = s->zones.begin(), it_end = s->zones.end(); it != it_end; ++it) - dnsmanager->Notify(*it); + for (const auto &zone : s->zones) + dnsmanager->Notify(zone); } return; @@ -669,7 +668,7 @@ class CommandOSDNS : public Command this->SetSyntax(_("DEPOOL \037server.name\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (params.empty()) this->DisplayPoolState(source); @@ -695,7 +694,7 @@ class CommandOSDNS : public Command this->OnSyntaxError(source, ""); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -729,24 +728,20 @@ class ModuleDNS : public Module bool remove_split_servers; bool readd_connected_servers; - time_t last_warn; + time_t last_warn = 0; public: ModuleDNS(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), - zone_type("DNSZone", DNSZone::Unserialize), dns_type("DNSServer", DNSServer::Unserialize), commandosdns(this), - last_warn(0) + zone_type("DNSZone", DNSZone::Unserialize), dns_type("DNSServer", DNSServer::Unserialize), commandosdns(this) { - - - for (unsigned j = 0; j < dns_servers->size(); ++j) + for (auto *s : *dns_servers) { - DNSServer *s = dns_servers->at(j); if (s->Pooled() && Server::Find(s->GetName(), true)) s->SetActive(true); } } - ~ModuleDNS() + ~ModuleDNS() override { for (unsigned i = zones->size(); i > 0; --i) delete zones->at(i - 1); @@ -754,7 +749,7 @@ class ModuleDNS : public Module delete dns_servers->at(i - 1); } - void OnReload(Configuration::Conf *conf) anope_override + void OnReload(Configuration::Conf *conf) override { Configuration::Block *block = conf->GetModule(this); this->ttl = block->Get<time_t>("ttl"); @@ -765,7 +760,7 @@ class ModuleDNS : public Module this->readd_connected_servers = block->Get<bool>("readd_connected_servers"); } - void OnNewServer(Server *s) anope_override + void OnNewServer(Server *s) override { if (s == Me || s->IsJuped()) return; @@ -780,7 +775,7 @@ class ModuleDNS : public Module } } - void OnServerQuit(Server *s) anope_override + void OnServerQuit(Server *s) override { DNSServer *dns = DNSServer::Find(s->GetName()); if (remove_split_servers && dns && dns->Pooled() && dns->Active()) @@ -793,7 +788,7 @@ class ModuleDNS : public Module } } - void OnUserConnect(User *u, bool &exempt) anope_override + void OnUserConnect(User *u, bool &exempt) override { if (!u->Quitting() && u->server) { @@ -807,7 +802,7 @@ class ModuleDNS : public Module } } - void OnPreUserLogoff(User *u) anope_override + void OnPreUserLogoff(User *u) override { if (u && u->server) { @@ -852,7 +847,7 @@ class ModuleDNS : public Module } } - void OnDnsRequest(DNS::Query &req, DNS::Query *packet) anope_override + void OnDnsRequest(DNS::Query &req, DNS::Query *packet) override { if (req.questions.empty()) return; @@ -865,21 +860,21 @@ class ModuleDNS : public Module size_t answer_size = packet->answers.size(); if (zone) { - for (std::set<Anope::string, ci::less>::iterator it = zone->servers.begin(), it_end = zone->servers.end(); it != it_end; ++it) + for (const auto &server : zone->servers) { - DNSServer *s = DNSServer::Find(*it); + DNSServer *s = DNSServer::Find(server); if (!s || !s->Active()) continue; - for (unsigned j = 0; j < s->GetIPs().size(); ++j) + for (const auto &ip : s->GetIPs()) { - DNS::QueryType q_type = s->GetIPs()[j].find(':') != Anope::string::npos ? DNS::QUERY_AAAA : DNS::QUERY_A; + DNS::QueryType q_type = ip.find(':') != Anope::string::npos ? DNS::QUERY_AAAA : DNS::QUERY_A; if (q.type == DNS::QUERY_AXFR || q.type == DNS::QUERY_ANY || q_type == q.type) { DNS::ResourceRecord rr(q.name, q_type); rr.ttl = this->ttl; - rr.rdata = s->GetIPs()[j]; + rr.rdata = ip; packet->answers.push_back(rr); } } @@ -889,21 +884,20 @@ class ModuleDNS : public Module if (packet->answers.size() == answer_size) { /* Default zone */ - for (unsigned i = 0; i < dns_servers->size(); ++i) + for (auto *s : *dns_servers) { - DNSServer *s = dns_servers->at(i); if (!s->Active()) continue; - for (unsigned j = 0; j < s->GetIPs().size(); ++j) + for (const auto &ip : s->GetIPs()) { - DNS::QueryType q_type = s->GetIPs()[j].find(':') != Anope::string::npos ? DNS::QUERY_AAAA : DNS::QUERY_A; + DNS::QueryType q_type = ip.find(':') != Anope::string::npos ? DNS::QUERY_AAAA : DNS::QUERY_A; if (q.type == DNS::QUERY_AXFR || q.type == DNS::QUERY_ANY || q_type == q.type) { DNS::ResourceRecord rr(q.name, q_type); rr.ttl = this->ttl; - rr.rdata = s->GetIPs()[j]; + rr.rdata = ip; packet->answers.push_back(rr); } } @@ -919,19 +913,17 @@ class ModuleDNS : public Module } /* Something messed up, just return them all and hope one is available */ - for (unsigned i = 0; i < dns_servers->size(); ++i) + for (auto *s : *dns_servers) { - DNSServer *s = dns_servers->at(i); - - for (unsigned j = 0; j < s->GetIPs().size(); ++j) + for (const auto &ip : s->GetIPs()) { - DNS::QueryType q_type = s->GetIPs()[j].find(':') != Anope::string::npos ? DNS::QUERY_AAAA : DNS::QUERY_A; + DNS::QueryType q_type = ip.find(':') != Anope::string::npos ? DNS::QUERY_AAAA : DNS::QUERY_A; if (q.type == DNS::QUERY_AXFR || q.type == DNS::QUERY_ANY || q_type == q.type) { DNS::ResourceRecord rr(q.name, q_type); rr.ttl = this->ttl; - rr.rdata = s->GetIPs()[j]; + rr.rdata = ip; packet->answers.push_back(rr); } } diff --git a/modules/commands/os_forbid.cpp b/modules/commands/os_forbid.cpp index 59cb3da3d..c17a719b7 100644 --- a/modules/commands/os_forbid.cpp +++ b/modules/commands/os_forbid.cpp @@ -17,7 +17,7 @@ static ServiceReference<NickServService> nickserv("NickServService", "NickServ") struct ForbidDataImpl : ForbidData, Serializable { ForbidDataImpl() : Serializable("ForbidData") { } - void Serialize(Serialize::Data &data) const anope_override; + void Serialize(Serialize::Data &data) const override; static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); }; @@ -68,19 +68,18 @@ class MyForbidService : public ForbidService public: MyForbidService(Module *m) : ForbidService(m), forbid_data("ForbidData") { } - ~MyForbidService() + ~MyForbidService() override { - std::vector<ForbidData *> f = GetForbids(); - for (unsigned i = 0; i < f.size(); ++i) - delete f[i]; + for (const auto *forbid : GetForbids()) + delete forbid; } - void AddForbid(ForbidData *d) anope_override + void AddForbid(ForbidData *d) override { this->forbids(d->type).push_back(d); } - void RemoveForbid(ForbidData *d) anope_override + void RemoveForbid(ForbidData *d) override { std::vector<ForbidData *>::iterator it = std::find(this->forbids(d->type).begin(), this->forbids(d->type).end(), d); if (it != this->forbids(d->type).end()) @@ -88,12 +87,12 @@ class MyForbidService : public ForbidService delete d; } - ForbidData *CreateForbid() anope_override + ForbidData *CreateForbid() override { return new ForbidDataImpl(); } - ForbidData *FindForbid(const Anope::string &mask, ForbidType ftype) anope_override + ForbidData *FindForbid(const Anope::string &mask, ForbidType ftype) override { for (unsigned i = this->forbids(ftype).size(); i > 0; --i) { @@ -105,7 +104,7 @@ class MyForbidService : public ForbidService return NULL; } - ForbidData *FindForbidExact(const Anope::string &mask, ForbidType ftype) anope_override + ForbidData *FindForbidExact(const Anope::string &mask, ForbidType ftype) override { for (unsigned i = this->forbids(ftype).size(); i > 0; --i) { @@ -117,7 +116,7 @@ class MyForbidService : public ForbidService return NULL; } - std::vector<ForbidData *> GetForbids() anope_override + std::vector<ForbidData *> GetForbids() override { std::vector<ForbidData *> f; for (unsigned j = FT_NICK; j < FT_SIZE; ++j) @@ -159,7 +158,7 @@ class CommandOSForbid : public Command this->SetSyntax("LIST [NICK|CHAN|EMAIL|REGISTER]"); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (!this->fs) return; @@ -245,8 +244,8 @@ class CommandOSForbid : public Command { int na_matches = 0; - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) - module->OnUserNickChange(it->second, ""); + for (const auto &[_, user] : UserListByNick) + module->OnUserNickChange(user, ""); for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end;) { @@ -358,31 +357,29 @@ class CommandOSForbid : public Command list.AddColumn(_("Mask")).AddColumn(_("Type")).AddColumn(_("Creator")).AddColumn(_("Expires")).AddColumn(_("Reason")); unsigned shown = 0; - for (unsigned i = 0; i < forbids.size(); ++i) + for (auto *forbid : forbids) { - ForbidData *d = forbids[i]; - - if (ftype != FT_SIZE && ftype != d->type) + if (ftype != FT_SIZE && ftype != forbid->type) continue; Anope::string stype; - if (d->type == FT_NICK) + if (forbid->type == FT_NICK) stype = "NICK"; - else if (d->type == FT_CHAN) + else if (forbid->type == FT_CHAN) stype = "CHAN"; - else if (d->type == FT_EMAIL) + else if (forbid->type == FT_EMAIL) stype = "EMAIL"; - else if (d->type == FT_REGISTER) + else if (forbid->type == FT_REGISTER) stype = "REGISTER"; else continue; ListFormatter::ListEntry entry; - entry["Mask"] = d->mask; + entry["Mask"] = forbid->mask; entry["Type"] = stype; - entry["Creator"] = d->creator; - entry["Expires"] = d->expires ? Anope::strftime(d->expires, NULL, true).c_str() : Language::Translate(source.GetAccount(), _("Never")); - entry["Reason"] = d->reason; + entry["Creator"] = forbid->creator; + entry["Expires"] = forbid->expires ? Anope::strftime(forbid->expires, NULL, true).c_str() : Language::Translate(source.GetAccount(), _("Never")); + entry["Reason"] = forbid->reason; list.AddEntry(entry); ++shown; } @@ -398,8 +395,8 @@ class CommandOSForbid : public Command std::vector<Anope::string> replies; list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); if (shown >= forbids.size()) source.Reply(_("End of forbid list.")); @@ -414,7 +411,7 @@ class CommandOSForbid : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -446,7 +443,7 @@ class OSForbid : public Module } - void OnUserConnect(User *u, bool &exempt) anope_override + void OnUserConnect(User *u, bool &exempt) override { if (u->Quitting() || exempt) return; @@ -454,7 +451,7 @@ class OSForbid : public Module this->OnUserNickChange(u, ""); } - void OnUserNickChange(User *u, const Anope::string &) anope_override + void OnUserNickChange(User *u, const Anope::string &) override { if (u->HasMode("OPER")) return; @@ -472,7 +469,7 @@ class OSForbid : public Module } } - EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) anope_override + EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) override { BotInfo *OperServ = Config->GetClient("OperServ"); if (u->HasMode("OPER") || !OperServ) @@ -501,7 +498,7 @@ class OSForbid : public Module return EVENT_CONTINUE; } - EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) anope_override + EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) override { if (command->name == "nickserv/info" && params.size() > 0) { diff --git a/modules/commands/os_ignore.cpp b/modules/commands/os_ignore.cpp index cacfccff6..f779840fb 100644 --- a/modules/commands/os_ignore.cpp +++ b/modules/commands/os_ignore.cpp @@ -15,8 +15,8 @@ struct IgnoreDataImpl : IgnoreData, Serializable { IgnoreDataImpl() : Serializable("IgnoreData") { } - ~IgnoreDataImpl(); - void Serialize(Serialize::Data &data) const anope_override; + ~IgnoreDataImpl() override; + void Serialize(Serialize::Data &data) const override; static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); }; @@ -64,19 +64,19 @@ class OSIgnoreService : public IgnoreService public: OSIgnoreService(Module *o) : IgnoreService(o), ignores("IgnoreData") { } - void AddIgnore(IgnoreData *ign) anope_override + void AddIgnore(IgnoreData *ign) override { ignores->push_back(ign); } - void DelIgnore(IgnoreData *ign) anope_override + void DelIgnore(IgnoreData *ign) override { std::vector<IgnoreData *>::iterator it = std::find(ignores->begin(), ignores->end(), ign); if (it != ignores->end()) ignores->erase(it); } - void ClearIgnores() anope_override + void ClearIgnores() override { for (unsigned i = ignores->size(); i > 0; --i) { @@ -85,12 +85,12 @@ class OSIgnoreService : public IgnoreService } } - IgnoreData *Create() anope_override + IgnoreData *Create() override { return new IgnoreDataImpl(); } - IgnoreData *Find(const Anope::string &mask) anope_override + IgnoreData *Find(const Anope::string &mask) override { User *u = User::Find(mask, true); std::vector<IgnoreData *>::iterator ign = this->ignores->begin(), ign_end = this->ignores->end(); @@ -148,7 +148,7 @@ class OSIgnoreService : public IgnoreService return NULL; } - std::vector<IgnoreData *> &GetIgnores() anope_override + std::vector<IgnoreData *> &GetIgnores() override { return *ignores; } @@ -282,8 +282,8 @@ class CommandOSIgnore : public Command std::vector<Anope::string> replies; list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); } } @@ -338,14 +338,14 @@ class CommandOSIgnore : public Command public: CommandOSIgnore(Module *creator) : Command(creator, "operserv/ignore", 1, 4) { - this->SetDesc(_("Modify the Services ignore list")); + this->SetDesc(_("Modify the services ignore list")); this->SetSyntax(_("ADD \037expiry\037 {\037nick\037|\037mask\037} [\037reason\037]")); this->SetSyntax(_("DEL {\037nick\037|\037mask\037}")); this->SetSyntax("LIST"); this->SetSyntax("CLEAR"); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &cmd = params[0]; @@ -363,17 +363,17 @@ class CommandOSIgnore : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); - source.Reply(_("Allows Services Operators to make Services ignore a nick or mask\n" + source.Reply(_("Allows Services Operators to make services ignore a nick or mask\n" "for a certain time or until the next restart. The default\n" "time format is seconds. You can specify it by using units.\n" "Valid units are: \037s\037 for seconds, \037m\037 for minutes,\n" "\037h\037 for hours and \037d\037 for days.\n" "Combinations of these units are not permitted.\n" - "To make Services permanently ignore the user, type 0 as time.\n" + "To make services permanently ignore the user, type 0 as time.\n" "When adding a \037mask\037, it should be in the format nick!user@host,\n" "everything else will be considered a nick. Wildcards are permitted.\n" " \n" @@ -404,7 +404,7 @@ class OSIgnore : public Module } - EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) anope_override + EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) override { if (!u->HasMode("OPER") && this->osignoreservice.Find(u->nick)) return EVENT_STOP; diff --git a/modules/commands/os_info.cpp b/modules/commands/os_info.cpp index 6cfe19cf1..8015f835d 100644 --- a/modules/commands/os_info.cpp +++ b/modules/commands/os_info.cpp @@ -13,15 +13,15 @@ struct OperInfo : Serializable Anope::string target; Anope::string info; Anope::string adder; - time_t created; + time_t created = 0; - OperInfo() : Serializable("OperInfo"), created(0) { } + OperInfo() : Serializable("OperInfo") { } OperInfo(const Anope::string &t, const Anope::string &i, const Anope::string &a, time_t c) : Serializable("OperInfo"), target(t), info(i), adder(a), created(c) { } - ~OperInfo(); + ~OperInfo() override; - void Serialize(Serialize::Data &data) const anope_override + void Serialize(Serialize::Data &data) const override { data["target"] << target; data["info"] << info; @@ -104,7 +104,7 @@ class CommandOSInfo : public Command this->SetSyntax(_("CLEAR \037target\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &cmd = params[0], target = params[1], info = params.size() > 2 ? params[2] : ""; @@ -148,10 +148,8 @@ class CommandOSInfo : public Command return; } - for (unsigned i = 0; i < (*oi)->size(); ++i) + for (auto *o : *(*oi)) { - OperInfo *o = (*oi)->at(i); - if (o->info.equals_ci(info)) { source.Reply(_("The oper info already exists on \002%s\002."), target.c_str()); @@ -236,7 +234,7 @@ class CommandOSInfo : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -262,9 +260,8 @@ class OSInfo : public Module if (!oi) return; - for (unsigned i = 0; i < (*oi)->size(); ++i) + for (auto *o : *(*oi)) { - OperInfo *o = (*oi)->at(i); info[_("Oper Info")] = Anope::printf(_("(by %s on %s) %s"), o->adder.c_str(), Anope::strftime(o->created, source.GetAccount(), true).c_str(), o->info.c_str()); } } @@ -276,12 +273,12 @@ class OSInfo : public Module } - void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) anope_override + void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) override { OnInfo(source, na->nc, info); } - void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) anope_override + void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) override { OnInfo(source, ci, info); } diff --git a/modules/commands/os_jupe.cpp b/modules/commands/os_jupe.cpp index beaba729d..1a773dee9 100644 --- a/modules/commands/os_jupe.cpp +++ b/modules/commands/os_jupe.cpp @@ -20,7 +20,7 @@ class CommandOSJupe : public Command this->SetSyntax(_("\037server\037 [\037reason\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &jserver = params[0]; const Anope::string &reason = params.size() > 1 ? params[1] : ""; @@ -49,12 +49,12 @@ class CommandOSJupe : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); - source.Reply(_("Tells Services to jupiter a server -- that is, to create\n" - "a fake \"server\" connected to Services which prevents\n" + source.Reply(_("Tells services to jupiter a server -- that is, to create\n" + "a fake \"server\" connected to services which prevents\n" "the real server of that name from connecting. The jupe\n" "may be removed using a standard \002SQUIT\002. If a reason is\n" "given, it is placed in the server information field;\n" diff --git a/modules/commands/os_kick.cpp b/modules/commands/os_kick.cpp index 933757ce6..0330bb4ce 100644 --- a/modules/commands/os_kick.cpp +++ b/modules/commands/os_kick.cpp @@ -20,7 +20,7 @@ class CommandOSKick : public Command this->SetSyntax(_("\037channel\037 \037user\037 \037reason\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &chan = params[0]; const Anope::string &nick = params[1]; @@ -55,7 +55,7 @@ class CommandOSKick : public Command Log(LOG_ADMIN, source, this) << "on " << u2->nick << " in " << c->name << " (" << s << ")"; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/os_kill.cpp b/modules/commands/os_kill.cpp index 7782f3579..4f9abd300 100644 --- a/modules/commands/os_kill.cpp +++ b/modules/commands/os_kill.cpp @@ -20,7 +20,7 @@ class CommandOSKill : public Command this->SetSyntax(_("\037user\037 [\037reason\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &nick = params[0]; Anope::string reason = params.size() > 1 ? params[1] : ""; @@ -41,7 +41,7 @@ class CommandOSKill : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/os_list.cpp b/modules/commands/os_list.cpp index 0d1a73ec3..163044210 100644 --- a/modules/commands/os_list.cpp +++ b/modules/commands/os_list.cpp @@ -20,7 +20,7 @@ class CommandOSChanList : public Command this->SetSyntax(_("[{\037pattern\037 | \037nick\037} [\037SECRET\037]]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &pattern = !params.empty() ? params[0] : ""; const Anope::string &opt = params.size() > 1 ? params[1] : ""; @@ -46,14 +46,16 @@ class CommandOSChanList : public Command { source.Reply(_("\002%s\002 channel list:"), u2->nick.c_str()); - for (User::ChanUserList::iterator uit = u2->chans.begin(), uit_end = u2->chans.end(); uit != uit_end; ++uit) + for (const auto &[_, cc]: u2->chans) { - ChanUserContainer *cc = uit->second; - if (!modes.empty()) - for (std::set<Anope::string>::iterator it = modes.begin(), it_end = modes.end(); it != it_end; ++it) - if (!cc->chan->HasMode(*it)) + { + for (const auto &mode : modes) + { + if (!cc->chan->HasMode(mode)) continue; + } + } ListFormatter::ListEntry entry; entry["Name"] = cc->chan->name; @@ -69,16 +71,18 @@ class CommandOSChanList : public Command { source.Reply(_("Channel list:")); - for (channel_map::const_iterator cit = ChannelList.begin(), cit_end = ChannelList.end(); cit != cit_end; ++cit) + for (const auto &[_, c] : ChannelList) { - Channel *c = cit->second; - if (!pattern.empty() && !Anope::Match(c->name, pattern, false, true)) continue; if (!modes.empty()) - for (std::set<Anope::string>::iterator it = modes.begin(), it_end = modes.end(); it != it_end; ++it) - if (!c->HasMode(*it)) + { + for (const auto &mode : modes) + { + if (!c->HasMode(mode)) continue; + } + } ListFormatter::ListEntry entry; entry["Name"] = c->name; @@ -94,13 +98,13 @@ class CommandOSChanList : public Command std::vector<Anope::string> replies; list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); source.Reply(_("End of channel list. \002%u\002 channels shown."), count); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -133,7 +137,7 @@ class CommandOSUserList : public Command this->SetSyntax(_("[{\037pattern\037 | \037channel\037} [\037INVISIBLE\037]]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &pattern = !params.empty() ? params[0] : ""; const Anope::string &opt = params.size() > 1 ? params[1] : ""; @@ -156,14 +160,16 @@ class CommandOSUserList : public Command { source.Reply(_("\002%s\002 users list:"), pattern.c_str()); - for (Channel::ChanUserList::iterator cuit = c->users.begin(), cuit_end = c->users.end(); cuit != cuit_end; ++cuit) + for (const auto &[_, uc] : c->users) { - ChanUserContainer *uc = cuit->second; - if (!modes.empty()) - for (std::set<Anope::string>::iterator it = modes.begin(), it_end = modes.end(); it != it_end; ++it) - if (!uc->user->HasMode(*it)) + { + for (const auto &mode : modes) + { + if (!uc->user->HasMode(mode)) continue; + } + } ListFormatter::ListEntry entry; entry["Name"] = uc->user->nick; @@ -178,8 +184,8 @@ class CommandOSUserList : public Command { /* Historically this has been ordered, so... */ Anope::map<User *> ordered_map; - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) - ordered_map[it->first] = it->second; + for (const auto &[nick, user] : UserListByNick) + ordered_map[nick] = user; source.Reply(_("Users list:")); @@ -197,10 +203,10 @@ class CommandOSUserList : public Command }; bool match = false; - for (unsigned int i = 0; i < sizeof(masks) / sizeof(*masks); ++i) + for (const auto &mask : masks) { /* Check mask with realname included, too */ - if (Anope::Match(masks[i], pattern, false, true) || Anope::Match(masks[i] + "#" + u2->realname, pattern, false, true)) + if (Anope::Match(mask, pattern, false, true) || Anope::Match(mask + "#" + u2->realname, pattern, false, true)) { match = true; break; @@ -211,9 +217,13 @@ class CommandOSUserList : public Command continue; if (!modes.empty()) - for (std::set<Anope::string>::iterator mit = modes.begin(), mit_end = modes.end(); mit != mit_end; ++mit) - if (!u2->HasMode(*mit)) + { + for (const auto &mode : modes) + { + if (!u2->HasMode(mode)) continue; + } + } } ListFormatter::ListEntry entry; @@ -229,14 +239,14 @@ class CommandOSUserList : public Command std::vector<Anope::string> replies; list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); source.Reply(_("End of users list. \002%u\002 users shown."), count); return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/os_login.cpp b/modules/commands/os_login.cpp index ace6d0393..023f1cfe8 100644 --- a/modules/commands/os_login.cpp +++ b/modules/commands/os_login.cpp @@ -20,7 +20,7 @@ class CommandOSLogin : public Command this->RequireUser(true); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &password = params[0]; @@ -45,7 +45,7 @@ class CommandOSLogin : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -55,7 +55,7 @@ class CommandOSLogin : public Command return true; } - const Anope::string GetDesc(CommandSource &source) const anope_override + const Anope::string GetDesc(CommandSource &source) const override { return Anope::printf(Language::Translate(source.GetAccount(), _("Login to %s")), source.service->nick.c_str()); } @@ -69,7 +69,7 @@ class CommandOSLogout : public Command this->RequireUser(true); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { User *u = source.GetUser(); Oper *o = source.nc->o; @@ -87,7 +87,7 @@ class CommandOSLogout : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -97,7 +97,7 @@ class CommandOSLogout : public Command return true; } - const Anope::string GetDesc(CommandSource &source) const anope_override + const Anope::string GetDesc(CommandSource &source) const override { return Anope::printf(Language::Translate(source.GetAccount(), _("Logout from %s")), source.service->nick.c_str()); } @@ -116,7 +116,7 @@ class OSLogin : public Module } - EventReturn IsServicesOper(User *u) anope_override + EventReturn IsServicesOper(User *u) override { if (!u->Account()->o->password.empty()) { diff --git a/modules/commands/os_logsearch.cpp b/modules/commands/os_logsearch.cpp index ea12aea20..ecea323c5 100644 --- a/modules/commands/os_logsearch.cpp +++ b/modules/commands/os_logsearch.cpp @@ -33,7 +33,7 @@ class CommandOSLogSearch : public Command this->SetSyntax(_("[+\037days\037d] [+\037limit\037l] \037pattern\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { int days = 7, replies = 50; @@ -147,16 +147,16 @@ class CommandOSLogSearch : public Command source.Reply(_("Matches for \002%s\002:"), search_string.c_str()); unsigned int count = 0; - for (std::vector<Anope::string>::iterator it = matches.begin(), it_end = matches.end(); it != it_end; ++it) - source.Reply("#%d: %s", ++count, it->c_str()); + for (const auto &match : matches) + source.Reply("#%d: %s", ++count, match.c_str()); source.Reply(_("Showed %d/%d matches for \002%s\002."), matches.size(), found, search_string.c_str()); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); - source.Reply(_("This command searches the Services logfiles for messages\n" + source.Reply(_("This command searches the services logfiles for messages\n" "that match the given pattern. The day and limit argument\n" "may be used to specify how many days of logs to search\n" "and the number of replies to limit to. By default this\n" diff --git a/modules/commands/os_mode.cpp b/modules/commands/os_mode.cpp index 0710065ea..096f50118 100644 --- a/modules/commands/os_mode.cpp +++ b/modules/commands/os_mode.cpp @@ -21,7 +21,7 @@ class CommandOSMode : public Command this->SetSyntax(_("\037channel\037 CLEAR [ALL]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &target = params[0]; const Anope::string &modes = params[1]; @@ -35,9 +35,8 @@ class CommandOSMode : public Command { bool all = params.size() > 2 && params[2].equals_ci("ALL"); - const Channel::ModeList chmodes = c->GetModes(); - for (Channel::ModeList::const_iterator it = chmodes.begin(), it_end = chmodes.end(); it != it_end && c; ++it) - c->RemoveMode(c->WhoSends(), it->first, it->second, false); + for (const auto &[mode, value] : c->GetModes()) + c->RemoveMode(c->WhoSends(), mode, value, false); if (!c) { @@ -47,10 +46,8 @@ class CommandOSMode : public Command if (all) { - for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) + for (const auto &[_, uc] : c->users) { - ChanUserContainer *uc = it->second; - if (uc->user->HasMode("OPER")) continue; @@ -126,7 +123,7 @@ class CommandOSMode : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -147,7 +144,7 @@ class CommandOSUMode : public Command this->SetSyntax(_("\037user\037 \037modes\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &target = params[0]; const Anope::string &modes = params[1]; @@ -166,7 +163,7 @@ class CommandOSUMode : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/os_modinfo.cpp b/modules/commands/os_modinfo.cpp index bed3a63ab..5d6de2e6c 100644 --- a/modules/commands/os_modinfo.cpp +++ b/modules/commands/os_modinfo.cpp @@ -20,7 +20,7 @@ class CommandOSModInfo : public Command this->SetSyntax(_("\037modname\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &file = params[0]; @@ -34,22 +34,18 @@ class CommandOSModInfo : public Command source.Reply(_(" Loaded at: %p"), m->handle); std::vector<Anope::string> servicekeys = Service::GetServiceKeys("Command"); - for (unsigned i = 0; i < servicekeys.size(); ++i) + for (const auto &servicekey : servicekeys) { - ServiceReference<Command> c("Command", servicekeys[i]); + ServiceReference<Command> c("Command", servicekey); if (!c || c->owner != m) continue; source.Reply(_(" Providing service: \002%s\002"), c->name.c_str()); - for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it) + for (const auto &[_, bi] : *BotListByNick) { - const BotInfo *bi = it->second; - - for (CommandInfo::map::const_iterator cit = bi->commands.begin(), cit_end = bi->commands.end(); cit != cit_end; ++cit) + for (const auto &[c_name, info] : bi->commands) { - const Anope::string &c_name = cit->first; - const CommandInfo &info = cit->second; if (info.name != c->name) continue; source.Reply(_(" Command \002%s\002 on \002%s\002 is linked to \002%s\002"), c_name.c_str(), bi->nick.c_str(), c->name.c_str()); @@ -63,7 +59,7 @@ class CommandOSModInfo : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -81,7 +77,7 @@ class CommandOSModList : public Command this->SetSyntax("[all|third|vendor|extra|database|encryption|pseudoclient|protocol]"); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string ¶m = !params.empty() ? params[0] : ""; @@ -116,10 +112,8 @@ class CommandOSModList : public Command source.Reply(_("Current module list:")); int count = 0; - for (std::list<Module *>::iterator it = ModuleManager::Modules.begin(), it_end = ModuleManager::Modules.end(); it != it_end; ++it) + for (auto *m : ModuleManager::Modules) { - Module *m = *it; - bool show = false; Anope::string mtype; @@ -189,7 +183,7 @@ class CommandOSModList : public Command source.Reply(_("%d modules loaded."), count); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/os_module.cpp b/modules/commands/os_module.cpp index 780b127b6..7f20132fa 100644 --- a/modules/commands/os_module.cpp +++ b/modules/commands/os_module.cpp @@ -20,7 +20,7 @@ class CommandOSModLoad : public Command this->SetSyntax(_("\037modname\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &mname = params[0]; @@ -38,7 +38,7 @@ class CommandOSModLoad : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -57,7 +57,7 @@ class CommandOSModReLoad : public Command this->SetSyntax(_("\037modname\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &mname = params[0]; @@ -111,7 +111,7 @@ class CommandOSModReLoad : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -129,7 +129,7 @@ class CommandOSModUnLoad : public Command this->SetSyntax(_("\037modname\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &mname = params[0]; @@ -161,7 +161,7 @@ class CommandOSModUnLoad : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/os_news.cpp b/modules/commands/os_news.cpp index 1c1faafb6..68c9f2629 100644 --- a/modules/commands/os_news.cpp +++ b/modules/commands/os_news.cpp @@ -61,7 +61,7 @@ struct NewsMessages msgarray[] = { struct MyNewsItem : NewsItem { - void Serialize(Serialize::Data &data) const anope_override + void Serialize(Serialize::Data &data) const override { data["type"] << this->type; data["text"] << this->text; @@ -99,24 +99,26 @@ class MyNewsService : public NewsService public: MyNewsService(Module *m) : NewsService(m) { } - ~MyNewsService() + ~MyNewsService() override { - for (unsigned i = 0; i < 3; ++i) - for (unsigned j = 0; j < newsItems[i].size(); ++j) - delete newsItems[i][j]; + for (const auto &newstype : newsItems) + { + for (const auto *newsitem : newstype) + delete newsitem; + } } - NewsItem *CreateNewsItem() anope_override + NewsItem *CreateNewsItem() override { return new MyNewsItem(); } - void AddNewsItem(NewsItem *n) anope_override + void AddNewsItem(NewsItem *n) override { this->newsItems[n->type].push_back(n); } - void DelNewsItem(NewsItem *n) anope_override + void DelNewsItem(NewsItem *n) override { std::vector<NewsItem *> &list = this->GetNewsList(n->type); std::vector<NewsItem *>::iterator it = std::find(list.begin(), list.end(), n); @@ -125,7 +127,7 @@ class MyNewsService : public NewsService delete n; } - std::vector<NewsItem *> &GetNewsList(NewsType t) anope_override + std::vector<NewsItem *> &GetNewsList(NewsType t) override { return this->newsItems[t]; } @@ -134,9 +136,9 @@ class MyNewsService : public NewsService #define lenof(a) (sizeof(a) / sizeof(*(a))) static const char **findmsgs(NewsType type) { - for (unsigned i = 0; i < lenof(msgarray); ++i) - if (msgarray[i].type == type) - return msgarray[i].msgs; + for (auto &msg : msgarray) + if (msg.type == type) + return msg.msgs; return NULL; } @@ -170,8 +172,8 @@ class NewsBase : public Command std::vector<Anope::string> replies; lflist.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); source.Reply(_("End of news list.")); } @@ -280,13 +282,13 @@ class NewsBase : public Command this->SetSyntax("LIST"); } - virtual ~NewsBase() + ~NewsBase() override { } - virtual void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) = 0; + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override = 0; - virtual bool OnHelp(CommandSource &source, const Anope::string &subcommand) = 0; + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override = 0; }; class CommandOSLogonNews : public NewsBase @@ -297,12 +299,12 @@ class CommandOSLogonNews : public NewsBase this->SetDesc(_("Define messages to be shown to users at logon")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { return this->DoNews(source, params, NEWS_LOGON); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -324,12 +326,12 @@ class CommandOSOperNews : public NewsBase this->SetDesc(_("Define messages to be shown to users who oper")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { return this->DoNews(source, params, NEWS_OPER); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -351,12 +353,12 @@ class CommandOSRandomNews : public NewsBase this->SetDesc(_("Define messages to be randomly shown to users at logon")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { return this->DoNews(source, params, NEWS_RANDOM); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -438,20 +440,20 @@ class OSNews : public Module { } - void OnReload(Configuration::Conf *conf) anope_override + void OnReload(Configuration::Conf *conf) override { oper_announcer = conf->GetModule(this)->Get<const Anope::string>("oper_announcer", "OperServ"); announcer = conf->GetModule(this)->Get<const Anope::string>("announcer", "Global"); news_count = conf->GetModule(this)->Get<unsigned>("newscount", "3"); } - void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) anope_override + void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) override { if (mname == "OPER") DisplayNews(u, NEWS_OPER); } - void OnUserConnect(User *user, bool &) anope_override + void OnUserConnect(User *user, bool &) override { if (user->Quitting() || !user->server->IsSynced()) return; diff --git a/modules/commands/os_noop.cpp b/modules/commands/os_noop.cpp index e99be9d78..23cf83142 100644 --- a/modules/commands/os_noop.cpp +++ b/modules/commands/os_noop.cpp @@ -21,7 +21,7 @@ class CommandOSNOOP : public Command this->SetSyntax(_("REVOKE \037server\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &cmd = params[0]; const Anope::string &server = params[1]; @@ -42,10 +42,8 @@ class CommandOSNOOP : public Command Anope::string reason = "NOOP command used by " + source.GetNick(); /* Kill all the IRCops of the server */ - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) + for (const auto &[_, u2] : UserListByNick) { - User *u2 = it->second; - if (u2->server == s && u2->HasMode("OPER")) u2->Kill(*source.service, reason); } @@ -61,7 +59,7 @@ class CommandOSNOOP : public Command this->OnSyntaxError(source, ""); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -85,7 +83,7 @@ class OSNOOP : public Module } - void OnUserModeSet(const MessageSource &, User *u, const Anope::string &mname) anope_override + void OnUserModeSet(const MessageSource &, User *u, const Anope::string &mname) override { Anope::string *setter; if (mname == "OPER" && (setter = noop.Get(u->server))) diff --git a/modules/commands/os_oline.cpp b/modules/commands/os_oline.cpp deleted file mode 100644 index 90d55f628..000000000 --- a/modules/commands/os_oline.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* OperServ core functions - * - * (C) 2003-2023 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - */ - -#include "module.h" - -class CommandOSOLine : public Command -{ - public: - CommandOSOLine(Module *creator) : Command(creator, "operserv/oline", 2, 2) - { - this->SetDesc(_("Give Operflags to a certain user")); - this->SetSyntax(_("\037nick\037 \037flags\037")); - } - - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - const Anope::string &nick = params[0]; - const Anope::string &flag = params[1]; - User *u2 = NULL; - - /* let's check whether the user is online */ - if (!(u2 = User::Find(nick, true))) - source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); - else if (u2 && flag[0] == '+') - { - IRCD->SendSVSO(source.service, nick, flag); - u2->SetMode(source.service, "OPER"); - u2->SendMessage(source.service, _("You are now an IRC Operator.")); - source.Reply(_("Operflags \002%s\002 have been added for \002%s\002."), flag.c_str(), nick.c_str()); - Log(LOG_ADMIN, source, this) << "for " << nick; - } - else if (u2 && flag[0] == '-') - { - IRCD->SendSVSO(source.service, nick, flag); - source.Reply(_("Operflags \002%s\002 have been removed from \002%s\002."), flag.c_str(), nick.c_str()); - Log(LOG_ADMIN, source, this) << "for " << nick; - } - else - this->OnSyntaxError(source, ""); - - return; - } - - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override - { - this->SendSyntax(source); - source.Reply(" "); - source.Reply(_("Allows Services Operators to give Operflags to any user.\n" - "Flags have to be prefixed with a \"+\" or a \"-\". To\n" - "remove all flags simply type a \"-\" instead of any flags.")); - return true; - } -}; - -class OSOLine : public Module -{ - CommandOSOLine commandosoline; - - public: - OSOLine(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandosoline(this) - { - - if (!IRCD || !IRCD->CanSVSO) - throw ModuleException("Your IRCd does not support OMODE."); - - } -}; - -MODULE_INIT(OSOLine) diff --git a/modules/commands/os_oper.cpp b/modules/commands/os_oper.cpp index a60682e48..67612ea74 100644 --- a/modules/commands/os_oper.cpp +++ b/modules/commands/os_oper.cpp @@ -15,7 +15,7 @@ struct MyOper : Oper, Serializable { MyOper(const Anope::string &n, OperType *o) : Oper(n, o), Serializable("Oper") { } - void Serialize(Serialize::Data &data) const anope_override + void Serialize(Serialize::Data &data) const override { data["name"] << this->name; data["type"] << this->ot->GetName(); @@ -50,15 +50,17 @@ class CommandOSOper : public Command { bool HasPrivs(CommandSource &source, OperType *ot) const { - std::list<Anope::string> commands = ot->GetCommands(), privs = ot->GetPrivs(); - - for (std::list<Anope::string>::iterator it = commands.begin(); it != commands.end(); ++it) - if (!source.HasCommand(*it)) + for (const auto &command : ot->GetCommands()) + { + if (!source.HasCommand(command)) return false; + } - for (std::list<Anope::string>::iterator it = privs.begin(); it != privs.end(); ++it) - if (!source.HasPriv(*it)) + for (const auto &priv : ot->GetPrivs()) + { + if (!source.HasPriv(priv)) return false; + } return true; } @@ -73,7 +75,7 @@ class CommandOSOper : public Command this->SetSyntax("LIST"); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &subcommand = params[0]; @@ -151,20 +153,17 @@ class CommandOSOper : public Command else if (subcommand.equals_ci("LIST")) { source.Reply(_("Name Type")); - for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it) + for (const auto &[_, nc] : *NickCoreList) { - const NickCore *nc = it->second; - if (!nc->o) continue; source.Reply(_("%-8s %s"), nc->o->name.c_str(), nc->o->ot->GetName().c_str()); if (std::find(Config->Opers.begin(), Config->Opers.end(), nc->o) != Config->Opers.end()) source.Reply(_(" This oper is configured in the configuration file.")); - for (std::list<User *>::const_iterator uit = nc->users.begin(); uit != nc->users.end(); ++uit) + for (auto *u : nc->users) { - User *u = *uit; - source.Reply(_(" %s is online using this oper block."), u->nick.c_str()); + source.Reply(_(" %s is online using this oper block."), u->nick.c_str()); } } } @@ -173,9 +172,8 @@ class CommandOSOper : public Command if (params.size() < 2) { source.Reply(_("Available opertypes:")); - for (unsigned i = 0; i < Config->MyOperTypes.size(); ++i) + for (auto *ot : Config->MyOperTypes) { - OperType *ot = Config->MyOperTypes[i]; source.Reply("%s", ot->GetName().c_str()); } return; @@ -196,9 +194,9 @@ class CommandOSOper : public Command source.Reply(_("Available commands for \002%s\002:"), ot->GetName().c_str()); Anope::string buf; std::list<Anope::string> cmds = ot->GetCommands(); - for (std::list<Anope::string>::const_iterator it = cmds.begin(), it_end = cmds.end(); it != it_end; ++it) + for (const auto &cmd : cmds) { - buf += *it + " "; + buf += cmd + " "; if (buf.length() > 400) { source.Reply("%s", buf.c_str()); @@ -218,9 +216,9 @@ class CommandOSOper : public Command source.Reply(_("Available privileges for \002%s\002:"), ot->GetName().c_str()); Anope::string buf; std::list<Anope::string> privs = ot->GetPrivs(); - for (std::list<Anope::string>::const_iterator it = privs.begin(), it_end = privs.end(); it != it_end; ++it) + for (const auto &priv : privs) { - buf += *it + " "; + buf += priv + " "; if (buf.length() > 400) { source.Reply("%s", buf.c_str()); @@ -243,7 +241,7 @@ class CommandOSOper : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -265,12 +263,10 @@ class OSOper : public Module { } - ~OSOper() + ~OSOper() override { - for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it) + for (const auto &[_, nc] : *NickCoreList) { - NickCore *nc = it->second; - if (nc->o && dynamic_cast<MyOper *>(nc->o)) { delete nc->o; @@ -279,7 +275,7 @@ class OSOper : public Module } } - void OnDelCore(NickCore *nc) anope_override + void OnDelCore(NickCore *nc) override { if (nc->o && dynamic_cast<MyOper *>(nc->o)) { diff --git a/modules/commands/os_reload.cpp b/modules/commands/os_reload.cpp index 722213f8f..7ae3228e4 100644 --- a/modules/commands/os_reload.cpp +++ b/modules/commands/os_reload.cpp @@ -19,7 +19,7 @@ class CommandOSReload : public Command this->SetDesc(_("Reload services' configuration file")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { try { @@ -40,13 +40,13 @@ class CommandOSReload : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); - source.Reply(_("Causes Services to reload the configuration file. Note that\n" - "some directives still need the restart of the Services to\n" - "take effect (such as Services' nicknames, activation of the\n" + source.Reply(_("Causes services to reload the configuration file. Note that\n" + "some directives still need the restart of the services to\n" + "take effect (such as services' nicknames, activation of the\n" "session limitation, etc.).")); return true; } diff --git a/modules/commands/os_session.cpp b/modules/commands/os_session.cpp index 4dca8eca5..07e1e551f 100644 --- a/modules/commands/os_session.cpp +++ b/modules/commands/os_session.cpp @@ -42,28 +42,27 @@ class MySessionService : public SessionService public: MySessionService(Module *m) : SessionService(m), Exceptions("Exception") { } - Exception *CreateException() anope_override + Exception *CreateException() override { return new Exception(); } - void AddException(Exception *e) anope_override + void AddException(Exception *e) override { this->Exceptions->push_back(e); } - void DelException(Exception *e) anope_override + void DelException(Exception *e) override { ExceptionVector::iterator it = std::find(this->Exceptions->begin(), this->Exceptions->end(), e); if (it != this->Exceptions->end()) this->Exceptions->erase(it); } - Exception *FindException(User *u) anope_override + Exception *FindException(User *u) override { - for (std::vector<Exception *>::const_iterator it = this->Exceptions->begin(), it_end = this->Exceptions->end(); it != it_end; ++it) + for (auto *e : *this->Exceptions) { - Exception *e = *it; if (Anope::Match(u->host, e->mask) || Anope::Match(u->ip.addr(), e->mask)) return e; @@ -73,11 +72,10 @@ class MySessionService : public SessionService return NULL; } - Exception *FindException(const Anope::string &host) anope_override + Exception *FindException(const Anope::string &host) override { - for (std::vector<Exception *>::const_iterator it = this->Exceptions->begin(), it_end = this->Exceptions->end(); it != it_end; ++it) + for (auto *e : *this->Exceptions) { - Exception *e = *it; if (Anope::Match(host, e->mask)) return e; @@ -88,7 +86,7 @@ class MySessionService : public SessionService return NULL; } - ExceptionVector &GetExceptions() anope_override + ExceptionVector &GetExceptions() override { return this->Exceptions; } @@ -98,7 +96,7 @@ class MySessionService : public SessionService this->Sessions.erase(s->addr); } - Session *FindSession(const Anope::string &ip) anope_override + Session *FindSession(const Anope::string &ip) override { cidr c(ip, ip.find(':') != Anope::string::npos ? ipv6_cidr : ipv4_cidr); if (!c.valid()) @@ -122,7 +120,7 @@ class MySessionService : public SessionService return this->Sessions[ip]; } - SessionMap &GetSessions() anope_override + SessionMap &GetSessions() override { return this->Sessions; } @@ -132,14 +130,14 @@ class ExceptionDelCallback : public NumberList { protected: CommandSource &source; - unsigned deleted; + unsigned deleted = 0; Command *cmd; public: - ExceptionDelCallback(CommandSource &_source, const Anope::string &numlist, Command *c) : NumberList(numlist, true), source(_source), deleted(0), cmd(c) + ExceptionDelCallback(CommandSource &_source, const Anope::string &numlist, Command *c) : NumberList(numlist, true), source(_source), cmd(c) { } - ~ExceptionDelCallback() + ~ExceptionDelCallback() override { if (!deleted) source.Reply(_("No matching entries on session-limit exception list.")); @@ -149,7 +147,7 @@ class ExceptionDelCallback : public NumberList source.Reply(_("Deleted %d entries from session-limit exception list."), deleted); } - virtual void HandleNumber(unsigned number) anope_override + void HandleNumber(unsigned number) override { if (!number || number > session_service->GetExceptions().size()) return; @@ -191,10 +189,8 @@ class CommandOSSession : public Command ListFormatter list(source.GetAccount()); list.AddColumn(_("Session")).AddColumn(_("Host")); - for (SessionService::SessionMap::iterator it = session_service->GetSessions().begin(), it_end = session_service->GetSessions().end(); it != it_end; ++it) + for (const auto &[_, session] : session_service->GetSessions()) { - Session *session = it->second; - if (session->count >= mincount) { ListFormatter::ListEntry entry; @@ -210,8 +206,8 @@ class CommandOSSession : public Command list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); } return; @@ -247,7 +243,7 @@ class CommandOSSession : public Command this->SetSyntax(_("VIEW \037host\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &cmd = params[0]; @@ -263,7 +259,7 @@ class CommandOSSession : public Command this->OnSyntaxError(source, ""); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -347,9 +343,8 @@ class CommandOSException : public Command return; } - for (std::vector<Exception *>::iterator it = session_service->GetExceptions().begin(), it_end = session_service->GetExceptions().end(); it != it_end; ++it) + for (auto *e : session_service->GetExceptions()) { - Exception *e = *it; if (e->mask.equals_ci(mask)) { if (e->limit != limit) @@ -445,7 +440,7 @@ class CommandOSException : public Command { } - void HandleNumber(unsigned Number) anope_override + void HandleNumber(unsigned Number) override { if (!Number || Number > session_service->GetExceptions().size()) return; @@ -495,8 +490,8 @@ class CommandOSException : public Command std::vector<Anope::string> replies; list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); } } @@ -526,7 +521,7 @@ class CommandOSException : public Command this->SetSyntax(_("VIEW [\037mask\037 | \037list\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &cmd = params[0]; @@ -544,7 +539,7 @@ class CommandOSException : public Command this->OnSyntaxError(source, ""); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -597,12 +592,12 @@ class OSSession : public Module this->SetPermanent(true); } - void Prioritize() anope_override + void Prioritize() override { ModuleManager::SetPriority(this, PRIORITY_FIRST); } - void OnReload(Configuration::Conf *conf) anope_override + void OnReload(Configuration::Conf *conf) override { Configuration::Block *block = Config->GetModule(this); @@ -622,7 +617,7 @@ class OSSession : public Module throw ConfigException(this->name + ": session CIDR value out of range"); } - void OnUserConnect(User *u, bool &exempt) anope_override + void OnUserConnect(User *u, bool &exempt) override { if (u->Quitting() || !session_limit || exempt || !u->server || u->server->IsULined()) return; @@ -693,7 +688,7 @@ class OSSession : public Module } } - void OnUserQuit(User *u, const Anope::string &msg) anope_override + void OnUserQuit(User *u, const Anope::string &msg) override { if (!session_limit || !u->server || u->server->IsULined()) return; @@ -716,7 +711,7 @@ class OSSession : public Module sessions.erase(sit); } - void OnExpireTick() anope_override + void OnExpireTick() override { if (Anope::NoExpire) return; diff --git a/modules/commands/os_set.cpp b/modules/commands/os_set.cpp index 61f195cd6..51d9788d4 100644 --- a/modules/commands/os_set.cpp +++ b/modules/commands/os_set.cpp @@ -166,11 +166,11 @@ class CommandOSSet : public Command public: CommandOSSet(Module *creator) : Command(creator, "operserv/set", 1, 2) { - this->SetDesc(_("Set various global Services options")); + this->SetDesc(_("Set various global services options")); this->SetSyntax(_("\037option\037 \037setting\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &option = params[0]; @@ -190,13 +190,13 @@ class CommandOSSet : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { if (subcommand.empty()) { this->SendSyntax(source); source.Reply(" "); - source.Reply(_("Sets various global Services options. Option names\n" + source.Reply(_("Sets various global services options. Option names\n" "currently defined are:\n" " READONLY Set read-only or read-write mode\n" " DEBUG Activate or deactivate debug mode\n" @@ -212,13 +212,13 @@ class CommandOSSet : public Command source.Reply(_("Syntax: \002READONLY {ON | OFF}\002\n" " \n" "Sets read-only mode on or off. In read-only mode, normal\n" - "users will not be allowed to modify any Services data,\n" + "users will not be allowed to modify any services data,\n" "including channel and nickname access lists, etc. IRCops\n" - "with sufficient Services privileges will be able to modify\n" + "with sufficient services privileges will be able to modify\n" "Services' AKILL, SQLINE, SNLINE and ignore lists, drop,\n" "suspend or forbid nicknames and channels, and manage news,\n" "oper info and DNS, but any such changes will not be saved\n" - "unless read-only mode is deactivated before Services are\n" + "unless read-only mode is deactivated before services are\n" "terminated or restarted.\n" " \n" "This option is equivalent to the command-line option\n" diff --git a/modules/commands/os_shutdown.cpp b/modules/commands/os_shutdown.cpp index 7dddf9f24..fbd9fd5e3 100644 --- a/modules/commands/os_shutdown.cpp +++ b/modules/commands/os_shutdown.cpp @@ -16,10 +16,10 @@ class CommandOSQuit : public Command public: CommandOSQuit(Module *creator) : Command(creator, "operserv/quit", 0, 0) { - this->SetDesc(_("Terminate Services WITHOUT saving")); + this->SetDesc(_("Terminate services WITHOUT saving")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { Log(LOG_ADMIN, source, this); Anope::QuitReason = source.command + " command received from " + source.GetNick(); @@ -27,11 +27,11 @@ class CommandOSQuit : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); - source.Reply(_("Causes Services to do an immediate shutdown; databases are\n" + source.Reply(_("Causes services to do an immediate shutdown; databases are\n" "\002not\002 saved. This command should not be used unless\n" "damage to the in-memory copies of the databases is feared\n" "and they should not be saved.")); @@ -47,7 +47,7 @@ class CommandOSRestart : public Command this->SetDesc(_("Save databases and restart Services")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { Log(LOG_ADMIN, source, this); Anope::QuitReason = source.command + " command received from " + source.GetNick(); @@ -56,10 +56,10 @@ class CommandOSRestart : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); - source.Reply(_("Causes Services to save all databases and then restart\n" + source.Reply(_("Causes services to save all databases and then restart\n" "(i.e. exit and immediately re-run the executable).")); return true; } @@ -73,7 +73,7 @@ class CommandOSShutdown : public Command this->SetDesc(_("Terminate services with save")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { Log(LOG_ADMIN, source, this); Anope::QuitReason = source.command + " command received from " + source.GetNick(); @@ -82,11 +82,11 @@ class CommandOSShutdown : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); - source.Reply(_("Causes Services to save all databases and then shut down.")); + source.Reply(_("Causes services to save all databases and then shut down.")); return true; } }; diff --git a/modules/commands/os_stats.cpp b/modules/commands/os_stats.cpp index 94c8365d8..2fe23ddaf 100644 --- a/modules/commands/os_stats.cpp +++ b/modules/commands/os_stats.cpp @@ -21,7 +21,7 @@ struct Stats : Serializable me = this; } - void Serialize(Serialize::Data &data) const anope_override + void Serialize(Serialize::Data &data) const override { data["maxusercnt"] << MaxUserCount; data["maxusertime"] << MaxUserTime; @@ -50,8 +50,10 @@ static int stats_count_servers(Server *s) int count = 1; if (!s->GetLinks().empty()) - for (unsigned i = 0, j = s->GetLinks().size(); i < j; ++i) - count += stats_count_servers(s->GetLinks()[i]); + { + for (auto *link : s->GetLinks()) + count += stats_count_servers(link); + } return count; } @@ -145,8 +147,8 @@ class CommandOSStats : public Command void DoStatsUplink(CommandSource &source) { Anope::string buf; - for (std::set<Anope::string>::iterator it = Servers::Capab.begin(); it != Servers::Capab.end(); ++it) - buf += " " + *it; + for (const auto &capab : Servers::Capab) + buf += " " + capab; if (!buf.empty()) buf.erase(buf.begin()); @@ -200,11 +202,11 @@ class CommandOSStats : public Command CommandOSStats(Module *creator) : Command(creator, "operserv/stats", 0, 1), akills("XLineManager", "xlinemanager/sgline"), snlines("XLineManager", "xlinemanager/snline"), sqlines("XLineManager", "xlinemanager/sqline") { - this->SetDesc(_("Show status of Services and network")); + this->SetDesc(_("Show status of services and network")); this->SetSyntax("[AKILL | HASH | UPLINK | UPTIME | ALL | RESET]"); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { Anope::string extra = !params.empty() ? params[0] : ""; @@ -229,13 +231,13 @@ class CommandOSStats : public Command source.Reply(_("Unknown STATS option: \002%s\002"), extra.c_str()); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); source.Reply(_("Without any option, shows the current number of users online,\n" - "and the highest number of users online since Services was\n" - "started, and the length of time Services has been running.\n" + "and the highest number of users online since services was\n" + "started, and the length of time services has been running.\n" " \n" "With the \002AKILL\002 option, displays the current size of the\n" "AKILL list and the current default expiry time.\n" @@ -266,7 +268,7 @@ class OSStats : public Module } - void OnUserConnect(User *u, bool &exempt) anope_override + void OnUserConnect(User *u, bool &exempt) override { if (UserListByNick.size() == MaxUserCount && Anope::CurTime == MaxUserTime) stats_saver.QueueUpdate(); diff --git a/modules/commands/os_svs.cpp b/modules/commands/os_svs.cpp index 493f0ddfd..8ac228270 100644 --- a/modules/commands/os_svs.cpp +++ b/modules/commands/os_svs.cpp @@ -20,7 +20,7 @@ class CommandOSSVSNick : public Command this->SetSyntax(_("\037nick\037 \037newnick\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &nick = params[0]; Anope::string newnick = params[1]; @@ -61,7 +61,7 @@ class CommandOSSVSNick : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -79,7 +79,7 @@ class CommandOSSVSJoin : public Command this->SetSyntax(_("\037nick\037 \037channel\037")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (!IRCD->CanSVSJoin) { @@ -105,7 +105,7 @@ class CommandOSSVSJoin : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -123,7 +123,7 @@ class CommandOSSVSPart : public Command this->SetSyntax(_("\037nick\037 \037channel\037 [\037reason\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (!IRCD->CanSVSJoin) { @@ -153,7 +153,7 @@ class CommandOSSVSPart : public Command } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/os_sxline.cpp b/modules/commands/os_sxline.cpp index 4918a1793..f08b64933 100644 --- a/modules/commands/os_sxline.cpp +++ b/modules/commands/os_sxline.cpp @@ -16,13 +16,13 @@ class SXLineDelCallback : public NumberList XLineManager *xlm; Command *command; CommandSource &source; - unsigned deleted; + unsigned deleted = 0; public: - SXLineDelCallback(XLineManager *x, Command *c, CommandSource &_source, const Anope::string &numlist) : NumberList(numlist, true), xlm(x), command(c), source(_source), deleted(0) + SXLineDelCallback(XLineManager *x, Command *c, CommandSource &_source, const Anope::string &numlist) : NumberList(numlist, true), xlm(x), command(c), source(_source) { } - ~SXLineDelCallback() + ~SXLineDelCallback() override { if (!deleted) source.Reply(_("No matching entries on the %s list."), source.command.c_str()); @@ -32,7 +32,7 @@ class SXLineDelCallback : public NumberList source.Reply(_("Deleted %d entries from the %s list."), deleted, source.command.c_str()); } - void HandleNumber(unsigned number) anope_override + void HandleNumber(unsigned number) override { if (!number) return; @@ -128,7 +128,7 @@ class CommandOSSXLineBase : public Command { } - void HandleNumber(unsigned number) anope_override + void HandleNumber(unsigned number) override { if (!number) return; @@ -182,8 +182,8 @@ class CommandOSSXLineBase : public Command std::vector<Anope::string> replies; list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); + for (const auto &reply : replies) + source.Reply(reply); } } @@ -228,12 +228,12 @@ class CommandOSSXLineBase : public Command { } - const Anope::string GetDesc(CommandSource &source) const anope_override + const Anope::string GetDesc(CommandSource &source) const override { return Anope::printf(Language::Translate(source.GetAccount(), _("Manipulate the %s list")), source.command.upper().c_str()); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &cmd = params[0]; @@ -253,17 +253,17 @@ class CommandOSSXLineBase : public Command return; } - virtual bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override = 0; + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override = 0; }; class CommandOSSNLine : public CommandOSSXLineBase { - XLineManager *xlm() anope_override + XLineManager *xlm() override { return this->snlines; } - void OnAdd(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void OnAdd(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (!this->xlm()) return; @@ -371,8 +371,8 @@ class CommandOSSNLine : public CommandOSSXLineBase x->id = XLineManager::GenerateUID(); unsigned int affected = 0; - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) - if (this->xlm()->Check(it->second, x)) + for (const auto &[_, user] : UserListByNick) + if (this->xlm()->Check(user, x)) ++affected; float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0; @@ -401,10 +401,8 @@ class CommandOSSNLine : public CommandOSSXLineBase { Anope::string rreason = "G-Lined: " + reason; - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) + for (const auto &[_, user] : UserListByNick) { - User *user = it->second; - if (!user->HasMode("OPER") && user->server != Me && this->xlm()->Check(user, x)) user->Kill(Me, rreason); } @@ -429,13 +427,13 @@ class CommandOSSNLine : public CommandOSSXLineBase this->SetSyntax("CLEAR"); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); source.Reply(_("Allows Services Operators to manipulate the SNLINE list. If\n" "a user with a realname matching an SNLINE mask attempts to\n" - "connect, Services will not allow it to pursue his IRC\n" + "connect, services will not allow it to pursue his IRC\n" "session.")); source.Reply(_(" \n" "\002SNLINE ADD\002 adds the given realname mask to the SNLINE\n" @@ -484,12 +482,12 @@ class CommandOSSNLine : public CommandOSSXLineBase class CommandOSSQLine : public CommandOSSXLineBase { - XLineManager *xlm() anope_override + XLineManager *xlm() override { return this->sqlines; } - void OnAdd(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void OnAdd(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (!this->xlm()) return; @@ -579,8 +577,8 @@ class CommandOSSQLine : public CommandOSSXLineBase x->id = XLineManager::GenerateUID(); unsigned int affected = 0; - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) - if (this->xlm()->Check(it->second, x)) + for (const auto &[_, user] : UserListByNick) + if (this->xlm()->Check(user, x)) ++affected; float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0; @@ -611,33 +609,28 @@ class CommandOSSQLine : public CommandOSSXLineBase if (mask[0] == '#') { - for (channel_map::const_iterator cit = ChannelList.begin(), cit_end = ChannelList.end(); cit != cit_end; ++cit) + for (const auto &[_, c] : ChannelList) { - Channel *c = cit->second; - if (!Anope::Match(c->name, mask, false, true)) continue; std::vector<User *> users; - for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) + for (const auto &[_, uc] : c->users) { - ChanUserContainer *uc = it->second; User *user = uc->user; if (!user->HasMode("OPER") && user->server != Me) users.push_back(user); } - for (unsigned i = 0; i < users.size(); ++i) - c->Kick(NULL, users[i], "%s", reason.c_str()); + for (auto *user : users) + c->Kick(NULL, user, "%s", reason.c_str()); } } else { - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) + for (const auto &[_, user] : UserListByNick) { - User *user = it->second; - if (!user->HasMode("OPER") && user->server != Me && this->xlm()->Check(user, x)) user->Kill(Me, rreason); } @@ -663,13 +656,13 @@ class CommandOSSQLine : public CommandOSSXLineBase this->SetSyntax("CLEAR"); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); source.Reply(_("Allows Services Operators to manipulate the SQLINE list. If\n" "a user with a nick matching an SQLINE mask attempts to\n" - "connect, Services will not allow it to pursue his IRC\n" + "connect, services will not allow it to pursue his IRC\n" "session.\n" "If the first character of the mask is #, services will\n" "prevent the use of matching channels. If the mask is a\n" diff --git a/modules/commands/os_update.cpp b/modules/commands/os_update.cpp index af2a008dd..1b88e4b0d 100644 --- a/modules/commands/os_update.cpp +++ b/modules/commands/os_update.cpp @@ -16,10 +16,10 @@ class CommandOSUpdate : public Command public: CommandOSUpdate(Module *creator) : Command(creator, "operserv/update", 0, 0) { - this->SetDesc(_("Force the Services databases to be updated immediately")); + this->SetDesc(_("Force the services databases to be updated immediately")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { Log(LOG_ADMIN, source, this); source.Reply(_("Updating databases.")); @@ -27,11 +27,11 @@ class CommandOSUpdate : public Command return; } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); - source.Reply(_("Causes Services to update all database files as soon as you\n" + source.Reply(_("Causes services to update all database files as soon as you\n" "send the command.")); return true; } |