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)
/* 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);
}
}
}
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;