#include "version.h" #include #include #include #include "readmap.h" #include "object.h" #include "char.h" #include "char_base.h" #include "chatmagic.h" #include "battle.h" #include "log.h" #include "configfile.h" #include "lssproto_serv.h" #include "saacproto_cli.h" #include "family.h" #include "chatroom.h" #include "net.h" #include "util.h" #ifdef _CHATROOMPROTOCOL // (不可开) Syu ADD 聊天室频道 #ifdef _UNIVERSE_CHATROOM UniChatRoomlist ChatRoom[MAX_CHATROOM]; BOOL ChatCheck_BeMaster( int myindex, int chatnum) { if( !CHAR_CHECKINDEX ( myindex ) ) return FALSE; if( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ) == 0 ) return FALSE; if( chatnum != -1 ){ if( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ) != chatnum ) return FALSE; } if( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) == 1 ) return TRUE; return FALSE; } BOOL ChatCheck_Free( int myindex) { int old_gold; if ( !CHAR_CHECKINDEX ( myindex ) ) return FALSE; old_gold = CHAR_getInt( myindex, CHAR_GOLD ); if( old_gold < 200 ){ CHAR_talkToCli ( myindex , -1 , "成立聊天室需花费200石币" , CHAR_COLORYELLOW ); return FALSE; } if ( CHAR_getInt ( myindex , CHAR_LV ) < 30 && CHAR_getInt ( myindex , CHAR_TRANSMIGRATION ) < 1 ) { CHAR_talkToCli ( myindex , -1 , "成立聊天室需0转30级以上!" , CHAR_COLORYELLOW ); return FALSE; } if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) != 0 ) { CHAR_talkToCli ( myindex , -1 , "你已经在其他聊天室中!" , CHAR_COLORYELLOW ); return FALSE; } return TRUE; } void resetChat_users( int chat, int ti) { if( chat<0 || chat >= MAX_CHATROOM ) return; if( ti<0 || ti >= MAX_PPLINROOM ) return; memset( ChatRoom[chat].charalist[ti].cdkey, 0, sizeof(ChatRoom[chat].charalist[ti].cdkey)); memset( ChatRoom[chat].charalist[ti].name, 0, sizeof(ChatRoom[chat].charalist[ti].name)); memset( ChatRoom[chat].charalist[ti].own, 0, sizeof(ChatRoom[chat].charalist[ti].own)); } void InitChatRoom( void ) { int i, j; for ( i = 0 ; i < MAX_CHATROOM ; i ++ ) { ChatRoom[ i ].use=0; ChatRoom[ i ].masindex= -1; ChatRoom[ i ].charanum= 0; for ( j = 0 ; j < MAX_PPLINROOM ; j ++ ) resetChat_users( i, j); } } int ChatRoom_getfree( void) { int i; for ( i=0; iMAX_PPLINROOM ) return; sprintf ( token , "R|r%d|%s|%d|%s|p%d|" , Num, ChatRoom[ Num ].chatname, ChatRoom[ Num ].masindex, ChatRoom[Num].charalist[ChatRoom[Num].masindex].name, ChatRoom[ Num ].charanum ); for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { if ( ChatRoom[ Num ].charalist[i].use == 0 ) continue; sprintf( buf , "I%d|%s|%s|" , i, ChatRoom[Num].charalist[i].name, ChatRoom[Num].charalist[i].own ); strncat ( token , buf , sizeof ( buf ) ) ; } for ( j=0; j= MAX_CHATROOM ) return; sprintf ( buf , "D|%d", chat); for ( j=0; j= 32 ) return; snprintf( token, sizeof( token),"C|%s|%s|%s|%s|", chatname, CHAR_getChar( charaindex, CHAR_CDKEY), CHAR_getChar( charaindex, CHAR_NAME), CHAR_getChar( charaindex, CHAR_OWNTITLE) ); }else if ( strcmp ( Head , "D" ) == 0 ) { // 删除频道 int chat; if( CHAR_getWorkInt( charaindex, CHAR_WORKCHATROOMTYPE) != 1 ) return; if( (chat = CHAR_getWorkInt( charaindex, CHAR_WORKCHATROOMNUM)) < 0 ) return; if( chat >= MAX_CHATROOM ) return; snprintf( token, sizeof( token),"D|%d|%s|%s|", chat, CHAR_getChar( charaindex, CHAR_CDKEY), CHAR_getChar( charaindex, CHAR_NAME) ); //ChatRoom_Destroy( myindex); /* }else if ( strcmp ( Head, "A") == 0 ) {// 同意加入频道 getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); getStringFromIndexWithDelim( data , "|", 3, buf, sizeof(buf)); ChatRoom_Agree ( myindex , atoi( message ) , atoi( buf ) ) ; */ }else if ( strcmp( Head , "J") == 0 ) {//加入频道 int chat; if( getStringFromIndexWithDelim( data , "|", 2, buf, sizeof(buf)) == FALSE ) return; chat = atoi( buf); if( chat < 0 || chat >= MAX_CHATROOM ) return; snprintf( token, sizeof( token),"J|%d|%s|%s|%s|", chat, CHAR_getChar( charaindex, CHAR_CDKEY), CHAR_getChar( charaindex, CHAR_NAME), CHAR_getChar( charaindex, CHAR_OWNTITLE) ); // ChatRoom_Join ( myindex , atoi( message ) ) ; }else if ( strcmp( Head , "L") == 0 ) {// 离开频道 ChatRoom_Leave( charaindex); return; }else if ( strcmp ( Head , "K" ) == 0 ) {//踢出频道 int ti, chat; if( getStringFromIndexWithDelim( data , "|", 2, buf, sizeof( buf)) == FALSE ) return; ti = atoi( buf); if( ti<0 || ti>=MAX_PPLINROOM ) return; if( CHAR_getWorkInt( charaindex, CHAR_WORKCHATROOMTYPE) != 1 ) return; if( (chat = CHAR_getWorkInt( charaindex, CHAR_WORKCHATROOMNUM)) < 0 ) return; if( chat >= MAX_CHATROOM ) return; snprintf( token, sizeof( token),"K|%d|%s|%s|%d|", chat, CHAR_getChar( charaindex, CHAR_CDKEY), CHAR_getChar( charaindex, CHAR_NAME), ti ); // ChatRoom_Kick ( myindex , atoi( message ) ); }else if ( strcmp ( Head , "M" ) == 0 ) { // 更换室长 int ti, chat; if( getStringFromIndexWithDelim( data , "|", 2, buf, sizeof(buf)) == FALSE ) return; ti = atoi( buf); if( CHAR_getWorkInt( charaindex, CHAR_WORKCHATROOMTYPE) != 1 ) return; if( (chat = CHAR_getWorkInt( charaindex, CHAR_WORKCHATROOMNUM)) < 0 ) return; if( chat >= MAX_CHATROOM ) return; if( ChatRoom[chat].charalist[ti].use == 0 ) return; snprintf( token, sizeof( token),"M|%d|%s|%s|%d|", chat, CHAR_getChar( charaindex, CHAR_CDKEY), CHAR_getChar( charaindex, CHAR_NAME), ti ); // ChatRoom_Make ( myindex , atoi( message ) ); }else if ( strcmp ( Head , "T" ) == 0 ) {// 频道讯息 int chat; if( getStringFromIndexWithDelim( data , "|", 2, buf, sizeof(buf)) == FALSE ) return; if( CHAR_getWorkInt( charaindex, CHAR_WORKCHATROOMTYPE) == 0 ) return; if( (chat = CHAR_getWorkInt( charaindex, CHAR_WORKCHATROOMNUM)) < 0 ) return; if( chat >= MAX_CHATROOM ) return; snprintf( token, sizeof( token),"T|%d|%s|", chat, buf); // ChatRoom_Message ( myindex , message ) ; }else if ( strcmp ( Head , "B" ) == 0 ) {// 聊天室清单 ChatRoom_List ( fd ); return; } fd = getfdFromCharaIndex( charaindex); saacproto_ACUniChatroom_send( acfd, charaindex, CONNECT_getFdid(fd), CHAR_getChar( charaindex, CHAR_CDKEY), token); } void saac_ChatRoom_recvall ( int fd , char *result, char *data, int charaindex, int clifdid) { char Head[4], buf[256]; int chat; charaindex = getCharindexFromFdid(clifdid); //andy_log print( "saac CR:%s.\n", data); if( getStringFromIndexWithDelim( data , "|", 1, Head, sizeof(Head)) == FALSE ) return; if( strcmp( Head, "C") == 0 ) { // 成立频道 // int fd = getfdFromCharaIndex( charaindex); // if( getStringFromIndexWithDelim( data , "|", 2, result, sizeof(result)) == FALSE ) return; if( !strcmp( result, SUCCESSFUL) ){ if( getStringFromIndexWithDelim( data , "|", 3, buf, sizeof(buf)) == FALSE ) return; chat = atoi( buf); if( chat < 0 || chat >= MAX_CHATROOM ) return; if( getStringFromIndexWithDelim( data , "|", 4, ChatRoom[chat].chatname, sizeof(ChatRoom[chat].chatname)) == FALSE ) return; if( getStringFromIndexWithDelim( data , "|", 5, buf, sizeof(buf)) == FALSE ) return; ChatRoom[chat].masindex = atoi( buf); if( getStringFromIndexWithDelim( data , "|", 6, ChatRoom[chat].charalist[0].cdkey, sizeof(ChatRoom[chat].charalist[0].cdkey)) == FALSE ) return; if( getStringFromIndexWithDelim( data , "|", 7, ChatRoom[chat].charalist[0].name, sizeof(ChatRoom[chat].charalist[0].name)) == FALSE ) return; if( getStringFromIndexWithDelim( data , "|", 8, ChatRoom[chat].charalist[0].own, sizeof(ChatRoom[chat].charalist[0].own)) == FALSE ) return; ChatRoom[chat].charalist[0].use=1; if( CHAR_DelGold( charaindex, 200) == 0 ) return; ChatRoom[chat].use = 1; CHAR_setWorkInt ( charaindex , CHAR_WORKCHATROOMTYPE , 1 ) ; CHAR_setWorkInt ( charaindex , CHAR_WORKCHATROOMNUM , chat ) ; CHAR_talkToCli ( charaindex , -1 , "成立聊天室扣除200石币。" , CHAR_COLORYELLOW ); ChatRoom_Refresh( chat); }else{ CHAR_talkToCli ( charaindex , -1 , "无法成立聊天室,聊天频道已满或条件不足!" , CHAR_COLORYELLOW ); } }else if( strcmp( Head, "U") == 0 ) { int k=2, ti; char bufarg[512]; if( getStringFromIndexWithDelim( data , ",", 1, bufarg, sizeof(bufarg)) == FALSE ) return; if( getStringFromIndexWithDelim( bufarg , "|", 2, buf, sizeof(buf)) == FALSE ) return; chat = atoi( buf); if( chat < 0 || chat >= MAX_CHATROOM ) return; if( getStringFromIndexWithDelim( bufarg , "|", 3, buf, sizeof(buf)) == FALSE ) return; ChatRoom[chat].use = atoi( buf); if( getStringFromIndexWithDelim( bufarg , "|", 4, ChatRoom[chat].chatname, sizeof(ChatRoom[chat].chatname)) == FALSE ) return; if( getStringFromIndexWithDelim( bufarg , "|", 5, buf, sizeof(buf)) == FALSE ) return; ChatRoom[chat].masindex = atoi( buf); if( getStringFromIndexWithDelim( bufarg , "|", 6, buf, sizeof(buf)) == FALSE ) return; ChatRoom[chat].charanum = atoi( buf); while( getStringFromIndexWithDelim( data , ",", k, bufarg, sizeof( bufarg) ) ){ k++; if( bufarg[0] == 0 || strlen( bufarg) <= 0 ) continue; if( getStringFromIndexWithDelim( bufarg , "|", 1, buf, sizeof(buf)) == FALSE ) return; ti = atoi( buf); if( getStringFromIndexWithDelim( bufarg , "|", 2, ChatRoom[chat].charalist[ti].cdkey, sizeof(ChatRoom[chat].charalist[ti].cdkey)) == FALSE ) return; if( getStringFromIndexWithDelim( bufarg , "|", 3, ChatRoom[chat].charalist[ti].name, sizeof(ChatRoom[chat].charalist[ti].name)) == FALSE ) return; if( getStringFromIndexWithDelim( bufarg , "|", 4, ChatRoom[chat].charalist[ti].own, sizeof(ChatRoom[chat].charalist[ti].own)) == FALSE ) return; ChatRoom[chat].charalist[ti].use = 1; } ChatRoom_Refresh( chat); }else if( strcmp( Head, "D") == 0 ) { ChatRoom_Destroy ( data); }else if( strcmp( Head, "L") == 0 ) { int chat, ti; if( getStringFromIndexWithDelim( data , "|", 2, buf, sizeof( buf)) == FALSE ) return; chat = atoi(buf); if( chat < 0 || chat >= MAX_CHATROOM ) return; if( getStringFromIndexWithDelim( data , "|", 3, buf, sizeof( buf)) == FALSE ) return; ti = atoi(buf); if( ti<0||ti>=MAX_PPLINROOM)return; ChatRoom[chat].charalist[ti].use = 0; ChatRoom_Refresh( chat); }else if( strcmp( Head, "M") == 0 ) { int ti, chat, j; int playernum = CHAR_getPlayerMaxNum(); if( getStringFromIndexWithDelim( data , "|", 2, buf, sizeof( buf)) == FALSE ) return; chat = atoi( buf); if( chat < 0 || chat >= MAX_CHATROOM ) return; if( getStringFromIndexWithDelim( data , "|", 3, buf, sizeof( buf)) == FALSE ) return; ti = atoi( buf); if( ti<0 || ti>=MAX_PPLINROOM )return; if( ChatRoom[chat].charalist[ti].use == 0 ) return; for ( j=0; j= MAX_CHATROOM ) return; if( getStringFromIndexWithDelim( data , "|", 3, buf, sizeof( buf)) == FALSE ) return; ti = atoi( buf); if( ti<0 || ti>=MAX_PPLINROOM ) return; //andy_log print( "\nK|%d|%d|\n", chat, ti); for ( j=0; j= MAX_CHATROOM ) return; if( getStringFromIndexWithDelim( data , "|", 3, result, sizeof( result)) == FALSE ) return; if( !strcmp( result, "FULL") ){ CHAR_talkToCli( charaindex, -1, "该频道已满!", CHAR_COLORYELLOW); }else if( !strcmp( result, "OK") ){ CHAR_talkToCli( charaindex, -1, "加入聊天频道!", CHAR_COLORYELLOW); CHAR_setWorkInt( charaindex, CHAR_WORKCHATROOMNUM, chat); CHAR_setWorkInt( charaindex, CHAR_WORKCHATROOMTYPE, 2); } ChatRoom_Refresh( chat); }else if( !strcmp( Head, "T") ) {//频道讯息 int j; char message[256]; int playernum = CHAR_getPlayerMaxNum(); if( getStringFromIndexWithDelim( data , "|", 2, buf, sizeof( buf)) == FALSE ) return; chat = atoi( buf); if( chat < 0 || chat >= MAX_CHATROOM ) return; if( getStringFromIndexWithDelim( data , "|", 3, buf, sizeof( buf)) == FALSE ) return; snprintf ( message, sizeof ( message ) , "T|%s" , buf ); for ( j=0; j 0 ) { i = CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ) ; // WON FIX if( i < 0 ) return; for ( j = 0 ; j < MAX_PPLINROOM ; j ++ ) { if ( !CHAR_CHECKINDEX ( ChatRoom[ i ].MemberList[ j ] ) ) continue; snprintf ( buf , sizeof ( buf ) , "T|%s" , message ) ; fd = getfdFromCharaIndex ( ChatRoom[ i ].MemberList[ j ] ); lssproto_CHATROOM_send ( fd , buf ) ; } } } void ChatRoom_Kick ( int myindex , int toindex ) { int i , fd ; int Num = CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ); if ( !CHAR_CHECKINDEX ( myindex ) ) return ; if ( !CHAR_CHECKINDEX ( toindex ) ) return ; if ( myindex == toindex ) return; if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) == 1 ) { if ( Num != CHAR_getWorkInt ( toindex , CHAR_WORKCHATROOMNUM ) ) return; else { CHAR_setWorkInt ( toindex , CHAR_WORKCHATROOMTYPE , 0 ) ; CHAR_setWorkInt ( toindex , CHAR_WORKCHATROOMNUM , -1) ; //CHAR_talkToCli ( toindex , -1 , "室长将你踢出聊天室!" , CHAR_COLORRED ) ; fd = getfdFromCharaIndex( toindex ); lssproto_CHATROOM_send ( fd , "K|" ) ; ChatRoom[ Num ].NowPeople --; for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { if ( ChatRoom[ Num ].MemberList[ i ] == toindex ) { ChatRoom[ Num ].MemberList[ i ] = -1 ; break; } } } } ChatRoom_Refresh ( Num ) ; } void ChatRoom_Make ( int myindex , int toindex ) { int Num = CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ); if ( !CHAR_CHECKINDEX ( myindex ) ) return ; if ( !CHAR_CHECKINDEX ( toindex ) ) return ; if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) == 1 ) { if ( Num != CHAR_getWorkInt ( toindex , CHAR_WORKCHATROOMNUM ) ) return; else if ( CHAR_getInt ( toindex , CHAR_LV ) >= 30 || CHAR_getInt ( toindex , CHAR_TRANSMIGRATION ) >= 1 ) { CHAR_setWorkInt ( myindex , CHAR_WORKCHATROOMTYPE , 2 ) ; CHAR_setWorkInt ( toindex , CHAR_WORKCHATROOMTYPE , 1 ) ; CHAR_talkToCli ( toindex , -1 , "你现在是聊天室的室长!" , CHAR_COLORRED ) ; ChatRoom[ Num ].Maker = toindex ; } else { CHAR_talkToCli ( myindex , -1 , "您选择的继任人物等级不足以担任室长!" , CHAR_COLORRED ) ; } } ChatRoom_Refresh ( Num ) ; } void ChatRoom_Leave ( int myindex ) { int i , NextMaker = -1 ; int Num = CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ); if ( !CHAR_CHECKINDEX ( myindex ) ) return ; if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) == 1 ) { for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { if ( ChatRoom[ Num ].MemberList[ i ] != myindex && ChatRoom[ Num ].MemberList[ i ] != -1 ) { if ( CHAR_CHECKINDEX ( ChatRoom[ Num ].MemberList[ i ] ) ) { if ( CHAR_getInt ( ChatRoom[ Num ].MemberList[ i ] , CHAR_LV ) >= 30 || CHAR_getInt ( ChatRoom[ Num ].MemberList[ i ] , CHAR_TRANSMIGRATION ) >= 1 ) { NextMaker = ChatRoom[ Num ].MemberList[ i ] ; break; } } } } if ( NextMaker != -1 ) { ChatRoom_Make( myindex , NextMaker ) ; CHAR_setWorkInt ( myindex , CHAR_WORKCHATROOMTYPE , 0) ; CHAR_setWorkInt ( myindex , CHAR_WORKCHATROOMNUM, -1) ; ChatRoom[ Num ].NowPeople --; for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { if ( ChatRoom[ Num ].MemberList[ i ] == myindex ) { ChatRoom[ Num ].MemberList[ i ] = -1 ; break; } } }else{ ChatRoom_Destroy( myindex ) ; return ; } }else if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) == 2 ) { CHAR_setWorkInt ( myindex, CHAR_WORKCHATROOMTYPE, 0) ; CHAR_setWorkInt ( myindex, CHAR_WORKCHATROOMNUM, -1) ; ChatRoom[ Num ].NowPeople --; for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { if ( ChatRoom[ Num ].MemberList[ i ] == myindex ) { ChatRoom[ Num ].MemberList[ i ] = -1 ; break; } } } ChatRoom_Refresh ( Num ) ; } void ChatRoom_Join ( int myindex , int num ) { int fd ; char buf[64]; if ( !CHAR_CHECKINDEX ( myindex ) ) return ; if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) != 0 ) return ; if ( ChatRoom[ num ].useFlag == TRUE && ChatRoom[ num ].NowPeople < MAX_PPLINROOM ) { sprintf ( buf , "J|%s|%d" , CHAR_getChar( myindex , CHAR_NAME ) , myindex ) ; fd = getfdFromCharaIndex( ChatRoom[ num ].Maker ); lssproto_CHATROOM_send ( fd , buf ); }else if ( ChatRoom[ num ].NowPeople >= MAX_PPLINROOM ) CHAR_talkToCli ( myindex , -1 , "聊天室人数已满!" , CHAR_COLORRED ) ; } void ChatRoom_Agree ( int myindex , int toindex , int YesNo ) { int i ; int Num = CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ); if ( !CHAR_CHECKINDEX ( myindex ) ) return ; if ( !CHAR_CHECKINDEX ( toindex ) ) return ; if ( CHAR_getWorkInt ( toindex , CHAR_WORKCHATROOMTYPE ) != 0 ) return; if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) == 1 ) { if ( ChatRoom[ Num ].NowPeople < MAX_PPLINROOM && YesNo == 1 ) { CHAR_setWorkInt ( toindex , CHAR_WORKCHATROOMTYPE , 2 ) ; CHAR_setWorkInt ( toindex , CHAR_WORKCHATROOMNUM , Num ) ; ChatRoom[ Num ].NowPeople ++ ; for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { if ( ChatRoom[ Num ].MemberList[ i ] == -1 ) { ChatRoom[ Num ].MemberList[ i ] = toindex ; break; } } }else if ( YesNo == 0 ) { CHAR_talkToCli ( toindex , -1 , "您申请的聊天室室长拒绝您的加入!" , CHAR_COLORRED ) ; }else if ( ChatRoom[ Num ].NowPeople >= MAX_PPLINROOM ) { CHAR_talkToCli ( toindex , -1 , "您申请的聊天室人数已满!" , CHAR_COLORRED ) ; CHAR_talkToCli ( myindex , -1 , "聊天室人数已满!" , CHAR_COLORRED ) ; } } ChatRoom_Refresh ( Num ) ; } void ChatRoom_List ( int fd ) { int i ; char buf[128]; char token[2048] = "B|"; for ( i = 0 ; i < MAX_CHATROOM ; i ++ ) { if ( ChatRoom[ i ].useFlag == TRUE ) { sprintf ( buf , "聊天室%2d资讯:室名=>%20s , 室长=>%16s , 人数=>%2d" , i , ChatRoom[ i ].RoomName , CHAR_getChar ( ChatRoom[ i ].Maker , CHAR_NAME ) , ChatRoom[ i ].NowPeople ); sprintf ( buf , "r%d|%s|%d|%s|p%d|" , i , ChatRoom[ i ].RoomName , ChatRoom[ i ].Maker , CHAR_getChar ( ChatRoom[ i ].Maker , CHAR_NAME ) , ChatRoom[ i ].NowPeople ); strncat ( token , buf , sizeof ( buf ) ) ; } } lssproto_CHATROOM_send ( fd , token ) ; } void ChatRoom_Refresh ( int Num ) { int fd , i , RoomLeader = -1 ; char token[2048] ; char token2[2096] ; char buf[64] ; if ( ChatRoom[ Num ].useFlag == TRUE ) { sprintf ( token , "R|r%d|%s|%d|%s|p%d|" , Num , ChatRoom[ Num ].RoomName , ChatRoom[ Num ].Maker , CHAR_getChar ( ChatRoom[ Num ].Maker , CHAR_NAME ) , ChatRoom[ Num ].NowPeople ); for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { if ( ChatRoom[ Num ].MemberList[ i ] != -1 ) { sprintf( buf , "I%d|%s|%s|" , ChatRoom[ Num ].MemberList[ i ] , CHAR_getChar ( ChatRoom[ Num ].MemberList[ i ] , CHAR_NAME ) , CHAR_getChar ( ChatRoom[ Num ].MemberList[ i ] , CHAR_OWNTITLE ) ); strncat ( token , buf , sizeof ( buf ) ) ; } } } for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { if ( ChatRoom[ Num ].MemberList[ i ] != -1 ) { if ( CHAR_getWorkInt ( ChatRoom[ Num ].MemberList[ i ] , CHAR_WORKCHATROOMTYPE ) == 1 ) RoomLeader = 1; else RoomLeader = 0 ; sprintf ( token2 , "%s%d|" , token , RoomLeader ) ; fd= getfdFromCharaIndex ( ChatRoom[ Num ].MemberList[ i ] ); lssproto_CHATROOM_send ( fd , token2 ) ; } } } void ChatRoom_recvall ( int fd , char *data ) { char Head[4]; char message[1024]; char buf[16]; int myindex ; myindex = CONNECT_getCharaindex(fd); if ( !CHAR_CHECKINDEX ( myindex ) )return ; getStringFromIndexWithDelim( data , "|", 1, Head, sizeof(Head)); getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); if ( strcmp ( Head , "C" ) == 0 ) { // 成立频道 if ( !ChatRoom_Create ( myindex , message ) ) print("\nSyu log Create Channel Error" ); }else if ( strcmp ( Head , "D" ) == 0 ) { // 删除频道 if ( !ChatRoom_Destroy ( myindex ) ) print("\nSyu log Destroy Channel Error" ) ; }else if ( strcmp ( Head , "A" ) == 0 ) {// 同意加入频道 getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); getStringFromIndexWithDelim( data , "|", 3, buf, sizeof(buf)); ChatRoom_Agree ( myindex , atoi( message ) , atoi( buf ) ) ; }else if ( strcmp ( Head , "J" ) == 0 ) {// 申请频道 getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); ChatRoom_Join ( myindex , atoi( message ) ) ; }else if ( strcmp ( Head , "L" ) == 0 ) {// 离开频道 ChatRoom_Leave ( myindex ) ; }else if ( strcmp ( Head , "K" ) == 0 ) {//踢出频道 getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); ChatRoom_Kick ( myindex , atoi( message ) ); }else if ( strcmp ( Head , "M" ) == 0 ) { // 更换室长 getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); ChatRoom_Make ( myindex , atoi( message ) ); }else if ( strcmp ( Head , "T" ) == 0 ) {// 频道讯息 getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); ChatRoom_Message ( myindex , message ) ; }else if ( strcmp ( Head , "B" ) == 0 ) {// 聊天室清单 ChatRoom_List ( fd ); }else print("\nSyu log None"); } #endif #endif