summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTest_User <hax@andrewyu.org>2023-08-09 01:38:34 -0400
committerTest_User <hax@andrewyu.org>2023-08-09 01:38:34 -0400
commitaae213da7118a8ab2c72abc594eeebc8da008b68 (patch)
treea310b25d055abffbdff7c7863962e5d870b8753a
parent0b913b75fd6eee2b7e8a6920de2fc1591ecb8396 (diff)
downloadcoupserv-aae213da7118a8ab2c72abc594eeebc8da008b68.tar.gz
coupserv-aae213da7118a8ab2c72abc594eeebc8da008b68.zip
Fix remove_user
-rw-r--r--general_network.c9
1 files 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);