⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 command.c

📁 打魔兽战网的都知道他是什么
💻 C
📖 第 1 页 / 共 5 页
字号:
    		bn_byte_set(&rpacket->u.server_friendmove_ack.pos2, n+1);		conn_push_outqueue(c,rpacket);		packet_del_ref(rpacket);		return 0;	    }	return 0;    }    if (strstart(text,"list")==0 || strstart(text,"l")==0) {	char const * friend;	char status[128];	char software[64];	char msgtemp[MAX_MESSAGE_LEN];	t_connection * dest_c;	t_account * friend_acc;	t_game const * game;	t_channel const * channel;	t_friend * fr;	t_list  * flist;	int num;	unsigned int uid;	message_send_text(c,message_type_info,c,"Your PvPGN - Friends List");	message_send_text(c,message_type_info,c,"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");	num = account_get_friendcount(my_acc);	flist=account_get_friends(my_acc);	if(flist!=NULL) {	    for (i=0;i<num;i++)	    {    		if ((!(uid = account_get_friend(my_acc,i))) || (!(fr = friendlist_find_uid(flist,uid))))    		{        	    eventlog(eventlog_level_error,__FUNCTION__,"friend uid in list");        	    continue;    		}    		software[0]='\0';    		friend_acc=friend_get_account(fr);		if (!(dest_c = connlist_find_connection_by_account(friend_acc)))	    	    sprintf(status, ", offline");		else {	    	    sprintf(software," using %s", clienttag_get_title(conn_get_clienttag(dest_c)));	    	    if(friend_get_mutual(fr)) {		        if ((game = conn_get_game(dest_c)))		            sprintf(status, ", in game \"%.64s\"", game_get_name(game));		        else if ((channel = conn_get_channel(dest_c))) {		            if(strcasecmp(channel_get_name(channel),"Arranged Teams")==0)		                sprintf(status, ", in game AT Preparation");		            else		                sprintf(status, ", in channel \"%.64s\",", channel_get_name(channel));		    	    }		        else		            sprintf(status, ", is in AT Preparation");	    	    } else {		        if ((game = conn_get_game(dest_c)))		            sprintf(status, ", is in a game");		        else if ((channel = conn_get_channel(dest_c)))		            sprintf(status, ", is in a chat channel");		        else		            sprintf(status, ", is in AT Preparation");	    	    }		}		friend=account_get_name(friend_acc);    		if (software[0]) sprintf(msgtemp, "%d: %s%.16s%.128s, %.64s", i+1, friend_get_mutual(fr)?"*":" ", friend, status,software);		else sprintf(msgtemp, "%d: %.16s%.128s", i+1, friend, status);		message_send_text(c,message_type_info,c,msgtemp);	    }	}	message_send_text(c,message_type_info,c,"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");	message_send_text(c,message_type_info,c,"End of Friends List");	return 0;    }    return 0;}static int _handle_me_command(t_connection * c, char const * text){  t_channel const * channel;  if (!(channel = conn_get_channel(c)))    {      message_send_text(c,message_type_error,c,"You are not in a channel.");      return 0;    }  text = skip_command(text);  if ((text[0]!='\0') && (!conn_quota_exceeded(c,text)))    channel_message_send(channel,message_type_emote,c,text);  return 0;}static int _handle_whisper_command(t_connection * c, char const *text){  char         dest[USER_NAME_MAX+REALM_NAME_LEN]; /* both include NUL, so no need to add one for middle @ or * */  unsigned int i,j;  for (i=0; text[i]!=' ' && text[i]!='\0'; i++); /* skip command */  for (; text[i]==' '; i++);  for (j=0; text[i]!=' ' && text[i]!='\0'; i++) /* get dest */    if (j<sizeof(dest)-1) dest[j++] = text[i];  dest[j] = '\0';  for (; text[i]==' '; i++);  if ((dest[0]=='\0') || (text[i]=='\0'))    {      message_send_text(c,message_type_info,c,"usage: /whisper <username> <text to whisper>");      return 0;    }  do_whisper(c,dest,&text[i]);  return 0;}static int _handle_status_command(t_connection * c, char const *text){    char ctag[5];    unsigned int i,j;    t_clienttag clienttag;    for (i=0; text[i]!=' ' && text[i]!='\0'; i++); /* skip command */    for (; text[i]==' '; i++);    for (j=0; text[i]!=' ' && text[i]!='\0'; i++) /* get clienttag */	if (j<sizeof(ctag)-1) ctag[j++] = text[i];    ctag[j] = '\0';    if (ctag[0]=='\0') {	sprintf(msgtemp,"There are currently %d users online, in %d games and %d channels.",	    connlist_login_get_length(),	    gamelist_get_length(),	    channellist_get_length());	message_send_text(c,message_type_info,c,msgtemp);	tag_uint_to_str(ctag,conn_get_clienttag(c));    }    for (i=0; i<strlen(ctag); i++)	if (isascii((int)ctag[i]) && islower((int)ctag[i]))	    ctag[i] = toupper((int)ctag[i]);    if (strcmp(ctag,"ALL") == 0)	clienttag = 0;    else	clienttag = tag_case_str_to_uint(ctag);    switch (clienttag)    {	case 0:	case CLIENTTAG_WAR3XP_UINT:	    sprintf(msgtemp,"There are currently %u user(s) in %u games of %s",		conn_get_user_count_by_clienttag(CLIENTTAG_WAR3XP_UINT),		game_get_count_by_clienttag(CLIENTTAG_WAR3XP_UINT),		clienttag_get_title(CLIENTTAG_WAR3XP_UINT));	    message_send_text(c,message_type_info,c,msgtemp);	    if (clienttag) break;	case CLIENTTAG_WARCRAFT3_UINT:	    sprintf(msgtemp,"There are currently %u user(s) in %u games of %s",		conn_get_user_count_by_clienttag(CLIENTTAG_WARCRAFT3_UINT),		game_get_count_by_clienttag(CLIENTTAG_WARCRAFT3_UINT),		clienttag_get_title(CLIENTTAG_WARCRAFT3_UINT));	    message_send_text(c,message_type_info,c,msgtemp);	    if (clienttag) break;	case CLIENTTAG_DIABLO2XP_UINT:	    sprintf(msgtemp,"There are currently %u user(s) in %u games of %s",		conn_get_user_count_by_clienttag(CLIENTTAG_DIABLO2XP_UINT),		game_get_count_by_clienttag(CLIENTTAG_DIABLO2XP_UINT),		clienttag_get_title(CLIENTTAG_DIABLO2XP_UINT));	    message_send_text(c,message_type_info,c,msgtemp);	    if (clienttag) break;	case CLIENTTAG_DIABLO2DV_UINT:	    sprintf(msgtemp,"There are currently %u user(s) in %u games of %s",		conn_get_user_count_by_clienttag(CLIENTTAG_DIABLO2DV_UINT),		game_get_count_by_clienttag(CLIENTTAG_DIABLO2DV_UINT),		clienttag_get_title(CLIENTTAG_DIABLO2DV_UINT));	    message_send_text(c,message_type_info,c,msgtemp);	    if (clienttag) break;	case CLIENTTAG_BROODWARS_UINT:	    sprintf(msgtemp,"There are currently %u user(s) in %u games of %s",		conn_get_user_count_by_clienttag(CLIENTTAG_BROODWARS_UINT),		game_get_count_by_clienttag(CLIENTTAG_BROODWARS_UINT),		clienttag_get_title(CLIENTTAG_BROODWARS_UINT));	    message_send_text(c,message_type_info,c,msgtemp);	    if (clienttag) break;	case CLIENTTAG_STARCRAFT_UINT:	    sprintf(msgtemp,"There are currently %u user(s) in %u games of %s",		conn_get_user_count_by_clienttag(CLIENTTAG_STARCRAFT_UINT),		game_get_count_by_clienttag(CLIENTTAG_STARCRAFT_UINT),		clienttag_get_title(CLIENTTAG_STARCRAFT_UINT));	    message_send_text(c,message_type_info,c,msgtemp);	    if (clienttag) break;	case CLIENTTAG_WARCIIBNE_UINT:	    sprintf(msgtemp,"There are currently %u user(s) in %u games of %s",		conn_get_user_count_by_clienttag(CLIENTTAG_WARCIIBNE_UINT),		game_get_count_by_clienttag(CLIENTTAG_WARCIIBNE_UINT),		clienttag_get_title(CLIENTTAG_WARCIIBNE_UINT));	    message_send_text(c,message_type_info,c,msgtemp);	    if (clienttag) break;	case CLIENTTAG_DIABLORTL_UINT:	    sprintf(msgtemp,"There are currently %u user(s) in %u games of %s",		conn_get_user_count_by_clienttag(CLIENTTAG_DIABLORTL_UINT),		game_get_count_by_clienttag(CLIENTTAG_DIABLORTL_UINT),		clienttag_get_title(CLIENTTAG_DIABLORTL_UINT));	    message_send_text(c,message_type_info,c,msgtemp);	    if (clienttag) break;	default:	    sprintf(msgtemp,"There are currently %u user(s) in %u games of %s",		conn_get_user_count_by_clienttag(conn_get_clienttag(c)),		game_get_count_by_clienttag(conn_get_clienttag(c)),		clienttag_get_title(conn_get_clienttag(c)));	    message_send_text(c,message_type_info,c,msgtemp);    }    return 0;}static int _handle_who_command(t_connection * c, char const *text){  t_connection const * conn;  t_channel const *    channel;  unsigned int         i;  char const *         tname;  for (i=0; text[i]!=' ' && text[i]!='\0'; i++); /* skip command */  for (; text[i]==' '; i++);  if (text[i]=='\0')  {	message_send_text(c,message_type_info,c,"usage: /who <channel>");	return 0;  }  if (!(channel = channellist_find_channel_by_name(&text[i],conn_get_country(c),realm_get_name(conn_get_realm(c)))))    {      message_send_text(c,message_type_error,c,"That channel does not exist.");      message_send_text(c,message_type_error,c,"(If you are trying to search for a user, use the /whois command.)");      return 0;    }  if (channel_check_banning(channel,c)==1)    {      message_send_text(c,message_type_error,c,"You are banned from that channel.");      return 0;    }  sprintf(msgtemp,"Users in channel %.64s:",&text[i]);  i = strlen(msgtemp);  for (conn=channel_get_first(channel); conn; conn=channel_get_next())    {      if (i+strlen((tname = conn_get_username(conn)))+2>sizeof(msgtemp)) /* " ", name, '\0' */	{	  message_send_text(c,message_type_info,c,msgtemp);	  i = 0;	}      sprintf(&msgtemp[i]," %s",tname);      i += strlen(&msgtemp[i]);    }  if (i>0)    message_send_text(c,message_type_info,c,msgtemp);  return 0;}static int _handle_whois_command(t_connection * c, char const * text){  unsigned int i;  for (i=0; text[i]!=' ' && text[i]!='\0'; i++); /* skip command */  for (; text[i]==' '; i++);  if (text[i]=='\0')  {    message_send_text(c,message_type_info,c,"usage: /whois <username>");    return 0;  }  do_whois(c,&text[i]);  return 0;}static int _handle_whoami_command(t_connection * c, char const *text){  char const * tname;  if (!(tname = conn_get_username(c)))    {      message_send_text(c,message_type_error,c,"Unable to obtain your account name.");      return 0;    }  do_whois(c,tname);  return 0;}static int _handle_announce_command(t_connection * c, char const *text){  unsigned int i;  t_message *  message;  for (i=0; text[i]!=' ' && text[i]!='\0'; i++); /* skip command */  for (; text[i]==' '; i++);  if (text[i]=='\0')  {	message_send_text(c,message_type_info,c,"usage: /announce <announcement>");	return 0;  }  sprintf(msgtemp,"Announcement from %.64s: %.128s",conn_get_username(c),&text[i]);  if (!(message = message_create(message_type_broadcast,c,NULL,msgtemp)))    message_send_text(c,message_type_info,c,"Could not broadcast message.");  else    {      if (message_send_all(message)<0)	message_send_text(c,message_type_info,c,"Could not broadcast message.");      message_destroy(message);    }  return 0;}static int _handle_beep_command(t_connection * c, char const *text){  message_send_text(c,message_type_info,c,"Audible notification on."); /* FIXME: actually do something */  return 0; /* FIXME: these only affect CHAT clients... I think they prevent ^G from being sent */}static int _handle_nobeep_command(t_connection * c, char const *text){  message_send_text(c,message_type_info,c,"Audible notification off."); /* FIXME: actually do something */  return 0;}static int _handle_version_command(t_connection * c, char const *text){  message_send_text(c,message_type_info,c,PVPGN_SOFTWARE" "PVPGN_VERSION);  return 0;}static int _handle_copyright_command(t_connection * c, char const *text){  static char const * const info[] =    {      " Copyright (C) 2002  See source for details",      " ",      " PvPGN is free software; you can redistribute it and/or",      " modify it under the terms of the GNU General Public License",      " as published by the Free Software Foundation; either version 2",      " of the License, or (at your option) any later version.",      " ",      " This program is distributed in the hope that it will be useful,",      " but WITHOUT ANY WARRANTY; without even the implied warranty of",      " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the",      " GNU General Public License for more details.",      " ",      " You should have received a copy of the GNU General Public License",      " along with this program; if not, write to the Free Software",      " Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.",      NULL    };  unsigned int i;  for (i=0; info[i]; i++)    message_send_text(c,message_type_info,c,info[i]);  return 0;}static int _handle_uptime_command(t_connection * c, char const *text){  sprintf(msgtemp,"Uptime: %s",seconds_to_timestr(server_g

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -