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 | |
parent | a4dddfd5f121c9cc74e05e08a568c6a9febfd56f (diff) |
Add a non-formatting overload of User::SetModesInternal.
-rw-r--r-- | include/users.h | 1 | ||||
-rw-r--r-- | modules/protocol/hybrid.cpp | 2 | ||||
-rw-r--r-- | modules/protocol/inspircd.cpp | 2 | ||||
-rw-r--r-- | modules/protocol/ngircd.cpp | 2 | ||||
-rw-r--r-- | modules/protocol/unrealircd.cpp | 4 | ||||
-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 |
9 files changed, 21 insertions, 14 deletions
diff --git a/include/users.h b/include/users.h index 28c32f385..f017c0e9d 100644 --- a/include/users.h +++ b/include/users.h @@ -309,6 +309,7 @@ public: * @param umodes The modes */ void SetModesInternal(const MessageSource &source, const char *umodes, ...) ATTR_FORMAT(3, 4); + void SetModesInternal(const MessageSource &source, const Anope::string &umodes); /** Get modes set for this user. * @return A string of modes set on the user diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index 44d39b5e9..f99e8de80 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -593,7 +593,7 @@ struct IRCDMessageSVSMode : IRCDMessage if (!params[1].is_pos_number_only() || convertTo<time_t>(params[1]) != u->timestamp) return; - u->SetModesInternal(source, "%s", params[2].c_str()); + u->SetModesInternal(source, params[2]); } }; diff --git a/modules/protocol/inspircd.cpp b/modules/protocol/inspircd.cpp index b3cae551e..0029d37bb 100644 --- a/modules/protocol/inspircd.cpp +++ b/modules/protocol/inspircd.cpp @@ -1690,7 +1690,7 @@ struct IRCDMessageMode : IRCDMessage */ User *u = User::Find(params[0]); if (u) - u->SetModesInternal(source, "%s", params[1].c_str()); + u->SetModesInternal(source, params[1]); } } }; diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index 576b9ea87..bb280db46 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -380,7 +380,7 @@ struct IRCDMessageMode : IRCDMessage User *u = User::Find(params[0]); if (u) - u->SetModesInternal(source, "%s", params[1].c_str()); + u->SetModesInternal(source, params[1]); } } }; diff --git a/modules/protocol/unrealircd.cpp b/modules/protocol/unrealircd.cpp index f506662fb..506af9b35 100644 --- a/modules/protocol/unrealircd.cpp +++ b/modules/protocol/unrealircd.cpp @@ -1153,7 +1153,7 @@ struct IRCDMessageMode : IRCDMessage { User *u = User::Find(params[0]); if (u) - u->SetModesInternal(source, "%s", params[1].c_str()); + u->SetModesInternal(source, params[1]); } } }; @@ -1622,7 +1622,7 @@ struct IRCDMessageUmode2 : IRCDMessage void Run(MessageSource &source, const std::vector<Anope::string> ¶ms, const Anope::map<Anope::string> &tags) override { - source.GetUser()->SetModesInternal(source, "%s", params[0].c_str()); + source.GetUser()->SetModesInternal(source, params[0]); } }; 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 |