summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-10-02 11:11:16 +0100
committerSadie Powell <sadie@witchery.services>2024-10-02 11:12:24 +0100
commit8232759a924e5bd8f7fa5a425dcb930bba4ef3fb (patch)
treeb112914c4a945e04bb35e4de0e05deaca33a6b4d /src
parentb006966d25888857f777892fd3412d8c6da6af5d (diff)
Change Channel::SetModesInternal to take a split mode change.
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp28
-rw-r--r--src/messages.cpp8
2 files changed, 17 insertions, 19 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 2598d7602..ff3dd8a03 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -611,13 +611,13 @@ void Channel::SetModes(BotInfo *bi, bool enforce_mlock, const Anope::string &cmo
}
}
-void Channel::SetModesInternal(MessageSource &source, const Anope::string &mode, time_t ts, bool enforce_mlock)
+void Channel::SetModesInternal(MessageSource &source, const Anope::string &modes, const std::vector<Anope::string> &params, time_t ts, bool enforce_mlock)
{
if (!ts)
;
else if (ts > this->creation_time)
{
- Log(LOG_DEBUG) << "Dropping mode " << mode << " on " << this->name << ", " << ts << " > " << this->creation_time;
+ Log(LOG_DEBUG) << "Dropping mode " << modes << " on " << this->name << ", " << ts << " > " << this->creation_time;
return;
}
else if (ts < this->creation_time)
@@ -631,20 +631,18 @@ void Channel::SetModesInternal(MessageSource &source, const Anope::string &mode,
/* Removing channel modes *may* delete this channel */
Reference<Channel> this_reference(this);
- spacesepstream sep_modes(mode);
- Anope::string m;
-
- sep_modes.GetToken(m);
-
Anope::string modestring;
Anope::string paramstring;
int add = -1;
bool changed = false;
- for (unsigned int i = 0, end = m.length(); i < end && this_reference; ++i)
+ auto paramit = params.begin();
+ for (const auto mchar : modes)
{
- ChannelMode *cm;
+ if (!this_reference)
+ break;
- switch (m[i])
+ ChannelMode *cm;
+ switch (mchar)
{
case '+':
modestring += '+';
@@ -657,10 +655,10 @@ void Channel::SetModesInternal(MessageSource &source, const Anope::string &mode,
default:
if (add == -1)
continue;
- cm = ModeManager::FindChannelModeByChar(m[i]);
+ cm = ModeManager::FindChannelModeByChar(mchar);
if (!cm)
{
- Log(LOG_DEBUG) << "Channel::SetModeInternal: Unknown mode char " << m[i];
+ Log(LOG_DEBUG) << "Channel::SetModeInternal: Unknown mode char " << mchar;
continue;
}
modestring += cm->mchar;
@@ -686,9 +684,9 @@ void Channel::SetModesInternal(MessageSource &source, const Anope::string &mode,
continue;
}
}
- Anope::string token;
- if (sep_modes.GetToken(token))
+ if (paramit != params.end())
{
+ auto token = *paramit++;
User *u = NULL;
if (cm->type == MODE_STATUS && (u = User::Find(token)))
paramstring += " " + u->nick;
@@ -703,7 +701,7 @@ void Channel::SetModesInternal(MessageSource &source, const Anope::string &mode,
this->RemoveModeInternal(source, cm, token, enforce_mlock);
}
else
- Log() << "warning: Channel::SetModesInternal() received more modes requiring params than params, modes: " << mode;
+ Log() << "warning: Channel::SetModesInternal() received more modes requiring params than params, modes: " << modes;
}
if (!this_reference)
diff --git a/src/messages.cpp b/src/messages.cpp
index d906e83d4..9e6f6ebb0 100644
--- a/src/messages.cpp
+++ b/src/messages.cpp
@@ -98,11 +98,11 @@ void Join::Run(MessageSource &source, const std::vector<Anope::string> &params,
users.emplace_back(ChannelStatus(), user);
Channel *chan = Channel::Find(channel);
- SJoin(source, channel, chan ? chan->creation_time : Anope::CurTime, "", users);
+ SJoin(source, channel, chan ? chan->creation_time : Anope::CurTime, "", {}, users);
}
}
-void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, const Anope::string &modes, const std::list<SJoinUser> &users)
+void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, const Anope::string &modes, const std::vector<Anope::string> &modeparams, const std::list<SJoinUser> &users)
{
bool created;
Channel *c = Channel::FindOrCreate(chan, created, ts ? ts : Anope::CurTime);
@@ -128,7 +128,7 @@ void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, co
/* If we are syncing, mlock is checked later in Channel::Sync. It is important to not check it here
* so that Channel::SetCorrectModes can correctly detect the presence of channel mode +r.
*/
- c->SetModesInternal(source, modes, ts, !c->syncing);
+ c->SetModesInternal(source, modes, modeparams, ts, !c->syncing);
for (const auto &[status, u] : users)
{
@@ -223,7 +223,7 @@ void Message::Mode::Run(MessageSource &source, const std::vector<Anope::string>
Channel *c = Channel::Find(params[0]);
if (c)
- c->SetModesInternal(source, buf.substr(1), 0);
+ c->SetModesInternal(source, params[1], { params.begin() + 2, params.end() });
}
else
{