diff options
author | Sadie Powell <sadie@witchery.services> | 2024-01-08 14:14:37 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2024-01-08 14:14:37 +0000 |
commit | 5b23fae8bfb40ae23a4cd206b4b58cb076600609 (patch) | |
tree | b7f045e18dafbc5d41f1f4f3635e54c5f4ed8164 | |
parent | aac4b0f0a3a0b615ed834dc2a61d472044906c79 (diff) |
Add a string overload of Channel::SetModes.
-rw-r--r-- | include/channels.h | 1 | ||||
-rw-r--r-- | modules/commands/os_defcon.cpp | 6 | ||||
-rw-r--r-- | src/channels.cpp | 12 |
3 files changed, 13 insertions, 6 deletions
diff --git a/include/channels.h b/include/channels.h index 3ff41005a..7d37a3544 100644 --- a/include/channels.h +++ b/include/channels.h @@ -205,6 +205,7 @@ public: * @param cmodes The modes to set */ void SetModes(BotInfo *bi, bool enforce_mlock, const char *cmodes, ...) ATTR_FORMAT(4, 5); + void SetModes(BotInfo *bi, bool enforce_mlock, const Anope::string &cmodes); /** Set a string of modes internally on a channel * @param source The setter diff --git a/modules/commands/os_defcon.cpp b/modules/commands/os_defcon.cpp index 906c64e6d..a41b104c9 100644 --- a/modules/commands/os_defcon.cpp +++ b/modules/commands/os_defcon.cpp @@ -541,7 +541,7 @@ public: void OnChannelSync(Channel *c) override { if (DConfig.Check(DEFCON_FORCE_CHAN_MODES)) - c->SetModes(Config->GetClient("OperServ"), false, "%s", DConfig.chanmodes.c_str()); + c->SetModes(Config->GetClient("OperServ"), false, DConfig.chanmodes); } }; @@ -557,7 +557,7 @@ static void runDefCon() Log(OperServ, "operserv/defcon") << "DEFCON: setting " << DConfig.chanmodes << " on all channels"; DefConModesSet = true; for (const auto &[_, chan] : ChannelList) - chan->SetModes(OperServ, false, "%s", DConfig.chanmodes.c_str()); + chan->SetModes(OperServ, false, DConfig.chanmodes); } } } @@ -573,7 +573,7 @@ static void runDefCon() { Log(OperServ, "operserv/defcon") << "DEFCON: setting " << newmodes << " on all channels"; for (const auto &[_, chan] : ChannelList) - chan->SetModes(OperServ, true, "%s", newmodes.c_str()); + chan->SetModes(OperServ, true, newmodes); } } } diff --git a/src/channels.cpp b/src/channels.cpp index 962debf56..74521e239 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -542,15 +542,21 @@ void Channel::SetModes(BotInfo *bi, bool enforce_mlock, const char *cmodes, ...) { char buf[BUFSIZE] = ""; va_list args; - Anope::string modebuf, sbuf; - int add = -1; va_start(args, cmodes); vsnprintf(buf, BUFSIZE - 1, cmodes, args); va_end(args); + SetModes(bi, enforce_mlock, Anope::string(buf)); +} + + +void Channel::SetModes(BotInfo *bi, bool enforce_mlock, const Anope::string &cmodes) +{ + Anope::string modebuf, sbuf; + int add = -1; Reference<Channel> this_reference(this); - spacesepstream sep(buf); + spacesepstream sep(cmodes); sep.GetToken(modebuf); for (unsigned i = 0, end = modebuf.length(); this_reference && i < end; ++i) { |