diff options
author | Sadie Powell <sadie@witchery.services> | 2024-01-06 14:41:54 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2024-01-08 13:11:50 +0000 |
commit | 5db79c1e242d4c06d1aeb2b09f99b8254b7fb5de (patch) | |
tree | 05beddb85b9a11c8c674d78f7405f50072f18f7b /src | |
parent | a4dddfd5f121c9cc74e05e08a568c6a9febfd56f (diff) |
Add a non-formatting overload of User::SetModesInternal.
Diffstat (limited to 'src')
-rw-r--r-- | src/bots.cpp | 2 | ||||
-rw-r--r-- | src/messages.cpp | 2 | ||||
-rw-r--r-- | src/servers.cpp | 2 | ||||
-rw-r--r-- | src/users.cpp | 18 |
4 files changed, 15 insertions, 9 deletions
diff --git a/src/bots.cpp b/src/bots.cpp index 3fc36ae74..9036250ed 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -37,7 +37,7 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A { Anope::string tmodes = !this->botmodes.empty() ? ("+" + this->botmodes) : IRCD->DefaultPseudoclientModes; if (!tmodes.empty()) - this->SetModesInternal(this, tmodes.c_str()); + this->SetModesInternal(this, tmodes); XLine x(this->nick, "Reserved for services"); IRCD->SendSQLine(NULL, &x); diff --git a/src/messages.cpp b/src/messages.cpp index a0f5f98d6..a57dcb6f9 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -229,7 +229,7 @@ void Message::Mode::Run(MessageSource &source, const std::vector<Anope::string> User *u = User::Find(params[0]); if (u) - u->SetModesInternal(source, "%s", buf.substr(1).c_str()); + u->SetModesInternal(source, buf.substr(1)); } } diff --git a/src/servers.cpp b/src/servers.cpp index feef808f5..ef9276fa9 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -52,7 +52,7 @@ Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Ano { Anope::string modes = !bi->botmodes.empty() ? ("+" + bi->botmodes) : IRCD->DefaultPseudoclientModes; - bi->SetModesInternal(bi, modes.c_str()); + bi->SetModesInternal(bi, modes); for (const auto &botchannel : bi->botchannels) { size_t h = botchannel.find('#'); diff --git a/src/users.cpp b/src/users.cpp index cc9ac9af0..f4e77c5f9 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -50,7 +50,7 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope: this->server = sserver; this->realname = srealname; this->timestamp = this->signon = ts; - this->SetModesInternal(sserver, "%s", smodes.c_str()); + this->SetModesInternal(sserver, smodes); this->uid = suid; this->super_admin = false; this->nc = NULL; @@ -664,16 +664,21 @@ void User::SetModesInternal(const MessageSource &source, const char *umodes, ... { char buf[BUFSIZE] = ""; va_list args; - Anope::string modebuf, sbuf; - int add = -1; va_start(args, umodes); vsnprintf(buf, BUFSIZE - 1, umodes, args); va_end(args); - if (this->server && this->server->IsSynced() && Anope::string(buf) != "+") - Log(this, "mode") << "changes modes to " << buf; + SetModesInternal(source, Anope::string(buf)); +} - spacesepstream sep(buf); +void User::SetModesInternal(const MessageSource &source, const Anope::string &umodes) +{ + if (this->server && this->server->IsSynced() && Anope::string(umodes) != "+") + Log(this, "mode") << "changes modes to " << umodes; + + int add = -1; + Anope::string modebuf; + spacesepstream sep(umodes); sep.GetToken(modebuf); for (auto mode : modebuf) { @@ -697,6 +702,7 @@ void User::SetModesInternal(const MessageSource &source, const char *umodes, ... if (add) { + Anope::string sbuf; if (um->type == MODE_PARAM && sep.GetToken(sbuf)) this->SetModeInternal(source, um, sbuf); else |