diff options
| author | Adam <Adam@anope.org> | 2012-04-23 05:08:26 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2012-04-23 05:08:26 -0400 |
| commit | 573e49a7ead331219eb6f0d3ca9cf83e793a5c9c (patch) | |
| tree | e145e04fa3d041cf92ce46da4ac790b63231059c /modules/commands | |
| parent | 63c639e108a00d7dbb0d7ac9891684fc83a3b207 (diff) | |
Reworked live SQL support yet again
Diffstat (limited to 'modules/commands')
88 files changed, 709 insertions, 520 deletions
diff --git a/modules/commands/bs_badwords.cpp b/modules/commands/bs_badwords.cpp index bb7a073f1..eaf00d347 100644 --- a/modules/commands/bs_badwords.cpp +++ b/modules/commands/bs_badwords.cpp @@ -81,7 +81,7 @@ class CommandBSBadwords : public Command if (!Number || Number > ci->GetBadWordCount()) return; - BadWord *bw = ci->GetBadWord(Number - 1); + const BadWord *bw = ci->GetBadWord(Number - 1); ListFormatter::ListEntry entry; entry["Number"] = stringify(Number); entry["Word"] = bw->word; @@ -96,7 +96,7 @@ class CommandBSBadwords : public Command { for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i) { - BadWord *bw = ci->GetBadWord(i); + const BadWord *bw = ci->GetBadWord(i); if (!word.empty() && !Anope::Match(bw->word, word)) continue; @@ -154,7 +154,7 @@ class CommandBSBadwords : public Command for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i) { - BadWord *bw = ci->GetBadWord(i); + const BadWord *bw = ci->GetBadWord(i); if (!bw->word.empty() && ((Config->BSCaseSensitive && realword.equals_cs(bw->word)) || (!Config->BSCaseSensitive && realword.equals_ci(bw->word)))) { @@ -183,7 +183,7 @@ class CommandBSBadwords : public Command else { unsigned i, end; - BadWord *badword; + const BadWord *badword; for (i = 0, end = ci->GetBadWordCount(); i < end; ++i) { diff --git a/modules/commands/bs_bot.cpp b/modules/commands/bs_bot.cpp index 526cd922c..b1f22909f 100644 --- a/modules/commands/bs_bot.cpp +++ b/modules/commands/bs_bot.cpp @@ -22,7 +22,6 @@ class CommandBSBot : public Command const Anope::string &user = params[2]; const Anope::string &host = params[3]; const Anope::string &real = params[4]; - BotInfo *bi; if (findbot(nick)) { @@ -93,7 +92,7 @@ class CommandBSBot : public Command return; } - bi = new BotInfo(nick, user, host, real); + BotInfo *bi = new BotInfo(nick, user, host, real); Log(LOG_ADMIN, source.u, this) << "ADD " << bi->GetMask() << " " << bi->realname; @@ -110,7 +109,6 @@ class CommandBSBot : public Command const Anope::string &user = params.size() > 3 ? params[3] : ""; const Anope::string &host = params.size() > 4 ? params[4] : ""; const Anope::string &real = params.size() > 5 ? params[5] : ""; - BotInfo *bi; if (oldnick.empty() || nick.empty()) { @@ -118,7 +116,8 @@ class CommandBSBot : public Command return; } - if (!(bi = findbot(oldnick))) + BotInfo *bi = findbot(oldnick); + if (!bi) { source.Reply(BOT_DOES_NOT_EXIST, oldnick.c_str()); return; @@ -263,7 +262,6 @@ class CommandBSBot : public Command void DoDel(CommandSource &source, const std::vector<Anope::string> ¶ms) { const Anope::string &nick = params[1]; - BotInfo *bi; if (nick.empty()) { @@ -271,7 +269,8 @@ class CommandBSBot : public Command return; } - if (!(bi = findbot(nick))) + BotInfo *bi = findbot(nick); + if (!bi) { source.Reply(BOT_DOES_NOT_EXIST, nick.c_str()); return; @@ -288,7 +287,7 @@ class CommandBSBot : public Command Log(LOG_ADMIN, source.u, this) << "DEL " << bi->nick; source.Reply(_("Bot \002%s\002 has been deleted."), nick.c_str()); - delete bi; + bi->destroy(); return; } public: diff --git a/modules/commands/bs_botlist.cpp b/modules/commands/bs_botlist.cpp index ed50371fc..68fb7bdfa 100644 --- a/modules/commands/bs_botlist.cpp +++ b/modules/commands/bs_botlist.cpp @@ -30,7 +30,7 @@ class CommandBSBotList : public Command list.addColumn("Nick").addColumn("Mask"); - for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) + for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it) { BotInfo *bi = it->second; diff --git a/modules/commands/bs_info.cpp b/modules/commands/bs_info.cpp index ed36818b3..251bd84df 100644 --- a/modules/commands/bs_info.cpp +++ b/modules/commands/bs_info.cpp @@ -17,12 +17,12 @@ class CommandBSInfo : public Command { private: - void send_bot_channels(std::vector<Anope::string> &buffers, BotInfo *bi) + 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 (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it) { - ChannelInfo *ci = it->second; + const ChannelInfo *ci = it->second; if (ci->bi == bi) { @@ -38,7 +38,7 @@ class CommandBSInfo : public Command buffers.push_back(buf); } - void CheckOptStr(Anope::string &buf, BotServFlag flag, const char *option, Flags<BotServFlag> &flags, NickCore *nc) + void CheckOptStr(Anope::string &buf, BotServFlag flag, const char *option, Flags<BotServFlag> &flags, const NickCore *nc) { if (flags.HasFlag(flag)) { @@ -60,7 +60,7 @@ class CommandBSInfo : public Command const Anope::string &query = params[0]; User *u = source.u; - BotInfo *bi = findbot(query); + const BotInfo *bi = findbot(query); ChannelInfo *ci; InfoFormatter info(u); diff --git a/modules/commands/bs_kick.cpp b/modules/commands/bs_kick.cpp index 42b43e7a1..819c5af74 100644 --- a/modules/commands/bs_kick.cpp +++ b/modules/commands/bs_kick.cpp @@ -900,7 +900,7 @@ class BSKick : public Module for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i) { - BadWord *bw = ci->GetBadWord(i); + const BadWord *bw = ci->GetBadWord(i); if (bw->type == BW_ANY && ((Config->BSCaseSensitive && nbuf.find(bw->word) != Anope::string::npos) || (!Config->BSCaseSensitive && nbuf.find_ci(bw->word) != Anope::string::npos))) mustkick = true; @@ -1012,7 +1012,7 @@ class BSKick : public Module Channel *chan = (*it)->chan; ++it; - if (chan->ci != NULL && chan->ci->botflags.HasFlag(BS_KICK_AMSGS) && !chan->ci->AccessFor(u).HasPriv("NOKICK")) + if (chan->ci && chan->ci->botflags.HasFlag(BS_KICK_AMSGS) && !chan->ci->AccessFor(u).HasPriv("NOKICK")) { check_ban(chan->ci, u, TTB_AMSGS); bot_kick(chan->ci, u, _("Don't use AMSGs!")); diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index aa32d29ef..a37446df2 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -15,7 +15,7 @@ static std::map<Anope::string, int16_t, ci::less> defaultLevels; -static void reset_levels(ChannelInfo *ci) +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) @@ -36,7 +36,7 @@ class AccessChanAccess : public ChanAccess return this->ci->GetLevel(name) != ACCESS_INVALID && this->level >= this->ci->GetLevel(name); } - Anope::string Serialize() + Anope::string Serialize() const { return stringify(this->level); } @@ -46,11 +46,11 @@ class AccessChanAccess : public ChanAccess this->level = convertTo<int>(data); } - static int DetermineLevel(ChanAccess *access) + static int DetermineLevel(const ChanAccess *access) { if (access->provider->name == "access/access") { - AccessChanAccess *aaccess = debug_cast<AccessChanAccess *>(access); + const AccessChanAccess *aaccess = debug_cast<const AccessChanAccess *>(access); return aaccess->level; } else @@ -108,7 +108,7 @@ class CommandCSAccess : public Command } AccessGroup u_access = ci->AccessFor(u); - ChanAccess *highest = u_access.Highest(); + const ChanAccess *highest = u_access.Highest(); int u_level = (highest ? AccessChanAccess::DetermineLevel(highest) : 0); if (level >= u_level && !u_access.Founder && !u->HasPriv("chanserv/access/modify")) { @@ -123,7 +123,7 @@ class CommandCSAccess : public Command bool override = !ci->AccessFor(u).HasPriv("ACCESS_CHANGE") || (level >= u_level && !u_access.Founder); - if (mask.find_first_of("!*@") == Anope::string::npos && findnick(mask) == NULL) + if (mask.find_first_of("!*@") == Anope::string::npos && !findnick(mask)) { User *targ = finduser(mask); if (targ != NULL) @@ -137,7 +137,7 @@ class CommandCSAccess : public Command for (unsigned i = ci->GetAccessCount(); i > 0; --i) { - ChanAccess *access = ci->GetAccess(i - 1); + const ChanAccess *access = ci->GetAccess(i - 1); if (mask.equals_ci(access->mask)) { /* Don't allow lowering from a level >= u_level */ @@ -230,7 +230,7 @@ class CommandCSAccess : public Command ChanAccess *access = ci->GetAccess(Number - 1); AccessGroup u_access = ci->AccessFor(user); - ChanAccess *u_highest = u_access.Highest(); + const ChanAccess *u_highest = u_access.Highest(); if ((u_highest ? AccessChanAccess::DetermineLevel(u_highest) : 0) <= AccessChanAccess::DetermineLevel(access) && !u_access.Founder && !this->override && !access->mask.equals_ci(user->Account()->display)) { @@ -255,7 +255,7 @@ class CommandCSAccess : public Command else { AccessGroup u_access = ci->AccessFor(u); - ChanAccess *highest = u_access.Highest(); + const ChanAccess *highest = u_access.Highest(); int u_level = (highest ? AccessChanAccess::DetermineLevel(highest) : 0); for (unsigned i = ci->GetAccessCount(); i > 0; --i) @@ -308,7 +308,7 @@ class CommandCSAccess : public Command if (!number || number > ci->GetAccessCount()) return; - ChanAccess *access = ci->GetAccess(number - 1); + const ChanAccess *access = ci->GetAccess(number - 1); Anope::string timebuf; if (ci->c) @@ -339,7 +339,7 @@ class CommandCSAccess : public Command { for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i) { - ChanAccess *access = ci->GetAccess(i); + const ChanAccess *access = ci->GetAccess(i); if (!nick.empty() && !Anope::Match(access->mask, nick)) continue; @@ -470,7 +470,7 @@ class CommandCSAccess : public Command has_access = true; else if (is_del) { - NickAlias *na = findnick(nick); + const NickAlias *na = findnick(nick); if (na && na->nc == u->Account()) has_access = true; } diff --git a/modules/commands/cs_akick.cpp b/modules/commands/cs_akick.cpp index beaa8ffd3..107f97584 100644 --- a/modules/commands/cs_akick.cpp +++ b/modules/commands/cs_akick.cpp @@ -54,9 +54,9 @@ class CommandCSAKick : public Command Anope::string mask = params[2]; Anope::string reason = params.size() > 3 ? params[3] : ""; - NickAlias *na = findnick(mask); + const NickAlias *na = findnick(mask); NickCore *nc = NULL; - AutoKick *akick; + const AutoKick *akick; if (!na) { @@ -113,7 +113,7 @@ 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 (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it) { na = it->second; @@ -166,7 +166,6 @@ class CommandCSAKick : public Command User *u = source.u; const Anope::string &mask = params[2]; - AutoKick *akick; unsigned i, end; if (!ci->GetAkickCount()) @@ -218,12 +217,12 @@ class CommandCSAKick : public Command } else { - NickAlias *na = findnick(mask); - NickCore *nc = na ? na->nc : NULL; + const NickAlias *na = findnick(mask); + const NickCore *nc = na ? *na->nc : NULL; for (i = 0, end = ci->GetAkickCount(); i < end; ++i) { - akick = ci->GetAkick(i); + const AutoKick *akick = ci->GetAkick(i); if ((aki |
