summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/modules.h7
-rw-r--r--src/modules.cpp2
-rw-r--r--src/modules/m_nickflood.cpp2
-rw-r--r--src/modules/m_nicklock.cpp5
-rw-r--r--src/modules/m_nonicks.cpp5
-rw-r--r--src/modules/m_svshold.cpp2
-rw-r--r--src/users.cpp6
7 files changed, 11 insertions, 18 deletions
diff --git a/include/modules.h b/include/modules.h
index a9db6919c..0f8c25691 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -558,17 +558,14 @@ class CoreExport Module : public classbase, public usecountbase
*/
virtual void OnBuildNeighborList(User* source, IncludeChanList& include_c, std::map<User*, bool>& exceptions);
- /** Called before any nickchange, local or remote. This can be used to implement Q-lines etc.
- * Please note that although you can see remote nickchanges through this function, you should
- * NOT make any changes to the User if the user is a remote user as this may cause a desnyc.
- * check user->server before taking any action (including returning nonzero from the method).
+ /** Called before local nickname changes. This can be used to implement Q-lines etc.
* If your method returns nonzero, the nickchange is silently forbidden, and it is down to your
* module to generate some meaninful output.
* @param user The username changing their nick
* @param newnick Their new nickname
* @return 1 to deny the change, 0 to allow
*/
- virtual ModResult OnUserPreNick(User* user, const std::string &newnick);
+ virtual ModResult OnUserPreNick(LocalUser* user, const std::string& newnick);
/** Called after any PRIVMSG sent from a user.
* The dest variable contains a User* if target_type is TYPE_USER and a Channel*
diff --git a/src/modules.cpp b/src/modules.cpp
index 2825b2d0e..9ca33e2dd 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -95,7 +95,7 @@ void Module::OnInfo(User*) { DetachEvent(I_OnInfo); }
void Module::OnWhois(User*, User*) { DetachEvent(I_OnWhois); }
ModResult Module::OnUserPreInvite(User*, User*, Channel*, time_t) { DetachEvent(I_OnUserPreInvite); return MOD_RES_PASSTHRU; }
ModResult Module::OnUserPreMessage(User*, void*, int, std::string&, char, CUList&, MessageType) { DetachEvent(I_OnUserPreMessage); return MOD_RES_PASSTHRU; }
-ModResult Module::OnUserPreNick(User*, const std::string&) { DetachEvent(I_OnUserPreNick); return MOD_RES_PASSTHRU; }
+ModResult Module::OnUserPreNick(LocalUser*, const std::string&) { DetachEvent(I_OnUserPreNick); return MOD_RES_PASSTHRU; }
void Module::OnUserPostNick(User*, const std::string&) { DetachEvent(I_OnUserPostNick); }
ModResult Module::OnPreMode(User*, User*, Channel*, const std::vector<std::string>&) { DetachEvent(I_OnPreMode); return MOD_RES_PASSTHRU; }
void Module::On005Numeric(std::map<std::string, std::string>&) { DetachEvent(I_On005Numeric); }
diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp
index f74a18422..cd1bddce4 100644
--- a/src/modules/m_nickflood.cpp
+++ b/src/modules/m_nickflood.cpp
@@ -126,7 +126,7 @@ class ModuleNickFlood : public Module
{
}
- ModResult OnUserPreNick(User* user, const std::string &newnick) CXX11_OVERRIDE
+ ModResult OnUserPreNick(LocalUser* user, const std::string& newnick) CXX11_OVERRIDE
{
for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++)
{
diff --git a/src/modules/m_nicklock.cpp b/src/modules/m_nicklock.cpp
index b8d4ac4df..21f02fe11 100644
--- a/src/modules/m_nicklock.cpp
+++ b/src/modules/m_nicklock.cpp
@@ -153,11 +153,8 @@ class ModuleNickLock : public Module
return Version("Provides the NICKLOCK command, allows an oper to change a users nick and lock them to it until they quit", VF_OPTCOMMON | VF_VENDOR);
}
- ModResult OnUserPreNick(User* user, const std::string &newnick) CXX11_OVERRIDE
+ ModResult OnUserPreNick(LocalUser* user, const std::string& newnick) CXX11_OVERRIDE
{
- if (!IS_LOCAL(user))
- return MOD_RES_PASSTHRU;
-
if (locked.get(user))
{
user->WriteNumeric(ERR_CANTCHANGENICK, ":You cannot change your nickname (your nick is locked)");
diff --git a/src/modules/m_nonicks.cpp b/src/modules/m_nonicks.cpp
index 15ee4e7f8..5a45bbb4a 100644
--- a/src/modules/m_nonicks.cpp
+++ b/src/modules/m_nonicks.cpp
@@ -46,11 +46,8 @@ class ModuleNoNickChange : public Module
tokens["EXTBAN"].push_back('N');
}
- ModResult OnUserPreNick(User* user, const std::string &newnick) CXX11_OVERRIDE
+ ModResult OnUserPreNick(LocalUser* user, const std::string& newnick) CXX11_OVERRIDE
{
- if (!IS_LOCAL(user))
- return MOD_RES_PASSTHRU;
-
for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++)
{
Channel* curr = (*i)->chan;
diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp
index af306ce62..a623e1553 100644
--- a/src/modules/m_svshold.cpp
+++ b/src/modules/m_svshold.cpp
@@ -192,7 +192,7 @@ class ModuleSVSHold : public Module
return MOD_RES_DENY;
}
- ModResult OnUserPreNick(User *user, const std::string &newnick) CXX11_OVERRIDE
+ ModResult OnUserPreNick(LocalUser* user, const std::string& newnick) CXX11_OVERRIDE
{
XLine *rl = ServerInstance->XLines->MatchesLine("SVSHOLD", newnick);
diff --git a/src/users.cpp b/src/users.cpp
index 1290b92be..8b34cfe8d 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -619,11 +619,13 @@ bool User::ChangeNick(const std::string& newnick, bool force, time_t newts)
return false;
}
- if (!force)
+ LocalUser* const localuser = IS_LOCAL(this);
+ if (!force && localuser)
{
ModResult MOD_RESULT;
- FIRST_MOD_RESULT(OnUserPreNick, MOD_RESULT, (this, newnick));
+ FIRST_MOD_RESULT(OnUserPreNick, MOD_RESULT, (localuser, newnick));
+ // If a module denied the change, abort now
if (MOD_RESULT == MOD_RES_DENY)
return false;
}