]> PatchyGit - patchyircd.git/commitdiff
fix sending NICK message twice
authorEgor <egor@patchysicp.xyz>
Thu, 26 May 2022 21:41:14 +0000 (00:41 +0300)
committerEgor <egor@patchysicp.xyz>
Thu, 26 May 2022 21:50:06 +0000 (00:50 +0300)
irc.c
net.c

diff --git a/irc.c b/irc.c
index a099a7c..5176a98 100644 (file)
--- a/irc.c
+++ b/irc.c
@@ -66,19 +66,12 @@ int get_cookie() {
 }
 void sendbuf_visible(struct client_data *client) {
        int cookie = get_cookie();
-       struct trie_find *f1 = NULL, *f2 = NULL;
-       if (trie_findfirst(&f1, &client->channels) == 1)
+       struct trie_find *f = NULL;
+       if (trie_findfirst(&f, &client->channels) == 1)
                do {
-                       struct channel *chan = f1->n->value;
-                       if (trie_findfirst(&f2, &chan->members) == 1)
-                               do {
-                                       struct client_data *cl = f2->n->value;
-                                       if (cl->cookie != cookie) {
-                                               sendbuf(cl);
-                                               cl->cookie = cookie;
-                                       }
-                               } while (trie_findnext(&f2) == 1);
-               } while (trie_findnext(&f1) == 1);
+                       struct channel *chan = f->n->value;
+                       sendbuf_list_sans_self(client, &chan->members, cookie);
+               } while (trie_findnext(&f) == 1);
 }
 const char *format_umodes(struct client_data *cl) {
        static char umodes[6] = "";
@@ -488,7 +481,6 @@ int processPacket(struct client_data *client, char *source, char *command, int a
                                        rpl_away(client, cl), sendbuf(client);
                        }
                }
-       // Start GitHub Copilot - this shit actually be copy pasting my code lmao
        } else if(strcmp(command, "QUIT") == 0) {
                msg_quit(client, "Quit: ", args[0] ? args[0] : "");
                sendbuf_visible(client);
diff --git a/net.c b/net.c
index 951b46c..56c87f8 100644 (file)
--- a/net.c
+++ b/net.c
@@ -16,7 +16,6 @@ void killConnection(struct client_data *cl, bool byChoice) {
                        clients[i] = 0;
        if (cl->peername)
                fprintf(stderr, "Client disconnected from Socket: %"PRISocket", IP: %s PORT: %d\n", cl->FD, cl->peername, cl->peerport);
-       // Start GitHub Copilot
        if(!byChoice && cl->nick && cl->username) {
                msg_quit(cl, "", "Has left the building (Forced)");
                sendbuf_visible(cl);
@@ -24,7 +23,6 @@ void killConnection(struct client_data *cl, bool byChoice) {
        // Send error to client informing them that they will be disconnected
        msg_error("Closing Link");
        sendbuf(cl);
-       // End GitHub Copilot
        if (cl->FD != INVALID_SOCKET) {
 #ifdef HAS_TLS
                if (cl->cctx) {