diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-05-11 18:14:12 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-05-11 18:14:12 +0000 |
commit | df54ef0105c6e59cc8bc3fe279ba8445691eb724 (patch) | |
tree | a0871755da7100064146cdf0b89c9f724af5cf0d | |
parent | 9c3a20c15123c4812c236f33418c1fdfe74c3ff2 (diff) |
One of my XXXs done, tidy logic in here
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6979 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/modules/m_nicklock.cpp | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/src/modules/m_nicklock.cpp b/src/modules/m_nicklock.cpp index 519aabe13..38208c724 100644 --- a/src/modules/m_nicklock.cpp +++ b/src/modules/m_nicklock.cpp @@ -41,33 +41,40 @@ class cmd_nicklock : public command_t irc::string server; irc::string me; - /* XXX - these ifs look damn ugly, note to myself to fix them -- w00t */ - if (source) + // check user exists + if (!source) { - if (source->GetExt("nick_locked", dummy)) - { - user->WriteServ("946 %s %s :This user's nickname is already locked.",user->nick,source->nick); - return CMD_FAILURE; - } - if (ServerInstance->IsNick(parameters[1])) - { - // give them a lock flag - ServerInstance->WriteOpers(std::string(user->nick)+" used NICKLOCK to change and hold "+parameters[0]+" to "+parameters[1]); - if (!source->ForceNickChange(parameters[1])) - { - userrec::QuitUser(ServerInstance, source, "Nickname collision"); - return CMD_FAILURE; - } - source->Extend("nick_locked", "ON"); - - /* route */ - return CMD_SUCCESS; - } + return CMD_FAILURE; + } + // check if user is locked + if (source->GetExt("nick_locked", dummy)) + { + user->WriteServ("946 %s %s :This user's nickname is already locked.",user->nick,source->nick); return CMD_FAILURE; } - return CMD_FAILURE; + // check nick is valid + if (!ServerInstance->IsNick(parameters[1])) + { + return CMD_FAILURE + } + + // let others know + ServerInstance->WriteOpers(std::string(user->nick)+" used NICKLOCK to change and hold "+parameters[0]+" to "+parameters[1]); + + if (!source->ForceNickChange(parameters[1])) + { + // ugh, nickchange failed for some reason -- possibly existing nick? + userrec::QuitUser(ServerInstance, source, "Nickname collision"); + return CMD_FAILURE; + } + + // give them a lock flag + source->Extend("nick_locked", "ON"); + + /* route */ + return CMD_SUCCESS; } }; |