merge mode.cpp change switch with letter in case
This commit is contained in:
commit
ae37859552
@ -6,11 +6,12 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/02/11 19:19:30 by apommier #+# #+# */
|
/* Created: 2023/02/11 19:19:30 by apommier #+# #+# */
|
||||||
/* Updated: 2023/03/09 01:49:10 by apommier ### ########.fr */
|
/* Updated: 2023/03/09 02:04:59 by apommier ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "../../../includes/ft_irc.hpp"
|
#include "../../../includes/ft_irc.hpp"
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
void chan_opt_o(fdList &allFds, int userNbr, std::vector<std::string> opt, int chanNbr, bool sign)
|
void chan_opt_o(fdList &allFds, int userNbr, std::vector<std::string> opt, int chanNbr, bool sign)
|
||||||
{
|
{
|
||||||
@ -85,7 +86,8 @@ void chan_opt_b(fdList &allFds, int userNbr, std::vector<std::string> opt, int c
|
|||||||
(void)ban;
|
(void)ban;
|
||||||
if (opt.size() == 3 && sign == true)
|
if (opt.size() == 3 && sign == true)
|
||||||
{
|
{
|
||||||
if (ban.empty())
|
// std::cout << "========ban = "<< ban[0] << std::endl;
|
||||||
|
if (ban.empty() == true)
|
||||||
{
|
{
|
||||||
std::cout << "Nobody was banned on this channel" << std::endl;
|
std::cout << "Nobody was banned on this channel" << std::endl;
|
||||||
return ;
|
return ;
|
||||||
@ -95,7 +97,7 @@ void chan_opt_b(fdList &allFds, int userNbr, std::vector<std::string> opt, int c
|
|||||||
std::cout << ban[i]->userName << std::endl;
|
std::cout << ban[i]->userName << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (opt.size() > 3)
|
if (opt.size() >= 4)
|
||||||
{
|
{
|
||||||
int target_in_client = find_user(allFds, opt[3]);
|
int target_in_client = find_user(allFds, opt[3]);
|
||||||
if (target_in_client == -1)
|
if (target_in_client == -1)
|
||||||
@ -107,8 +109,11 @@ void chan_opt_b(fdList &allFds, int userNbr, std::vector<std::string> opt, int c
|
|||||||
if (sign == true && target_in_ban == -1)
|
if (sign == true && target_in_ban == -1)
|
||||||
allFds.channelList[chanNbr].banList.push_back(&allFds.userData[target_in_client]);
|
allFds.channelList[chanNbr].banList.push_back(&allFds.userData[target_in_client]);
|
||||||
if (sign == false && target_in_ban != -1)
|
if (sign == false && target_in_ban != -1)
|
||||||
|
{
|
||||||
|
std::cout <<"target in bam == "<< allFds.channelList[chanNbr].banList[target_in_ban]->nickname << std::endl;
|
||||||
allFds.channelList[chanNbr].banList.erase(allFds.channelList[chanNbr].banList.begin() + (target_in_ban));
|
allFds.channelList[chanNbr].banList.erase(allFds.channelList[chanNbr].banList.begin() + (target_in_ban));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_chan_opt(fdList &allFds, int userNbr, std::vector<std::string> opt, int chanNbr /*, channel (string or direct reference or pointer but no copy)*/)
|
void do_chan_opt(fdList &allFds, int userNbr, std::vector<std::string> opt, int chanNbr /*, channel (string or direct reference or pointer but no copy)*/)
|
||||||
@ -149,6 +154,10 @@ void do_chan_opt(fdList &allFds, int userNbr, std::vector<std::string> opt, int
|
|||||||
default : std::cout << "Not launching option" << std::endl;
|
default : std::cout << "Not launching option" << std::endl;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
//mode_i()
|
||||||
|
//call option
|
||||||
|
//switch ? if forest? map container ? 2 tab (name and function pointer) ?
|
||||||
|
// opt_i(int signe (+ ou -), channel, user);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -162,6 +171,12 @@ void do_user_opt(fdList &allFds, int userNbr, std::vector<std::string> opt, int
|
|||||||
bool sign = true;
|
bool sign = true;
|
||||||
if (opt[2][0] == '-')
|
if (opt[2][0] == '-')
|
||||||
sign = false;
|
sign = false;
|
||||||
|
if (allFds.userData[userNbr].userName != opt[1])
|
||||||
|
{
|
||||||
|
std::cout << "not the same user ! don't try to change someone else MODE you stupid bitch\n"
|
||||||
|
//cmd_error(allFds, allFds.userData[userNbr].fd, "401 *" + opt[1] + " :No such nick/channel\n");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
for (int i = 1; opt[2][i]; i++)
|
for (int i = 1; opt[2][i]; i++)
|
||||||
{
|
{
|
||||||
//int j = 0;
|
//int j = 0;
|
||||||
@ -169,13 +184,7 @@ void do_user_opt(fdList &allFds, int userNbr, std::vector<std::string> opt, int
|
|||||||
// j++;
|
// j++;
|
||||||
switch(opt[2][i])
|
switch(opt[2][i])
|
||||||
{
|
{
|
||||||
case 'i':
|
case 'i': allFds.userData[new_target].mode.i = (sign = true) ? true : false;
|
||||||
if (allFds.userData[userNbr].userName != opt[1])
|
|
||||||
{
|
|
||||||
cmd_error(allFds, allFds.userData[userNbr].fd, "401 *" + opt[1] + " :No such nick/channel\n");
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
allFds.userData[new_target].mode.i = (sign = true) ? true : false;
|
|
||||||
break ;
|
break ;
|
||||||
case 's': allFds.userData[new_target].mode.s = (sign = true) ? true : false;
|
case 's': allFds.userData[new_target].mode.s = (sign = true) ? true : false;
|
||||||
break ;
|
break ;
|
||||||
@ -212,6 +221,8 @@ void MODE(std::string buffer, fdList &allFds, int userNbr)
|
|||||||
if ((pos = find_channel(allFds, splitBuff[1])) == -1) //if true chan doesn't exist
|
if ((pos = find_channel(allFds, splitBuff[1])) == -1) //if true chan doesn't exist
|
||||||
{
|
{
|
||||||
std::cout << splitBuff[1] << ": No such channel" << std::endl;
|
std::cout << splitBuff[1] << ": No such channel" << std::endl;
|
||||||
|
// 403 ERR_NOSUCHCHANNEL
|
||||||
|
// "<nom de canal> :No such channel"
|
||||||
return ;
|
return ;
|
||||||
}//else
|
}//else
|
||||||
//verify_option(allFds, str, i); //needed?
|
//verify_option(allFds, str, i); //needed?
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user