ModeAction ModeChannelKey::OnModeChange(User* source, User*, Channel* channel, std::string ¶meter, bool adding, bool servermode)
{
- if ((channel->modes[CM_KEY] != adding) || (!IS_LOCAL(source)))
+ if ((channel->IsModeSet('k') != adding) || (!IS_LOCAL(source)))
{
- if (((channel->modes[CM_KEY]) && (strcasecmp(parameter.c_str(),channel->key))) && (IS_LOCAL(source)))
+ if (((channel->IsModeSet('k')) && (parameter != channel->key)) && (IS_LOCAL(source)))
{
/* Key is currently set and the correct key wasnt given */
return MODEACTION_DENY;
}
- else if ((!channel->modes[CM_KEY]) || ((adding) && (!IS_LOCAL(source))))
+ else if ((!channel->IsModeSet('k')) || ((adding) && (!IS_LOCAL(source))))
{
/* Key isnt currently set */
if ((parameter.length()) && (parameter.rfind(' ') == std::string::npos))
{
- strlcpy(channel->key,parameter.c_str(),32);
- channel->modes[CM_KEY] = adding;
+ channel->key.assign(parameter, 0, 32);
+ channel->SetMode('k', adding);
parameter = channel->key;
return MODEACTION_ALLOW;
}
else
return MODEACTION_DENY;
}
- else if (((channel->modes[CM_KEY]) && (!strcasecmp(parameter.c_str(),channel->key))) || ((!adding) && (!IS_LOCAL(source))))
+ else if (((channel->IsModeSet('k')) && (parameter == channel->key)) || ((!adding) && (!IS_LOCAL(source))))
{
/* Key is currently set, and correct key was given */
- *channel->key = 0;
- channel->modes[CM_KEY] = adding;
+ channel->key.clear();
+ channel->SetMode('k', adding);
return MODEACTION_ALLOW;
}
return MODEACTION_DENY;