diff options
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/cmd_away.cpp | 10 | ||||
-rw-r--r-- | src/commands/cmd_invite.cpp | 8 | ||||
-rw-r--r-- | src/commands/cmd_kill.cpp | 6 | ||||
-rw-r--r-- | src/commands/cmd_nick.cpp | 17 | ||||
-rw-r--r-- | src/commands/cmd_notice.cpp | 20 | ||||
-rw-r--r-- | src/commands/cmd_privmsg.cpp | 22 | ||||
-rw-r--r-- | src/commands/cmd_stats.cpp | 6 | ||||
-rw-r--r-- | src/commands/cmd_user.cpp | 6 |
8 files changed, 47 insertions, 48 deletions
diff --git a/src/commands/cmd_away.cpp b/src/commands/cmd_away.cpp index aba803134..261bdd38c 100644 --- a/src/commands/cmd_away.cpp +++ b/src/commands/cmd_away.cpp @@ -23,13 +23,13 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance) */ CmdResult CommandAway::Handle (const std::vector<std::string>& parameters, User *user) { - int MOD_RESULT = 0; + ModResult MOD_RESULT; if ((parameters.size()) && (!parameters[0].empty())) { - FOREACH_RESULT(I_OnSetAway, OnSetAway(user, parameters[0])); + FIRST_MOD_RESULT(ServerInstance, OnSetAway, MOD_RESULT, (user, parameters[0])); - if (MOD_RESULT != 0 && IS_LOCAL(user)) + if (MOD_RESULT == MOD_RES_DENY && IS_LOCAL(user)) return CMD_FAILURE; user->awaytime = ServerInstance->Time(); @@ -39,9 +39,9 @@ CmdResult CommandAway::Handle (const std::vector<std::string>& parameters, User } else { - FOREACH_RESULT(I_OnSetAway, OnSetAway(user, "")); + FIRST_MOD_RESULT(ServerInstance, OnSetAway, MOD_RESULT, (user, "")); - if (MOD_RESULT != 0 && IS_LOCAL(user)) + if (MOD_RESULT == MOD_RES_DENY && IS_LOCAL(user)) return CMD_FAILURE; user->awaymsg.clear(); diff --git a/src/commands/cmd_invite.cpp b/src/commands/cmd_invite.cpp index 1d875b74e..31c6f459c 100644 --- a/src/commands/cmd_invite.cpp +++ b/src/commands/cmd_invite.cpp @@ -23,7 +23,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance) */ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, User *user) { - int MOD_RESULT = 0; + ModResult MOD_RESULT; if (parameters.size() == 2 || parameters.size() == 3) { @@ -56,13 +56,13 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use return CMD_FAILURE; } - FOREACH_RESULT(I_OnUserPreInvite,OnUserPreInvite(user,u,c,timeout)); + FIRST_MOD_RESULT(ServerInstance, OnUserPreInvite, MOD_RESULT, (user,u,c,timeout)); - if (MOD_RESULT == 1) + if (MOD_RESULT == MOD_RES_DENY) { return CMD_FAILURE; } - else if (MOD_RESULT == 0) + else if (MOD_RESULT == MOD_RES_PASSTHRU) { if (IS_LOCAL(user)) { diff --git a/src/commands/cmd_kill.cpp b/src/commands/cmd_kill.cpp index 842f1239e..2f1a4783e 100644 --- a/src/commands/cmd_kill.cpp +++ b/src/commands/cmd_kill.cpp @@ -29,7 +29,7 @@ CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User User *u = ServerInstance->FindNick(parameters[0]); char killreason[MAXBUF]; - int MOD_RESULT = 0; + ModResult MOD_RESULT; if (u) { @@ -46,9 +46,9 @@ CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User * Moved this event inside the IS_LOCAL check also, we don't want half the network killing a user * and the other half not. This would be a bad thing. ;p -- w00t */ - FOREACH_RESULT(I_OnKill, OnKill(user, u, parameters[1])); + FIRST_MOD_RESULT(ServerInstance, OnKill, MOD_RESULT, (user, u, parameters[1])); - if (MOD_RESULT) + if (MOD_RESULT == MOD_RES_DENY) return CMD_FAILURE; if (*ServerInstance->Config->HideKillsServer) diff --git a/src/commands/cmd_nick.cpp b/src/commands/cmd_nick.cpp index 44ccffbac..33e0e8081 100644 --- a/src/commands/cmd_nick.cpp +++ b/src/commands/cmd_nick.cpp @@ -70,9 +70,9 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User * the nick AAA is the same as the nick aaa. */ oldnick.assign(user->nick, 0, IS_LOCAL(user) ? ServerInstance->Config->Limits.NickMax : MAXBUF); - int MOD_RESULT = 0; - FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(user,parameters[0])); - if (MOD_RESULT) + ModResult MOD_RESULT; + FIRST_MOD_RESULT(ServerInstance, OnUserPreNick, MOD_RESULT, (user,parameters[0])); + if (MOD_RESULT == MOD_RES_DENY) return CMD_FAILURE; if (user->registered == REG_ALL) user->WriteCommon("NICK %s",parameters[0].c_str()); @@ -151,9 +151,9 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User } - int MOD_RESULT = 0; - FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(user, parameters[0])); - if (MOD_RESULT) + ModResult MOD_RESULT; + FIRST_MOD_RESULT(ServerInstance, OnUserPreNick, MOD_RESULT, (user, parameters[0])); + if (MOD_RESULT == MOD_RES_DENY) // if a module returns true, the nick change is silently forbidden. return CMD_FAILURE; @@ -187,9 +187,8 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User if (user->registered == REG_NICKUSER) { /* user is registered now, bit 0 = USER command, bit 1 = sent a NICK command */ - MOD_RESULT = 0; - FOREACH_RESULT(I_OnUserRegister,OnUserRegister(user)); - if (MOD_RESULT > 0) + FIRST_MOD_RESULT(ServerInstance, OnUserRegister, MOD_RESULT, (user)); + if (MOD_RESULT == MOD_RES_DENY) return CMD_FAILURE; // return early to not penalize new users diff --git a/src/commands/cmd_notice.cpp b/src/commands/cmd_notice.cpp index 13ffd6c75..e9049d7ab 100644 --- a/src/commands/cmd_notice.cpp +++ b/src/commands/cmd_notice.cpp @@ -35,10 +35,10 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use if (!user->HasPrivPermission("users/mass-message")) return CMD_SUCCESS; - int MOD_RESULT = 0; + ModResult MOD_RESULT; std::string temp = parameters[1]; - FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user, (void*)parameters[0].c_str(), TYPE_SERVER, temp, 0, exempt_list)); - if (MOD_RESULT) + FIRST_MOD_RESULT(ServerInstance, OnUserPreNotice, MOD_RESULT, (user, (void*)parameters[0].c_str(), TYPE_SERVER, temp, 0, exempt_list)); + if (MOD_RESULT == MOD_RES_DENY) return CMD_FAILURE; const char* text = temp.c_str(); const char* servermask = (parameters[0].c_str()) + 1; @@ -80,13 +80,13 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use return CMD_FAILURE; } } - int MOD_RESULT = 0; + ModResult MOD_RESULT; std::string temp = parameters[1]; - FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,chan,TYPE_CHANNEL,temp,status, exempt_list)); - if (MOD_RESULT) { + FIRST_MOD_RESULT(ServerInstance, OnUserPreNotice, MOD_RESULT, (user,chan,TYPE_CHANNEL,temp,status, exempt_list)); + if (MOD_RESULT == MOD_RES_DENY) return CMD_FAILURE; - } + const char* text = temp.c_str(); if (temp.empty()) @@ -157,10 +157,10 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use return CMD_FAILURE; } - int MOD_RESULT = 0; + ModResult MOD_RESULT; std::string temp = parameters[1]; - FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,dest,TYPE_USER,temp,0,exempt_list)); - if (MOD_RESULT) { + FIRST_MOD_RESULT(ServerInstance, OnUserPreNotice, MOD_RESULT, (user,dest,TYPE_USER,temp,0,exempt_list)); + if (MOD_RESULT == MOD_RES_DENY) { return CMD_FAILURE; } const char* text = temp.c_str(); diff --git a/src/commands/cmd_privmsg.cpp b/src/commands/cmd_privmsg.cpp index 5c6e462c8..c6e74db8b 100644 --- a/src/commands/cmd_privmsg.cpp +++ b/src/commands/cmd_privmsg.cpp @@ -35,10 +35,10 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us if (!user->HasPrivPermission("users/mass-message")) return CMD_SUCCESS; - int MOD_RESULT = 0; + ModResult MOD_RESULT; std::string temp = parameters[1]; - FOREACH_RESULT(I_OnUserPreMessage,OnUserPreMessage(user, (void*)parameters[0].c_str(), TYPE_SERVER, temp, 0, except_list)); - if (MOD_RESULT) + FIRST_MOD_RESULT(ServerInstance, OnUserPreMessage, MOD_RESULT, (user, (void*)parameters[0].c_str(), TYPE_SERVER, temp, 0, except_list)); + if (MOD_RESULT == MOD_RES_DENY) return CMD_FAILURE; const char* text = temp.c_str(); @@ -91,13 +91,13 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us } } } - int MOD_RESULT = 0; + ModResult MOD_RESULT; std::string temp = parameters[1]; - FOREACH_RESULT(I_OnUserPreMessage,OnUserPreMessage(user,chan,TYPE_CHANNEL,temp,status,except_list)); - if (MOD_RESULT) { + FIRST_MOD_RESULT(ServerInstance, OnUserPreMessage, MOD_RESULT, (user,chan,TYPE_CHANNEL,temp,status,except_list)); + if (MOD_RESULT == MOD_RES_DENY) return CMD_FAILURE; - } + const char* text = temp.c_str(); /* Check again, a module may have zapped the input string */ @@ -175,13 +175,13 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us user->WriteNumeric(301, "%s %s :%s", user->nick.c_str(), dest->nick.c_str(), dest->awaymsg.c_str()); } - int MOD_RESULT = 0; + ModResult MOD_RESULT; std::string temp = parameters[1]; - FOREACH_RESULT(I_OnUserPreMessage,OnUserPreMessage(user, dest, TYPE_USER, temp, 0, except_list)); - if (MOD_RESULT) { + FIRST_MOD_RESULT(ServerInstance, OnUserPreMessage, MOD_RESULT, (user, dest, TYPE_USER, temp, 0, except_list)); + if (MOD_RESULT == MOD_RES_DENY) return CMD_FAILURE; - } + const char* text = temp.c_str(); FOREACH_MOD(I_OnText,OnText(user, dest, TYPE_USER, text, 0, except_list)); diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp index eb0321c8a..ecd19a71e 100644 --- a/src/commands/cmd_stats.cpp +++ b/src/commands/cmd_stats.cpp @@ -67,9 +67,9 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str return; } - int MOD_RESULT = 0; - FOREACH_RESULT(I_OnStats,OnStats(statschar, user, results)); - if (MOD_RESULT) + ModResult MOD_RESULT; + FIRST_MOD_RESULT(ServerInstance, OnStats, MOD_RESULT, (statschar, user, results)); + if (MOD_RESULT == MOD_RES_DENY) { results.push_back(sn+" 219 "+user->nick+" "+statschar+" :End of /STATS report"); ServerInstance->SNO->WriteToSnoMask('t',"%s '%c' requested by %s (%s@%s)", diff --git a/src/commands/cmd_user.cpp b/src/commands/cmd_user.cpp index 833a9b275..b9ef94c97 100644 --- a/src/commands/cmd_user.cpp +++ b/src/commands/cmd_user.cpp @@ -54,11 +54,11 @@ CmdResult CommandUser::Handle (const std::vector<std::string>& parameters, User /* parameters 2 and 3 are local and remote hosts, and are ignored */ if (user->registered == REG_NICKUSER) { - int MOD_RESULT = 0; + ModResult MOD_RESULT; /* user is registered now, bit 0 = USER command, bit 1 = sent a NICK command */ - FOREACH_RESULT(I_OnUserRegister,OnUserRegister(user)); - if (MOD_RESULT > 0) + FIRST_MOD_RESULT(ServerInstance, OnUserRegister, MOD_RESULT, (user)); + if (MOD_RESULT == MOD_RES_DENY) return CMD_FAILURE; } |