summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp97
-rw-r--r--src/modes.cpp124
-rw-r--r--src/protocol.cpp61
-rw-r--r--src/servers.cpp4
-rw-r--r--src/users.cpp20
5 files changed, 159 insertions, 147 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index b8fa74443..25826ad1a 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -209,7 +209,7 @@ Anope::string Channel::GetModes(bool complete, bool plus)
{
Anope::string res, params;
- for (const auto &[mode, value] : this->modes)
+ for (const auto &[mode, data] : this->modes)
{
ChannelMode *cm = ModeManager::FindChannelModeByName(mode);
if (!cm || cm->type == MODE_LIST)
@@ -217,14 +217,14 @@ Anope::string Channel::GetModes(bool complete, bool plus)
res += cm->mchar;
- if (complete && !value.empty())
+ if (complete && !data.value.empty())
{
ChannelModeParam *cmp = NULL;
if (cm->type == MODE_PARAM)
cmp = anope_dynamic_static_cast<ChannelModeParam *>(cm);
if (plus || !cmp || !cmp->minus_no_arg)
- params += " " + value;
+ params += " " + data.value;
}
}
@@ -236,46 +236,42 @@ const Channel::ModeList &Channel::GetModes() const
return this->modes;
}
-template<typename F, typename S>
-struct second final
-{
- S operator()(const std::pair<F, S> &p)
- {
- return p.second;
- }
-};
-
std::vector<Anope::string> Channel::GetModeList(const Anope::string &mname)
{
std::vector<Anope::string> r;
- std::transform(modes.lower_bound(mname), modes.upper_bound(mname), std::back_inserter(r), second<Anope::string, Anope::string>());
+ std::transform(modes.lower_bound(mname), modes.upper_bound(mname), std::back_inserter(r), [](const auto &mode) {
+ return mode.second.value;
+ });
return r;
}
-void Channel::SetModeInternal(MessageSource &setter, ChannelMode *ocm, const Anope::string &oparam, bool enforce_mlock)
+void Channel::SetModeInternal(MessageSource &setter, ChannelMode *ocm, const ModeData &data, bool enforce_mlock)
{
if (!ocm)
return;
- Anope::string param = oparam;
- ChannelMode *cm = ocm->Unwrap(param);
+ // We build a mode data which has more than what the caller gives us.
+ ModeData mdata;
+ mdata.set_at = data.set_at ? data.set_at : Anope::CurTime;
+ mdata.set_by = data.set_by.empty() ? setter.GetName() : data.set_by;
+ mdata.value = data.value;
+ auto *cm = ocm->Unwrap(mdata.value);
EventReturn MOD_RESULT;
/* Setting v/h/o/a/q etc */
if (cm->type == MODE_STATUS)
{
- if (param.empty())
+ if (mdata.value.empty())
{
Log() << "Channel::SetModeInternal() mode " << cm->mchar << " with no parameter for channel " << this->name;
return;
}
- User *u = User::Find(param);
-
+ auto *u = User::Find(mdata.value);
if (!u)
{
- Log(LOG_DEBUG) << "MODE " << this->name << " +" << cm->mchar << " for nonexistent user " << param;
+ Log(LOG_DEBUG) << "MODE " << this->name << " +" << cm->mchar << " for nonexistent user " << mdata.value;
return;
}
@@ -286,7 +282,7 @@ void Channel::SetModeInternal(MessageSource &setter, ChannelMode *ocm, const Ano
if (cc)
cc->status.AddMode(cm->mchar);
- FOREACH_RESULT(OnChannelModeSet, MOD_RESULT, (this, setter, cm, param));
+ FOREACH_RESULT(OnChannelModeSet, MOD_RESULT, (this, setter, cm, data));
/* Enforce secureops, etc */
if (enforce_mlock && MOD_RESULT != EVENT_STOP)
@@ -296,12 +292,12 @@ void Channel::SetModeInternal(MessageSource &setter, ChannelMode *ocm, const Ano
if (cm->type != MODE_LIST)
this->modes.erase(cm->name);
- else if (this->HasMode(cm->name, param))
+ else if (this->HasMode(cm->name, mdata.value))
return;
- this->modes.emplace(cm->name, param);
+ this->modes.emplace(cm->name, mdata);
- if (param.empty() && cm->type != MODE_REGULAR)
+ if (mdata.value.empty() && cm->type != MODE_REGULAR)
{
Log() << "Channel::SetModeInternal() mode " << cm->mchar << " for " << this->name << " with no parameter, but is a param mode";
return;
@@ -310,10 +306,10 @@ void Channel::SetModeInternal(MessageSource &setter, ChannelMode *ocm, const Ano
if (cm->type == MODE_LIST)
{
ChannelModeList *cml = anope_dynamic_static_cast<ChannelModeList *>(cm);
- cml->OnAdd(this, param);
+ cml->OnAdd(this, mdata.value);
}
- FOREACH_RESULT(OnChannelModeSet, MOD_RESULT, (this, setter, cm, param));
+ FOREACH_RESULT(OnChannelModeSet, MOD_RESULT, (this, setter, cm, data));
/* Check if we should enforce mlock */
if (!enforce_mlock || MOD_RESULT == EVENT_STOP)
@@ -368,7 +364,7 @@ void Channel::RemoveModeInternal(MessageSource &setter, ChannelMode *ocm, const
if (cm->type == MODE_LIST)
{
for (Channel::ModeList::iterator it = modes.lower_bound(cm->name), it_end = modes.upper_bound(cm->name); it != it_end; ++it)
- if (param.equals_ci(it->second))
+ if (param.equals_ci(it->second.value))
{
this->modes.erase(it);
break;
@@ -401,27 +397,33 @@ void Channel::RemoveModeInternal(MessageSource &setter, ChannelMode *ocm, const
this->CheckModes();
}
-void Channel::SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string &param, bool enforce_mlock)
+void Channel::SetMode(BotInfo *bi, ChannelMode *cm, const ModeData &data, bool enforce_mlock)
{
- Anope::string wparam = param;
if (!cm)
return;
+
+ // We build a mode data which has more than what the caller gives us.
+ ModeData mdata;
+ mdata.set_at = data.set_at ? data.set_at : Anope::CurTime;
+ mdata.set_by = data.set_by.empty() && bi ? bi->nick : data.set_by;
+ mdata.value = data.value;
+
/* Don't set modes already set */
if (cm->type == MODE_REGULAR && HasMode(cm->name))
return;
else if (cm->type == MODE_PARAM)
{
ChannelModeParam *cmp = anope_dynamic_static_cast<ChannelModeParam *>(cm);
- if (!cmp->IsValid(wparam))
+ if (!cmp->IsValid(mdata.value))
return;
Anope::string cparam;
- if (GetParam(cm->name, cparam) && cparam.equals_cs(wparam))
+ if (GetParam(cm->name, cparam) && cparam.equals_cs(mdata.value))
return;
}
else if (cm->type == MODE_STATUS)
{
- User *u = User::Find(param);
+ User *u = User::Find(mdata.value);
if (!u || HasUserStatus(u, anope_dynamic_static_cast<ChannelModeStatus *>(cm)))
return;
}
@@ -429,10 +431,10 @@ void Channel::SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string &param,
{
ChannelModeList *cml = anope_dynamic_static_cast<ChannelModeList *>(cm);
- if (!cml->IsValid(wparam))
+ if (!cml->IsValid(mdata.value))
return;
- if (this->HasMode(cm->name, wparam))
+ if (this->HasMode(cm->name, mdata.value))
return;
}
@@ -447,16 +449,16 @@ void Channel::SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string &param,
this->chanserv_modecount++;
}
- ChannelMode *wcm = cm->Wrap(wparam);
+ ChannelMode *wcm = cm->Wrap(mdata.value);
- ModeManager::StackerAdd(bi, this, wcm, true, wparam);
+ ModeManager::StackerAdd(bi, this, wcm, true, mdata);
MessageSource ms(bi);
- SetModeInternal(ms, wcm, wparam, enforce_mlock);
+ SetModeInternal(ms, wcm, mdata, enforce_mlock);
}
-void Channel::SetMode(BotInfo *bi, const Anope::string &mname, const Anope::string &param, bool enforce_mlock)
+void Channel::SetMode(BotInfo *bi, const Anope::string &mname, const ModeData &data, bool enforce_mlock)
{
- SetMode(bi, ModeManager::FindChannelModeByName(mname), param, enforce_mlock);
+ SetMode(bi, ModeManager::FindChannelModeByName(mname), data, enforce_mlock);
}
void Channel::RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string &wparam, bool enforce_mlock)
@@ -520,13 +522,13 @@ void Channel::RemoveMode(BotInfo *bi, const Anope::string &mname, const Anope::s
bool Channel::GetParam(const Anope::string &mname, Anope::string &target) const
{
- std::multimap<Anope::string, Anope::string>::const_iterator it = this->modes.find(mname);
+ const auto it = this->modes.find(mname);
target.clear();
if (it != this->modes.end())
{
- target = it->second;
+ target = it->second.value;
return true;
}
@@ -586,7 +588,7 @@ void Channel::SetModes(BotInfo *bi, bool enforce_mlock, const Anope::string &cmo
this->SetMode(bi, cm, sbuf, enforce_mlock);
}
else
- this->SetMode(bi, cm, "", enforce_mlock);
+ this->SetMode(bi, cm, {}, enforce_mlock);
}
else if (!add)
{
@@ -659,12 +661,16 @@ void Channel::SetModesInternal(MessageSource &source, const Anope::string &modes
modestring += cm->mchar;
}
+ ModeData data;
+ data.set_by = source.GetName();
+ data.set_at = ts ? ts : Anope::CurTime;
+
if (cm->type == MODE_REGULAR)
{
/* something changed if we are adding a mode we don't have, or removing one we have */
changed |= !!add != this->HasMode(cm->name);
if (add)
- this->SetModeInternal(source, cm, "", false);
+ this->SetModeInternal(source, cm, data, false);
else
this->RemoveModeInternal(source, cm, "", false);
continue;
@@ -691,7 +697,10 @@ void Channel::SetModesInternal(MessageSource &source, const Anope::string &modes
changed |= !!add != this->HasMode(cm->name, token);
/* CheckModes below doesn't check secureops (+ the module event) */
if (add)
- this->SetModeInternal(source, cm, token, enforce_mlock);
+ {
+ data.value = token;
+ this->SetModeInternal(source, cm, data, enforce_mlock);
+ }
else
this->RemoveModeInternal(source, cm, token, enforce_mlock);
}
diff --git a/src/modes.cpp b/src/modes.cpp
index fdaae7716..c68389c2d 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -41,19 +41,20 @@ unsigned ModeManager::GenericChannelModes = 0, ModeManager::GenericUserModes = 0
struct StackerInfo final
{
+ using ModeList = std::list<std::pair<Mode *, ModeData>>;
/* Modes to be added */
- std::list<std::pair<Mode *, Anope::string> > AddModes;
+ ModeList AddModes;
/* Modes to be deleted */
- std::list<std::pair<Mode *, Anope::string> > DelModes;
+ ModeList DelModes;
/* Bot this is sent from */
BotInfo *bi = nullptr;
/** Add a mode to this object
* @param mode The mode
* @param set true if setting, false if unsetting
- * @param param The param for the mode
+ * @param data Data about the mode.
*/
- void AddMode(Mode *mode, bool set, const Anope::string &param);
+ void AddMode(Mode *mode, bool set, const ModeData &data);
};
ChannelStatus::ChannelStatus(const Anope::string &m) : modes(m)
@@ -246,11 +247,11 @@ bool ChannelModeNoone::CanSet(User *u) const
return false;
}
-void StackerInfo::AddMode(Mode *mode, bool set, const Anope::string &param)
+void StackerInfo::AddMode(Mode *mode, bool set, const ModeData &data)
{
bool is_param = mode->type == MODE_PARAM;
- std::list<std::pair<Mode *, Anope::string> > *list, *otherlist;
+ ModeList *list, *otherlist;
if (set)
{
list = &AddModes;
@@ -263,13 +264,13 @@ void StackerInfo::AddMode(Mode *mode, bool set, const Anope::string &param)
}
/* Loop through the list and find if this mode is already on here */
- std::list<std::pair<Mode *, Anope::string > >::iterator it, it_end;
+ StackerInfo::ModeList::iterator it, it_end;
for (it = list->begin(), it_end = list->end(); it != it_end; ++it)
{
/* The param must match too (can have multiple status or list modes), but
* if it is a param mode it can match no matter what the param is
*/
- if (it->first == mode && (is_param || param.equals_cs(it->second)))
+ if (it->first == mode && (is_param || data.value.equals_cs(it->second.value)))
{
list->erase(it);
/* It can only be on this list once */
@@ -282,7 +283,7 @@ void StackerInfo::AddMode(Mode *mode, bool set, const Anope::string &param)
/* The param must match too (can have multiple status or list modes), but
* if it is a param mode it can match no matter what the param is
*/
- if (it->first == mode && (is_param || param.equals_cs(it->second)))
+ if (it->first == mode && (is_param || data.value.equals_cs(it->second.value)))
{
otherlist->erase(it);
return;
@@ -294,7 +295,7 @@ void StackerInfo::AddMode(Mode *mode, bool set, const Anope::string &param)
}
/* Add this mode and its param to our list */
- list->emplace_back(mode, param);
+ list->emplace_back(mode, data);
}
static class ModePipe final
@@ -323,72 +324,6 @@ static StackerInfo *GetInfo(List &l, Object *o)
return s;
}
-/** Build a list of mode strings to send to the IRCd from the mode stacker
- * @param info The stacker info for a channel or user
- * @return a list of strings
- */
-static auto BuildModeStrings(StackerInfo *info)
-{
- std::list<std::pair<Anope::string, std::vector<Anope::string>>> ret;
- std::list<std::pair<Mode *, Anope::string> >::iterator it, it_end;
- Anope::string buf = "+";
- std::vector<Anope::string> parambuf;
- unsigned NModes = 0;
- size_t paramlen = 0;
-
- for (it = info->AddModes.begin(), it_end = info->AddModes.end(); it != it_end; ++it)
- {
- if ((IRCD->MaxModes && ++NModes > IRCD->MaxModes) || (IRCD->MaxLine && buf.length() + paramlen > IRCD->MaxLine - 100)) // Leave room for command, channel, etc
- {
- ret.push_back({buf, parambuf});
- buf = "+";
- parambuf.clear();
- paramlen = 0;
- NModes = 1;
- }
-
- buf += it->first->mchar;
-
- if (!it->second.empty())
- {
- parambuf.push_back(it->second);
- paramlen += it->second.length() + 1;
- }
- }
-
- if (buf[buf.length() - 1] == '+')
- buf.erase(buf.length() - 1);
-
- buf += "-";
- for (it = info->DelModes.begin(), it_end = info->DelModes.end(); it != it_end; ++it)
- {
- if ((IRCD->MaxModes && ++NModes > IRCD->MaxModes) || (IRCD->MaxLine && buf.length() + paramlen > IRCD->MaxLine - 100)) // Leave room for command, channel, etc
- {
- ret.push_back({buf, parambuf});
- buf = "-";
- parambuf.clear();
- paramlen = 0;
- NModes = 1;
- }
-
- buf += it->first->mchar;
-
- if (!it->second.empty())
- {
- parambuf.push_back(it->second);
- paramlen += it->second.length() + 1;
- }
- }
-
- if (buf[buf.length() - 1] == '-')
- buf.erase(buf.length() - 1);
-
- if (!buf.empty())
- ret.push_back({buf, parambuf});
-
- return ret;
-}
-
bool ModeManager::AddUserMode(UserMode *um)
{
if (ModeManager::FindUserModeByChar(um->mchar) != NULL)
@@ -606,10 +541,10 @@ void ModeManager::RebuildStatusModes()
std::sort(ChannelModesByStatus.begin(), ChannelModesByStatus.end(), statuscmp);
}
-void ModeManager::StackerAdd(BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, const Anope::string &Param)
+void ModeManager::StackerAdd(BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, const ModeData &data)
{
StackerInfo *s = GetInfo(ChannelStackerObjects, c);
- s->AddMode(cm, Set, Param);
+ s->AddMode(cm, Set, data);
if (bi)
s->bi = bi;
else
@@ -620,10 +555,10 @@ void ModeManager::StackerAdd(BotInfo *bi, Channel *c, ChannelMode *cm, bool Set,
modePipe->Notify();
}
-void ModeManager::StackerAdd(BotInfo *bi, User *u, UserMode *um, bool Set, const Anope::string &Param)
+void ModeManager::StackerAdd(BotInfo *bi, User *u, UserMode *um, bool Set, const ModeData &data)
{
StackerInfo *s = GetInfo(UserStackerObjects, u);
- s->AddMode(um, Set, Param);
+ s->AddMode(um, Set, data);
if (bi)
s->bi = bi;
@@ -632,14 +567,24 @@ void ModeManager::StackerAdd(BotInfo *bi, User *u, UserMode *um, bool Set, const
modePipe->Notify();
}
+static auto BuildModeMap(StackerInfo *info)
+{
+ // TODO: make the stacker store this so we don't need to build it.
+ ModeManager::Change change;
+ for (const auto &[mode, data] : info->AddModes)
+ change.emplace(mode, std::make_pair(true, data));
+ for (const auto &[mode, data] : info->DelModes)
+ change.emplace(mode, std::make_pair(false, data));
+ return change;
+}
+
void ModeManager::ProcessModes()
{
if (!UserStackerObjects.empty())
{
for (const auto &[u, s] : UserStackerObjects)
{
- for (const auto &modestr : BuildModeStrings(s))
- IRCD->SendModeInternal(s->bi, u, modestr.first, modestr.second);
+ IRCD->SendMode(s->bi, u, BuildModeMap(s));
delete s;
}
UserStackerObjects.clear();
@@ -649,8 +594,7 @@ void ModeManager::ProcessModes()
{
for (const auto &[c, s] : ChannelStackerObjects)
{
- for (const auto &modestr : BuildModeStrings(s))
- IRCD->SendModeInternal(s->bi, c, modestr.first, modestr.second);
+ IRCD->SendMode(s->bi, c, BuildModeMap(s));
delete s;
}
ChannelStackerObjects.clear();
@@ -664,9 +608,7 @@ static void StackerDel(std::map<T *, StackerInfo *> &map, T *obj)
if (it != map.end())
{
StackerInfo *si = it->second;
- for (const auto &modestr : BuildModeStrings(si))
- IRCD->SendModeInternal(si->bi, obj, modestr.first, modestr.second);
-
+ IRCD->SendMode(si->bi, obj, BuildModeMap(si));
delete si;
map.erase(it);
}
@@ -689,7 +631,7 @@ void ModeManager::StackerDel(Mode *m)
StackerInfo *si = it->second;
++it;
- for (std::list<std::pair<Mode *, Anope::string> >::iterator it2 = si->AddModes.begin(), it2_end = si->AddModes.end(); it2 != it2_end;)
+ for (StackerInfo::ModeList::iterator it2 = si->AddModes.begin(), it2_end = si->AddModes.end(); it2 != it2_end;)
{
if (it2->first == m)
it2 = si->AddModes.erase(it2);
@@ -697,7 +639,7 @@ void ModeManager::StackerDel(Mode *m)
++it2;
}
- for (std::list<std::pair<Mode *, Anope::string> >::iterator it2 = si->DelModes.begin(), it2_end = si->DelModes.end(); it2 != it2_end;)
+ for (StackerInfo::ModeList::iterator it2 = si->DelModes.begin(), it2_end = si->DelModes.end(); it2 != it2_end;)
{
if (it2->first == m)
it2 = si->DelModes.erase(it2);
@@ -711,7 +653,7 @@ void ModeManager::StackerDel(Mode *m)
StackerInfo *si = it->second;
++it;
- for (std::list<std::pair<Mode *, Anope::string> >::iterator it2 = si->AddModes.begin(), it2_end = si->AddModes.end(); it2 != it2_end;)
+ for (StackerInfo::ModeList::iterator it2 = si->AddModes.begin(), it2_end = si->AddModes.end(); it2 != it2_end;)
{
if (it2->first == m)
it2 = si->AddModes.erase(it2);
@@ -719,7 +661,7 @@ void ModeManager::StackerDel(Mode *m)
++it2;
}
- for (std::list<std::pair<Mode *, Anope::string> >::iterator it2 = si->DelModes.begin(), it2_end = si->DelModes.end(); it2 != it2_end;)
+ for (StackerInfo::ModeList::iterator it2 = si->DelModes.begin(), it2_end = si->DelModes.end(); it2 != it2_end;)
{
if (it2->first == m)
it2 = si->DelModes.erase(it2);
diff --git a/src/protocol.cpp b/src/protocol.cpp
index 7a167582a..882ef6c5c 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -113,6 +113,61 @@ void IRCDProto::SendSVSKill(const MessageSource &source, User *user, const Anope
Uplink::Send(source, "KILL", user->GetUID(), buf);
}
+static auto BuildModeChange(const ModeManager::Change &change)
+{
+ std::list<std::pair<Anope::string, std::vector<Anope::string>>> modes;
+
+ Anope::string modebuf;
+ size_t modecount = 0;
+ std::vector<Anope::string> parambuf;
+ size_t paramlen;
+
+ auto adding = true;
+ for (const auto &[mode, info] : change)
+ {
+ const auto reached_max_line = IRCD->MaxLine && modebuf.length() + paramlen > IRCD->MaxLine - 100; // Leave room for command, channel, etc
+ const auto reached_max_modes = IRCD->MaxModes && ++modecount > IRCD->MaxModes;
+ if (reached_max_modes || reached_max_line)
+ {
+ modes.push_back({modebuf, parambuf});
+
+ modebuf.clear();
+ modecount = 0;
+
+ parambuf.clear();
+ paramlen = 0;
+ }
+
+ // Push the mode.
+ const auto direction = info.first;
+ if (modebuf.empty() || adding != direction)
+ {
+ adding = direction;
+ modebuf += (adding ? '+' : '-');
+ }
+ modebuf += mode->mchar;
+
+ // If it has a value push that too.
+ const auto &data = info.second;
+ if (!data.value.empty())
+ {
+ parambuf.push_back(data.value);
+ paramlen += data.value.length() + 1;
+ }
+ }
+
+ if (!modebuf.empty())
+ modes.push_back({modebuf, parambuf});
+
+ return modes;
+}
+
+void IRCDProto::SendMode(const MessageSource &source, Channel *chan, const ModeManager::Change &change)
+{
+ for (const auto &[modes, params] : BuildModeChange(change))
+ IRCD->SendModeInternal(source, chan, modes, params);
+}
+
void IRCDProto::SendModeInternal(const MessageSource &source, Channel *chan, const Anope::string &modes, const std::vector<Anope::string> &values)
{
auto params = values;
@@ -120,6 +175,12 @@ void IRCDProto::SendModeInternal(const MessageSource &source, Channel *chan, con
Uplink::SendInternal({}, source, "MODE", params);
}
+void IRCDProto::SendMode(const MessageSource &source, User *dest, const ModeManager::Change &change)
+{
+ for (const auto &[modes, params] : BuildModeChange(change))
+ IRCD->SendModeInternal(source, dest, modes, params);
+}
+
void IRCDProto::SendModeInternal(const MessageSource &source, User *dest, const Anope::string &modes, const std::vector<Anope::string> &values)
{
auto params = values;
diff --git a/src/servers.cpp b/src/servers.cpp
index 9f98aeb07..a9962f9ab 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -117,12 +117,12 @@ Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Ano
IRCD->SendJoin(uc->user, c, &uc->status);
}
- for (const auto &[mode, value] : c->GetModes())
+ for (const auto &[mode, data] : c->GetModes())
{
ChannelMode *cm = ModeManager::FindChannelModeByName(mode);
if (!cm || cm->type != MODE_LIST)
continue;
- ModeManager::StackerAdd(c->WhoSends(), c, cm, true, value);
+ ModeManager::StackerAdd(c->WhoSends(), c, cm, true, data);
}
if (!c->topic.empty() && !c->topic_setter.empty())
diff --git a/src/users.cpp b/src/users.cpp
index 3d6034691..63a524488 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -548,12 +548,12 @@ bool User::HasMode(const Anope::string &mname) const
return this->modes.count(mname);
}
-void User::SetModeInternal(const MessageSource &source, UserMode *um, const Anope::string &param)
+void User::SetModeInternal(const MessageSource &source, UserMode *um, const ModeData &data)
{
if (!um)
return;
- this->modes[um->name] = param;
+ this->modes[um->name] = data;
if (um->name == "OPER")
{
@@ -609,18 +609,18 @@ void User::RemoveModeInternal(const MessageSource &source, UserMode *um)
FOREACH_MOD(OnUserModeUnset, (source, this, um->name));
}
-void User::SetMode(BotInfo *bi, UserMode *um, const Anope::string &param)
+void User::SetMode(BotInfo *bi, UserMode *um, const ModeData &data)
{
if (!um || HasMode(um->name))
return;
- ModeManager::StackerAdd(bi, this, um, true, param);
- SetModeInternal(bi, um, param);
+ ModeManager::StackerAdd(bi, this, um, true, data);
+ SetModeInternal(bi, um, data);
}
-void User::SetMode(BotInfo *bi, const Anope::string &uname, const Anope::string &param)
+void User::SetMode(BotInfo *bi, const Anope::string &uname, const ModeData &data)
{
- SetMode(bi, ModeManager::FindUserModeByName(uname), param);
+ SetMode(bi, ModeManager::FindUserModeByName(uname), data);
}
void User::RemoveMode(BotInfo *bi, UserMode *um, const Anope::string &param)
@@ -730,7 +730,7 @@ Anope::string User::GetModes() const
{
Anope::string m, params;
- for (const auto &[mode, value] : this->modes)
+ for (const auto &[mode, data] : this->modes)
{
UserMode *um = ModeManager::FindUserModeByName(mode);
if (um == NULL)
@@ -738,8 +738,8 @@ Anope::string User::GetModes() const
m += um->mchar;
- if (!value.empty())
- params += " " + value;
+ if (!data.value.empty())
+ params += " " + data.value;
}
return m + params;