From 18116562b709204804c3e01b1cbfcc0a6efa8e3d Mon Sep 17 00:00:00 2001 From: jdomingu98 Date: Wed, 24 Apr 2024 10:40:37 +0200 Subject: [PATCH] simplify assignation --- src/commands/KickCommand.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/commands/KickCommand.cpp b/src/commands/KickCommand.cpp index 9933ab4..a72c115 100644 --- a/src/commands/KickCommand.cpp +++ b/src/commands/KickCommand.cpp @@ -28,6 +28,7 @@ void KickCommand::execute(int clientFd) { std::string nickname = user.getNickname(); std::string comment = this->_comment.empty() ? nickname : this->_comment; std::string kickedUser; + size_t pos; for (size_t i = 0; i < this->_channels.size(); i++) { Channel &channel = server.getChannelByName(this->_channels[i]); @@ -38,8 +39,8 @@ void KickCommand::execute(int clientFd) { if (!channel.isOper(nickname)) throw ChanOPrivsNeededException(this->_channels[i]); - kickedUser = this->_channels.size() == this->_users.size() ? this->_users[i].getNickname() - : this->_users[0].getNickname(); + pos = this->_channels.size() == this->_users.size() ? i : 0; + kickedUser = this->_users[pos].getNickname(); if (this->_channels.size() == 1) { for (size_t j = 0; j < this->_users.size(); j++) { kickedUser = this->_users[j].getNickname();