Topic: Error on message.cpp
Please help me !
My Code _Handle_Chat_command
static int _handle_chat_command(t_connection * c, char const *text)
{
t_connection * conn;
char key[256];
unsigned int i,j,k;
t_account *acc=conn_get_account(c);
text = skip_command(text);
if ( k = account_get_numattr(acc,"chat\\num_chat") ) {
i = 1;
j = 0;
while ( i <= k ) {
std::sprintf(key,"chat\\chat_%d",i);
if (conn=connlist_find_connection_by_accountname(account_get_strattr(acc,key))) {
message_send_text(conn,message_type_whisper,c,text);
j++;
}
i++;
}
if ( j == 0 ) {
message_send_text(c,message_type_info,c,"all member offline");
}
else {
std::sprintf(key,"Success sent to %d other",k);
message_send_text(c,message_type_info,c,key);
}
}
else {
message_send_text(c,message_type_info,c,"please usage /addchat <username> to add a new chat");
}
return 0;
}
And My code on Message.cpp :
extern int message_send_user(t_connection * src, t_message_type type, char const * text)
{
t_elem const * curr;
t_connection * tc;
int counter = 0;
LIST_TRAVERSE_CONST(connlist(),curr)
{
tc = (t_connection*)elem_get_data(curr);
if (!tc)
continue;
if (!conn_get_game(tc) || strcasecmp(game_status_get_str(game_get_status(conn_get_game(tc))),"open")==0 )
{
message_send_text(tc,type,src,text);
counter++;
}
}
return counter;
}