X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fusers.cpp;h=abe0f8804b4f7765281387f2b943741aa6d0cfa5;hb=acccaa39641500b8a691db4136e6571102a438ed;hp=39e1ec79640b95b7e52bbb72a76a7e592fd2ff21;hpb=5b1ee304b5e1d71c71eec9ebf8f40758dfce5c1e;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/users.cpp b/src/users.cpp index 39e1ec796..abe0f8804 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -24,8 +24,6 @@ #include "inspircd.h" -#include -#include "socketengine.h" #include "xline.h" already_sent_t LocalUser::already_sent_id = 0; @@ -613,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) { @@ -621,21 +619,10 @@ bool User::ChangeNick(const std::string& newnick, bool force, time_t newts) return false; } - if (!force) + User* const InUse = ServerInstance->FindNickOnly(newnick); + if (InUse == this) { - ModResult MOD_RESULT; - FIRST_MOD_RESULT(OnUserPreNick, MOD_RESULT, (this, newnick)); - - if (MOD_RESULT == MOD_RES_DENY) - { - ServerInstance->stats.Collisions++; - return false; - } - } - - if (assign(newnick) == assign(nick)) - { - // case change, don't need to check Q:lines and such + // case change, don't need to check campers // and, if it's identical including case, we can leave right now // We also don't update the nick TS if it's a case change, either if (newnick == nick) @@ -643,42 +630,6 @@ bool User::ChangeNick(const std::string& newnick, bool force, time_t newts) } else { - /* - * Don't check Q:Lines if it's a server-enforced change, just on the off-chance some fucking *moron* - * tries to Q:Line SIDs, also, this means we just get our way period, as it really should be. - * Thanks Kein for finding this. -- w00t - * - * Also don't check Q:Lines for remote nickchanges, they should have our Q:Lines anyway to enforce themselves. - * -- w00t - */ - if (IS_LOCAL(this) && !force) - { - XLine* mq = ServerInstance->XLines->MatchesLine("Q",newnick); - if (mq) - { - if (this->registered == REG_ALL) - { - ServerInstance->SNO->WriteGlobalSno('a', "Q-Lined nickname %s from %s: %s", - newnick.c_str(), GetFullRealHost().c_str(), mq->reason.c_str()); - } - this->WriteNumeric(ERR_ERRONEUSNICKNAME, "%s :Invalid nickname: %s", newnick.c_str(), mq->reason.c_str()); - return false; - } - - 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; - } - } - } - } - /* * Uh oh.. if the nickname is in use, and it's not in use by the person using it (doh) -- * then we have a potential collide. Check whether someone else is camping on the nick @@ -688,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) { @@ -697,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 {