return MODEACTION_DENY;
}
- if (mh->GetTranslateType() == TR_NICK && !ServerInstance->FindNick(parameter))
+ if (mh->GetTranslateType() == TR_NICK)
{
- user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), parameter.c_str());
- return MODEACTION_DENY;
+ User* prefixtarget;
+ if (IS_LOCAL(user))
+ prefixtarget = ServerInstance->FindNickOnly(parameter);
+ else
+ prefixtarget = ServerInstance->FindNick(parameter);
+
+ if (!prefixtarget)
+ {
+ user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), parameter.c_str());
+ return MODEACTION_DENY;
+ }
}
if (mh->GetPrefixRank() && chan)
void ModeParser::Process(const std::vector<std::string>& parameters, User *user, bool merge)
{
- std::string target = parameters[0];
+ const std::string& target = parameters[0];
Channel* targetchannel = ServerInstance->FindChan(target);
- User* targetuser = ServerInstance->FindNick(target);
+ User* targetuser = NULL;
+ if (!targetchannel)
+ {
+ if (IS_LOCAL(user))
+ targetuser = ServerInstance->FindNickOnly(target);
+ else
+ targetuser = ServerInstance->FindNick(target);
+ }
ModeType type = targetchannel ? MODETYPE_CHANNEL : MODETYPE_USER;
LastParse.clear();
{
parameter = parameters[param_at++];
/* Make sure the user isn't trying to slip in an invalid parameter */
- if ((parameter.find(':') == 0) || (parameter.rfind(' ') != std::string::npos))
+ if ((parameter.empty()) || (parameter.find(':') == 0) || (parameter.rfind(' ') != std::string::npos))
continue;
if (merge && targetchannel && targetchannel->IsModeSet(modechar) && !mh->IsListMode())
{
mw->GetModeType() == MODETYPE_USER ? mask = MASK_USER : mask = MASK_CHANNEL;
pos = (mw->GetModeChar()-65) | mask;
- ModeWatchIter a = find(modewatchers[pos].begin(),modewatchers[pos].end(),mw);
+ ModeWatchIter a = std::find(modewatchers[pos].begin(),modewatchers[pos].end(),mw);
if (a == modewatchers[pos].end())
{