diff options
| author | Naram Qashat <cyberbotx@cyberbotx.com> | 2010-06-27 23:15:05 -0400 |
|---|---|---|
| committer | Naram Qashat <cyberbotx@cyberbotx.com> | 2010-06-27 23:15:05 -0400 |
| commit | 28e12bc24a9c85f4f0d1e37567618ec39cb501f6 (patch) | |
| tree | cc70ebeef95a9d95174afe3ef038b0d673346f58 /src/core | |
| parent | 051ebe3eea0f8529b64c0e443c61103ba2f7dee8 (diff) | |
The next of a few "CBX OCDing over code style" commits, maybe the last.
NOTES: I have been unable to compile the db_mysql_* functions on my system here, so those are untested. db-convert seems to be badly programmed and needs more work in my opinion.
Diffstat (limited to 'src/core')
34 files changed, 176 insertions, 273 deletions
diff --git a/src/core/os_akill.cpp b/src/core/os_akill.cpp index 06be20d1b..a6eb05632 100644 --- a/src/core/os_akill.cpp +++ b/src/core/os_akill.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" @@ -22,7 +21,7 @@ class AkillDelCallback : public NumberList AkillDelCallback(User *_u, const std::string &numlist) : NumberList(numlist, true), u(_u), Deleted(0) { } - + ~AkillDelCallback() { if (!Deleted) @@ -83,7 +82,7 @@ class AkillListCallback : public NumberList DoList(u, x, Number); } - + static void DoList(User *u, XLine *x, unsigned Number) { notice_lang(Config.s_OperServ, u, OPER_AKILL_LIST_FORMAT, Number + 1, x->Mask.c_str(), x->Reason.c_str()); @@ -274,11 +273,11 @@ class CommandOSAKill : public Command { bool SentHeader = false; - for (unsigned i = 0; i < SGLine->GetCount(); ++i) + for (unsigned i = 0, end = SGLine->GetCount(); i < end; ++i) { XLine *x = SGLine->GetEntry(i); - if (mask.empty() || (mask == x->Mask || Anope::Match(x->Mask, mask))) + if (mask.empty() || mask == x->Mask || Anope::Match(x->Mask, mask)) { if (!SentHeader) { @@ -315,11 +314,11 @@ class CommandOSAKill : public Command { bool SentHeader = false; - for (unsigned i = 0; i < SGLine->GetCount(); ++i) + for (unsigned i = 0, end = SGLine->GetCount(); i < end; ++i) { XLine *x = SGLine->GetEntry(i); - if (mask.empty() || (mask == x->Mask || Anope::Match(x->Mask, mask))) + if (mask.empty() || mask == x->Mask || Anope::Match(x->Mask, mask)) { if (!SentHeader) { @@ -394,6 +393,7 @@ class OSAKill : public Module { this->SetAuthor("Anope"); this->SetType(CORE); + this->AddCommand(OperServ, new CommandOSAKill()); } }; diff --git a/src/core/os_chankill.cpp b/src/core/os_chankill.cpp index 8a22fa256..f751d6dee 100644 --- a/src/core/os_chankill.cpp +++ b/src/core/os_chankill.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" @@ -67,7 +66,7 @@ class CommandOSChanKill : public Command if ((c = findchan(channel))) { - 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/os_chanlist.cpp b/src/core/os_chanlist.cpp index e48cd2b9c..d1a154d2f 100644 --- a/src/core/os_chanlist.cpp +++ b/src/core/os_chanlist.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" @@ -38,18 +37,14 @@ class CommandOSChanList : public Command { notice_lang(Config.s_OperServ, u, OPER_CHANLIST_HEADER_USER, u2->nick.c_str()); - for (UChannelList::iterator uit = u2->chans.begin(); uit != u2->chans.end(); ++uit) + for (UChannelList::iterator uit = u2->chans.begin(), uit_end = u2->chans.end(); uit != uit_end; ++uit) { ChannelContainer *cc = *uit; if (!Modes.empty()) - { - for (std::list<ChannelModeName>::iterator it = Modes.begin(); it != Modes.end(); ++it) - { + for (std::list<ChannelModeName>::iterator it = Modes.begin(), it_end = Modes.end(); it != it_end; ++it) if (!cc->chan->HasMode(*it)) continue; - } - } notice_lang(Config.s_OperServ, u, OPER_CHANLIST_RECORD, cc->chan->name.c_str(), cc->chan->users.size(), chan_get_modes(cc->chan, 1, 1), cc->chan->topic ? cc->chan->topic : ""); } @@ -58,20 +53,16 @@ class CommandOSChanList : public Command { notice_lang(Config.s_OperServ, u, OPER_CHANLIST_HEADER); - for (channel_map::const_iterator cit = ChannelList.begin(); cit != ChannelList.end(); ++cit) + for (channel_map::const_iterator cit = ChannelList.begin(), cit_end = ChannelList.end(); cit != cit_end; ++cit) { Channel *c = cit->second; - + if (pattern && !Anope::Match(c->name, pattern, false)) continue; if (!Modes.empty()) - { - for (std::list<ChannelModeName>::iterator it = Modes.begin(); it != Modes.end(); ++it) - { + for (std::list<ChannelModeName>::iterator it = Modes.begin(), it_end = Modes.end(); it != it_end; ++it) if (!c->HasMode(*it)) continue; - } - } notice_lang(Config.s_OperServ, u, OPER_CHANLIST_RECORD, c->name.c_str(), c->users.size(), chan_get_modes(c, 1, 1), c->topic ? c->topic : ""); } diff --git a/src/core/os_clearmodes.cpp b/src/core/os_clearmodes.cpp index f3d6223ea..3c73846c4 100644 --- a/src/core/os_clearmodes.cpp +++ b/src/core/os_clearmodes.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" @@ -42,10 +41,12 @@ class CommandOSClearModes : public Command else { ci::string s = params.size() > 1 ? params[1] : ""; - if (!s.empty()) { + if (!s.empty()) + { if (s == "ALL") all = 1; - else { + else + { this->OnSyntaxError(u, ""); return MOD_CONT; } @@ -60,7 +61,7 @@ class CommandOSClearModes : public Command ircdproto->SendSVSModeChan(c, "-o", NULL); 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; @@ -74,11 +75,11 @@ class CommandOSClearModes : public Command ircdproto->SendSVSModeChan(c, "-v", NULL); 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; - if (uc->Status->HasFlag(CMODE_VOICE)) + if (uc->Status->HasFlag(CMODE_VOICE)) c->RemoveMode(NULL, CMODE_VOICE, uc->user->nick); } } @@ -90,7 +91,7 @@ class CommandOSClearModes : public Command ircdproto->SendSVSModeChan(c, "-h", NULL); 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; @@ -110,7 +111,7 @@ class CommandOSClearModes : public Command ircdproto->SendSVSModeChan(c, buf.c_str(), NULL); 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; @@ -130,7 +131,7 @@ class CommandOSClearModes : public Command ircdproto->SendSVSModeChan(c, buf.c_str(), NULL); 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; diff --git a/src/core/os_defcon.cpp b/src/core/os_defcon.cpp index de3c6b030..78e366071 100644 --- a/src/core/os_defcon.cpp +++ b/src/core/os_defcon.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" @@ -125,7 +124,7 @@ class CommandOSDEFCON : public Command { syntax_error(Config.s_OperServ, u, "DEFCON", OPER_DEFCON_SYNTAX); } - + void OnServHelp(User *u) { notice_lang(Config.s_OperServ, u, OPER_HELP_CMD_DEFCON); @@ -137,13 +136,11 @@ class OSDEFCON : public Module public: OSDEFCON(const std::string &modname, const std::string &creator) : Module(modname, creator) { - this->SetAuthor("Anope"); - this->SetType(CORE); - if (!Config.DefConLevel) - { throw ModuleException("Invalid configuration settings"); - } + + this->SetAuthor("Anope"); + this->SetType(CORE); Implementation i[] = { I_OnPreUserConnect, I_OnChannelModeSet, I_OnChannelModeUnset, I_OnPreCommandRun, I_OnPreCommand, I_OnUserConnect, I_OnChannelModeAdd, I_OnChannelCreate }; ModuleManager::Attach(i, this, 8); @@ -197,9 +194,7 @@ class OSDEFCON : public Module std::string param; if (GetDefConParam(Name, param)) - { c->SetMode(OperServ, Name, param); - } else c->SetMode(OperServ, Name); @@ -220,9 +215,7 @@ class OSDEFCON : public Module if ((CheckDefCon(DEFCON_OPER_ONLY) || CheckDefCon(DEFCON_SILENT_OPER_ONLY)) && !is_oper(u)) { if (!CheckDefCon(DEFCON_SILENT_OPER_ONLY)) - { notice_lang(bi->nick.c_str(), u, OPER_DEFCON_DENIED); - } return EVENT_STOP; } @@ -236,13 +229,10 @@ class OSDEFCON : public Module { if (command == "SET") { - if (!params.empty() && params[0] == "MLOCK") + if (!params.empty() && params[0] == "MLOCK" && CheckDefCon(DEFCON_NO_MLOCK_CHANGE)) { - if (CheckDefCon(DEFCON_NO_MLOCK_CHANGE)) - { - notice_lang(Config.s_ChanServ, u, OPER_DEFCON_DENIED); - return EVENT_STOP; - } + notice_lang(Config.s_ChanServ, u, OPER_DEFCON_DENIED); + return EVENT_STOP; } } else if (command == "REGISTER" || command == "GROUP") @@ -295,7 +285,7 @@ class OSDEFCON : public Module ircdproto->SendMessage(OperServ, u->nick.c_str(), "%s", Config.SessionLimitDetailsLoc); kill_user(Config.s_OperServ, u->nick, "Session limit exceeded"); - session->hits++; + ++session->hits; if (Config.MaxSessionKill && session->hits >= Config.MaxSessionKill) { SGLine->Add(NULL, NULL, ci::string("*@") + u->host, time(NULL) + Config.SessionAutoKillExpiry, "Session limit exceeded"); @@ -312,21 +302,17 @@ class OSDEFCON : public Module std::string modes = Config.DefConChanModes; if (modes.find(cm->ModeChar) != std::string::npos) - { /* New mode has been added to Anope, check to see if defcon * requires it */ defconParseModeString(Config.DefConChanModes); - } } } void OnChannelCreate(Channel *c) { if (CheckDefCon(DEFCON_FORCE_CHAN_MODES)) - { c->SetModes(OperServ, false, Config.DefConChanModes); - } } }; @@ -398,7 +384,7 @@ void runDefCon() */ void defconParseModeString(const char *str) { - 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; ChannelModeParam *cmp; @@ -414,7 +400,7 @@ void defconParseModeString(const char *str) ss.GetToken(modes); /* Loop while there are modes to set */ - for (unsigned i = 0; i < modes.size(); ++i) + for (unsigned i = 0, end = modes.size(); i < end; ++i) { mode = modes[i]; @@ -466,34 +452,26 @@ void defconParseModeString(const char *str) DefConModesOn.UnsetFlag(cm->Name); if (cm->Type == MODE_PARAM) - { UnsetDefConParam(cm->Name); - } } } } } - if ((cm = ModeManager::FindChannelModeByName(CMODE_REDIRECT))) + /* We can't mlock +L if +l is not mlocked as well. */ + if ((cm = ModeManager::FindChannelModeByName(CMODE_REDIRECT)) && DefConModesOn.HasFlag(cm->Name) && !DefConModesOn.HasFlag(CMODE_LIMIT)) { - /* We can't mlock +L if +l is not mlocked as well. */ - if (DefConModesOn.HasFlag(cm->Name) && !DefConModesOn.HasFlag(CMODE_LIMIT)) - { - DefConModesOn.UnsetFlag(CMODE_REDIRECT); + DefConModesOn.UnsetFlag(CMODE_REDIRECT); - Alog() << "DefConChanModes must lock mode +l as well to lock mode +L"; - } + Alog() << "DefConChanModes must lock mode +l as well to lock mode +L"; } /* 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 (ircd->knock_needs_i && (cm = ModeManager::FindChannelModeByName(CMODE_NOKNOCK))) + if (ircd->knock_needs_i && (cm = ModeManager::FindChannelModeByName(CMODE_NOKNOCK)) && DefConModesOn.HasFlag(cm->Name) && !DefConModesOn.HasFlag(CMODE_INVITE)) { - if (DefConModesOn.HasFlag(cm->Name) && !DefConModesOn.HasFlag(CMODE_INVITE)) - { - DefConModesOn.UnsetFlag(CMODE_NOKNOCK); - Alog() << "DefConChanModes must lock mode +i as well to lock mode +K"; - } + DefConModesOn.UnsetFlag(CMODE_NOKNOCK); + Alog() << "DefConChanModes must lock mode +i as well to lock mode +K"; } } @@ -501,13 +479,12 @@ static char *defconReverseModes(const char *modes) { char *newmodes = NULL; unsigned i = 0; - if (!modes) { + if (!modes) return NULL; - } - if (!(newmodes = new char[strlen(modes) + 1])) { + if (!(newmodes = new char[strlen(modes) + 1])) return NULL; - } - for (i = 0; i < strlen(modes); i++) { + for (i = 0; i < strlen(modes); ++i) + { if (modes[i] == '+') newmodes[i] = '-'; else if (modes[i] == '-') diff --git a/src/core/os_global.cpp b/src/core/os_global.cpp index afa040be8..a5abde2ff 100644 --- a/src/core/os_global.cpp +++ b/src/core/os_global.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/os_help.cpp b/src/core/os_help.cpp index 433d673c7..9ddeda66e 100644 --- a/src/core/os_help.cpp +++ b/src/core/os_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" @@ -30,7 +29,7 @@ class CommandOSHelp : public Command void OnSyntaxError(User *u, const ci::string &subcommand) { notice_help(Config.s_OperServ, u, OPER_HELP); - for (CommandMap::const_iterator it = NickServ->Commands.begin(); it != NickServ->Commands.end(); ++it) + for (CommandMap::const_iterator it = OperServ->Commands.begin(), it_end = OperServ->Commands.end(); it != it_end; ++it) it->second->OnServHelp(u); notice_help(Config.s_OperServ, u, OPER_HELP_LOGGED); } @@ -43,6 +42,7 @@ class OSHelp : public Module { this->SetAuthor("Anope"); this->SetType(CORE); + this->AddCommand(OperServ, new CommandOSHelp()); } }; diff --git a/src/core/os_ignore.cpp b/src/core/os_ignore.cpp index cbee6e3fb..881f79601 100644 --- a/src/core/os_ignore.cpp +++ b/src/core/os_ignore.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" @@ -141,12 +140,13 @@ class OSIgnore : public Module { this->SetAuthor("Anope"); this->SetType(CORE); + this->AddCommand(OperServ, new CommandOSIgnore()); Implementation i[] = { I_OnDatabaseRead, I_OnDatabaseWrite }; ModuleManager::Attach(i, this, 2); } - + EventReturn OnDatabaseRead(const std::vector<std::string> ¶ms) { std::string buf; @@ -177,7 +177,7 @@ class OSIgnore : public Module { next = ign->next; - if (ign->time != 0 && ign->time <= now) + if (ign->time && ign->time <= now) { Alog(LOG_DEBUG) << "[os_ignore] Expiring ignore entry " << ign->mask; if (ign->prev) diff --git a/src/core/os_jupe.cpp b/src/core/os_jupe.cpp index cce908949..8718f95d8 100644 --- a/src/core/os_jupe.cpp +++ b/src/core/os_jupe.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/os_kick.cpp b/src/core/os_kick.cpp index e05764a09..2600814f3 100644 --- a/src/core/os_kick.cpp +++ b/src/core/os_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" diff --git a/src/core/os_mode.cpp b/src/core/os_mode.cpp index 139ef8edf..3f33257fe 100644 --- a/src/core/os_mode.cpp +++ b/src/core/os_mode.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/os_modinfo.cpp b/src/core/os_modinfo.cpp index e867713f8..d71f146c7 100644 --- a/src/core/os_modinfo.cpp +++ b/src/core/os_modinfo.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" @@ -35,7 +34,7 @@ class CommandOSModInfo : public Command tm = *localtime(&m->created); strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_DATE_TIME_FORMAT, &tm); notice_lang(Config.s_OperServ, u, OPER_MODULE_INFO_LIST, m->name.c_str(), !m->version.empty() ? m->version.c_str() : "?", !m->author.empty() ? m->author.c_str() : "?", timebuf); - + showModuleCmdLoaded(HostServ, m->name.c_str(), u); showModuleCmdLoaded(OperServ, m->name.c_str(), u); showModuleCmdLoaded(NickServ, m->name.c_str(), u); @@ -73,6 +72,7 @@ class OSModInfo : public Module { this->SetAuthor("Anope"); this->SetType(CORE); + this->AddCommand(OperServ, new CommandOSModInfo()); } }; @@ -81,10 +81,10 @@ static int showModuleCmdLoaded(BotInfo *bi, const ci::string &mod_name, User *u) { if (!bi) return 0; - + int display = 0; - for (std::map<ci::string, Command *>::iterator it = bi->Commands.begin(); it != bi->Commands.end(); ++it) + for (std::map<ci::string, Command *>::iterator it = bi->Commands.begin(), it_end = bi->Commands.end(); it != it_end; ++it) { Command *c = it->second; diff --git a/src/core/os_modlist.cpp b/src/core/os_modlist.cpp index 114327aaa..c719b734d 100644 --- a/src/core/os_modlist.cpp +++ b/src/core/os_modlist.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/os_modload.cpp b/src/core/os_modload.cpp index 7134aae9f..f70c80c05 100644 --- a/src/core/os_modload.cpp +++ b/src/core/os_modload.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/os_modunload.cpp b/src/core/os_modunload.cpp index 12dce4300..0988d4473 100644 --- a/src/core/os_modunload.cpp +++ b/src/core/os_modunload.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/os_news.cpp b/src/core/os_news.cpp index 3626d4e02..c3ebabf3a 100644 --- a/src/core/os_news.cpp +++ b/src/core/os_news.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" @@ -18,19 +17,21 @@ /* List of messages for each news type. This simplifies message sending. */ -#define MSG_SYNTAX 0 -#define MSG_LIST_HEADER 1 -#define MSG_LIST_ENTRY 2 -#define MSG_LIST_NONE 3 -#define MSG_ADD_SYNTAX 4 -#define MSG_ADD_FULL 5 -#define MSG_ADDED 6 -#define MSG_DEL_SYNTAX 7 -#define MSG_DEL_NOT_FOUND 8 -#define MSG_DELETED 9 -#define MSG_DEL_NONE 10 -#define MSG_DELETED_ALL 11 -#define MSG_MAX 11 +enum +{ + MSG_SYNTAX, + MSG_LIST_HEADER, + MSG_LIST_ENTRY, + MSG_LIST_NONE, + MSG_ADD_SYNTAX, + MSG_ADD_FULL, + MSG_ADDED, + MSG_DEL_SYNTAX, + MSG_DEL_NOT_FOUND, + MSG_DELETED, + MSG_DEL_NONE, + MSG_DELETED_ALL +}; struct newsmsgs msgarray[] = { {NEWS_LOGON, "LOGON", @@ -96,7 +97,7 @@ static void DisplayNews(User *u, NewsType Type) unsigned displayed = 0; bool NewsExists = false; - for (unsigned i = 0; i < News.size(); ++i) + for (unsigned i = 0, end = News.size(); i < end; ++i) { if (News[i]->type == Type) { @@ -129,18 +130,16 @@ static void DisplayNews(User *u, NewsType Type) } } -static int add_newsitem(User * u, const char *text, NewsType type) +static int add_newsitem(User *u, const char *text, NewsType type) { int num = 0; for (unsigned i = News.size(); i > 0; --i) - { if (News[i - 1]->type == type) { num = News[i - 1]->num; break; } - } NewsItem *news = new NewsItem; news->type = type; @@ -159,27 +158,25 @@ static int del_newsitem(unsigned num, NewsType type) int count = 0; for (unsigned i = News.size(); i > 0; --i) - { if (News[i - 1]->type == type && (num == 0 || News[i - 1]->num == num)) { delete News[i - 1]; News.erase(News.begin() + i - 1); ++count; } - } return count; } static int *findmsgs(NewsType type, const char **type_name) { - for (unsigned i = 0; i < lenof(msgarray); i++) { - if (msgarray[i].type == type) { + for (unsigned i = 0; i < lenof(msgarray); ++i) + if (msgarray[i].type == type) + { if (type_name) *type_name = msgarray[i].name; return msgarray[i].msgs; } - } return NULL; } @@ -192,8 +189,7 @@ class NewsBase : public Command char timebuf[64]; struct tm *tm; - for (unsigned i = 0; i < News.size(); ++i) - { + for (unsigned i = 0, end = News.size(); i < end; ++i) if (News[i]->type == type) { if (!count) @@ -203,7 +199,6 @@ class NewsBase : public Command notice_lang(Config.s_OperServ, u, msgs[MSG_LIST_ENTRY], News[i]->num, timebuf, !News[i]->who.empty() ? News[i]->who.c_str() : "<unknown>", News[i]->Text.c_str()); ++count; } - } if (!count) notice_lang(Config.s_OperServ, u, msgs[MSG_LIST_NONE]); else @@ -256,11 +251,9 @@ class NewsBase : public Command if (num > 0 && del_newsitem(num, type)) { notice_lang(Config.s_OperServ, u, msgs[MSG_DELETED], num); - for (unsigned i = 0; i < News.size(); ++i) - { + for (unsigned i = 0, end = News.size(); i < end; ++i) if (News[i]->type == type && News[i]->num > num) --News[i]->num; - } } else notice_lang(Config.s_OperServ, u, msgs[MSG_DEL_NOT_FOUND], num); @@ -422,7 +415,7 @@ class OSNews : public Module ~OSNews() { - for (std::vector<NewsItem *>::iterator it = News.begin(); it != News.end(); ++it) + for (std::vector<NewsItem *>::iterator it = News.begin(), it_end = News.end(); it != it_end; ++it) delete *it; News.clear(); } @@ -430,9 +423,7 @@ class OSNews : public Module void OnUserModeSet(User *u, UserModeName Name) { if (Name == UMODE_OPER) - { DisplayNews(u, NEWS_OPER); - } } void OnUserConnect(User *u) diff --git a/src/core/os_noop.cpp b/src/core/os_noop.cpp index f6269592a..51337106e 100644 --- a/src/core/os_noop.cpp +++ b/ |
