diff options
Diffstat (limited to 'src')
53 files changed, 586 insertions, 836 deletions
diff --git a/src/core/bs_act.cpp b/src/core/bs_act.cpp index d313fd587..3cf1cb0f9 100644 --- a/src/core/bs_act.cpp +++ b/src/core/bs_act.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" diff --git a/src/core/bs_assign.cpp b/src/core/bs_assign.cpp index d5fa0bdef..b6703c04c 100644 --- a/src/core/bs_assign.cpp +++ b/src/core/bs_assign.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" diff --git a/src/core/bs_badwords.cpp b/src/core/bs_badwords.cpp index 7a9c6ebdf..d4be661bf 100644 --- a/src/core/bs_badwords.cpp +++ b/src/core/bs_badwords.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -86,16 +85,14 @@ class CommandBSBadwords : public Command CommandReturn DoList(User *u, ChannelInfo *ci, const ci::string &word) { if (!ci->GetBadWordCount()) - { notice_lang(Config.s_BotServ, u, BOT_BADWORDS_LIST_EMPTY, ci->name.c_str()); - } else if (!word.empty() && strspn(word.c_str(), "1234567890,-") == word.length()) (new BadwordsListCallback(u, ci, word.c_str()))->Process(); else { bool SentHeader = false; - - for (unsigned i = 0; i < ci->GetBadWordCount(); i++) + + for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i) { BadWord *bw = ci->GetBadWord(i); @@ -145,12 +142,11 @@ class CommandBSBadwords : public Command return MOD_CONT; } - for (unsigned i = 0; i < ci->GetBadWordCount(); ++i) + for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i) { BadWord *bw = ci->GetBadWord(i); - if (!bw->word.empty() && ((Config.BSCaseSensitive && !stricmp(bw->word.c_str(), realword.c_str())) - || (!Config.BSCaseSensitive && bw->word == realword.c_str()))) + if (!bw->word.empty() && ((Config.BSCaseSensitive && !stricmp(bw->word.c_str(), realword.c_str())) || (!Config.BSCaseSensitive && bw->word == realword.c_str()))) { notice_lang(Config.s_BotServ, u, BOT_BADWORDS_ALREADY_EXISTS, bw->word.c_str(), ci->name.c_str()); return MOD_CONT; @@ -171,10 +167,10 @@ class CommandBSBadwords : public Command (new BadwordsDelCallback(u, ci, word.c_str()))->Process(); else { - unsigned i; + unsigned i, end; BadWord *badword; - for (i = 0; i < ci->GetBadWordCount(); ++i) + for (i = 0, end = ci->GetBadWordCount(); i < end; ++i) { badword = ci->GetBadWord(i); @@ -182,12 +178,12 @@ class CommandBSBadwords : public Command break; } - if (i == ci->GetBadWordCount()) + if (i == end) { notice_lang(Config.s_BotServ, u, BOT_BADWORDS_NOT_FOUND, word.c_str(), ci->name.c_str()); return MOD_CONT; } - + ci->EraseBadWord(i); notice_lang(Config.s_BotServ, u, BOT_BADWORDS_DELETED, badword->word.c_str(), ci->name.c_str()); diff --git a/src/core/bs_bot.cpp b/src/core/bs_bot.cpp index 1d3103e29..2b7cc5cf4 100644 --- a/src/core/bs_bot.cpp +++ b/src/core/bs_bot.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -57,14 +56,12 @@ class CommandBSBot : public Command return MOD_CONT; } - for (ch = nick; *ch && (ch - nick) < Config.NickLen; ch++) - { + for (ch = nick; *ch && ch - nick < Config.NickLen; ++ch) if (!isvalidnick(*ch)) { notice_lang(Config.s_BotServ, u, BOT_BAD_NICK); return MOD_CONT; } - } /* check for hardcored ircd forbidden nicks */ if (!ircdproto->IsNickValid(nick)) @@ -80,15 +77,12 @@ class CommandBSBot : public Command return MOD_CONT; } - for (ch = user; *ch && (ch - user) < Config.UserLen; ch++) - { + for (ch = user; *ch && ch - user < Config.UserLen; ++ch) if (!isalnum(*ch)) { notice_lang(Config.s_BotServ, u, BOT_BAD_IDENT, Config.UserLen); return MOD_CONT; } - } - /* We check whether the nick is registered, and inform the user * if so. You need to drop the nick manually before you can use @@ -185,14 +179,12 @@ class CommandBSBot : public Command return MOD_CONT; } - for (ch = nick; *ch && (ch - nick) < Config.NickLen; ch++) - { + for (ch = nick; *ch && ch - nick < Config.NickLen; ++ch) if (!isvalidnick(*ch)) { notice_lang(Config.s_BotServ, u, BOT_BAD_NICK); return MOD_CONT; } - } /* check for hardcored ircd forbidden nicks */ if (!ircdproto->IsNickValid(nick)) @@ -208,16 +200,12 @@ class CommandBSBot : public Command } if (user) - { - for (ch = user; *ch && (ch - user) < Config.UserLen; ch++) - { + for (ch = user; *ch && ch - user < Config.UserLen; ++ch) if (!isalnum(*ch)) { notice_lang(Config.s_BotServ, u, BOT_BAD_IDENT, Config.UserLen); return MOD_CONT; } - } - } ci::string ci_bi_nick(bi->nick.c_str()); if (ci_bi_nick != nick && findbot(nick)) @@ -271,10 +259,9 @@ class CommandBSBot : public Command if (user) { - if (ircd->ts6) { + if (ircd->ts6) // This isn't the nicest way to do this, unfortunately. bi->uid = ts6_uid_retrieve(); - } ircdproto->SendClientIntroduction(bi->nick, bi->user, bi->host, bi->real, ircd->pseudoclient_mode, bi->uid); XLine x(bi->nick.c_str(), "Reserved for services"); ircdproto->SendSQLine(&x); diff --git a/src/core/bs_botlist.cpp b/src/core/bs_botlist.cpp index ebebf7a71..bfc0cfc58 100644 --- a/src/core/bs_botlist.cpp +++ b/src/core/bs_botlist.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -31,15 +30,15 @@ class CommandBSBotList : public Command return MOD_CONT; } - for (botinfo_map::const_iterator it = BotListByNick.begin(); it != BotListByNick.end(); ++it) + for (botinfo_map::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { BotInfo *bi = it->second; - + if (!bi->HasFlag(BI_PRIVATE)) { if (!count) notice_lang(Config.s_BotServ, u, BOT_BOTLIST_HEADER); - count++; + ++count; u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->user.c_str(), bi->host.c_str()); } } @@ -48,14 +47,14 @@ class CommandBSBotList : public Command { notice_lang(Config.s_BotServ, u, BOT_BOTLIST_PRIVATE_HEADER); - for (botinfo_map::const_iterator it = BotListByNick.begin(); it != BotListByNick.end(); ++it) + for (botinfo_map::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { BotInfo *bi = it->second; - + if (bi->HasFlag(BI_PRIVATE)) { u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->user.c_str(), bi->host.c_str()); - count++; + ++count; } } } diff --git a/src/core/bs_help.cpp b/src/core/bs_help.cpp index 80070c138..3842b8910 100644 --- a/src/core/bs_help.cpp +++ b/src/core/bs_help.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -33,7 +32,7 @@ class CommandBSHelp : public Command { // Abuse syntax error to display general list help. notice_help(Config.s_BotServ, u, BOT_HELP); - for (CommandMap::const_iterator it = BotServ->Commands.begin(); it != BotServ->Commands.end(); ++it) + for (CommandMap::const_iterator it = BotServ->Commands.begin(), it_end = BotServ->Commands.end(); it != it_end; ++it) it->second->OnServHelp(u); notice_help(Config.s_BotServ, u, BOT_HELP_FOOTER, Config.BSMinUsers); } @@ -51,6 +50,4 @@ class BSHelp : public Module } }; - - MODULE_INIT(BSHelp) diff --git a/src/core/bs_info.cpp b/src/core/bs_info.cpp index 4e8cf042f..45e650d29 100644 --- a/src/core/bs_info.cpp +++ b/src/core/bs_info.cpp @@ -24,7 +24,7 @@ class CommandBSInfo : public Command *buf = 0; end = buf; - for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it) + for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it) { ChannelInfo *ci = it->second; @@ -90,142 +90,114 @@ class CommandBSInfo : public Command else notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_BOT_NONE); - if (ci->botflags.HasFlag(BS_KICK_BADWORDS)) { + if (ci->botflags.HasFlag(BS_KICK_BADWORDS)) + { if (ci->ttb[TTB_BADWORDS]) - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS_BAN, - getstring(u, BOT_INFO_ACTIVE), - ci->ttb[TTB_BADWORDS]); + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS_BAN, getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_BADWORDS]); else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS, - getstring(u, BOT_INFO_ACTIVE)); - } else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS, - getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags.HasFlag(BS_KICK_BOLDS)) { + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS, getstring(u, BOT_INFO_ACTIVE)); + } + else + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS, getstring(u, BOT_INFO_INACTIVE)); + if (ci->botflags.HasFlag(BS_KICK_BOLDS)) + { if (ci->ttb[TTB_BOLDS]) - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS_BAN, - getstring(u, BOT_INFO_ACTIVE), - ci->ttb[TTB_BOLDS]); + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS_BAN, getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_BOLDS]); else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS, - getstring(u, BOT_INFO_ACTIVE)); - } else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS, - getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags.HasFlag(BS_KICK_CAPS)) { + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS, getstring(u, BOT_INFO_ACTIVE)); + } + else + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS, getstring(u, BOT_INFO_INACTIVE)); + if (ci->botflags.HasFlag(BS_KICK_CAPS)) + { if (ci->ttb[TTB_CAPS]) - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_BAN, - getstring(u, BOT_INFO_ACTIVE), - ci->ttb[TTB_CAPS], ci->capsmin, - ci->capspercent); + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_BAN, getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_CAPS], ci->capsmin, ci->capspercent); else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_ON, - getstring(u, BOT_INFO_ACTIVE), ci->capsmin, - ci->capspercent); - } else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_OFF, - getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags.HasFlag(BS_KICK_COLORS)) { + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_ON, getstring(u, BOT_INFO_ACTIVE), ci->capsmin, ci->capspercent); + } + else + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_OFF, getstring(u, BOT_INFO_INACTIVE)); + if (ci->botflags.HasFlag(BS_KICK_COLORS)) + { if (ci->ttb[TTB_COLORS]) - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS_BAN, - getstring(u, BOT_INFO_ACTIVE), - ci->ttb[TTB_COLORS]); + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS_BAN, getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_COLORS]); else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS, - getstring(u, BOT_INFO_ACTIVE)); - } else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS, - getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags.HasFlag(BS_KICK_FLOOD)) { + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS, getstring(u, BOT_INFO_ACTIVE)); + } + else + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS, getstring(u, BOT_INFO_INACTIVE)); + if (ci->botflags.HasFlag(BS_KICK_FLOOD)) + { if (ci->ttb[TTB_FLOOD]) - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_BAN, - getstring(u, BOT_INFO_ACTIVE), - ci->ttb[TTB_FLOOD], ci->floodlines, - ci->floodsecs); + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_BAN, getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_FLOOD], ci->floodlines, ci->floodsecs); else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_ON, - getstring(u, BOT_INFO_ACTIVE), - ci->floodlines, ci->floodsecs); - } else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_OFF, - getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags.HasFlag(BS_KICK_REPEAT)) { + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_ON, getstring(u, BOT_INFO_ACTIVE), ci->floodlines, ci->floodsecs); + } + else + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_OFF, getstring(u, BOT_INFO_INACTIVE)); + if (ci->botflags.HasFlag(BS_KICK_REPEAT)) + { if (ci->ttb[TTB_REPEAT]) - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_BAN, - getstring(u, BOT_INFO_ACTIVE), - ci->ttb[TTB_REPEAT], ci->repeattimes); + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_BAN, getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_REPEAT], ci->repeattimes); else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_ON, - getstring(u, BOT_INFO_ACTIVE), - ci->repeattimes); - } else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_OFF, - getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags.HasFlag(BS_KICK_REVERSES)) { + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_ON, getstring(u, BOT_INFO_ACTIVE), ci->repeattimes); + } + else + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_OFF, getstring(u, BOT_INFO_INACTIVE)); + if (ci->botflags.HasFlag(BS_KICK_REVERSES)) + { if (ci->ttb[TTB_REVERSES]) - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES_BAN, - getstring(u, BOT_INFO_ACTIVE), - ci->ttb[TTB_REVERSES]); + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES_BAN, getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_REVERSES]); else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES, - getstring(u, BOT_INFO_ACTIVE)); - } else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES, - getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags.HasFlag(BS_KICK_UNDERLINES)) { + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES, getstring(u, BOT_INFO_ACTIVE)); + } + else + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES, getstring(u, BOT_INFO_INACTIVE)); + if (ci->botflags.HasFlag(BS_KICK_UNDERLINES)) + { if (ci->ttb[TTB_UNDERLINES]) - notice_lang(Config.s_BotServ, u, - BOT_INFO_CHAN_KICK_UNDERLINES_BAN, - getstring(u, BOT_INFO_ACTIVE), - ci->ttb[TTB_UNDERLINES]); + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES_BAN, getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_UNDERLINES]); else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES, - getstring(u, BOT_INFO_ACTIVE)); - } else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES, - getstring(u, BOT_INFO_INACTIVE)); + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES, getstring(u, BOT_INFO_ACTIVE)); + } + else + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES, getstring(u, BOT_INFO_INACTIVE)); end = buf; *end = 0; - if (ci->botflags.HasFlag(BS_DONTKICKOPS)) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s", - getstring(u, BOT_INFO_OPT_DONTKICKOPS)); + if (ci->botflags.HasFlag(BS_DONTKICKOPS)) + { + end += snprintf(end, sizeof(buf) - (end - buf), "%s", getstring(u, BOT_INFO_OPT_DONTKICKOPS)); need_comma = 1; } - if (ci->botflags.HasFlag(BS_DONTKICKVOICES)) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u, BOT_INFO_OPT_DONTKICKVOICES)); + if (ci->botflags.HasFlag(BS_DONTKICKVOICES)) + { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", getstring(u, BOT_INFO_OPT_DONTKICKVOICES)); need_comma = 1; } - if (ci->botflags.HasFlag(BS_FANTASY)) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u, BOT_INFO_OPT_FANTASY)); + if (ci->botflags.HasFlag(BS_FANTASY)) + { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", getstring(u, BOT_INFO_OPT_FANTASY)); need_comma = 1; } - if (ci->botflags.HasFlag(BS_GREET)) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u, BOT_INFO_OPT_GREET)); + if (ci->botflags.HasFlag(BS_GREET)) + { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", getstring(u, BOT_INFO_OPT_GREET)); need_comma = 1; } - if (ci->botflags.HasFlag(BS_NOBOT)) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u, BOT_INFO_OPT_NOBOT)); + if (ci->botflags.HasFlag(BS_NOBOT)) + { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", getstring(u, BOT_INFO_OPT_NOBOT)); need_comma = 1; } - if (ci->botflags.HasFlag(BS_SYMBIOSIS)) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u, BOT_INFO_OPT_SYMBIOSIS)); + if (ci->botflags.HasFlag(BS_SYMBIOSIS)) + { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", getstring(u, BOT_INFO_OPT_SYMBIOSIS)); need_comma = 1; } - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_OPTIONS, - *buf ? buf : getstring(u, BOT_INFO_OPT_NONE)); - - } else + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_OPTIONS, *buf ? buf : getstring(u, BOT_INFO_OPT_NONE)); + } + else notice_lang(Config.s_BotServ, u, BOT_INFO_NOT_FOUND, query); return MOD_CONT; } diff --git a/src/core/bs_kick.cpp b/src/core/bs_kick.cpp index 6c8e020e4..54781a134 100644 --- a/src/core/bs_kick.cpp +++ b/src/core/bs_kick.cpp @@ -40,14 +40,18 @@ class CommandBSKick : public Command notice_lang(Config.s_BotServ, u, ACCESS_DENIED); else if (!ci->bi) notice_help(Config.s_BotServ, u, BOT_NOT_ASSIGNED); - else { - if (option == "BADWORDS") { - if (value == "ON") { - if (ttb) { + else + { + if (option == "BADWORDS") + { + if (value == "ON") + { + if (ttb) + { errno = 0; ci->ttb[TTB_BADWORDS] = strtol(ttb, NULL, 10); /* Only error if errno returns ERANGE or EINVAL or we are less then 0 - TSL */ - if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_BADWORDS] < 0) + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_BADWORDS] < 0) { /* leaving the debug behind since we might want to know what these are */ Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_BADWORDS]; @@ -56,59 +60,71 @@ class CommandBSKick : public Command notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; } - } else { - ci->ttb[TTB_BADWORDS] = 0; } + else + ci->ttb[TTB_BADWORDS] = 0; ci->botflags.SetFlag(BS_KICK_BADWORDS); if (ci->ttb[TTB_BADWORDS]) - notice_lang(Config.s_BotServ, u, BOT_KICK_BADWORDS_ON_BAN, - ci->ttb[TTB_BADWORDS]); + notice_lang(Config.s_BotServ, u, BOT_KICK_BADWORDS_ON_BAN, ci->ttb[TTB_BADWORDS]); else notice_lang(Config.s_BotServ, u, BOT_KICK_BADWORDS_ON); - } else { + } + else + { ci->botflags.UnsetFlag(BS_KICK_BADWORDS); notice_lang(Config.s_BotServ, u, BOT_KICK_BADWORDS_OFF); } - } else if (option == "BOLDS") { - if (value == "ON") { - if (ttb) { + } + else if (option == "BOLDS") + { + if (value == "ON") + { + if (ttb) + { errno = 0; ci->ttb[TTB_BOLDS] = strtol(ttb, NULL, 10); - if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_BOLDS] < 0) + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_BOLDS] < 0) { Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_BOLDS]; ci->ttb[TTB_BOLDS] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; } - } else + } + else ci->ttb[TTB_BOLDS] = 0; ci->botflags.SetFlag(BS_KICK_BOLDS); if (ci->ttb[TTB_BOLDS]) - notice_lang(Config.s_BotServ, u, BOT_KICK_BOLDS_ON_BAN, - ci->ttb[TTB_BOLDS]); + notice_lang(Config.s_BotServ, u, BOT_KICK_BOLDS_ON_BAN, ci->ttb[TTB_BOLDS]); else notice_lang(Config.s_BotServ, u, BOT_KICK_BOLDS_ON); - } else { + } + else + { ci->botflags.UnsetFlag(BS_KICK_BOLDS); notice_lang(Config.s_BotServ, u, BOT_KICK_BOLDS_OFF); } - } else if (option == "CAPS") { - if (value == "ON") { + } + else if (option == "CAPS") + { + if (value == "ON") + { const char *min = params.size() > 4 ? params[4].c_str() : NULL; const char *percent = params.size() > 5 ? params[5].c_str() : NULL; - if (ttb) { + if (ttb) + { errno = 0; ci->ttb[TTB_CAPS] = strtol(ttb, NULL, 10); - if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_CAPS] < 0) + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_CAPS] < 0) { Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_CAPS]; ci->ttb[TTB_CAPS] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; } - } else + } + else ci->ttb[TTB_CAPS] = 0; if (!min) @@ -127,19 +143,22 @@ class CommandBSKick : public Command ci->botflags.SetFlag(BS_KICK_CAPS); if (ci->ttb[TTB_CAPS]) - notice_lang(Config.s_BotServ, u, BOT_KICK_CAPS_ON_BAN, - ci->capsmin, ci->capspercent, - ci->ttb[TTB_CAPS]); + notice_lang(Config.s_BotServ, u, BOT_KICK_CAPS_ON_BAN, ci->capsmin, ci->capspercent, ci->ttb[TTB_CAPS]); else - notice_lang(Config.s_BotServ, u, BOT_KICK_CAPS_ON, - ci->capsmin, ci->capspercent); - } else { + notice_lang(Config.s_BotServ, u, BOT_KICK_CAPS_ON, ci->capsmin, ci->capspercent); + } + else + { ci->botflags.UnsetFlag(BS_KICK_CAPS); notice_lang(Config.s_BotServ, u, BOT_KICK_CAPS_OFF); } - } else if (option == "COLORS") { - if (value == "ON") { - if (ttb) { + } + else if (option == "COLORS") + { + if (value == "ON") + { + if (ttb) + { errno = 0; ci->ttb[TTB_COLORS] = strtol(ttb, NULL, 10); if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_COLORS] < 0) @@ -149,33 +168,41 @@ class CommandBSKick : public Command notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; } - } else + } + else ci->ttb[TTB_COLORS] = 0; ci->botflags.SetFlag(BS_KICK_COLORS); if (ci->ttb[TTB_COLORS]) - notice_lang(Config.s_BotServ, u, BOT_KICK_COLORS_ON_BAN, - ci->ttb[TTB_COLORS]); + notice_lang(Config.s_BotServ, u, BOT_KICK_COLORS_ON_BAN, ci->ttb[TTB_COLORS]); else notice_lang(Config.s_BotServ, u, BOT_KICK_COLORS_ON); - } else { + } + else + { ci->botflags.UnsetFlag(BS_KICK_COLORS); notice_lang(Config.s_BotServ, u, BOT_KICK_COLORS_OFF); } - } else if (option == "FLOOD") { - if (value == "ON") { + } + else if (option == "FLOOD") + { + if (value == "ON") + { const char *lines = params.size() > 4 ? params[4].c_str() : NULL; const char *secs = params.size() > 5 ? params[5].c_str() : NULL; - if (ttb) { + if (ttb) + { errno = 0; ci->ttb[TTB_FLOOD] = strtol(ttb, NULL, 10); - if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_FLOOD] < 0) { + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_FLOOD] < 0) + { Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_FLOOD]; ci->ttb[TTB_FLOOD] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; } - } else + } + else ci->ttb[TTB_FLOOD] = 0; if (!lines) @@ -194,31 +221,35 @@ class CommandBSKick : public Command ci->botflags.SetFlag(BS_KICK_FLOOD); if (ci->ttb[TTB_FLOOD]) - notice_lang(Config.s_BotServ, u, BOT_KICK_FLOOD_ON_BAN, - ci->floodlines, ci->floodsecs, - ci->ttb[TTB_FLOOD]); + notice_lang(Config.s_BotServ, u, BOT_KICK_FLOOD_ON_BAN, ci->floodlines, ci->floodsecs, ci->ttb[TTB_FLOOD]); else - notice_lang(Config.s_BotServ, u, BOT_KICK_FLOOD_ON, - ci->floodlines, ci->floodsecs); - } else { + notice_lang(Config.s_BotServ, u, BOT_KICK_FLOOD_ON, ci->floodlines, ci->floodsecs); + } + else + { ci->botflags.UnsetFlag(BS_KICK_FLOOD); notice_lang(Config.s_BotServ, u, BOT_KICK_FLOOD_OFF); } - } else if (option == "REPEAT") { - if (value == "ON") { + } + else if (option == "REPEAT") + { + if (value == "ON") + { const char *times = params.size() > 4 ? params[4].c_str() : NULL; - if (ttb) { + if (ttb) + { errno = 0; ci->ttb[TTB_REPEAT] = strtol(ttb, NULL, 10); - if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_REPEAT] < 0) + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_REPEAT] < 0) { Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_REPEAT]; ci->ttb[TTB_REPEAT] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; } - } else + } + else ci->ttb[TTB_REPEAT] = 0; if (!times) @@ -230,66 +261,77 @@ class CommandBSKick : public Command ci->botflags.SetFlag(BS_KICK_REPEAT); if (ci->ttb[TTB_REPEAT]) - notice_lang(Config.s_BotServ, u, BOT_KICK_REPEAT_ON_BAN, - ci->repeattimes, ci->ttb[TTB_REPEAT]); + notice_lang(Config.s_BotServ, u, BOT_KICK_REPEAT_ON_BAN, ci->repeattimes, ci->ttb[TTB_REPEAT]); else - notice_lang(Config.s_BotServ, u, BOT_KICK_REPEAT_ON, - ci->repeattimes); - } else { + notice_lang(Config.s_BotServ, u, BOT_KICK_REPEAT_ON, ci->repeattimes); + } + else + { ci->botflags.UnsetFlag(BS_KICK_REPEAT); notice_lang(Config.s_BotServ, u, BOT_KICK_REPEAT_OFF); } - } else if (option == "REVERSES") { - if (value == "ON") { - if (ttb) { + } + else if (option == "REVERSES") + { + if (value == "ON") + { + if (ttb) + { errno = 0; - ci->ttb[TTB_REVERSES] = - strtol(ttb, NULL, 10); - if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_REVERSES] < 0) + ci->ttb[TTB_REVERSES] = strtol(ttb, NULL, 10); + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_REVERSES] < 0) { Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_REVERSES]; ci->ttb[TTB_REVERSES] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; } - } else + } + else ci->ttb[TTB_REVERSES] = 0; ci->botflags.SetFlag(BS_KICK_REVERSES); if (ci->ttb[TTB_REVERSES]) - notice_lang(Config.s_BotServ, u, BOT_KICK_REVERSES_ON_BAN, - ci->ttb[TTB_REVERSES]); + notice_lang(Config.s_BotServ, u, BOT_KICK_REVERSES_ON_BAN, ci->ttb[TTB_REVERSES]); else notice_lang(Config.s_BotServ, u, BOT_KICK_REVERSES_ON); - } else { + } + else + { ci->botflags.UnsetFlag(BS_KICK_REVERSES); notice_lang(Config.s_BotServ, u, BOT_KICK_REVERSES_OFF); } - } else if (option == "UNDERLINES") { - if (value == "ON") { - if (ttb) { + } + else if (option == "UNDERLINES") + { + if (value == "ON") + { + if (ttb) + { errno = 0; - ci->ttb[TTB_UNDERLINES] = - strtol(ttb, NULL, 10); - if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_UNDERLINES] < 0) + ci->ttb[TTB_UNDERLINES] = strtol(ttb, NULL, 10); + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_UNDERLINES] < 0) { Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_UNDERLINES]; ci->ttb[TTB_UNDERLINES] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; } - } else + } + else ci->ttb[TTB_UNDERLINES] = 0; ci->botflags.SetFlag(BS_KICK_UNDERLINES); if (ci->ttb[TTB_UNDERLINES]) - notice_lang(Config.s_BotServ, u, BOT_KICK_UNDERLINES_ON_BAN, - ci->ttb[TTB_UNDERLINES]); + notice_lang(Config.s_BotServ, u, BOT_KICK_UNDERLINES_ON_BAN, ci->ttb[TTB_UNDERLINES]); else notice_lang(Config.s_BotServ, u, BOT_KICK_UNDERLINES_ON); - } else { + } + else + { ci->botflags.UnsetFlag(BS_KICK_UNDERLINES); notice_lang(Config.s_BotServ, u, BOT_KICK_UNDERLINES_OFF); } - } else + } + else notice_help(Config.s_BotServ, u, BOT_KICK_UNKNOWN, option.c_str()); } return MOD_CONT; diff --git a/src/core/bs_say.cpp b/src/core/bs_say.cpp index a388a1ec9..40d48fef2 100644 --- a/src/core/bs_say.cpp +++ b/src/core/bs_say.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" diff --git a/src/core/bs_set.cpp b/src/core/bs_set.cpp index a5fee9d4f..9d89c696c 100644 --- a/src/core/bs_set.cpp +++ b/src/core/bs_set.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -56,90 +55,109 @@ class CommandBSSet : public Command notice_lang(Config.s_BotServ, u, BOT_SET_PRIVATE_OFF, bi->nick.c_str()); } else - { syntax_error(Config.s_BotServ, u, "SET PRIVATE", BOT_SET_PRIVATE_SYNTAX); - } return MOD_CONT; - } else if (!(ci = cs_findchan(chan))) + } + else if (!(ci = cs_findchan(chan))) notice_lang(Config.s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); else if (!u->Account()->HasPriv("botserv/administration") && !check_access(u, ci, CA_SET)) notice_lang(Config.s_BotServ, u, ACCESS_DENIED); - else { - if (option == "DONTKICKOPS") { - if (value == "ON") { + else + { + if (option == "DONTKICKOPS") + { + if (value == "ON") + { ci->botflags.SetFlag(BS_DONTKICKOPS); - notice_lang(Config.s_BotServ, u, BOT_SET_DONTKICKOPS_ON, - ci->name.c_str()); - } else if (value == "OFF") { + notice_lang(Config.s_BotServ, u, BOT_SET_DONTKICKOPS_ON, ci->name.c_str()); + } + else if (value == "OFF") + { ci->botflags.UnsetFlag(BS_DONTKICKOPS); - notice_lang(Config.s_BotServ, u, BOT_SET_DONTKICKOPS_OFF, - ci->name.c_str()); - } else { - syntax_error(Config.s_BotServ, u, "SET DONTKICKOPS", - BOT_SET_DONTKICKOPS_SYNTAX); + notice_lang(Config.s_BotServ, u, BOT_SET_DONTKICKOPS_OFF, ci->name.c_str()); } - } else if (option == "DONTKICKVOICES") { - if (value == "ON") { + else + syntax_error(Config.s_BotServ, u, "SET DONTKICKOPS", BOT_SET_DONTKICKOPS_SYNTAX); + } + else if (option == "DONTKICKVOICES") + { + if (value == "ON") + { ci->botflags.SetFlag(BS_DONTKICKVOICES); - notice_lang(Config.s_BotServ, u, BOT_SET_DONTKICKVOICES_ON, - ci->name.c_str()); - } else if (value == "OFF") { + notice_lang(Config.s_BotServ, u, BOT_SET_DONTKICKVOICES_ON, ci->name.c_str()); + } + else if (value == "OFF") + { ci->botflags.UnsetFlag(BS_DONTKICKVOICES); - notice_lang(Config.s_BotServ, u, BOT_SET_DONTKICKVOICES_OFF, - ci->name.c_str()); - } else { - syntax_error(Config.s_BotServ, u, "SET DONTKICKVOICES", - BOT_SET_DONTKICKVOICES_SYNTAX); + notice_lang(Config.s_BotServ, u, BOT_SET_DONTKICKVOICES_OFF, ci->name.c_str()); } - } else if (option == "FANTASY") { - if (value == "ON") { + else + syntax_error(Config.s_BotServ, u, "SET DONTKICKVOICES", BOT_SET_DONTKICKVOICES_SYNTAX); + } + else if (option == "FANTASY") + { + if (value == "ON") + { ci->botflags.SetFlag(BS_FANTASY); notice_lang(Config.s_BotServ, u, BOT_SET_FANTASY_ON, ci->name.c_str()); - } else if (value == "OFF") { + } + else if (value == "OFF") + { ci->botflags.UnsetFlag(BS_FANTASY); notice_lang(Config.s_BotServ, u, BOT_SET_FANTASY_OFF, ci->name.c_str()); - } else { - syntax_error(Config.s_BotServ, u, "SET FANTASY", - BOT_SET_FANTASY_SYNTAX); } - } else if (option == "GREET") { - if (value == "ON") { + else + syntax_error(Config.s_BotServ, u, "SET FANTASY", BOT_SET_FANTASY_SYNTAX); + } + else if (option == "GREET") + { + if (value == "ON") + { ci->botflags.SetFlag(BS_GREET); notice_lang(Config.s_BotServ, u, BOT_SET_GREET_ON, ci->name.c_str()); - } else if (value == "OFF") { + } + else if (value == "OFF") + { ci->botflags.UnsetFlag(BS_GREET); notice_lang(Config.s_BotServ, u, BOT_SET_GREET_OFF, ci->name.c_str()); - } else { - syntax_error(Config.s_BotServ, u, "SET GREET", - BOT_SET_GREET_SYNTAX); } - } else if (u->Account()->HasCommand("botserv/set/nobot") && option == "NOBOT") { - if (value == "ON") { + else + syntax_error(Config.s_BotServ, u, "SET GREET", BOT_SET_GREET_SYNTAX); + } + else if (u->Account()->HasCommand("botserv/set/nobot") && option == "NOBOT") + { + if (value == "ON") + { ci->botflags.SetFlag(BS_NOBOT); if (ci->bi) ci->bi->UnAssign(u, ci); notice_lang(Config.s_BotServ, u, BOT_SET_NOBOT_ON, ci->name.c_str()); - } else if (value == "OFF") { + } + else if (value == "OFF") + { ci->botflags.UnsetFlag(BS_NOBOT); notice_lang(Config.s_BotServ, u, BOT_SET_NOBOT_OFF, ci->name.c_str()); - } else { - syntax_error(Config.s_BotServ, u, "SET NOBOT", - BOT_SET_NOBOT_SYNTAX); } - } else if (option == "SYMBIOSIS") { - if (value == "ON") { + else + syntax_error(Config.s_BotServ, u, "SET NOBOT", BOT_SET_NOBOT_SYNTAX); + } + else if (option == "SYMBIOSIS") + { + if (value == "ON") + { ci->botflags.SetFlag(BS_SYMBIOSIS); notice_lang(Config.s_BotServ, u, BOT_SET_SYMBIOSIS_ON, ci->name.c_str()); - } else if (value == "OFF") { + } + else if (value == "OFF") + { ci->botflags.UnsetFlag(BS_SYMBIOSIS); notice_lang(Config.s_BotServ, u, BOT_SET_SYMBIOSIS_OFF, ci->name.c_str()); - } else { - syntax_error(Config.s_BotServ, u, "SET SYMBIOSIS", - BOT_SET_SYMBIOSIS_SYNTAX); } - } else { - notice_help(Config.s_BotServ, u, BOT_SET_UNKNOWN, option.c_str()); + else + syntax_error(Config.s_BotServ, u, "SET SYMBIOSIS", BOT_SET_SYMBIOSIS_SYNTAX); } + else + notice_help(Config.s_BotServ, u, BOT_SET_UNKNOWN, option.c_str()); } return MOD_CONT; } @@ -182,6 +200,7 @@ class CommandBSSet : public Command notice_lang(Config.s_BotServ, u, BOT_HELP_CMD_SET); } }; + class BSSet : public Module { public: diff --git a/src/core/bs_unassign.cpp b/src/core/bs_unassign.cpp index 72e62a310..cab7e817c 100644 --- a/src/core/bs_unassign.cpp +++ b/src/core/bs_unassign.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" diff --git a/src/core/cs_access.cpp b/src/core/cs_access.cpp index 49d253d12..3ab17a31a 100644 --- a/src/core/cs_access.cpp +++ b/src/core/cs_access.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -153,7 +152,7 @@ class AccessDelCallback : public NumberList Nicks += ", " + std::string(access->nc->display); else Nicks = access->nc->display; - + FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, u, access->nc)); ci->EraseAccess(Number - 1); @@ -231,8 +230,7 @@ class CommandCSAccess : public Command FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, u, nc, level)); - Alog() << Config.s_ChanServ << ": " << u->GetMask() << " (level " << ulev << ") set access level " << level << " to " << na->nick << " (group " << nc->display << ") on channel " << -ci->name; + Alog() << Config.s_ChanServ << ": " << u->GetMask() << " (level " << ulev << ") set access level " << level << " to " << na->nick << " (group " << nc->display << ") on channel " << ci->name; notice_lang(Config.s_ChanServ, u, CHAN_ACCESS_ADDED, nc->display, ci->name.c_str(), level); return MOD_CONT; @@ -257,9 +255,9 @@ ci->name; NickCore *nc = na->nc; - unsigned i; + unsigned i, end; ChanAccess *access = NULL; - for (i = 0; i < ci->GetAccessCount(); ++i) + for (i = 0, end = ci->GetAccessCount(); i < end; ++i) { access = ci->GetAccess(i); @@ -267,14 +265,10 @@ ci->name; break; } - if (i == ci->GetAccessCount()) - { + if (i == end) notice_lang(Config.s_ChanServ, u, CHAN_ACCESS_NOT_FOUND, nick.c_str(), ci->name.c_str()); - } else if (get_access(u, ci) <= access->level && !u->Account()->HasPriv("chanserv/access/modify")) - { notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - } else { notice_lang(Config.s_ChanServ, u, CHAN_ACCESS_DELETED, access->nc->display, ci->name.c_str()); @@ -300,7 +294,7 @@ ci->name; { bool SentHeader = false; - for (unsigned i = 0; i < ci->GetAccessCount(); i++) + for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i) { ChanAccess *access = ci->GetAccess(i); @@ -337,7 +331,7 @@ ci->name; { bool SentHeader = false; - for (unsigned i = 0; i < ci->GetAccessCount(); ++i) + for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i) { ChanAccess *access = ci->GetAccess(i); @@ -365,9 +359,7 @@ ci->name; CommandReturn DoClear(User *u, ChannelInfo *ci, const std::vector<ci::string> ¶ms) { if (!IsFounder(u, ci) && !u->Account()->HasPriv("chanserv/access/modify")) - { notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - } else { ci->ClearAccess(); @@ -410,40 +402,22 @@ ci->name; else notice_lang(Config.s_ChanServ, u, CHAN_ACCESS_XOP, Config.s_ChanServ); } - else if (( - (is_list && !check_access(u, ci, CA_ACCESS_LIST) && !u->Account()->HasCommand("chanserv/access/list")) - || - (!is_list && !check_access(u, ci, CA_ACCESS_CHANGE) && !u->Account()->HasPriv("chanserv/access/modify")) - )) + else if ((is_list && !check_access(u, ci, CA_ACCESS_LIST) && !u->Account()->HasCommand("chanserv/access/list")) || (!is_list && !check_access(u, ci, CA_ACCESS_CHANGE) && !u->Account()->HasPriv("chanserv/access/modify"))) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); else if (readonly && (cmd == "ADD" || cmd == "DEL" || cmd == "CLEAR")) - { notice_lang(Config.s_ChanServ, u, CHAN_ACCESS_DISABLED); - } else if (cmd == "ADD") - { this->DoAdd(u, ci, params); - } else if (cmd == "DEL") - { this->DoDel(u, ci, params); - } else if (cmd == "LIST") - { this->DoList(u, ci, params); - } else if (cmd == "VIEW") - { this->DoView(u, ci, params); - } else if (cmd == "CLEAR") - { this->DoClear(u, ci, params); - } else - { this->OnSyntaxError(u, ""); - } return MOD_CONT; } @@ -461,7 +435,6 @@ ci->name; } }; - class CommandCSLevels : public Command { CommandReturn DoSet(User *u, ChannelInfo *ci, const std::vector<ci::string> ¶ms) @@ -478,17 +451,12 @@ class CommandCSLevels : public Command *error = '\0'; } - if (*error != '\0') - { + if (*error) this->OnSyntaxError(u, "SET"); - } else if (level <= ACCESS_INVALID || level > ACCESS_FOUNDER) - { notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_RANGE, ACCESS_INVALID + 1, ACCESS_FOUNDER - 1); - } else - { - for (int i = 0; levelinfo[i].what >= 0; i++) + for (int i = 0; levelinfo[i].what >= 0; ++i) { if (levelinfo[i].name == what) { @@ -502,8 +470,6 @@ class CommandCSLevels : public Command return MOD_CONT; } } - } - notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_UNKNOWN, what.c_str(), Config.s_ChanServ); @@ -516,20 +482,18 @@ class CommandCSLevels : public Command /* Don't allow disabling of the founder level. It would be hard to change it back if you dont have access to use this command */ if (what != "FOUNDER") - { - for (int i = 0; levelinfo[i].what >= 0; i++) + for (int i = 0; levelinfo[i].what >= 0; ++i) { if (levelinfo[i].name == what) { ci->levels[levelinfo[i].what] = ACCESS_INVALID; FOREACH_MOD(I_OnLevelChange, OnLevelChange(u, ci, i, levelinfo[i].what)); - + Alog() << Config.s_ChanServ << ": " << u->GetMask() << " disabled level " << levelinfo[i].name << " on channel " << ci->name; notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_DISABLED, levelinfo[i].name, ci->name.c_str()); return MOD_CONT; } } - } notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_UNKNOWN, what.c_str(), Config.s_ChanServ); @@ -541,31 +505,30 @@ class CommandCSLevels : public Command notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_LIST_HEADER, ci->name.c_str()); if (!levelinfo_maxwidth) - { - for (int i = 0; levelinfo[i].what >= 0; i++) { + for (int i = 0; levelinfo[i].what >= 0; ++i) + { int len = strlen(levelinfo[i].name); if (len > levelinfo_maxwidth) levelinfo_maxwidth = len; } - } - for (int i = 0; levelinfo[i].what >= 0; i++) { + for (int i = 0; levelinfo[i].what >= 0; ++i) + { int j = ci->levels[levelinfo[i].what]; - if (j == ACCESS_INVALID) { + if (j == ACCESS_INVALID) + { j = levelinfo[i].what; - if (j == CA_AUTOOP || j == CA_AUTODEOP || j == CA_AUTOVOICE - || j == CA_NOJOIN) { + if (j == CA_AUTOOP || j == CA_AUTODEOP || j == CA_AUTOVOICE || j == CA_NOJOIN) notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_LIST_DISABLED, levelinfo_maxwidth, levelinfo[i].name); - } else { + else notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_LIST_DISABLED, levelinfo_maxwidth, levelinfo[i].name); - } - } else if (j == ACCESS_FOUNDER) { + } + else if (j == ACCESS_FOUNDER) notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_LIST_FOUNDER, levelinfo_maxwidth, levelinfo[i].name); - } else { + else notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_LIST_NORMAL, levelinfo_maxwidth, levelinfo[i].name, j); - } } return MOD_CONT; @@ -604,25 +567,15 @@ class CommandCSLevels : public Command else if (!check_access(u, ci, CA_FOUNDER) && !u->Account()->HasPriv("chanserv/access/modify")) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); else if (cmd == "SET") - { this->DoSet(u, ci, params); - } else if (cmd == "DIS" || cmd == "DISABLE") - { this->DoDisable(u, ci, params); - } else if (cmd == "LIST") - { this->DoList(u, ci, params); - } else if (cmd == "RESET") - { this->DoReset(u, ci, params); - } else - { this->OnSyntaxError(u, ""); - } return MOD_CONT; } @@ -645,7 +598,6 @@ class CommandCSLevels : public Command } }; - class CSAccess : public Module { public: @@ -660,5 +612,4 @@ class CSAccess : public Module } }; - MODULE_INIT(CSAccess) diff --git a/src/core/cs_akick.cpp b/src/core/cs_akick.cpp index e2ad9de99..cb9ae7f08 100644 --- a/src/core/cs_akick.cpp +++ b/src/core/cs_akick.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -19,8 +18,7 @@ * missing parts. */ -static void split_usermask(const char *mask, const char **nick, const char **user, - const char **host) +static void split_usermask(const char *mask, const char **nick, const char **user, const char **host) { char *mask2 = sstrdup(mask); @@ -28,7 +26,8 @@ static void split_usermask(const char *mask, const char **nick, const char **use *user = strtok(NULL, "@"); *host = strtok(NULL, ""); /* Handle special case: mask == user@host */ - if (*nick && !*user && strchr(*nick, '@')) { + if (*nick && !*user && strchr(*nick, '@')) + { *nick = NULL; *user = strtok(mask2, "@"); *host = strtok(NULL, ""); @@ -78,9 +77,7 @@ class AkickListCallback : public NumberList static void DoList(User *u, ChannelInfo *ci, unsigned index, AutoKick *akick) { - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_FORMAT, index + 1, - ((akick->HasFlag(AK_ISNICK)) ? akick->nc->display : akick->mask.c_str()), - (!akick->reason.empty() ? akick->reason.c_str() : getstring(u, NO_REASON))); + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_FORMAT, index + 1, akick->HasFlag(AK_ISNICK) ? akick->nc->display : akick->mask.c_str(), !akick->reason.empty() ? akick->reason.c_str() : getstring(u, NO_REASON)); } }; @@ -120,10 +117,7 @@ class AkickViewCallback : public AkickListCallback else snprintf(timebuf, sizeof(timebuf), "%s", getstring(u, UNKNOWN)); - notice_lang(Config.s_ChanServ, u, (akick->HasFlag(AK_STUCK) ? CHAN_AKICK_VIEW_FORMAT_STUCK : CHAN_AKICK_VIEW_FORMAT), index + 1, - ((akick->HasFlag(AK_ISNICK)) ? akick->nc->display : akick->mask.c_str()), - !akick->creator.empty() ? akick->creator.c_str() : getstring(u, UNKNOWN), timebuf, - (!akick->reason.empty() ? akick->reason.c_str() : getstring(u, NO_REASON))); + notice_lang(Config.s_ChanServ, u, (akick->HasFlag(AK_STUCK) ? CHAN_AKICK_VIEW_FORMAT_STUCK : CHAN_AKICK_VIEW_FORMAT), index + 1, (akick->HasFlag(AK_ISNICK)) ? akick->nc->display : akick->mask.c_str(), !akick->creator.empty() ? akick->creator.c_str() : getstring(u, UNKNOWN), timebuf, !akick->reason.empty() ? akick->reason.c_str() : getstring(u, NO_REASON)); if (akick->last_used) { @@ -197,53 +191,47 @@ class CommandCSAKick : public Command } /* Check excepts BEFORE we get this far */ - if (ModeManager::FindChannelModeByName(CMODE_EXCEPT)) + if (ModeManager::FindChannelModeByName(CMODE_EXCEPT) && is_excepted_mask(ci, mask.c_str())) { - if (is_excepted_mask(ci, mask.c_str())) - { - notice_lang(Config.s_ChanServ, u, CHAN_EXCEPTED, mask.c_str(), ci->name.c_str()); - return; - } + notice_lang(Config.s_ChanServ, u, CHAN_EXCEPTED, mask.c_str(), ci->name.c_str()); + return; } /* Check whether target nick has equal/higher access * or whether the mask matches a user with higher/equal access - Viper */ - if ((ci->HasFlag(CI_PEACE)) && nc) + if (ci->HasFlag(CI_PEACE) && nc) { - if ((nc == ci->founder) || (get_access_level(ci, nc) >= get_access(u, ci))) - { + if (nc == ci->founder || get_access_level(ci, nc) >= get_access(u, ci)) + { notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); return; - } + } } - else if ((ci->HasFlag(CI_PEACE))) + else if (ci->HasFlag(CI_PEACE)) { - /* Match against all currently online users with equal or - * higher access. - Viper */ - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) - { - User *u2 = it->second; - - if (check_access(u2, ci, CA_FOUNDER) || (get_access(u2, ci) >= get_access(u, ci))) + /* Match against all currently online users with equal or + * higher access. - Viper */ + for (user_map::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it) + { + User *u2 = it->second; + + if ((check_access(u2, ci, CA_FOUNDER) || get_access(u2, ci) >= get_access(u, ci)) && match_usermask(mask.c_str(), u2)) { - if (match_usermask(mask.c_str(), u2)) - { - notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - return; - } + notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); + return; } - } + } /* Match against the lastusermask of all nickalias's with equal * or higher access. - Viper */ - for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it) + for (nickalias_map::const_iterator it = NickAliasList.begin(), it_end = NickAliasList.end(); it != it_end; ++it) { NickAlias *na2 = it->second; - + if (na2->HasFlag(NS_FORBIDDEN)) continue; - if (na2->nc && ((na2->nc == ci->founder) || (get_access_level(ci, na2->nc) >= get_access(u, ci)))) + if (na2->nc && (na2->nc == ci->founder || get_access_level(ci, na2->nc) >= get_access(u, ci))) { char buf[BUFSIZE]; @@ -257,12 +245,12 @@ class CommandCSAKick : public Command } } - for (unsigned j = 0; j < ci->GetAkickCount(); ++j) + for (unsigned j = 0, end = ci->GetAkickCount(); j < end; ++j) { akick = ci->GetAkick(j); - if ((akick->HasFlag(AK_ISNICK)) ? akick->nc == nc : akick->mask == mask) + if (akick->HasFlag(AK_ISNICK) ? akick->nc == nc : akick->mask == mask) { - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_ALREADY_EXISTS, (akick->HasFlag(AK_ISNICK)) ? akick->nc->display : akick->mask.c_str(), ci->name.c_str()); + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_ALREADY_EXISTS, akick->HasFlag(AK_ISNICK) ? akick->nc->display : akick->mask.c_str(), ci->name.c_str()); return; } } @@ -291,39 +279,39 @@ class CommandCSAKick : public Command NickAlias *na; NickCore *nc; ci::string mask = params[2]; - unsigned i; + unsigned i, end; AutoKick *akick; if (!ci->GetAkickCount()) { - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); - return; + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); + return; } na = findnick(mask); - nc = (na ? na->nc : NULL); + nc = na ? na->nc : NULL; - for (i = 0; i < ci->GetAkickCount(); ++i) + for (i = 0, end = ci->GetAkickCount(); i < end; ++i) { akick = ci->GetAkick(i); - if (akick->HasFlag(AK_ISNICK)) - continue; + if (akick->HasFlag(AK_ISNICK)) + continue; if (akick->mask == mask) - break; + break; } - if (i == ci->GetAkickCount()) + if (i == end) { - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask.c_str(), ci->name.c_str()); - return; + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask.c_str(), ci->name.c_str()); + return; } akick->SetFlag(AK_STUCK); notice_lang(Config.s_ChanServ, u, CHAN_AKICK_STUCK, akick->mask.c_str(), ci->name.c_str()); if (ci->c) - stick_mask(ci, akick); + stick_mask(ci, akick); } void DoUnStick(User *u, ChannelInfo *ci, const std::vector<ci::string> ¶ms) @@ -331,32 +319,32 @@ class CommandCSAKick : public Command NickAlias *na; NickCore *nc; AutoKick *akick; - unsigned i; + unsigned i, end; ci::string mask = params[2]; if (!ci->GetAkickCount()) { - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); - return; + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); + return; } na = findnick(mask); - nc = (na ? na->nc : NULL); + nc = na ? na->nc : NULL; - for (i = 0; i < ci->GetAkickCount(); ++i) + for (i = 0, end = ci->GetAkickCount(); i < end; ++i) { akick = ci->GetAkick(i); - if (akick->HasFlag(AK_ISNICK)) - continue; + if (akick->HasFlag(AK_ISNICK)) + continue; if (akick->mask == mask) - break; + break; } - if (i == ci->GetAkickCount()) + if (i == end) { - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask.c_str(), ci->name.c_str()); - return; + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask.c_str(), ci->name.c_str()); + return; } akick->UnsetFlag(AK_STUCK); @@ -367,12 +355,12 @@ class CommandCSAKick : public Command { ci::string mask = params[2]; AutoKick *akick; - unsigned i; + unsigned i, end; if (!ci->GetAkickCount()) { - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); - return; + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); + return; } /* Special case: is it a number/list? Only do search if it isn't. */ @@ -380,16 +368,14 @@ class CommandCSAKick : public Command (new AkickDelCallback(u, ci, mask.c_str()))->Process(); else { - NickAlias *na = findnick(mask); - NickCore *nc = (na ? na->nc : NULL); + NickAlias *na = findnick(mask); + NickCore *nc = (na ? na->nc : NULL); - for (i = 0; i < ci->GetAkickCount(); ++i) + for (i = 0, end = ci->GetAkickCount(); i < end; ++i) { akick = ci->GetAkick(i); - if (((akick->HasFlag(AK_ISNICK)) && akick->nc == nc) - || (!(akick->HasFlag(AK_ISNICK)) - && akick->mask == mask)) + if ((akick->HasFlag(AK_ISNICK) && akick->nc == nc) || (!akick->HasFlag(AK_ISNICK) && akick->mask == mask)) break; } @@ -411,8 +397,8 @@ class CommandCSAKick : public Command if (!ci->GetAkickCount()) { - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); - return; + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); + return; } if (!mask.empty() && isdigit(*mask.c_str()) && strspn(mask.c_str(), "1234567890,-") == mask.length()) @@ -421,18 +407,18 @@ class CommandCSAKick : public Command { bool SentHeader = false; - for (unsigned i = 0; i < ci->GetAkickCount(); ++i) + for (unsigned i = 0, end = ci->GetAkickCount(); i < end; ++i) { AutoKick *akick = ci->GetAkick(i); - if (!mask.empty()) + if (!mask.empty()) { - if (!(akick->HasFlag(AK_ISNICK)) && !Anope::Match(akick->mask.c_str(), mask.c_str(), false)) - continue; - if ((akick->HasFlag(AK_ISNICK)) && !Anope::Match(akick->nc->display, mask.c_str(), false)) - continue; - } - + if (!akick->HasFlag(AK_ISNICK) && !Anope::Match(akick->mask.c_str(), mask.c_str(), false)) + continue; + if (akick->HasFlag(AK_ISNICK) && !Anope::Match(akick->nc->display, mask.c_str(), false)) + continue; + } + if (!SentHeader) { SentHeader = true; @@ -440,10 +426,10 @@ class CommandCSAKick : public Command } AkickListCallback::DoList(u, ci, i, akick); - } - - if (!SentHeader) - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_NO_MATCH, ci->name.c_str()); + } + + if (!SentHeader) + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_NO_MATCH, ci->name.c_str()); } } @@ -453,8 +439,8 @@ class CommandCSAKick : public Command if (!ci->GetAkickCount()) { - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); - return; + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); + return; } if (!mask.empty() && isdigit(*mask.c_str()) && strspn(mask.c_str(), "1234567890,-") == mask.length()) @@ -463,17 +449,17 @@ class CommandCSAKick : public Command { bool SentHeader = false; - for (unsigned i = 0; i < ci->GetAkickCount(); ++i) + for (unsigned i = 0, end = ci->GetAkickCount(); i < end; ++i) { AutoKick *akick = ci->GetAkick(i); - if (!mask.empty()) + if (!mask.empty()) { - if (!(akick->HasFlag(AK_ISNICK)) && !Anope::Match(akick->mask.c_str(), mask.c_str(), false)) - continue; - if ((akick->HasFlag(AK_ISNICK)) && !Anope::Match(akick->nc->display, mask.c_str(), false)) - continue; - } + if (!akick->HasFlag(AK_ISNICK) && !Anope::Match(akick->mask.c_str(), mask.c_str(), false)) + continue; + if (akick->HasFlag(AK_ISNICK) && !Anope::Match(akick->nc->display, mask.c_str(), false)) + continue; + } if (!SentHeader) { @@ -482,7 +468,7 @@ class CommandCSAKick : public Command } AkickViewCallback::DoList(u, ci, i, akick); - } + } if (!SentHeader) notice_lang(Config.s_ChanServ, u, CHAN_AKICK_NO_MATCH, ci->name.c_str()); @@ -496,18 +482,16 @@ class CommandCSAKick : public Command if (!c) { - notice_lang(Config.s_ChanServ, u, CHAN_X_NOT_IN_USE, ci->name.c_str()); - return; + notice_lang(Config.s_ChanServ, u, CHAN_X_NOT_IN_USE, ci->name.c_str()); + return; } - for (CUserList::iterator it = c->users.begin(); it != c->users.end();) + for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ) { UserContainer *uc = *it++; if (ci->CheckKick(uc->user)) - { - count++; - } + ++count; } notice_lang(Config.s_ChanServ, u, CHAN_AKICK_ENFORCE_DONE, ci->name.c_str(), count); @@ -577,9 +561,6 @@ class CommandCSAKick : public Command } }; - - - class CSAKick : public Module { public: diff --git a/src/core/cs_ban.cpp b/src/core/cs_ban.cpp index 9aee9d1dc..578ca9868 100644 --- a/src/core/cs_ban.cpp +++ b/src/core/cs_ban.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -28,9 +27,7 @@ class CommandCSBan : public Command const char *reason = NULL; if (params.size() > 2) - { reason = params[2].c_str(); - } Channel *c = findchan(chan); ChannelInfo *ci; @@ -41,30 +38,29 @@ class CommandCSBan : public Command if (!reason) reason = "Requested"; - is_same = (stricmp(target, u->nick.c_str()) == 0); + is_same = !stricmp(target, u->nick.c_str()); if (c) ci = c->ci; - if (!c) { + if (!c) notice_lang(Config.s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); - } else if (is_same ? !(u2 = u) : !(u2 = finduser(target))) { + else if (is_same ? !(u2 = u) : !(u2 = finduser(target))) notice_lang(Config.s_ChanServ, u, NICK_X_NOT_IN_USE, target); - } else if (!is_same ? !check_access(u, ci, CA_BAN) : - !check_access(u, ci, CA_BANME)) { + else if (!is_same ? !check_access(u, ci, CA_BAN) : !check_access(u, ci, CA_BANME)) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - } else if (!is_same && (ci->HasFlag(CI_PEACE)) - && (get_access(u2, ci) >= get_access(u, ci))) { + else if (!is_same && (ci->HasFlag(CI_PEACE)) && (get_access(u2, ci) >= get_access(u, ci))) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - /* - * Dont ban/kick the user on channels where he is excepted - * to prevent services <-> server wars. - */ - } else if (ModeManager::FindChannelModeByName(CMODE_EXCEPT) && is_excepted(ci, u2)) { + /* + * Dont ban/kick the user on channels where he is excepted + * to prevent services <-> server wars. + */ + else if (ModeManager::FindChannelModeByName(CMODE_EXCEPT) && is_excepted(ci, u2)) notice_lang(Config.s_ChanServ, u, CHAN_EXCEPTED, u2->nick.c_str(), ci->name.c_str()); - } else if (u2->IsProtected()) + else if (u2->IsProtected()) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - else { + else + { char mask[BUFSIZE]; get_idealban(ci, u2, mask, sizeof(mask)); @@ -100,7 +96,6 @@ class CommandCSBan : public Command } }; - class CSBan : public Module { public: @@ -114,5 +109,4 @@ class CSBan : public Module } }; - MODULE_INIT(CSBan) diff --git a/src/core/cs_clear.cpp b/src/core/cs_clear.cpp index f331f7a24..088dae741 100644 --- a/src/core/cs_clear.cpp +++ b/src/core/cs_clear.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -19,7 +18,6 @@ class CommandCSClear : public Command public: CommandCSClear() : Command("CLEAR", 2, 2) { - } CommandReturn Execute(User *u, const std::vector<ci::string> ¶ms) @@ -51,14 +49,12 @@ class CommandCSClear : public Command c->ClearExcepts(); notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_EXCEPTS, chan); - } else if (ModeManager::FindChannelModeByName(CMODE_INVITE) && what == "invites") { c->ClearInvites(); notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_INVITES, chan); - } else if (what == "modes") { @@ -95,7 +91,7 @@ class CommandCSClear : public Command } else { - for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) + for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) { UserContainer *uc = *it; @@ -112,7 +108,7 @@ class CommandCSClear : public Command } else if ((halfop && what == "hops") || (voice && what == "voices")) { - ChannelMode *cm = (what == "hops" ? halfop : voice); + ChannelMode *cm = what == "hops" ? halfop : voice; if (ircd->svsmode_ucmode) { @@ -123,7 +119,7 @@ class CommandCSClear : public Command } else { - for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) + for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) { UserContainer *uc = *it; @@ -136,7 +132,7 @@ class CommandCSClear : public Command { std::string buf = "CLEAR USERS command from " + u->nick; - for (CUserList::iterator it = c->users.begin(); it != c->users.end();) + for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ) { UserContainer *uc = *it++; diff --git a/src/core/cs_drop.cpp b/src/core/cs_drop.cpp index 04b2f595f..cb54ab274 100644 --- a/src/core/cs_drop.cpp +++ b/src/core/cs_drop.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -36,13 +35,13 @@ class CommandCSDrop : public Command ci = cs_findchan(chan); - if ((ci->HasFlag(CI_FORBIDDEN)) && !u->Account()->HasCommand("chanserv/drop")) + if (ci->HasFlag(CI_FORBIDDEN) && !u->Account()->HasCommand("chanserv/drop")) { notice_lang(Config.s_ChanServ, u, CHAN_X_FORBIDDEN, chan); return MOD_CONT; } - if ((ci->HasFlag(CI_SUSPENDED)) && !u->Account()->HasCommand("chanserv/drop")) + if (ci->HasFlag(CI_SUSPENDED) && !u->Account()->HasCommand("chanserv/drop")) { notice_lang(Config.s_ChanServ, u, CHAN_X_FORBIDDEN, chan); return MOD_CONT; @@ -56,13 +55,8 @@ class CommandCSDrop : public Command int level = get_access(u, ci); - if (ci->c) - { - if (ModeManager::FindChannelModeByName(CMODE_REGISTERED)) - { - ci->c->RemoveMode(NULL, CMODE_REGISTERED, "", false); - } - } + if (ci->c && ModeManager::FindChannelModeByName(CMODE_REGISTERED)) + ci->c->RemoveMode(NULL, CMODE_REGISTERED, "", false); if (ircd->chansqline && (ci->HasFlag(CI_FORBIDDEN))) { @@ -70,18 +64,15 @@ class CommandCSDrop : public Command ircdproto->SendSQLineDel(&x); } - Alog() << Config.s_ChanServ << ": Channel " << ci->name << " dropped by " << u->GetMask() << " (founder: " - << (ci->founder ? ci->founder->display : "(none)") << ")"; + Alog() << Config.s_ChanServ << ": Channel " << ci->name << " dropped by " << u->GetMask() << " (founder: " << (ci->founder ? ci->founder->display : "(none)") << ")"; delete ci; /* We must make sure that the Services admin has not normally the right to * drop the channel before issuing the wallops. */ - if (Config.WallDrop) { - if ((level < ACCESS_FOUNDER) || (!IsFounder(u, ci) && ci->HasFlag(CI_SECUREFOUNDER))) - ircdproto->SendGlobops(ChanServ, "\2%s\2 used DROP on channel \2%s\2", u->nick.c_str(), chan); - } + if (Config.WallDrop && (level < ACCESS_FOUNDER || (!IsFounder(u, ci) && ci->HasFlag(CI_SECUREFOUNDER)))) + ircdproto->SendGlobops(ChanServ, "\2%s\2 used DROP on channel \2%s\2", u->nick.c_str(), chan); notice_lang(Config.s_ChanServ, u, CHAN_DROPPED, chan); @@ -104,7 +95,7 @@ class CommandCSDrop : public Command { syntax_error(Config.s_ChanServ, u, "DROP", CHAN_DROP_SYNTAX); } - + void OnServHelp(User *u) { notice_lang(Config.s_ChanServ, u, CHAN_HELP_CMD_DROP); diff --git a/src/core/cs_forbid.cpp b/src/core/cs_forbid.cpp index d59be57b2..e1717548b 100644 --- a/src/core/cs_forbid.cpp +++ b/src/core/cs_forbid.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -48,7 +47,7 @@ class CommandCSForbid : public Command return MOD_CONT; } - if ((ci = cs_findchan(chan)) != NULL) + if ((ci = cs_findchan(chan))) delete ci; ci = new ChannelInfo(chan); @@ -71,7 +70,7 @@ class CommandCSForbid : public Command c->ClearExcepts(); c->ClearInvites(); - for (CUserList::iterator it = c->users.begin(); it != c->users.end();) + for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ) { UserContainer *uc = *it++; diff --git a/src/core/cs_getkey.cpp b/src/core/cs_getkey.cpp index dc89bbbd0..5c92d1d70 100644 --- a/src/core/cs_getkey.cpp +++ b/src/core/cs_getkey.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -62,7 +61,6 @@ class CommandCSGetKey : public Command } }; - class CSGetKey : public Module { public: diff --git a/src/core/cs_help.cpp b/src/core/cs_help.cpp index 3fe704349..e7c352644 100644 --- a/src/core/cs_help.cpp +++ b/src/core/cs_help.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -32,18 +31,14 @@ class CommandCSHelp : public Command int i; notice_help(Config.s_ChanServ, u, CHAN_HELP_LEVELS_DESC); if (!levelinfo_maxwidth) - { - for (i = 0; levelinfo[i].what >= 0; i++) + for (i = 0; levelinfo[i].what >= 0; ++i) { int len = strlen(levelinfo[i].name); if (len > levelinfo_maxwidth) levelinfo_maxwidth = len; } - } - for (i = 0; levelinfo[i].what >= 0; i++) - { + for (i = 0; levelinfo[i].what >= 0; ++i) notice_help(Config.s_ChanServ, u, CHAN_HELP_LEVELS_DESC_FORMAT, levelinfo_maxwidth, levelinfo[i].name, getstring(u, levelinfo[i].desc)); - } } else mod_help_cmd(ChanServ, u, cmd.c_str()); @@ -63,7 +58,6 @@ class CommandCSHelp : public Command } }; - class CSHelp : public Module { public: diff --git a/src/core/cs_info.cpp b/src/core/cs_info.cpp index 4e5bf9159..8ff54de67 100644 --- a/src/core/cs_info.cpp +++ b/src/core/cs_info.cpp @@ -7,15 +7,14 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" class CommandCSInfo : public Command -{ +{ void CheckOptStr(std::string &buf, ChannelInfoFlag opt, const std::string &str, ChannelInfo *ci, NickCore *nc) { if (ci->HasFlag(opt)) @@ -52,10 +51,7 @@ class CommandCSInfo : public Command if (ci->HasFlag(CI_FORBIDDEN)) { if (is_oper(u) && ci->forbidby) - notice_lang(Config.s_ChanServ, u, CHAN_X_FORBIDDEN_OPER, chan, - ci->forbidby, - (ci->forbidreason ? ci-> - forbidreason : getstring(u, NO_REASON))); + notice_lang(Config.s_ChanServ, u, CHAN_X_FORBIDDEN_OPER, chan, ci->forbidby, ci->forbidreason ? ci->forbidreason : getstring(u, NO_REASON)); else notice_lang(Config.s_ChanServ, u, CHAN_X_FORBIDDEN, chan); @@ -119,9 +115,7 @@ class CommandCSInfo : public Command // XXX: we could just as easily (and tidily) merge this in with the flags display above. if (ci->HasFlag(CI_NO_EXPIRE)) - { notice_lang(Config.s_ChanServ, u, CHAN_INFO_NO_EXPIRE); - } else { if (has_auspex) @@ -134,9 +128,7 @@ class CommandCSInfo : public Command } } if (ci->HasFlag(CI_SUSPENDED)) - { notice_lang(Config.s_ChanServ, u, CHAN_X_SUSPENDED, ci->forbidby, (ci->forbidreason ? ci->forbidreason : getstring(u, NO_REASON))); - } FOREACH_MOD(I_OnChanInfo, OnChanInfo(u, ci, show_all)); diff --git a/src/core/cs_invite.cpp b/src/core/cs_invite.cpp index 40999af83..c8b1f15e2 100644 --- a/src/core/cs_invite.cpp +++ b/src/core/cs_invite.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" diff --git a/src/core/cs_kick.cpp b/src/core/cs_kick.cpp index e28b1f176..70c3114a3 100644 --- a/src/core/cs_kick.cpp +++ b/src/core/cs_kick.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -28,9 +27,7 @@ class CommandCSKick : public Command const char *reason = NULL; if (params.size() > 2) - { reason = params[2].c_str(); - } Channel *c = findchan(chan); ChannelInfo *ci; @@ -38,29 +35,28 @@ class CommandCSKick : public Command int is_same; - if (!reason) { + if (!reason) reason = "Requested"; - } - is_same = (target == u->nick.c_str()) ? 1 : (stricmp(target, u->nick.c_str()) == 0); + is_same = target == u->nick.c_str() ? 1 : !stricmp(target, u->nick.c_str()); if (c) ci = c->ci; - if (!c) { + if (!c) notice_lang(Config.s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); - } else if (is_same ? !(u2 = u) : !(u2 = finduser(target))) { + else if (is_same ? !(u2 = u) : !(u2 = finduser(target))) notice_lang(Config.s_ChanServ, u, NICK_X_NOT_IN_USE, target); - } else if (!is_same ? !check_access(u, ci, CA_KICK) : !check_access(u, ci, CA_KICKME)) { + else if (!is_same ? !check_access(u, ci, CA_KICK) : !check_access(u, ci, CA_KICKME)) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - } else if (!is_same && (ci->HasFlag(CI_PEACE)) - && (get_access(u2, ci) >= get_access(u, ci))) { + else if (!is_same && (ci->HasFlag(CI_PEACE)) && get_access(u2, ci) >= get_access(u, ci)) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - } else if (u2->IsProtected()) + else if (u2->IsProtected()) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - else if (!c->FindUser(u2)) { + else if (!c->FindUser(u2)) notice_lang(Config.s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick.c_str(), c->name.c_str()); - } else { + else + { if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !check_access(u, ci, CA_SIGNKICK))) ci->c->Kick(whosends(ci), u2, "%s (%s)", reason, u->nick.c_str()); else diff --git a/src/core/cs_list.cpp b/src/core/cs_list.cpp index 9e8ed1779..0fc272e46 100644 --- a/src/core/cs_list.cpp +++ b/src/core/cs_list.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -51,8 +50,7 @@ public: notice_lang(Config.s_ChanServ, u, CS_LIST_INCORRECT_RANGE); return MOD_CONT; } - for (s = tmp; *s; s++) - { + for (s = tmp; *s; ++s) if (!isdigit(*s)) { delete [] tmp; @@ -60,7 +58,6 @@ public: notice_lang(Config.s_ChanServ, u, CS_LIST_INCORRECT_RANGE); return MOD_CONT; } - } from = atoi(tmp); delete [] tmp; tmp = myStrGetTokenRemainder(pattern, '-', 1); /* Read TO out */ @@ -70,8 +67,7 @@ public: notice_lang(Config.s_ChanServ, u, CS_LIST_INCORRECT_RANGE); return MOD_CONT; } - for (s = tmp; *s; s++) - { + for (s = tmp; *s; ++s) if (!isdigit(*s)) { delete [] tmp; @@ -79,7 +75,6 @@ public: notice_lang(Config.s_ChanServ, u, CS_LIST_INCORRECT_RANGE); return MOD_CONT; } - } to = atoi(tmp); delete [] tmp; pattern = sstrdup("*"); @@ -90,18 +85,16 @@ public: if (is_servadmin && params.size() > 1) { - std::string keyword; + ci::string keyword; spacesepstream keywords(params[1].c_str()); while (keywords.GetToken(keyword)) { - ci::string keyword_ci = keyword.c_str(); - if (keyword_ci == "FORBIDDEN") + if (keyword == "FORBIDDEN") forbidden = true; - if (keyword_ci == "SUSPENDED") + if (keyword == "SUSPENDED") suspended = true; - if (keyword_ci == "NOEXPIRE") + if (keyword == "NOEXPIRE") channoexpire = true; - } } @@ -111,12 +104,11 @@ public: notice_lang(Config.s_ChanServ, u, CHAN_LIST_HEADER, pattern); - for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it) + for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it) { ChannelInfo *ci = it->second; - if (!is_servadmin && ((ci->HasFlag(CI_PRIVATE)) - || (ci->HasFlag(CI_FORBIDDEN)) || (ci->HasFlag(CI_SUSPENDED)))) + if (!is_servadmin && (ci->HasFlag(CI_PRIVATE) || ci->HasFlag(CI_FORBIDDEN) || ci->HasFlag(CI_SUSPENDED))) continue; if (forbidden && !ci->HasFlag(CI_FORBIDDEN)) continue; @@ -125,43 +117,28 @@ public: else if (channoexpire && !ci->HasFlag(CI_NO_EXPIRE)) continue; - if ((stricmp(pattern, ci->name.c_str()) == 0) - || (stricmp(spattern, ci->name.c_str()) == 0) - || Anope::Match(ci->name, pattern, false) - || Anope::Match(ci->name, spattern, false)) + if (!stricmp(pattern, ci->name.c_str()) || !stricmp(spattern, ci->name.c_str()) || Anope::Match(ci->name, pattern, false) || Anope::Match(ci->name, spattern, false)) { - if ((((count + 1 >= from) && (count + 1 <= to)) - || ((from == 0) && (to == 0))) - && (++nchans <= Config.CSListMax)) + if (((count + 1 >= from && count + 1 <= to) || (!from && !to)) && ++nchans <= Config.CSListMax) { char noexpire_char = ' '; if (is_servadmin && (ci->HasFlag(CI_NO_EXPIRE))) noexpire_char = '!'; if (ci->HasFlag(CI_FORBIDDEN)) - { - snprintf(buf, sizeof(buf), - "%-20s [Forbidden]", ci->name.c_str()); - } + snprintf(buf, sizeof(buf), "%-20s [Forbidden]", ci->name.c_str()); else if (ci->HasFlag(CI_SUSPENDED)) - { - snprintf(buf, sizeof(buf), - "%-20s [Suspended]", ci->name.c_str()); - } + snprintf(buf, sizeof(buf), "%-20s [Suspended]", ci->name.c_str()); else - { - snprintf(buf, sizeof(buf), "%-20s %s", - ci->name.c_str(), ci->desc ? ci->desc : ""); - } + snprintf(buf, sizeof(buf), "%-20s %s", ci->name.c_str(), ci->desc ? ci->desc : ""); u->SendMessage(Config.s_ChanServ, " %c%s", noexpire_char, buf); } - count++; + ++count; } } - notice_lang(Config.s_ChanServ, u, CHAN_LIST_END, - nchans > Config.CSListMax ? Config.CSListMax : nchans, nchans); + notice_lang(Config.s_ChanServ, u, CHAN_LIST_END, nchans > Config.CSListMax ? Config.CSListMax : nchans, nchans); delete [] spattern; if (tofree) delete [] pattern; diff --git a/src/core/cs_modes.cpp b/src/core/cs_modes.cpp index 67d38ba49..343f96ddf 100644 --- a/src/core/cs_modes.cpp +++ b/src/core/cs_modes.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -36,7 +35,7 @@ static CommandReturn do_util(User *u, ChannelMode *cm, const char *chan, const c if (!nick) nick = u->nick.c_str(); - is_same = (nick == u->nick) ? 1 : (stricmp(nick, u->nick.c_str()) == 0); + is_same = nick == u->nick ? 1 : !stricmp(nick, u->nick.c_str()); if (c) ci = c->ci; @@ -61,8 +60,7 @@ static CommandReturn do_util(User *u, ChannelMode *cm, const char *chan, const c c->RemoveMode(NULL, cm, u2->nick); if (notice && ci->HasFlag(notice)) - ircdproto->SendMessage(whosends(ci), c->name.c_str(), "%s command used for %s by %s", - name.c_str(), u2->nick.c_str(), u->nick.c_str()); + ircdproto->SendMessage(whosends(ci), c->name.c_str(), "%s command used for %s by %s", name.c_str(), u2->nick.c_str(), u->nick.c_str()); } return MOD_CONT; @@ -79,7 +77,7 @@ class CommandCSOp : public Command { ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_OP); - return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_OPDEOP, CA_OPDEOPME, "OP", CI_OPNOTICE); + return do_util(u, cm, params.size() > 0 ? params[0].c_str() : NULL, params.size() > 1 ? params[1].c_str() : NULL, true, CA_OPDEOP, CA_OPDEOPME, "OP", CI_OPNOTICE); } bool OnHelp(User *u, const ci::string &subcommand) @@ -99,7 +97,6 @@ class CommandCSOp : public Command } }; - class CommandCSDeOp : public Command { public: @@ -111,7 +108,7 @@ class CommandCSDeOp : public Command { ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_OP); - return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_OPDEOP, CA_OPDEOPME, "DEOP", CI_OPNOTICE); + return do_util(u, cm, params.size() > 0 ? params[0].c_str() : NULL, params.size() > 1 ? params[1].c_str() : NULL, false, CA_OPDEOP, CA_OPDEOPME, "DEOP", CI_OPNOTICE); } bool OnHelp(User *u, const ci::string &subcommand) @@ -131,7 +128,6 @@ class CommandCSDeOp : public Command } }; - class CommandCSVoice : public Command { public: @@ -143,7 +139,7 @@ class CommandCSVoice : public Command { ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_VOICE); - return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_VOICE, CA_VOICEME, "VOICE", CI_BEGIN); + return do_util(u, cm, params.size() > 0 ? params[0].c_str() : NULL, params.size() > 1 ? params[1].c_str() : NULL, true, CA_VOICE, CA_VOICEME, "VOICE", CI_BEGIN); } bool OnHelp(User *u, const ci::string &subcommand) @@ -163,7 +159,6 @@ class CommandCSVoice : public Command } }; - class CommandCSDeVoice : public Command { public: @@ -175,7 +170,7 @@ class CommandCSDeVoice : public Command { ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_VOICE); - return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_VOICE, CA_VOICEME, "DEVOICE", CI_BEGIN); + return do_util(u, cm, params.size() > 0 ? params[0].c_str() : NULL, params.size() > 1 ? params[1].c_str() : NULL, false, CA_VOICE, CA_VOICEME, "DEVOICE", CI_BEGIN); } bool OnHelp(User *u, const ci::string &subcommand) @@ -195,7 +190,6 @@ class CommandCSDeVoice : public Command } }; - class CommandCSHalfOp : public Command { public: @@ -206,13 +200,13 @@ class CommandCSHalfOp : public Command CommandReturn Execute(User *u, const std::vector<ci::string> ¶ms) { ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_HALFOP); - + if (!cm) { return MOD_CONT; } - return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_HALFOP, CA_HALFOPME, "HALFOP", CI_BEGIN); + return do_util(u, cm, params.size() > 0 ? params[0].c_str() : NULL, params.size() > 1 ? params[1].c_str() : NULL, true, CA_HALFOP, CA_HALFOPME, "HALFOP", CI_BEGIN); } bool OnHelp(User *u, const ci::string &subcommand) @@ -232,7 +226,6 @@ class CommandCSHalfOp : public Command } }; - class CommandCSDeHalfOp : public Command { public: @@ -245,12 +238,9 @@ class CommandCSDeHalfOp : public Command ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_HALFOP); if (!cm) - { return MOD_CONT; - } - - return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_HALFOP, CA_HALFOPME, "DEHALFOP", CI_BEGIN); + return do_util(u, cm, params.size() > 0 ? params[0].c_str() : NULL, params.size() > 1 ? params[1].c_str() : NULL, false, CA_HALFOP, CA_HALFOPME, "DEHALFOP", CI_BEGIN); } bool OnHelp(User *u, const ci::string &subcommand) @@ -270,7 +260,6 @@ class CommandCSDeHalfOp : public Command } }; - class CommandCSProtect : public Command { public: @@ -283,11 +272,9 @@ class CommandCSProtect : public Command ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_PROTECT); if (!cm) - { return MOD_CONT; - } - return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_PROTECT, CA_PROTECTME, "PROTECT", CI_BEGIN); + return do_util(u, cm, params.size() > 0 ? params[0].c_str() : NULL, params.size() > 1 ? params[1].c_str() : NULL, true, CA_PROTECT, CA_PROTECTME, "PROTECT", CI_BEGIN); } bool OnHelp(User *u, const ci::string &subcommand) @@ -319,11 +306,9 @@ class CommandCSDeProtect : public Command ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_PROTECT); if (!cm) - { return MOD_CONT; - } - return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_PROTECT, CA_PROTECTME, "DEPROTECT", CI_BEGIN); + return do_util(u, cm, params.size() > 0 ? params[0].c_str() : NULL, params.size() > 1 ? params[1].c_str() : NULL, false, CA_PROTECT, CA_PROTECTME, "DEPROTECT", CI_BEGIN); } bool OnHelp(User *u, const ci::string &subcommand) @@ -355,11 +340,9 @@ class CommandCSOwner : public Command ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_OWNER); if (!cm) - { return MOD_CONT; - } - return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_OWNER, CA_OWNERME, "OWNER", CI_BEGIN); + return do_util(u, cm, params.size() > 0 ? params[0].c_str() : NULL, params.size() > 1 ? params[1].c_str() : NULL, true, CA_OWNER, CA_OWNERME, "OWNER", CI_BEGIN); } bool OnHelp(User *u, const ci::string &subcommand) @@ -391,11 +374,9 @@ class CommandCSDeOwner : public Command ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_OWNER); if (!cm) - { return MOD_CONT; - } - return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_OWNER, CA_OWNERME, "DEOWNER", CI_BEGIN); + return do_util(u, cm, params.size() > 0 ? params[0].c_str() : NULL, params.size() > 1 ? params[1].c_str() : NULL, false, CA_OWNER, CA_OWNERME, "DEOWNER", CI_BEGIN); } bool OnHelp(User *u, const ci::string &subcommand) @@ -415,7 +396,6 @@ class CommandCSDeOwner : public Command } }; - class CSModes : public Module { public: @@ -433,9 +413,7 @@ class CSModes : public Module if (Me && Me->IsSynced()) OnUplinkSync(NULL); - Implementation i[] = { - I_OnUplinkSync, I_OnServerDisconnect - }; + Implementation i[] = {I_OnUplinkSync, I_OnServerDisconnect}; ModuleManager::Attach(i, this, 2); } @@ -471,5 +449,4 @@ class CSModes : public Module } }; - MODULE_INIT(CSModes) diff --git a/src/core/cs_register.cpp b/src/core/cs_register.cpp index 1706ac16e..38aced195 100644 --- a/src/core/cs_register.cpp +++ b/src/core/cs_register.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -92,9 +91,7 @@ class CommandCSRegister : public Command ci->SetFlag(CI_PERSIST); /* Persist may be in def cflags, set it here */ else if (ci->HasFlag(CI_PERSIST) && (cm = ModeManager::FindChannelModeByName(CMODE_PERM))) - { c->SetMode(NULL, CMODE_PERM); - } } FOREACH_MOD(I_OnChanRegistered, OnChanRegistered(ci)); diff --git a/src/core/cs_saset.cpp b/src/core/cs_saset.cpp index 29f7f7264..02a44e974 100644 --- a/src/core/cs_saset.cpp +++ b/src/core/cs_saset.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -26,10 +24,8 @@ class CommandCSSASet : public Command ~CommandCSSASet() { - for (std::map<ci::string, Command *>::const_iterator it = this->subcommands.begin(); it != this->subcommands.end(); ++it) - { + for (std::map<ci::string, Command *>::const_iterator it = this->subcommands.begin(), it_end = this->subcommands.end(); it != it_end; ++it) delete it->second; - } this->subcommands.clear(); } @@ -46,7 +42,7 @@ class CommandCSSASet : public Command if (c) { ci::string cmdparams = cs_findchan(params[0])->name.c_str(); - for (std::vector<ci::string>::const_iterator it = params.begin() + 2; it != params.end(); ++it) + for (std::vector<ci::string>::const_iterator it = params.begin() + 2, it_end = params.end(); it != it_end; ++it) cmdparams += " " + *it; mod_run_cmd(ChanServ, u, c, params[1], cmdparams); } @@ -64,7 +60,7 @@ class CommandCSSASet : public Command if (subcommand.empty()) { notice_help(Config.s_ChanServ, u, CHAN_HELP_SASET_HEAD); - for (std::map<ci::string, Command *>::iterator it = this->subcommands.begin(); it != this->subcommands.end(); ++it) + for (std::map<ci::string, Command *>::iterator it = this->subcommands.begin(), it_end = this->subcommands.end(); it != it_end; ++it) it->second->OnServHelp(u); notice_help(Config.s_ChanServ, u, CHAN_HELP_SET_TAIL); return true; @@ -74,9 +70,7 @@ class CommandCSSASet : public Command Command *c = this->FindCommand(subcommand); if (c) - { return c->OnHelp(u, subcommand); - } } return false; @@ -107,9 +101,7 @@ class CommandCSSASet : public Command std::map<ci::string, Command *>::const_iterator it = this->subcommands.find(subcommand); if (it != this->subcommands.end()) - { return it->second; - } return NULL; } @@ -121,7 +113,7 @@ class CSSASet : public Module CSSASet(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); this->AddCommand(ChanServ, new CommandCSSASet("SASET")); diff --git a/src/core/cs_saset_noexpire.cpp b/src/core/cs_saset_noexpire.cpp index 8d9ce2e18..c73bcf7b8 100644 --- a/src/core/cs_saset_noexpire.cpp +++ b/src/core/cs_saset_noexpire.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -66,7 +64,7 @@ class CSSetNoexpire : public Module CSSetNoexpire(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SASET"); diff --git a/src/core/cs_set.cpp b/src/core/cs_set.cpp index c11a1c102..5f7d2da83 100644 --- a/src/core/cs_set.cpp +++ b/src/core/cs_set.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -25,10 +24,8 @@ class CommandCSSet : public Command ~CommandCSSet() { - for (std::map<ci::string, Command *>::const_iterator it = this->subcommands.begin(); it != this->subcommands.end(); ++it) - { + for (std::map<ci::string, Command *>::const_iterator it = this->subcommands.begin(), it_end = this->subcommands.end(); it != it_end; ++it) delete it->second; - } this->subcommands.clear(); } @@ -45,13 +42,12 @@ class CommandCSSet : public Command return MOD_CONT; } - Command *c = this->FindCommand(params[1]); if (c) { ci::string cmdparams = cs_findchan(params[0])->name.c_str(); - for (std::vector<ci::string>::const_iterator it = params.begin() + 2; it != params.end(); ++it) + for (std::vector<ci::string>::const_iterator it = params.begin() + 2, it_end = params.end(); it != it_end; ++it) cmdparams += " " + *it; mod_run_cmd(ChanServ, u, c, params[1], cmdparams); } @@ -69,7 +65,7 @@ class CommandCSSet : public Command if (subcommand.empty()) { notice_help(Config.s_ChanServ, u, CHAN_HELP_SET_HEAD); - for (std::map<ci::string, Command *>::iterator it = this->subcommands.begin(); it != this->subcommands.end(); ++it) + for (std::map<ci::string, Command *>::iterator it = this->subcommands.begin(), it_end = this->subcommands.end(); it != it_end; ++it) it->second->OnServHelp(u); notice_help(Config.s_ChanServ, u, CHAN_HELP_SET_TAIL); return true; @@ -79,9 +75,7 @@ class CommandCSSet : public Command Command *c = this->FindCommand(subcommand); if (c) - { return c->OnHelp(u, subcommand); - } } return false; @@ -112,9 +106,7 @@ class CommandCSSet : public Command std::map<ci::string, Command *>::const_iterator it = this->subcommands.find(subcommand); if (it != this->subcommands.end()) - { return it->second; - } return NULL; } diff --git a/src/core/cs_set_bantype.cpp b/src/core/cs_set_bantype.cpp index fca1e6fdc..7095ad717 100644 --- a/src/core/cs_set_bantype.cpp +++ b/src/core/cs_set_bantype.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -31,7 +29,7 @@ class CommandCSSetBanType : public Command int16 bantype = strtol(params[1].c_str(), &endptr, 10); - if (*endptr != 0 || bantype < 0 || bantype > 3) + if (*endptr || bantype < 0 || bantype > 3) notice_lang(Config.s_ChanServ, u, CHAN_SET_BANTYPE_INVALID, params[1].c_str()); else { @@ -86,7 +84,7 @@ class CSSetBanType : public Module CSSetBanType(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_set_description.cpp b/src/core/cs_set_description.cpp index 0900f4792..b4b99cde0 100644 --- a/src/core/cs_set_description.cpp +++ b/src/core/cs_set_description.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -80,7 +78,7 @@ class CSSetDescription : public Module CSSetDescription(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_set_email.cpp b/src/core/cs_set_email.cpp index 9923f6061..98253999b 100644 --- a/src/core/cs_set_email.cpp +++ b/src/core/cs_set_email.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -87,7 +85,7 @@ class CSSetEMail : public Module CSSetEMail(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_set_entrymsg.cpp b/src/core/cs_set_entrymsg.cpp index 321f00f73..651f68271 100644 --- a/src/core/cs_set_entrymsg.cpp +++ b/src/core/cs_set_entrymsg.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -87,7 +85,7 @@ class CSSetEntryMsg : public Module CSSetEntryMsg(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_set_founder.cpp b/src/core/cs_set_founder.cpp index c1dbfb62f..d835e7fea 100644 --- a/src/core/cs_set_founder.cpp +++ b/src/core/cs_set_founder.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -55,16 +53,15 @@ class CommandCSSetFounder : public Command return MOD_CONT; } - Alog() << Config.s_ChanServ << ": Changing founder of " << ci->name << " from " << ci->founder->display - << " to " << nc->display << " by " << u->GetMask(); + Alog() << Config.s_ChanServ << ": Changing founder of " << ci->name << " from " << ci->founder->display << " to " << nc->display << " by " << u->GetMask(); /* Founder and successor must not be the same group */ if (nc == ci->successor) ci->successor = NULL; - nc0->channelcount--; + --nc0->channelcount; ci->founder = nc; - nc->channelcount++; + ++nc->channelcount; notice_lang(Config.s_ChanServ, u, CHAN_FOUNDER_CHANGED, ci->name.c_str(), na->nick); @@ -115,7 +112,7 @@ class CSSetFounder : public Module CSSetFounder(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_set_keeptopic.cpp b/src/core/cs_set_keeptopic.cpp index 819d3e9c8..5fa154fd2 100644 --- a/src/core/cs_set_keeptopic.cpp +++ b/src/core/cs_set_keeptopic.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -85,7 +83,7 @@ class CSSetKeepTopic : public Module CSSetKeepTopic(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_set_mlock.cpp b/src/core/cs_set_mlock.cpp index 87d55790a..bffe9e833 100644 --- a/src/core/cs_set_mlock.cpp +++ b/src/core/cs_set_mlock.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -27,7 +25,7 @@ class CommandCSSetMLock : public Command ChannelInfo *ci = cs_findchan(params[0]); assert(ci); - int add = -1; /* 1 if adding, 0 if deleting, -1 if neither */ + int add = -1; /* 1 if adding, 0 if deleting, -1 if neither */ unsigned char mode; ChannelMode *cm; unsigned paramcount = 2; @@ -41,24 +39,23 @@ class CommandCSSetMLock : public Command const char *modes = params[1].c_str(); while (modes && (mode = *modes++)) { - switch (mode) { - case '+': - add = 1; - continue; - case '-': - add = 0; - continue; - default: - if (add < 0) + switch (mode) + { + case '+': + add = 1; + continue; + case '-': + add = 0; continue; + default: + if (add < 0) + continue; } if ((cm = ModeManager::FindChannelModeByChar(mode))) { if (cm->Type == MODE_STATUS || cm->Type == MODE_LIST || !cm->CanSet(u)) - { notice_lang(Config.s_ChanServ, u, CHAN_SET_MLOCK_IMPOSSIBLE_CHAR, mode); - } else if (add) { ci->RemoveMLock(cm->Name); @@ -78,46 +75,33 @@ class CommandCSSetMLock : public Command ci->SetMLock(cmp->Name, true, param); } else - { ci->SetMLock(cm->Name, true); - } } else - { ci->SetMLock(cm->Name, false); - } } else notice_lang(Config.s_ChanServ, u, CHAN_SET_MLOCK_UNKNOWN_CHAR, mode); - } /* while (*modes) */ + } /* while (*modes) */ - if (ModeManager::FindChannelModeByName(CMODE_REDIRECT)) - { - /* We can't mlock +L if +l is not mlocked as well. */ - if (ci->HasMLock(CMODE_REDIRECT, true) && !ci->HasMLock(CMODE_LIMIT, true)) - { - ci->RemoveMLock(CMODE_REDIRECT); - notice_lang(Config.s_ChanServ, u, CHAN_SET_MLOCK_L_REQUIRED); - } + /* We can't mlock +L if +l is not mlocked as well. */ + if (ModeManager::FindChannelModeByName(CMODE_REDIRECT) && ci->HasMLock(CMODE_REDIRECT, true) && !ci->HasMLock(CMODE_LIMIT, true)) + ci->RemoveMLock(CMODE_REDIRECT); + notice_lang(Config.s_ChanServ, u, CHAN_SET_MLOCK_L_REQUIRED); } /* Some ircd we can't set NOKNOCK without INVITE */ /* So check if we need there is a NOKNOCK MODE and that we need INVITEONLY */ - if (ModeManager::FindChannelModeByName(CMODE_NOKNOCK) && ircd->knock_needs_i) - { - if (ci->HasMLock(CMODE_NOKNOCK, true) && !ci->HasMLock(CMODE_INVITE, true)) - { - ci->RemoveMLock(CMODE_NOKNOCK); - notice_lang(Config.s_ChanServ, u, CHAN_SET_MLOCK_K_REQUIRED); - } + if (ModeManager::FindChannelModeByName(CMODE_NOKNOCK) && ircd->knock_needs_i && ci->HasMLock(CMODE_NOKNOCK, true) && !ci->HasMLock(CMODE_INVITE, true)) + ci->RemoveMLock(CMODE_NOKNOCK); + notice_lang(Config.s_ChanServ, u, CHAN_SET_MLOCK_K_REQUIRED); } /* Since we always enforce mode r there is no way to have no * mode lock at all. */ - if (get_mlock_modes(ci, 0)) { + if (get_mlock_modes(ci, 0)) notice_lang(Config.s_ChanServ, u, CHAN_MLOCK_CHANGED, ci->name.c_str(), get_mlock_modes(ci, 0)); - } /* Implement the new lock. */ if (ci->c) @@ -170,7 +154,7 @@ class CSSetMLock : public Module CSSetMLock(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_set_opnotice.cpp b/src/core/cs_set_opnotice.cpp index 3c4950d6f..eb7259d8a 100644 --- a/src/core/cs_set_opnotice.cpp +++ b/src/core/cs_set_opnotice.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -85,7 +83,7 @@ class CSSetOpNotice : public Module CSSetOpNotice(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_set_peace.cpp b/src/core/cs_set_peace.cpp index 613dad6fd..f0eef7c29 100644 --- a/src/core/cs_set_peace.cpp +++ b/src/core/cs_set_peace.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -38,9 +36,7 @@ class CommandCSSetPeace : public Command notice_lang(Config.s_ChanServ, u, CHAN_SET_PEACE_OFF, ci->name.c_str()); } else - { this->OnSyntaxError(u, "PEACE"); - } return MOD_CONT; } @@ -87,7 +83,7 @@ class CSSetPeace : public Module CSSetPeace(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_set_persist.cpp b/src/core/cs_set_persist.cpp index 592e54485..c3f3c16d0 100644 --- a/src/core/cs_set_persist.cpp +++ b/src/core/cs_set_persist.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -44,19 +42,15 @@ class CommandCSSetPersist : public Command } /* No botserv bot, no channel mode */ + /* Give them ChanServ + * Yes, this works fine with no Config.s_BotServ + */ if (!ci->bi && !cm) - { - /* Give them ChanServ - * Yes, this works fine with no Config.s_BotServ - */ - ChanServ->Assign(NULL, ci); - } + ChanServ->Assign(NULL, ci); /* Set the perm mode */ if (cm && ci->c && !ci->c->HasMode(CMODE_PERM)) - { ci->c->SetMode(NULL, cm); - } } notice_lang(Config.s_ChanServ, u, CHAN_SET_PERSIST_ON, ci->name.c_str()); @@ -77,10 +71,8 @@ class CommandCSSetPersist : public Command * which was assigned when persist was set on */ if (!cm && !Config.s_BotServ && ci->bi) - { /* Unassign bot */ ChanServ->UnAssign(NULL, ci); - } if (ci->c && ci->c->users.empty()) delete ci->c; @@ -136,7 +128,7 @@ class CSSetPersist : public Module CSSetPersist(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_set_private.cpp b/src/core/cs_set_private.cpp index 53e482000..edbd6b036 100644 --- a/src/core/cs_set_private.cpp +++ b/src/core/cs_set_private.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -85,7 +83,7 @@ class CSSetPrivate : public Module CSSetPrivate(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_set_restricted.cpp b/src/core/cs_set_restricted.cpp index 8fe4c244e..b2b06dcff 100644 --- a/src/core/cs_set_restricted.cpp +++ b/src/core/cs_set_restricted.cpp @@ -7,9 +7,6 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ /*************************************************************************/ @@ -89,7 +86,7 @@ class CSSetRestricted : public Module CSSetRestricted(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_set_secure.cpp b/src/core/cs_set_secure.cpp index 4c70a43de..a20aa72ff 100644 --- a/src/core/cs_set_secure.cpp +++ b/src/core/cs_set_secure.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -85,7 +83,7 @@ class CSSetSecure : public Module CSSetSecure(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_set_securefounder.cpp b/src/core/cs_set_securefounder.cpp index c999dffd1..710a5a613 100644 --- a/src/core/cs_set_securefounder.cpp +++ b/src/core/cs_set_securefounder.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -91,7 +89,7 @@ class CSSetSecureFounder : public Module CSSetSecureFounder(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_set_secureops.cpp b/src/core/cs_set_secureops.cpp index 88deb7a90..4d7df341e 100644 --- a/src/core/cs_set_secureops.cpp +++ b/src/core/cs_set_secureops.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -85,7 +83,7 @@ class CSSetSecureOps : public Module CSSetSecureOps(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_set_signkick.cpp b/src/core/cs_set_signkick.cpp index a54548b1f..fa8105bb1 100644 --- a/src/core/cs_set_signkick.cpp +++ b/src/core/cs_set_signkick.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -93,7 +91,7 @@ class CSSetSignKick : public Module CSSetSignKick(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_set_successor.cpp b/src/core/cs_set_successor.cpp index 30b9060ba..9beb4ee51 100644 --- a/src/core/cs_set_successor.cpp +++ b/src/core/cs_set_successor.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -60,9 +58,7 @@ class CommandCSSetSuccessor : public Command else nc = NULL; - Alog() << Config.s_ChanServ << ": Changing successor of " << ci->name << " from " - << (ci->successor ? ci->successor->display : "none") - << " to " << (nc ? nc->display : "none") << " by " << u->GetMask(); + Alog() << Config.s_ChanServ << ": Changing successor of " << ci->name << " from " << (ci->successor ? ci->successor->display : "none") << " to " << (nc ? nc->display : "none") << " by " << u->GetMask(); ci->successor = nc; @@ -118,7 +114,7 @@ class CSSetSuccessor : public Module CSSetSuccessor(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_set_topiclock.cpp b/src/core/cs_set_topiclock.cpp index 4edea3961..4ea832020 100644 --- a/src/core/cs_set_topiclock.cpp +++ b/src/core/cs_set_topiclock.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -85,7 +83,7 @@ class CSSetTopicLock : public Module CSSetTopicLock(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_set_url.cpp b/src/core/cs_set_url.cpp index 241c0645b..26f6decee 100644 --- a/src/core/cs_set_url.cpp +++ b/src/core/cs_set_url.cpp @@ -7,10 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ + /*************************************************************************/ #include "module.h" @@ -87,7 +85,7 @@ class CSSetURL : public Module CSSetURL(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_set_xop.cpp b/src/core/cs_set_xop.cpp index 648eefba1..05e050837 100644 --- a/src/core/cs_set_xop.cpp +++ b/src/core/cs_set_xop.cpp @@ -7,15 +7,12 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * $Id$ - * */ /*************************************************************************/ #include "module.h" -#define CHECKLEV(lev) ((ci->levels[(lev)] != ACCESS_INVALID) && (access->level >= ci->levels[(lev)])) +#define CHECKLEV(lev) (ci->levels[(lev)] != ACCESS_INVALID && access->level >= ci->levels[(lev)]) class CommandCSSetXOP : public Command { @@ -54,9 +51,8 @@ class CommandCSSetXOP : public Command access->level = ACCESS_SOP; else if (CHECKLEV(CA_AUTOOP) || CHECKLEV(CA_OPDEOP) || CHECKLEV(CA_OPDEOPME)) access->level = ACCESS_AOP; - else if (ModeManager::FindChannelModeByName(CMODE_HALFOP) && (CHECKLEV(CA_AUTOHALFOP) || CHECKLEV(CA_HALFOP) -|| CHECKLEV(CA_HALFOPME))) - access->level = ACCESS_HOP; + else if (ModeManager::FindChannelModeByName(CMODE_HALFOP) && (CHECKLEV(CA_AUTOHALFOP) || CHECKLEV(CA_HALFOP) || CHECKLEV(CA_HALFOPME))) + access->level = ACCESS_HOP; else if (CHECKLEV(CA_AUTOVOICE) || CHECKLEV(CA_VOICE) || CHECKLEV(CA_VOICEME)) access->level = ACCESS_VOP; else @@ -125,7 +121,7 @@ class CSSetXOP : public Module CSSetXOP(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); - this->SetVersion("$Id$"); + this->SetVersion(VERSION_STRING); this->SetType(CORE); Command *c = FindCommand(ChanServ, "SET"); diff --git a/src/core/cs_status.cpp b/src/core/cs_status.cpp index 174d1a2d8..498f9b2b5 100644 --- a/src/core/cs_status.cpp +++ b/src/core/cs_status.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" diff --git a/src/core/cs_suspend.cpp b/src/core/cs_suspend.cpp index 6931fb62b..486c210df 100644 --- a/src/core/cs_suspend.cpp +++ b/src/core/cs_suspend.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -61,7 +60,7 @@ class CommandCSSuspend : public Command if ((c = findchan(ci->name))) { - for (CUserList::iterator it = c->users.begin(); it != c->users.end();) + for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ) { UserContainer *uc = *it++; diff --git a/src/core/cs_topic.cpp b/src/core/cs_topic.cpp index 9e62fe681..6030c6a9b 100644 --- a/src/core/cs_topic.cpp +++ b/src/core/cs_topic.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" diff --git a/src/core/cs_unban.cpp b/src/core/cs_unban.cpp index c361032bf..23d530c52 100644 --- a/src/core/cs_unban.cpp +++ b/src/core/cs_unban.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -88,4 +87,3 @@ class CSUnban : public Module }; MODULE_INIT(CSUnban) - diff --git a/src/core/cs_xop.cpp b/src/core/cs_xop.cpp index 4eb8d15f2..5a3757035 100644 --- a/src/core/cs_xop.cpp +++ b/src/core/cs_xop.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -128,7 +127,7 @@ class XOPListCallback : public NumberList return; ChanAccess *access = ci->GetAccess(Number - 1); - + if (level != access->level) return; @@ -165,7 +164,7 @@ class XOPDelCallback : public NumberList notice_lang(Config.s_ChanServ, u, messages[XOP_NO_MATCH], ci->name.c_str()); else { - Alog() << Config.s_ChanServ << ": " << u->GetMask() << " (level " << get_access(u, ci) << ") deleted access of users " << Nicks << " on " << ci->name; + Alog() << Config.s_ChanServ << ": " << u->GetMask() << " (level " << get_access(u, ci) << ") deleted access of users " << Nicks << " on " << ci->name; if (Deleted == 1) notice_lang(Config.s_ChanServ, u, messages[XOP_DELETED_ONE], ci->name.c_str()); @@ -256,9 +255,7 @@ class XOPBase : public Command } if (!change) - { ci->AddAccess(nc, level, u->nick); - } else { access->level = level; @@ -266,9 +263,7 @@ class XOPBase : public Command access->creator = u->nick; } - Alog() << Config.s_ChanServ << ": " << u->GetMask() << " (level " << ulev << ") " - << (change ? "changed" : "set") << " access level " << level << " to " << na->nick - << " (group " << nc->display << ") on channel " << ci->name; + Alog() << Config.s_ChanServ << ": " << u->GetMask() << " (level " << ulev << ") " << (change ? "changed" : "set") << " access level " << level << " to " << na->nick << " (group " << nc->display << ") on channel " << ci->name; if (!change) { @@ -328,8 +323,8 @@ class XOPBase : public Command } NickCore *nc = na->nc; - unsigned i; - for (i = 0; i < ci->GetAccessCount(); ++i) + unsigned i, end; + for (i = 0, end = ci->GetAccessCount(); i < end; ++i) { access = ci->GetAccess(nc, level); @@ -337,16 +332,14 @@ class XOPBase : public Command break; } - if (i == ci->GetAccessCount()) + if (i == end) { notice_lang(Config.s_ChanServ, u, messages[XOP_NOT_FOUND], nick, ci->name.c_str()); return MOD_CONT; } if (ulev <= access->level && !u->Account()->HasPriv("chanserv/access/modify")) - { notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - } else { Alog() << Config.s_ChanServ << ": " << u->GetMask() << " (level " << get_access(u, ci) << ") deleted access of user " << access->nc->display << " on " << ci->name; @@ -384,7 +377,7 @@ class XOPBase : public Command { bool SentHeader = false; - for (unsigned i = 0; i < ci->GetAccessCount(); ++i) + for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i) { ChanAccess *access = ci->GetAccess(i); @@ -641,9 +634,7 @@ class CSXOP : public Module if (Me && Me->IsSynced()) OnUplinkSync(NULL); - Implementation i[] = { - I_OnUplinkSync, I_OnServerDisconnect - }; + Implementation i[] = {I_OnUplinkSync, I_OnServerDisconnect}; ModuleManager::Attach(i, this, 2); } |