static int _handle_host_command(t_connection * c, char const * text)
{
t_account * account;
account = conn_get_account(c);
t_account * acc1;
t_account * acc2;
t_account * acc3;
t_account * acc4;
t_connection * user;
t_connection * unhost;
char * game_type;
char * game_mode;
char * game_name;
char t[MAX_MESSAGE_LEN];
unsigned int i,j;
char arg1[256];
char arg2[256];
char arg3[256];
char const * bot1="Uz.1";
char const * bot2="Uz.2";
char const * bot3="Uz.3";
char const * bot4="Uz.4";
std::strncpy(t, text, MAX_MESSAGE_LEN - 1);
for (i=0; t[i]!=' ' && t[i]!='\0'; i++);
for (; t[i]==' '; i++);
for (j=0; t[i]!=' ' && t[i]!='\0'; i++)
if (j<sizeof(arg1)-1) arg1[j++] = t[i];
arg1[j] = '\0';
for (; t[i]==' '; i++);
for (j=0; t[i]!='\0'; i++)
if (j<sizeof(arg2)-1) arg2[j++] = t[i];
arg2[j] = '\0';
for (; t[i]==' '; i++);
for (j=0; t[i]!='\0'; i++)
if (j<sizeof(arg3)-1) arg3[j++] = t[i];
arg3[j] = '\0';
acc1 = accountlist_find_account(bot1);
acc2 = accountlist_find_account(bot2);
acc3 = accountlist_find_account(bot3);
acc4 = accountlist_find_account(bot4);
game_type = arg1;
game_mode = arg2;
game_name = arg3;
if (arg1[0] =='\0') {
message_send_text(c,message_type_info,c,"Используйте: /host [тип] [мод] [названия игры]");
}
else if (account_get_auth_bot1host(account,NULL)==1)
{
message_send_text(c,message_type_info,c,"У вас уже есть созданная игра!");
}
else if (account_get_auth_bot2host(account,NULL)==1)
{
message_send_text(c,message_type_info,c,"У вас уже есть созданная игра!");
}
else if (account_get_auth_bot3host(account,NULL)==1)
{
message_send_text(c,message_type_info,c,"У вас уже есть созданная игра!");
}
else if (account_get_auth_bot4host(account,NULL)==1)
{
message_send_text(c,message_type_info,c,"У вас уже есть созданная игра!");
}
//custom
else if (account_get_auth_cbot1host(account,NULL)==1)
{
message_send_text(c,message_type_info,c,"У вас уже есть созданная игра!");
}
else if (account_get_auth_cbot2host(account,NULL)==1)
{
message_send_text(c,message_type_info,c,"У вас уже есть созданная игра!");
}
else if (account_get_auth_cbot3host(account,NULL)==1)
{
message_send_text(c,message_type_info,c,"У вас уже есть созданная игра!");
}
else if (account_get_auth_cbot4host(account,NULL)==1)
{
message_send_text(c,message_type_info,c,"У вас уже есть созданная игра!");
}
else if ((account_get_auth_bot1(account, NULL) == 1) || (account_get_auth_bot1on(acc1, NULL) == 0))
{
t_account * stats = accountlist_find_account( bot1 );
if (stats)
{
t_connection * conn = account_get_conn(stats);
if (conn)
snprintf(msgtemp3, sizeof(msgtemp3), "!load dota");
message_send_text(conn,message_type_whisper,conn, msgtemp3);
snprintf(msgtemp, sizeof(msgtemp), "!pubby %s %s %s %s",account_get_name(conn_get_account(c)),game_type,game_mode,game_name);
message_send_text(conn,message_type_whisper,conn, msgtemp);
snprintf(msgtemp3, sizeof(msgtemp3), "!modprotected %s",game_mode);
message_send_text(conn,message_type_whisper,conn, msgtemp3);
account_set_auth_bot1on(stats,NULL,1);
account_set_auth_bot1host(account,NULL,1);
snprintf(msgtemp4, sizeof(msgtemp4), "Ваша игра создана");
message_send_text(c,message_type_info,c,msgtemp4);
} else {
if (!(user = connlist_find_connection_by_accountname(bot1))) {
message_send_text(c,message_type_error,c,"Бот оффлайн");
}
}
return 0;
}
//bot2
else if ((account_get_auth_bot2(account, NULL) == 1) || (account_get_auth_bot2on(acc2, NULL) == 0))
{
t_account * stats = accountlist_find_account( bot2 );
if (stats)
{
t_connection * conn = account_get_conn(stats);
if (conn)
snprintf(msgtemp3, sizeof(msgtemp3), "!load dota");
message_send_text(conn,message_type_whisper,conn, msgtemp3);
snprintf(msgtemp, sizeof(msgtemp), "!pubby %s %s %s %s",account_get_name(conn_get_account(c)),game_type,game_mode,game_name);
message_send_text(conn,message_type_whisper,conn, msgtemp);
snprintf(msgtemp3, sizeof(msgtemp3), "!modprotected %s",game_mode);
message_send_text(conn,message_type_whisper,conn, msgtemp3);
account_set_auth_bot2on(stats,NULL,1);
account_set_auth_bot2host(account,NULL,1);
snprintf(msgtemp4, sizeof(msgtemp4), "Ваша игра создана");
message_send_text(c,message_type_info,c,msgtemp4);
} else {
if (!(user = connlist_find_connection_by_accountname(bot2))) {
message_send_text(c,message_type_error,c,"Бот оффлайн");
}
}
//
return 0;
}
//bot3
else if ((account_get_auth_bot3(account, NULL) == 1) || (account_get_auth_bot3on(acc3, NULL) == 0))
{
t_account * stats = accountlist_find_account( bot3 );
if (stats)
{
t_connection * conn = account_get_conn(stats);
if (conn)
snprintf(msgtemp3, sizeof(msgtemp3), "!load dota");
message_send_text(conn,message_type_whisper,conn, msgtemp3);
snprintf(msgtemp, sizeof(msgtemp), "!pubby %s %s %s %s",account_get_name(conn_get_account(c)),game_type,game_mode,game_name);
message_send_text(conn,message_type_whisper,conn, msgtemp);
snprintf(msgtemp3, sizeof(msgtemp3), "!modprotected %s",game_mode);
message_send_text(conn,message_type_whisper,conn, msgtemp3);
account_set_auth_bot3on(stats,NULL,1);
account_set_auth_bot3host(account,NULL,1);
snprintf(msgtemp4, sizeof(msgtemp4), "Ваша игра создана");
message_send_text(c,message_type_info,c,msgtemp4);
} else {
if (!(user = connlist_find_connection_by_accountname(bot3))) {
message_send_text(c,message_type_error,c,"Бот оффлайн");
}
}
//
return 0;
}
//bot4
else if ((account_get_auth_bot4(account, NULL) == 1) || (account_get_auth_bot4on(acc4, NULL) == 0))
{
t_account * stats = accountlist_find_account( bot4 );
if (stats)
{
t_connection * conn = account_get_conn(stats);
if (conn)
snprintf(msgtemp3, sizeof(msgtemp3), "!load dota");
message_send_text(conn,message_type_whisper,conn, msgtemp3);
snprintf(msgtemp, sizeof(msgtemp), "!pubby %s %s %s %s",account_get_name(conn_get_account(c)),game_type,game_mode,game_name);
message_send_text(conn,message_type_whisper,conn, msgtemp);
snprintf(msgtemp3, sizeof(msgtemp3), "!modprotected %s",game_mode);
message_send_text(conn,message_type_whisper,conn, msgtemp3);
account_set_auth_bot4on(stats,NULL,1);
account_set_auth_bot4host(account,NULL,1);
snprintf(msgtemp4, sizeof(msgtemp4), "Ваша игра создана");
message_send_text(c,message_type_info,c,msgtemp4);
} else {
if (!(user = connlist_find_connection_by_accountname(bot4))) {
message_send_text(c,message_type_error,c,"Бот оффлайн");
}
}
//
return 0;
}
return 0;
}