Channel::Channel(const std::string &cname, time_t ts)
: name(cname), age(ts), topicset(0)
{
- if (!ServerInstance->chanlist->insert(std::make_pair(cname, this)).second)
+ if (!ServerInstance->chanlist.insert(std::make_pair(cname, this)).second)
throw CoreException("Cannot create duplicate channel " + cname);
}
void Channel::SetMode(ModeHandler* mh, bool on)
{
- modes[mh->GetModeChar() - 65] = on;
-}
-
-void Channel::SetModeParam(ModeHandler* mh, const std::string& parameter)
-{
- char mode = mh->GetModeChar();
- if (parameter.empty())
- {
- custom_mode_params.erase(mode);
- modes[mode-65] = false;
- }
- else
- {
- custom_mode_params[mode] = parameter;
- modes[mode-65] = true;
- }
-}
-
-std::string Channel::GetModeParameter(ModeHandler* mode)
-{
- CustomModeList::iterator n = custom_mode_params.find(mode->GetModeChar());
- if (n != custom_mode_params.end())
- return n->second;
- return "";
+ modes[mh->GetId()] = on;
}
void Channel::SetTopic(User* u, const std::string& ntopic)
if (res == MOD_RES_DENY)
return;
- chan_hash::iterator iter = ServerInstance->chanlist->find(this->name);
+ chan_hash::iterator iter = ServerInstance->chanlist.find(this->name);
/* kill the record */
- if (iter != ServerInstance->chanlist->end())
+ if (iter != ServerInstance->chanlist.end())
{
FOREACH_MOD(OnChannelDelete, (this));
- ServerInstance->chanlist->erase(iter);
+ ServerInstance->chanlist.erase(iter);
}
ClearInvites();
ListModeBase* banlm = static_cast<ListModeBase*>(*ban);
const ListModeBase::ModeList* bans = banlm->GetList(this);
if (bans)
-
{
for (ListModeBase::ModeList::const_iterator it = bans->begin(); it != bans->end(); ++it)
{
/* This was still iterating up to 190, Channel::modes is only 64 elements -- Om */
for(int n = 0; n < 64; n++)
{
- if(this->modes[n])
+ ModeHandler* mh = ServerInstance->Modes->FindMode(n + 65, MODETYPE_CHANNEL);
+ if (mh && IsModeSet(mh))
{
scratch.push_back(n + 65);
- ModeHandler* mh = ServerInstance->Modes->FindMode(n+'A', MODETYPE_CHANNEL);
- if (!mh)
+
+ ParamModeBase* pm = mh->IsParameterMode();
+ if (!pm)
continue;
if (n == 'k' - 65 && !showkey)
}
else
{
- const std::string param = this->GetModeParameter(mh);
- if (!param.empty())
- {
- sparam += ' ';
- sparam += param;
- }
+ sparam += ' ';
+ pm->GetParameter(this, sparam);
}
}
}
std::string nick;
for (UserMembIter i = userlist.begin(); i != userlist.end(); ++i)
{
- if (i->first->quitting)
- continue;
if ((!has_user) && (i->first->IsModeSet(invisiblemode)) && (!has_privs))
{
/*
continue;
}
- prefixlist = this->GetPrefixChar(i->first);
+ Membership* memb = i->second;
+
+ prefixlist.clear();
+ prefixlist.push_back(memb->GetPrefixChar());
nick = i->first->nick;
- FOREACH_MOD(OnNamesListItem, (user, i->second, prefixlist, nick));
+ FOREACH_MOD(OnNamesListItem, (user, memb, prefixlist, nick));
/* Nick was nuked, a module wants us to skip it */
if (nick.empty())
* % for halfop etc. If the user has several modes set, the highest mode
* the user has must be returned.
*/
-const char* Channel::GetPrefixChar(User *user)
+char Membership::GetPrefixChar() const
{
- static char pf[2] = {0, 0};
- *pf = 0;
+ char pf = 0;
unsigned int bestrank = 0;
- UserMembIter m = userlist.find(user);
- if (m != userlist.end())
+ for (std::string::const_iterator i = modes.begin(); i != modes.end(); ++i)
{
- for(unsigned int i=0; i < m->second->modes.length(); i++)
+ PrefixMode* mh = ServerInstance->Modes->FindPrefixMode(*i);
+ if (mh && mh->GetPrefixRank() > bestrank && mh->GetPrefix())
{
- PrefixMode* mh = ServerInstance->Modes->FindPrefixMode(m->second->modes[i]);
- if (mh && mh->GetPrefixRank() > bestrank && mh->GetPrefix())
- {
- bestrank = mh->GetPrefixRank();
- pf[0] = mh->GetPrefix();
- }
+ bestrank = mh->GetPrefixRank();
+ pf = mh->GetPrefix();
}
}
return pf;
return rv;
}
-const char* Channel::GetAllPrefixChars(User* user)
+const char* Membership::GetAllPrefixChars() const
{
static char prefix[64];
int ctr = 0;
- UserMembIter m = userlist.find(user);
- if (m != userlist.end())
+ for (std::string::const_iterator i = modes.begin(); i != modes.end(); ++i)
{
- for(unsigned int i=0; i < m->second->modes.length(); i++)
- {
- PrefixMode* mh = ServerInstance->Modes->FindPrefixMode(m->second->modes[i]);
- if (mh && mh->GetPrefix())
- prefix[ctr++] = mh->GetPrefix();
- }
+ PrefixMode* mh = ServerInstance->Modes->FindPrefixMode(*i);
+ if (mh && mh->GetPrefix())
+ prefix[ctr++] = mh->GetPrefix();
}
prefix[ctr] = 0;