diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-01-30 18:56:39 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-01-30 18:56:39 +0000 |
commit | dfc2301e0b5e18a05d9543f5fec0cb55753a410c (patch) | |
tree | 2824c07ff62c9fa94ddda0a91695e0da8d647ea4 | |
parent | ab8305ad99d7bb7d2cfe4154b2deb007546d5b70 (diff) |
Remove UpdateNickHash due to incorrect behavior
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12331 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/users.h | 8 | ||||
-rw-r--r-- | src/users.cpp | 35 |
2 files changed, 10 insertions, 33 deletions
diff --git a/include/users.h b/include/users.h index b71f32748..da68bfd78 100644 --- a/include/users.h +++ b/include/users.h @@ -513,14 +513,6 @@ class CoreExport User : public Extensible */ void Oper(OperInfo* info); - /** Change this users hash key to a new string. - * You should not call this function directly. It is used by the core - * to update the users hash entry on a nickchange. - * @param New new user_hash key - * @return Pointer to User in hash (usually 'this') - */ - User* UpdateNickHash(const char* New); - /** Force a nickname change. * If the nickname change fails (for example, because the nick in question * already exists) this function will return false, and you must then either diff --git a/src/users.cpp b/src/users.cpp index f429597da..8456703cc 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -864,27 +864,6 @@ void LocalUser::FullConnect() ServerInstance->BanCache->AddHit(this->GetIPString(), "", ""); } -/** User::UpdateNick() - * re-allocates a nick in the user_hash after they change nicknames, - * returns a pointer to the new user as it may have moved - */ -User* User::UpdateNickHash(const char* New) -{ - //user_hash::iterator newnick; - user_hash::iterator oldnick = ServerInstance->Users->clientlist->find(this->nick); - - if (!irc::string(this->nick.c_str()).compare(New)) - return oldnick->second; - - if (oldnick == ServerInstance->Users->clientlist->end()) - return NULL; /* doesnt exist */ - - User* olduser = oldnick->second; - ServerInstance->Users->clientlist->erase(oldnick); - (*(ServerInstance->Users->clientlist))[New] = olduser; - return olduser; -} - void User::InvalidateCache() { /* Invalidate cache */ @@ -971,8 +950,11 @@ bool User::ChangeNick(const std::string& newnick, bool force) /* force the camper to their UUID, and ask them to re-send a NICK. */ InUse->WriteTo(InUse, "NICK %s", InUse->uuid.c_str()); InUse->WriteNumeric(433, "%s %s :Nickname overruled.", InUse->nick.c_str(), InUse->nick.c_str()); - InUse->UpdateNickHash(InUse->uuid.c_str()); - InUse->nick.assign(InUse->uuid, 0, IS_LOCAL(InUse) ? ServerInstance->Config->Limits.NickMax : MAXBUF); + + ServerInstance->Users->clientlist->erase(InUse->nick); + (*(ServerInstance->Users->clientlist))[InUse->uuid] = InUse; + + InUse->nick = InUse->uuid; InUse->InvalidateCache(); InUse->registered &= ~REG_NICK; } @@ -980,7 +962,7 @@ bool User::ChangeNick(const std::string& newnick, bool force) { /* No camping, tell the incoming user to stop trying to change nick ;p */ this->WriteNumeric(433, "%s %s :Nickname is already in use.", this->registered >= REG_NICK ? this->nick.c_str() : "*", newnick.c_str()); - return CMD_FAILURE; + return false; } } } @@ -989,8 +971,11 @@ bool User::ChangeNick(const std::string& newnick, bool force) this->WriteCommon("NICK %s",newnick.c_str()); std::string oldnick = nick; nick = newnick; + InvalidateCache(); - UpdateNickHash(newnick.c_str()); + ServerInstance->Users->clientlist->erase(oldnick); + (*(ServerInstance->Users->clientlist))[newnick] = this; + FOREACH_MOD(I_OnUserPostNick,OnUserPostNick(this,oldnick)); return true; } |