From 157d9445f53ff63cfabf19d5f16ebdf84e6e0454 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Mon, 1 Apr 2013 16:32:01 +0200 Subject: cmd_invite Check if the inviting user is on the channel before potentially telling him the target is already on it --- src/commands/cmd_invite.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/commands') diff --git a/src/commands/cmd_invite.cpp b/src/commands/cmd_invite.cpp index fd595d618..c69e6bd1b 100644 --- a/src/commands/cmd_invite.cpp +++ b/src/commands/cmd_invite.cpp @@ -72,16 +72,16 @@ CmdResult CommandInvite::Handle (const std::vector& parameters, Use return CMD_FAILURE; } - if (c->HasUser(u)) - { - user->WriteNumeric(ERR_USERONCHANNEL, "%s %s %s :is already on channel",user->nick.c_str(),u->nick.c_str(),c->name.c_str()); - return CMD_FAILURE; - } - if ((IS_LOCAL(user)) && (!c->HasUser(user))) - { + { user->WriteNumeric(ERR_NOTONCHANNEL, "%s %s :You're not on that channel!",user->nick.c_str(), c->name.c_str()); - return CMD_FAILURE; + return CMD_FAILURE; + } + + if (c->HasUser(u)) + { + user->WriteNumeric(ERR_USERONCHANNEL, "%s %s %s :is already on channel",user->nick.c_str(),u->nick.c_str(),c->name.c_str()); + return CMD_FAILURE; } FIRST_MOD_RESULT(OnUserPreInvite, MOD_RESULT, (user,u,c,timeout)); -- cgit v1.3.1-10-gc9f91 From 153bd37b598373f4f52024747ee3bc2cbb76f629 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Mon, 1 Apr 2013 16:42:04 +0200 Subject: cmd_stats List opers without iterating the whole userlist --- src/commands/cmd_stats.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/commands') diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp index 9a5bfc52d..898e89a7d 100644 --- a/src/commands/cmd_stats.cpp +++ b/src/commands/cmd_stats.cpp @@ -161,13 +161,14 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results) case 'P': { - int idx = 0; - for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); i++) + unsigned int idx = 0; + for (std::list::const_iterator i = ServerInstance->Users->all_opers.begin(); i != ServerInstance->Users->all_opers.end(); ++i) { - if (IS_OPER(i->second) && !ServerInstance->ULine(i->second->server)) + User* oper = *i; + if (!ServerInstance->ULine(oper->server)) { - results.push_back(sn+" 249 "+user->nick+" :"+i->second->nick+" ("+i->second->ident+"@"+i->second->dhost+") Idle: "+ - (IS_LOCAL(i->second) ? ConvToStr(ServerInstance->Time() - i->second->idle_lastmsg) + " secs" : "unavailable")); + results.push_back(sn+" 249 " + user->nick + " :" + oper->nick + " (" + oper->ident + "@" + oper->dhost + ") Idle: " + + (IS_LOCAL(oper) ? ConvToStr(ServerInstance->Time() - oper->idle_lastmsg) + " secs" : "unavailable")); idx++; } } -- cgit v1.3.1-10-gc9f91