diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-12-30 13:34:33 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-12-30 13:34:33 +0100 |
commit | 5d050846f7f3f152422e56e5c871302ee7a5a1ed (patch) | |
tree | 53785ff666b468bdd47733f462ec0cc9d889acda /src | |
parent | 84924a36317abe82f82a12a4509985515217fea3 (diff) |
cmd_names Switch to Numeric::Builder
Diffstat (limited to 'src')
-rw-r--r-- | src/coremods/core_channel/cmd_names.cpp | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/src/coremods/core_channel/cmd_names.cpp b/src/coremods/core_channel/cmd_names.cpp index 05f16e10b..986dbe018 100644 --- a/src/coremods/core_channel/cmd_names.cpp +++ b/src/coremods/core_channel/cmd_names.cpp @@ -68,7 +68,8 @@ CmdResult CommandNames::HandleLocal(const std::vector<std::string>& parameters, void CommandNames::SendNames(LocalUser* user, Channel* chan, bool show_invisible) { - std::string list; + Numeric::Builder<' '> reply(user, RPL_NAMREPLY, false); + std::string& list = reply.GetNumeric(); if (chan->IsModeSet(secretmode)) list.push_back('@'); else if (chan->IsModeSet(privatemode)) @@ -78,9 +79,8 @@ void CommandNames::SendNames(LocalUser* user, Channel* chan, bool show_invisible list.push_back(' '); list.append(chan->name).append(" :"); - std::string::size_type pos = list.size(); + reply.SaveBeginPos(); - const size_t maxlen = ServerInstance->Config->Limits.MaxLine - 10 - ServerInstance->Config->ServerName.size() - user->nick.size(); std::string prefixlist; std::string nick; const Channel::MemberMap& members = chan->GetUsers(); @@ -107,21 +107,9 @@ void CommandNames::SendNames(LocalUser* user, Channel* chan, bool show_invisible if (res == MOD_RES_DENY) continue; - if (list.size() + prefixlist.length() + nick.length() + 1 > maxlen) - { - // List overflowed into multiple numerics - user->WriteNumeric(RPL_NAMREPLY, list); - - // Erase all nicks, keep the constant part - list.erase(pos); - } - - list.append(prefixlist).append(nick).push_back(' '); + reply.Add(prefixlist, nick); } - // Only send the user list numeric if there is at least one user in it - if (list.size() != pos) - user->WriteNumeric(RPL_NAMREPLY, list); - + reply.Flush(); user->WriteNumeric(RPL_ENDOFNAMES, "%s :End of /NAMES list.", chan->name.c_str()); } |