Fix CHANGE_NICK_ON_KILL feature

Remove the 'resend_only' flag option to fudge_nickname().  The only caller passing it was the CHANGE_NICK_ON_KILL
feature, and in that case it was the wrong thing too (and stopped that function from working at all).

Some other minor cleanups in fudge_nickname() while we're there.
This commit is contained in:
Kevin Easton
2017-07-15 23:29:14 +10:00
parent b481ed1e6e
commit cd9c358eed
6 changed files with 15 additions and 24 deletions

View File

@@ -1,5 +1,7 @@
[Changes 1.2.2] [Changes 1.2.2]
* Fix CHANGE_NICK_ON_KILL feature. (caf)
* Improve error handling in /READLOG. (caf) * Improve error handling in /READLOG. (caf)
* Fix memory leak in /QUEUE -FLUSH. (caf) * Fix memory leak in /QUEUE -FLUSH. (caf)

View File

@@ -510,7 +510,7 @@ extern Function_ptr *global;
#define set_server_redirect (*(void (*)(int , const char *))global[SET_SERVER_REDIRECT]) #define set_server_redirect (*(void (*)(int , const char *))global[SET_SERVER_REDIRECT])
#define get_server_redirect (*(char *(*)(int ))global[GET_SERVER_REDIRECT]) #define get_server_redirect (*(char *(*)(int ))global[GET_SERVER_REDIRECT])
#define check_server_redirect (*(int (*)(char *))global[CHECK_SERVER_REDIRECT]) #define check_server_redirect (*(int (*)(char *))global[CHECK_SERVER_REDIRECT])
#define fudge_nickname (*(void (*)(int , int ))global[FUDGE_NICKNAME]) #define fudge_nickname (*(void (*)(int))global[FUDGE_NICKNAME])
#define reset_nickname (*(void (*)(int ))global[RESET_NICKNAME]) #define reset_nickname (*(void (*)(int ))global[RESET_NICKNAME])
#define set_server_cookie (*(void (*)(int , char *))global[SET_SERVER_COOKIE]) #define set_server_cookie (*(void (*)(int , char *))global[SET_SERVER_COOKIE])

View File

@@ -284,7 +284,7 @@ extern SGroup *server_group_list;
void change_server_nickname (int, char *); void change_server_nickname (int, char *);
void register_server (int, char *); void register_server (int, char *);
void BX_fudge_nickname (int, int); void BX_fudge_nickname (int);
char *BX_get_pending_nickname (int); char *BX_get_pending_nickname (int);
void accept_server_nickname (int, char *); void accept_server_nickname (int, char *);
void BX_reset_nickname (int); void BX_reset_nickname (int);

View File

@@ -503,7 +503,7 @@ char *t = NULL;
if (nick && (t = get_string_var(ALTNICK_VAR))) if (nick && (t = get_string_var(ALTNICK_VAR)))
{ {
if (!my_stricmp(t, nick)) if (!my_stricmp(t, nick))
fudge_nickname(server, 0); fudge_nickname(server);
else else
change_server_nickname(server, t); change_server_nickname(server, t);
} else } else
@@ -513,7 +513,7 @@ char *t = NULL;
else else
reset_nickname(from_server); reset_nickname(from_server);
#endif #endif
fudge_nickname(server, 0); fudge_nickname(server);
} }
/* /*
@@ -1149,7 +1149,6 @@ void numbered_command(char *from, int comm, char **ArgList)
* Sometimes the server doesn't catch the USER line, so * Sometimes the server doesn't catch the USER line, so
* here we send a simplified version again -lynx * here we send a simplified version again -lynx
*/ */
/* fudge_nickname(from_server, 1);*/
register_server(from_server, NULL); register_server(from_server, NULL);
PasteArgs(ArgList, 0); PasteArgs(ArgList, 0);

View File

@@ -1302,7 +1302,7 @@ static void p_kill(char *from, char **ArgList)
ArgList[1] ? ArgList[1] : "(No Reason)")) ArgList[1] ? ArgList[1] : "(No Reason)"))
put_it("%s", convert_output_format(fget_string_var(FORMAT_KILL_FSET), "%s %s %s", update_clock(GET_TIME), from, ArgList[1]? ArgList[1] : "You have been Killed")); put_it("%s", convert_output_format(fget_string_var(FORMAT_KILL_FSET), "%s %s %s", update_clock(GET_TIME), from, ArgList[1]? ArgList[1] : "You have been Killed"));
if (get_int_var(CHANGE_NICK_ON_KILL_VAR)) if (get_int_var(CHANGE_NICK_ON_KILL_VAR))
fudge_nickname(from_server, 1); fudge_nickname(from_server);
if (get_int_var(AUTO_RECONNECT_VAR)) if (get_int_var(AUTO_RECONNECT_VAR))
servercmd (NULL, sc, empty_string, NULL); servercmd (NULL, sc, empty_string, NULL);
logmsg(LOG_KILL, from, 0, "%s", ArgList[1]?ArgList[1]:"(No Reason)"); logmsg(LOG_KILL, from, 0, "%s", ArgList[1]?ArgList[1]:"(No Reason)");

View File

@@ -2798,8 +2798,8 @@ void change_server_nickname (int ssn_index, char *nick)
reset_nickname(ssn_index); reset_nickname(ssn_index);
} }
if (server_list[ssn_index].s_nickname) if (s->s_nickname && s->write > -1)
my_send_to_server(ssn_index, "NICK %s", server_list[ssn_index].s_nickname); my_send_to_server(ssn_index, "NICK %s", s->s_nickname);
} }
void accept_server_nickname (int ssn_index, char *nick) void accept_server_nickname (int ssn_index, char *nick)
@@ -2847,15 +2847,11 @@ int is_orignick_pending (int servnum)
* out of guesses, and if it ever gets to that point, it will do the * out of guesses, and if it ever gets to that point, it will do the
* manually-ask-you-for-a-new-nickname thing. * manually-ask-you-for-a-new-nickname thing.
*/ */
void BX_fudge_nickname (int servnum, int resend_only) void BX_fudge_nickname(int servnum)
{ {
char l_nickname[BIG_BUFFER_SIZE + 1]; char l_nickname[NICKNAME_LEN];
Server *s = &server_list[from_server]; Server *s = &server_list[from_server];
if (resend_only)
{
change_server_nickname(servnum, NULL);
return;
}
/* /*
* If we got here because the user did a /NICK command, and * If we got here because the user did a /NICK command, and
* the nick they chose doesnt exist, then we just dont do anything, * the nick they chose doesnt exist, then we just dont do anything,
@@ -2867,7 +2863,7 @@ void BX_fudge_nickname (int servnum, int resend_only)
return; return;
} }
if ((s->orignick_pending) && (!s->nickname_pending) && (!resend_only)) if (s->orignick_pending)
{ {
new_free(&s->s_nickname); new_free(&s->s_nickname);
say("orignick feature failed, sorry"); say("orignick feature failed, sorry");
@@ -2914,14 +2910,8 @@ void BX_fudge_nickname (int servnum, int resend_only)
else else
{ {
char tmp = l_nickname[8]; char tmp = l_nickname[8];
l_nickname[8] = l_nickname[7];
l_nickname[7] = l_nickname[6]; memmove(&l_nickname[1], &l_nickname[0], 8);
l_nickname[6] = l_nickname[5];
l_nickname[5] = l_nickname[4];
l_nickname[4] = l_nickname[3];
l_nickname[3] = l_nickname[2];
l_nickname[2] = l_nickname[1];
l_nickname[1] = l_nickname[0];
l_nickname[0] = tmp; l_nickname[0] = tmp;
} }
if (!strcmp(l_nickname, "_________")) if (!strcmp(l_nickname, "_________"))