Find account handler(src->handlers->account), find case PACKET_REQUEST, and paste this code fragment(name validation):
case PACKET_REQUEST: // Check if a character exists
{
std::string username = reader.GetEndString();
std::transform(username.begin(), username.end(), username.begin(), static_cast<int(*)(int)>(std::tolower));
reply.SetID(PACKET_ACCOUNT, PACKET_REPLY);
if (!Player::ValidName(username))
{
reply.AddShort(PACKET_ACCOUNT_NOT_APPROVED);
reply.AddString("NO");
}
else if (Player::Exists(username))
{
reply.AddShort(PACKET_ACCOUNT_EXISTS);
reply.AddString("NO");
}
else
{
reply.AddShort(PACKET_ACCOUNT_CONTINUE);
reply.AddString("OK");
}
CLIENT_SEND(reply);
}