]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
m_rmode Call Channel::GetUsers() instead of directly accessing Channel::userlist
[user/henk/code/inspircd.git] / src / users.cpp
index 75852330f2e2680bf0e818cc93a2d4ea68fa3e56..c2b8852d8f4f6bed0da558d1c6516d1aef6533ce 100644 (file)
@@ -611,7 +611,7 @@ void User::InvalidateCache()
        cached_fullrealhost.clear();
 }
 
-bool User::ChangeNick(const std::string& newnick, bool force, time_t newts)
+bool User::ChangeNick(const std::string& newnick, time_t newts)
 {
        if (quitting)
        {
@@ -619,33 +619,8 @@ bool User::ChangeNick(const std::string& newnick, bool force, time_t newts)
                return false;
        }
 
-       LocalUser* const localuser = IS_LOCAL(this);
-       if (!force && localuser)
-       {
-               ModResult MOD_RESULT;
-               FIRST_MOD_RESULT(OnUserPreNick, MOD_RESULT, (localuser, newnick));
-
-               // If a module denied the change, abort now
-               if (MOD_RESULT == MOD_RES_DENY)
-                       return false;
-
-               // Disallow the nick change if <security:restrictbannedusers> is on and there is a ban matching this user in
-               // one of the channels they are on
-               if (ServerInstance->Config->RestrictBannedUsers)
-               {
-                       for (UCListIter i = this->chans.begin(); i != this->chans.end(); ++i)
-                       {
-                               Channel* chan = (*i)->chan;
-                               if (chan->GetPrefixValue(this) < VOICE_VALUE && chan->IsBanned(this))
-                               {
-                                       this->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (you're banned)", chan->name.c_str());
-                                       return false;
-                               }
-                       }
-               }
-       }
-
-       if (assign(newnick) == assign(nick))
+       User* const InUse = ServerInstance->FindNickOnly(newnick);
+       if (InUse == this)
        {
                // case change, don't need to check campers
                // and, if it's identical including case, we can leave right now
@@ -664,8 +639,7 @@ bool User::ChangeNick(const std::string& newnick, bool force, time_t newts)
                 * If the guy using the nick is already using it, tell the incoming nick change to gtfo,
                 * because the nick is already (rightfully) in use. -- w00t
                 */
-               User* InUse = ServerInstance->FindNickOnly(newnick);
-               if (InUse && (InUse != this))
+               if (InUse)
                {
                        if (InUse->registered != REG_ALL)
                        {
@@ -673,12 +647,8 @@ bool User::ChangeNick(const std::string& newnick, bool force, time_t newts)
                                InUse->WriteFrom(InUse, "NICK %s", InUse->uuid.c_str());
                                InUse->WriteNumeric(ERR_NICKNAMEINUSE, "%s :Nickname overruled.", InUse->nick.c_str());
 
-                               ServerInstance->Users->clientlist.erase(InUse->nick);
-                               ServerInstance->Users->clientlist[InUse->uuid] = InUse;
-
-                               InUse->nick = InUse->uuid;
-                               InUse->InvalidateCache();
                                InUse->registered &= ~REG_NICK;
+                               InUse->ChangeNick(InUse->uuid);
                        }
                        else
                        {
@@ -921,8 +891,8 @@ void User::WriteCommonRaw(const std::string &line, bool include_self)
        for (IncludeChanList::const_iterator v = include_c.begin(); v != include_c.end(); ++v)
        {
                Channel* c = (*v)->chan;
-               const UserMembList* ulist = c->GetUsers();
-               for (UserMembList::const_iterator i = ulist->begin(); i != ulist->end(); i++)
+               const Channel::MemberMap& ulist = c->GetUsers();
+               for (Channel::MemberMap::const_iterator i = ulist.begin(); i != ulist.end(); ++i)
                {
                        LocalUser* u = IS_LOCAL(i->first);
                        if (u && u->already_sent != LocalUser::already_sent_id)
@@ -961,8 +931,8 @@ void User::WriteCommonQuit(const std::string &normal_text, const std::string &op
        }
        for (IncludeChanList::const_iterator v = include_c.begin(); v != include_c.end(); ++v)
        {
-               const UserMembList* ulist = (*v)->chan->GetUsers();
-               for (UserMembList::const_iterator i = ulist->begin(); i != ulist->end(); i++)
+               const Channel::MemberMap& ulist = (*v)->chan->GetUsers();
+               for (Channel::MemberMap::const_iterator i = ulist.begin(); i != ulist.end(); i++)
                {
                        LocalUser* u = IS_LOCAL(i->first);
                        if (u && (u->already_sent != uniq_id))
@@ -1027,7 +997,7 @@ void User::SendText(const std::string& linePrefix, std::stringstream& textStream
 bool User::SharesChannelWith(User *other)
 {
        /* Outer loop */
-       for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
+       for (User::ChanList::iterator i = this->chans.begin(); i != this->chans.end(); ++i)
        {
                /* Eliminate the inner loop (which used to be ~equal in size to the outer loop)
                 * by replacing it with a map::find which *should* be more efficient
@@ -1200,7 +1170,7 @@ void LocalUser::SetClass(const std::string &explicit_name)
 void User::PurgeEmptyChannels()
 {
        // firstly decrement the count on each channel
-       for (UCListIter i = this->chans.begin(); i != this->chans.end(); )
+       for (User::ChanList::iterator i = this->chans.begin(); i != this->chans.end(); )
        {
                Channel* c = (*i)->chan;
                ++i;