aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-07-08 23:31:01 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2010-07-08 23:31:01 +0100
commit9a9b520df6044cfc034f9736fb97660a46e879b9 (patch)
tree16f45502a8b8d7e2c30c33b744605e70250f1c59
parent69b896b5967e5d13b1c60c68cb3bc7d4a0d5cd06 (diff)
Allow nick changes if they're only different in capitalisation, fixed
faulty responses in the NICK command, and fixing crash bug in nick changes before finishing login.
-rw-r--r--irc_commands.c11
-rw-r--r--irc_user.c4
-rw-r--r--root_commands.c4
3 files changed, 12 insertions, 7 deletions
diff --git a/irc_commands.c b/irc_commands.c
index 197a7e6e..0573601d 100644
--- a/irc_commands.c
+++ b/irc_commands.c
@@ -71,16 +71,18 @@ static void irc_cmd_user( irc_t *irc, char **cmd )
static void irc_cmd_nick( irc_t *irc, char **cmd )
{
- if( irc_user_by_name( irc, cmd[1] ) )
+ irc_user_t *iu;
+
+ if( ( iu = irc_user_by_name( irc, cmd[1] ) ) && iu != irc->user )
{
- irc_send_num( irc, 433, ":This nick is already in use" );
+ irc_send_num( irc, 433, "%s :This nick is already in use", cmd[1] );
}
else if( !nick_ok( cmd[1] ) )
{
/* [SH] Invalid characters. */
- irc_send_num( irc, 432, ":This nick contains invalid characters" );
+ irc_send_num( irc, 432, "%s :This nick contains invalid characters", cmd[1] );
}
- else if( irc->user->nick )
+ else if( irc->status & USTATUS_LOGGED_IN )
{
if( irc->status & USTATUS_IDENTIFIED )
{
@@ -97,6 +99,7 @@ static void irc_cmd_nick( irc_t *irc, char **cmd )
}
else
{
+ g_free( irc->user->nick );
irc->user->nick = g_strdup( cmd[1] );
irc_check_login( irc );
diff --git a/irc_user.c b/irc_user.c
index cb7ea1e7..7d29cae0 100644
--- a/irc_user.c
+++ b/irc_user.c
@@ -119,11 +119,13 @@ irc_user_t *irc_user_by_name( irc_t *irc, const char *nick )
int irc_user_set_nick( irc_user_t *iu, const char *new )
{
irc_t *irc = iu->irc;
+ irc_user_t *new_iu;
char key[strlen(new)+1];
GSList *cl;
strcpy( key, new );
- if( iu == NULL || !nick_lc( key ) || irc_user_by_name( irc, new ) )
+ if( iu == NULL || !nick_lc( key ) ||
+ ( ( new_iu = irc_user_by_name( irc, new ) ) && new_iu != iu ) )
return 0;
for( cl = irc->channels; cl; cl = cl->next )
diff --git a/root_commands.c b/root_commands.c
index 62fe1e79..5c5ead7b 100644
--- a/root_commands.c
+++ b/root_commands.c
@@ -661,7 +661,7 @@ static void cmd_info( irc_t *irc, char **cmd )
static void cmd_rename( irc_t *irc, char **cmd )
{
- irc_user_t *iu;
+ irc_user_t *iu, *old;
iu = irc_user_by_name( irc, cmd[1] );
@@ -677,7 +677,7 @@ static void cmd_rename( irc_t *irc, char **cmd )
{
irc_usermsg( irc, "Nick `%s' is invalid", cmd[2] );
}
- else if( irc_user_by_name( irc, cmd[2] ) )
+ else if( ( old = irc_user_by_name( irc, cmd[2] ) ) && old != iu )
{
irc_usermsg( irc, "Nick `%s' already exists", cmd[2] );
}