}
else {
/* Local client setting NICK the first time */
- strcpy(cli_name(sptr), nick);
+ if(!force)
+ strcpy(cli_name(sptr), nick);
+ else {
+ /* use a "temponary" nick here (we'll switch later) */
+ char tmpnick[NICKLEN + 2];
+ int tmpnickend;
+ strcpy(tmpnick, nick);
+ /* we need at least 10 characters */
+ if (strlen(tmpnick) > IRCD_MIN(NICKLEN, feature_int(FEAT_NICKLEN)) - 10)
+ tmpnick[IRCD_MIN(NICKLEN, feature_int(FEAT_NICKLEN))-10] = '\0';
+ tmpnickend = strlen(tmpnick);
+
+ do { /* get a non-used nick... */
+ sprintf(tmpnick + tmpnickend, "[rz%d]", ircrandom() % 10000);
+ } while(FindClient(tmpnick));
+ strcpy(cli_name(sptr), tmpnick);
+ }
hAddClient(sptr);
return auth_set_nick(cli_auth(sptr), nick);
}