From 33bb47c623d1c605a5a131ef882feb6df42570b7 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Sun, 31 Mar 2024 22:23:59 +0100 Subject: Don't bother trying to do removenickfromchannel() after a PART or a KICK if we just did removechannel() because the PARTing/KICKed nick was ours. --- message.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'message.c') diff --git a/message.c b/message.c index 9d85f63..07292be 100644 --- a/message.c +++ b/message.c @@ -240,16 +240,14 @@ int processservermessage(SSL *server_ssl, char *str, struct client *clients, int // Just get the nick for comparison extractnickfromprefix(prefixcopy, 1); if ((strlen(prefixcopy) == strlen(ircdstate->ircnick)) && (strncmp(prefixcopy, ircdstate->ircnick, strlen(tokens[0])) == 0)) { - debugprint(DEBUG_FULL, "Server PART: nick is ours ('%s' vs '%s').\n", prefixcopy, ircdstate->ircnick); + debugprint(DEBUG_FULL, "Server PART: nick is ours ('%s' vs '%s'), removing channel.\n", prefixcopy, ircdstate->ircnick); removechannel(channels, ircdstate->maxchannelcount, tokens[2]); } else { - debugprint(DEBUG_FULL, "Server PART: nick is NOT ours ('%s' vs '%s').\n", prefixcopy, ircdstate->ircnick); - } - - // Remove the PARTing nick from our local channel struct - // TODO - don't bother with this if we did removechannel() above? - if (!removenickfromchannel(tokens[0], tokens[2], channels, ircdstate->maxchannelcount)) { - debugprint(DEBUG_CRIT, "Failed to remove nick from channel struct.\n"); + debugprint(DEBUG_FULL, "Server PART: nick is NOT ours ('%s' vs '%s'), removing nick from channel.\n", prefixcopy, ircdstate->ircnick); + // Remove the PARTing nick from our local channel struct + if (!removenickfromchannel(tokens[0], tokens[2], channels, ircdstate->maxchannelcount)) { + debugprint(DEBUG_CRIT, "Failed to remove nick from channel struct.\n"); + } } // And then send to all clients @@ -276,17 +274,15 @@ int processservermessage(SSL *server_ssl, char *str, struct client *clients, int // If the user being KICKed is us, then we must have left a channel, so remove it from our local channel array. // (If it's not us, then it's another user being KICKed from a channel, so just pass straight through to letting all our clients know.) if ((strlen(tokens[3]) == strlen(ircdstate->ircnick)) && (strncmp(tokens[3], ircdstate->ircnick, strlen(tokens[3])) == 0)) { - debugprint(DEBUG_FULL, "Server KICK: nick is ours ('%s' vs '%s').\n", tokens[3], ircdstate->ircnick); + debugprint(DEBUG_FULL, "Server KICK: nick is ours ('%s' vs '%s'), removing channel.\n", tokens[3], ircdstate->ircnick); removechannel(channels, ircdstate->maxchannelcount, tokens[2]); } else { - debugprint(DEBUG_FULL, "Server KICK: nick is NOT ours ('%s' vs '%s').\n", tokens[3], ircdstate->ircnick); - } - - // Remove the KICKed nick from our local channel struct - // TODO - removenickfromchannel() first argument expects ":nick!user@host" but we're passing "nick" here - // TODO - don't bother with this if we did removechannel() above? - if (!removenickfromchannel(tokens[3], tokens[2], channels, ircdstate->maxchannelcount)) { - debugprint(DEBUG_CRIT, "Server KICK: Failed to remove nick from channel struct.\n"); + debugprint(DEBUG_FULL, "Server KICK: nick is NOT ours ('%s' vs '%s'), removing nick from channel.\n", tokens[3], ircdstate->ircnick); + // Remove the KICKed nick from our local channel struct + // TODO - removenickfromchannel() first argument expects ":nick!user@host" but we're passing "nick" here + if (!removenickfromchannel(tokens[3], tokens[2], channels, ircdstate->maxchannelcount)) { + debugprint(DEBUG_CRIT, "Server KICK: Failed to remove nick from channel struct.\n"); + } } // And then send to all clients -- cgit v1.2.3