summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/listmode.h15
-rw-r--r--src/listmode.cpp41
2 files changed, 21 insertions, 35 deletions
diff --git a/include/listmode.h b/include/listmode.h
index 40c28f67f..c21f9b93f 100644
--- a/include/listmode.h
+++ b/include/listmode.h
@@ -25,12 +25,13 @@ class ListModeBase : public ModeHandler
public:
/** An item in a listmode's list
*/
- class ListItem
+ struct ListItem
{
- public:
- std::string nick;
+ std::string setter;
std::string mask;
- std::string time;
+ time_t time;
+ ListItem(const std::string& Mask, const std::string& Setter, time_t Time)
+ : setter(Setter), mask(Mask), time(Time) { }
};
/** Items stored in the channel's list
@@ -40,16 +41,16 @@ class ListModeBase : public ModeHandler
private:
/** The number of items a listmode's list may contain
*/
- class ListLimit
+ struct ListLimit
{
- public:
std::string mask;
unsigned int limit;
+ ListLimit(const std::string& Mask, unsigned int Limit) : mask(Mask), limit(Limit) { }
};
/** Max items per channel by name
*/
- typedef std::list<ListLimit> limitlist;
+ typedef std::vector<ListLimit> limitlist;
protected:
/** Numeric to use when outputting the list
diff --git a/src/listmode.cpp b/src/listmode.cpp
index adae627f1..f45f1624f 100644
--- a/src/listmode.cpp
+++ b/src/listmode.cpp
@@ -34,7 +34,7 @@ void ListModeBase::DisplayList(User* user, Channel* channel)
{
for (ModeList::reverse_iterator it = el->rbegin(); it != el->rend(); ++it)
{
- user->WriteNumeric(listnumeric, "%s %s %s %s %s", user->nick.c_str(), channel->name.c_str(), it->mask.c_str(), (it->nick.length() ? it->nick.c_str() : ServerInstance->Config->ServerName.c_str()), it->time.c_str());
+ user->WriteNumeric(listnumeric, "%s %s %s %s %lu", user->nick.c_str(), channel->name.c_str(), it->mask.c_str(), (!it->setter.empty() ? it->setter.c_str() : ServerInstance->Config->ServerName.c_str()), (unsigned long) it->time);
}
}
user->WriteNumeric(endoflistnumeric, "%s %s :%s", user->nick.c_str(), channel->name.c_str(), endofliststring.c_str());
@@ -89,20 +89,14 @@ void ListModeBase::DoRehash()
{
// For each <banlist> tag
ConfigTag* c = i->second;
- ListLimit limit;
- limit.mask = c->getString("chan");
- limit.limit = c->getInt("limit");
+ ListLimit limit(c->getString("chan"), c->getInt("limit"));
if (limit.mask.size() && limit.limit > 0)
chanlimits.push_back(limit);
}
- if (chanlimits.size() == 0)
- {
- ListLimit limit;
- limit.mask = "*";
- limit.limit = 64;
- chanlimits.push_back(limit);
- }
+
+ if (chanlimits.empty())
+ chanlimits.push_back(ListLimit("*", 64));
}
void ListModeBase::DoImplements(Module* m)
@@ -181,12 +175,7 @@ ModeAction ListModeBase::OnModeChange(User* source, User*, Channel* channel, std
if (ValidateParam(source, channel, parameter))
{
// And now add the mask onto the list...
- ListItem e;
- e.mask = parameter;
- e.nick = source->nick;
- e.time = ConvToStr(ServerInstance->Time());
-
- el->push_back(e);
+ el->push_back(ListItem(parameter, source->nick, ServerInstance->Time()));
return MODEACTION_ALLOW;
}
else
@@ -205,10 +194,6 @@ ModeAction ListModeBase::OnModeChange(User* source, User*, Channel* channel, std
if (parameter == it->mask)
{
el->erase(it);
- if (el->size() == 0)
- {
- extItem.unset(channel);
- }
return MODEACTION_ALLOW;
}
}
@@ -224,17 +209,17 @@ ModeAction ListModeBase::OnModeChange(User* source, User*, Channel* channel, std
void ListModeBase::DoSyncChannel(Channel* chan, Module* proto, void* opaque)
{
ModeList* mlist = extItem.get(chan);
+ if (!mlist)
+ return;
+
irc::modestacker modestack(true);
std::vector<std::string> stackresult;
std::vector<TranslateType> types;
types.push_back(TR_TEXT);
- if (mlist)
- {
- for (ModeList::iterator it = mlist->begin(); it != mlist->end(); it++)
- {
- modestack.Push(std::string(1, mode)[0], it->mask);
- }
- }
+
+ for (ModeList::iterator it = mlist->begin(); it != mlist->end(); it++)
+ modestack.Push(mode, it->mask);
+
while (modestack.GetStackedLine(stackresult))
{
types.assign(stackresult.size(), this->GetTranslateType());