From aae213da7118a8ab2c72abc594eeebc8da008b68 Mon Sep 17 00:00:00 2001 From: Test_User Date: Wed, 9 Aug 2023 01:38:34 -0400 Subject: Fix remove_user --- general_network.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/general_network.c b/general_network.c index 861fadc..86b60ca 100644 --- a/general_network.c +++ b/general_network.c @@ -140,14 +140,15 @@ int PRIVMSG(struct string source, struct string target, struct string message) { } int remove_user(struct string uid, struct string reason) { // If disconnecting the local client, set client_connected = 0 *before* calling this - struct user_info *info = remove_table_index(&user_list, uid); + struct user_info *info = get_table_index(user_list, uid); if (!info) return 1; + int send_client = client_connected; for (uint64_t i = 0; i < channel_list.len; i++) { // TODO: Use channel list attached to the user (doesn't exist yet) struct channel_info *chan_info = channel_list.array[i].ptr; if (has_table_index(chan_info->user_list, uid)) { - if (client_connected && has_table_index(chan_info->user_list, STRING("1HC000001"))) { + if (send_client && has_table_index(chan_info->user_list, STRING("1HC000001"))) { SENDCLIENT(STRING(":")); SENDCLIENT(info->nick); SENDCLIENT(STRING("!")); @@ -161,12 +162,16 @@ int remove_user(struct string uid, struct string reason) { // If disconnecting t } else { SENDCLIENT(STRING(" QUIT\r\n")); } + + send_client = 0; } remove_table_index(&(chan_info->user_list), uid); } } + remove_table_index(&user_list, uid); + free(info->server.data); free(info->nick.data); free(info->opertype.data); -- cgit v1.2.3