mirror of
https://github.com/anope/anope.git
synced 2026-06-12 19:14:47 +02:00
Add a string overload of Channel::SetModes.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-3
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user