X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fusers.cpp;h=1e2554107b1905c1d1a9bb1f30918e2c85330ebb;hb=48a400f2e068527b338ceecf8ed1dde2da971ca9;hp=7f56994d4e8fb4d8c19aedf73ad644999551a620;hpb=3398ce7e50f1c269e8221df04e1eefb52d54c820;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/users.cpp b/src/users.cpp index 7f56994d4..1e2554107 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -458,6 +458,7 @@ void User::UnOper() ModeHandler* opermh = ServerInstance->Modes->FindMode('o', MODETYPE_USER); this->SetMode(opermh, false); + FOREACH_MOD(OnPostDeoper, (this)); } /* @@ -645,8 +646,8 @@ bool User::ChangeNick(const std::string& newnick, time_t newts) } if (this->registered == REG_ALL) - this->WriteCommon("NICK %s",newnick.c_str()); - std::string oldnick = nick; + this->WriteCommon("NICK %s", newnick.c_str()); + const std::string oldnick = nick; nick = newnick; InvalidateCache(); @@ -767,10 +768,12 @@ void LocalUser::Write(const std::string& text) if (!SocketEngine::BoundsCheckFd(&eh)) return; - if (text.length() > ServerInstance->Config->Limits.MaxLine - 2) + // The maximum size of an IRC message minus the terminating CR+LF. + const size_t maxmessage = ServerInstance->Config->Limits.MaxLine - 2; + if (text.length() > maxmessage) { - // this should happen rarely or never. Crop the string at 512 and try again. - std::string try_again(text, 0, ServerInstance->Config->Limits.MaxLine - 2); + // This should happen rarely or never. Crop the string at MaxLine and try again. + std::string try_again(text, 0, maxmessage); Write(try_again); return; } @@ -780,8 +783,9 @@ void LocalUser::Write(const std::string& text) eh.AddWriteBuf(text); eh.AddWriteBuf(wide_newline); - ServerInstance->stats.Sent += text.length() + 2; - this->bytes_out += text.length() + 2; + const size_t bytessent = text.length() + 2; + ServerInstance->stats.Sent += bytessent; + this->bytes_out += bytessent; this->cmds_out++; }