- if (!strcasecmp(user->server,Srv->GetServerName().c_str()))
- {
- // give them a lock flag
- Srv->SendOpers(std::string(user->nick)+" used NICKLOCK to change and hold "+std::string(parameters[0])+" to "+parameters[1]);
- Srv->ChangeUserNick(source,std::string(parameters[1]));
- // only attempt to set their lockflag after we know the change succeeded
- userrec* s2 = Srv->FindNick(std::string(parameters[1]));
- if (s2)
- s2->Extend("nick_locked",dummy);
- }
- else
+ user->WriteNumeric(946, "%s %s :This user's nickname is already locked.",user->nick.c_str(),target->nick.c_str());
+ return CMD_FAILURE;
+ }
+
+ // check nick is valid
+ if (IS_LOCAL(user) && !ServerInstance->IsNick(parameters[1].c_str(), ServerInstance->Config->Limits.NickMax))
+ {
+ return CMD_FAILURE;
+ }
+
+ // let others know
+ ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick)+" used NICKLOCK to change and hold "+parameters[0]+" to "+parameters[1]);
+
+ if (!target->ForceNickChange(parameters[1].c_str()))
+ {
+ // ugh, nickchange failed for some reason -- possibly existing nick?
+ if (!target->ForceNickChange(target->uuid.c_str()))