📄 recv.c
字号:
} for(i=0;i<30;i++){ memset(temp, 0, sizeof(temp)); easyGetTokenFromString( char_data , count , temp , sizeof( temp )); item_pet_chang.pool_item[i] = atoi(temp); count++; } for(i=0;i<5;i++){ memset(temp, 0, sizeof(temp)); easyGetTokenFromString( char_data , count , temp , sizeof( temp )); item_pet_chang.have_pet[i] = atoi(temp); count++; } for(i=0;i<20;i++){ memset(temp, 0, sizeof(temp)); easyGetTokenFromString( char_data , count , temp , sizeof( temp )); item_pet_chang.pool_pet[i] = atoi(temp); count++; } // 处理部分回溯功能 recal_part_backup(fd, uid, userfdid, GmCliId, id, char_num, date); } }void recal_part_backup(int fd, char *uid, int userfdid, int GmCliId, char *id, int char_num, int date){/* extern struct ITEM_PET_CHANG item_pet_chang; FILE *fp; char filename[128], filename2[128], body[128]; char onlin_char[65500], backup_char[65500]; char *c_ptr, c_temp; int i=0; char *temp=NULL, *temp2, *temp3, *temp4, *temp5, *msg1, delim[20], out_msg[65530]; // 线上人物 { c_ptr=onlin_char; snprintf(body , sizeof(body ) , "%s.%d.char" , id , char_num ); makeDirFilename(filename , sizeof(filename), chardir , getHash(id) ,body); if( !(fp=fopen(filename, "r")) ){ log("\n open (%s) file err", filename ); return; } memset(onlin_char, 0, sizeof(onlin_char)); do{ c_temp = fgetc(fp); *c_ptr=c_temp; c_ptr++; }while(c_temp != EOF); *c_ptr='\0'; fclose(fp); } // 备份人物 { c_ptr=backup_char; snprintf(body , sizeof(body ) , "%s.%d.char" , id , char_num ); makeDirFilename(filename , sizeof(filename), chardir , getHash(id) ,body); sprintf(filename2, "%s/%s", BACKUP_DIR, filename); if( !(fp=fopen( filename2, "r" )) ){ log("\n won test 100 ==> open (%s) file err", filename ); return; } memset(backup_char, 0, sizeof(backup_char)); do{ c_temp = fgetc(fp); *c_ptr=c_temp; c_ptr++; }while(c_temp != EOF); *c_ptr='\0'; fclose(fp); } log("\n won test 1 ==>"); { for(i=0;i<5;i++){ if( item_pet_chang.equit_item[i] != i ){ log("\n won test 2 ==> i(%d) item(%d)", i, item_pet_chang.equit_item[i]); // 线上人物 while( temp==NULL ){ log("\n won test 2.1 ==> temp(%s)", temp); sprintf( delim, "item%d=", i); log("\n won test 2.2 ==> delim(%s)", delim); temp=strstr( onlin_char, delim); log("\n won test 2.3 ==> temp(%s)", temp); if((i==0)&&(temp==NULL)){ sprintf( delim, "flg2="); temp=strstr( onlin_char, delim); log("\n won test 2.4 ==> temp(%s)", temp); break; } i--; } log("\n won test 3 ==> temp(%s)", temp); temp2=strstr( temp, "\n"); log("\n won test 3.1 ==> temp2(%s)", temp2); msg1=(char*)calloc( 1,sizeof(char)*strlen(onlin_char)-strlen(temp2)+1); snprintf(msg1, strlen(onlin_char)-strlen(temp2), "%s", onlin_char ); log("\n won test 3.2 ==> msg1(%s)", msg1); // 备份人物 sprintf( delim, "item%d=", item_pet_chang.equit_item[i]-5+1); temp3=strstr( backup_char, delim); temp4=strstr( temp3, "\n"); temp5=(char*)calloc( 1,sizeof(char)*strlen(temp3)-strlen(temp4)+1); snprintf(temp5, strlen(temp3)-strlen(temp4), "%s", temp3); log("\n won test 4 ==> temp5(%s)", temp5); // 组合 memset(out_msg, 0, sizeof(out_msg)); strcpy(out_msg, msg1); strcat(out_msg, temp5); // 回溯的部分 strcat(out_msg, temp2); log("\n won test 5 ==> out_msg(%s)", out_msg); } } }*/}#endif#ifdef _CHECKFMSCHEDULE // Syu ADD 透过AC确认家族挑战排程void saacproto_ACCheckSchedule_recv(int fd,char *data){ extern gmsv gs[MAXCONNECTION]; int i,j; char filename[256]; char token[256]; char line[64]; char line1[64]; char line2[64]; FILE* fpm; easyGetTokenFromBuf(data, '|', 2, line1, sizeof(line1)); j = atoi(data); snprintf( filename ,sizeof( filename ) ,"%s/%d.%s" , "family",j,"fmschedule.txt"); if( !(fpm=fopen( filename , "r")) ) { log("\nSyu log open file error!!"); sprintf(line2,"%d %s",j,"FALSE"); for (i=0; i<MAXCONNECTION; i++) if (gs[i].use && gs[i].name[0]) saacproto_ACCheckSchedule_send(i,line2); } else { fgets( token , sizeof(token) , fpm ); easyGetTokenFromBuf(token, '|', 2, line, sizeof(line)); log("\nSyu test line -> %s , %s",line,line1); if ( atoi(line1) > atoi(line) ) { sprintf(line2,"%d %s",j,"TRUE"); for (i=0; i<MAXCONNECTION; i++) if (gs[i].use && gs[i].name[0]) saacproto_ACCheckSchedule_send(i,line2); } else { sprintf(line2,"%d %s",j,"FALSE"); for (i=0; i<MAXCONNECTION; i++) if (gs[i].use && gs[i].name[0]) saacproto_ACCheckSchedule_send(i,line2); } }}#endifvoid saacproto_ACManorPKAck_recv(int fd, char *data){#ifdef __FAMILY#ifdef _AC_SEND_FM_PK // WON ADD 庄园对战列表储存在AC // 不处理#else extern gmsv gs[MAXCONNECTION]; int i; for (i=0; i<MAXCONNECTION; i++) { if (gs[i].use && gs[i].name[0]) { saacproto_ACManorPKAck_send(i, data); } }#endif#endif}#ifdef _AUCTIONEERvoid saacproto_ACAuctionSold_recv(int fd, char *data){ AuctionSold(data);}#endif#ifdef _WAEI_KICKvoid saacproto_ACKick_recv( int ti ,char* id, int lock,int mesgid ){ if( ti != -1 ) { if( !is_game_server_login(ti) ){ //MAXCONNECTION saacproto_ACKick_send( ti , 0 , "not login" , mesgid ); return; } } sprintf(retdata, "ACTION !!"); //"LSLOCK","KICK","DEUNLOCK","UNLOCKALL","LOCK","TYPE", "UNLOCK" switch( lock) { case 0://LSLOCK#ifdef _LOCK_SERVER LServer_SAUNLock_send( ti, id, mesgid, 0);#endif break; case 1: //跨星球踢人 KICK { int i; for(i=0;i<MAXCONNECTION;i++) { if( is_game_server_login(i) ){ saacproto_ACKick_send( i , 1 , id , mesgid ); } } } break; case 2: //DEUNLOCK break; case 3: //UNLOCKALL { extern gmsv gs[MAXCONNECTION]; DeleteMemLockServer( gs[ti].name); sprintf(retdata, "GM UNLOCK ALL"); } break; case 4: //LOCK#ifdef _LOCK_ADD_NAME if ( lockUser( getGSName( ti ) , id , "" , "0" , lock , result,sizeof(result), retdata ,sizeof( retdata ) , "0" , "0") < 0 ) {#else if ( lockUser( getGSName( ti ) , id , "0" , lock , result,sizeof(result), retdata ,sizeof( retdata ) , "0" , "0") < 0 ) {#endif sprintf(retdata, "LOCK USER !!"); } break; case 5: //查询玩家状态 TYPE { char buf[4096]; if (GetMemLockState(getHash(id) & 0xff, id, buf)) { sprintf(retdata, "USR LOCKED: %s", buf); } else { sprintf(retdata, "USR UNLOCKED: %s", buf); } } break; case 6: //MEMORY UNLOCK; UNLOCK { char result[100], retdata[100], process[16]; int ret = 0;#ifdef _LOCK_ADD_NAME ret = lockUser( getGSName(ti), id , "" , "0" , 0 , result , sizeof( result ) , retdata , sizeof( retdata ) , "0" , "0");#else ret = lockUser( getGSName(ti), id , "0" , 0 , result , sizeof( result ) , retdata , sizeof( retdata ) , "0" , "0");#endif if( strcmp( result , SUCCESSFUL ) == 0 ){ log( "UCHECK: unlock %s OK\n" , id ); } else { log( "UCHECK: unlock %s FAILED\n" , id ); return; } snprintf( process , sizeof(process) , "%d" , ret );#ifdef _UNLOCKPOOL if( addUnlockPool( ti, id, "", process, mesgid) <0 ) {#else if( addWorkerTask( id , "dummy" , "3" , dummyCallback , ti , id , "dummy" , charname , process ,"", mesgid , 0 ) < 0 ) {#endif log("Game end error, process=%s\n" , process ); }else { log("Game end :process=%s\n" , process ); } } break;#ifdef _FIX_MESSAGE case 7: { char buf[4096]; int i; if (GetMemLockState(getHash(id) & 0xff, id, buf)) { log("\n won test 20.1 ==>"); // 有lock的话踢人 for(i=0;i<MAXCONNECTION;i++) { if( is_game_server_login(i) ){ saacproto_ACKick_send( i , 1 , id , mesgid ); } } } else { // 没有lock的话,送 game end char result[100], retdata[100], process[16]; int ret = 0; log("\n won test 20.2 ==>");#ifdef _LOCK_ADD_NAME ret = lockUser( getGSName(ti), id , "" , "0" , 0 , result , sizeof( result ) , retdata , sizeof( retdata ) , "0" , "0");#else ret = lockUser( getGSName(ti), id , "0" , 0 , result , sizeof( result ) , retdata , sizeof( retdata ) , "0" , "0");#endif snprintf( process , sizeof(process) , "%d" , ret );#ifdef _UNLOCKPOOL if( addUnlockPool( ti, id, "", process, mesgid) <0 ) {#else if( addWorkerTask( id , "dummy" , "3" , dummyCallback , ti , id , "dummy" , charname , process ,"", mesgid , 0 ) < 0 ) {#endif log("Game end error, process=%s\n" , process ); }else { log("Game end :process=%s\n" , process ); } } } break;#endif case 10: //跨星球踢人不含load该星球 { int i; for(i=0;i<MAXCONNECTION;i++) { if( is_game_server_login(i) && i != ti ){ saacproto_ACKick_send( i , 1 , id , mesgid ); } } } break; } saacproto_ACKick_send( ti, 0, retdata, mesgid );}#endif#ifdef _WORKER_AUTO_LOGOUT // WON ADD GS断线自动送LOGOUT给WORKERvoid Worker_send_logout( int ti ,char* id ){ char result[100], retdata[100], process[16]; int ret = 0; #ifdef _LOCK_ADD_NAME ret = lockUser( getGSName(ti), id , "" , "0" , 0 , result , sizeof( result ) , retdata , sizeof( retdata ) , "0" , "0");#else ret = lockUser( getGSName(ti), id , "0" , 0 , result , sizeof( result ) , retdata , sizeof( retdata ) , "0" , "0");#endif snprintf( process , sizeof(process) , "%d" , ret );#ifdef _UNLOCKPOOL if( addUnlockPool( ti, id, "", process, -1) <0 ) {#else if( addWorkerTask( id , "dummy" , "3" , dummyCallback , ti , id , "dummy" , charname , process ,"", -1 , 0 ) < 0 ) {#endif log("\n Game end error, process(%s)\n" , process ); }else { log("\n Game end :process(%s)\n" , process ); }}#endif#ifdef _NEW_PLAYERGOLDvoid saacproto_ACNewPlayerList_recv( int fd, char *CdKey, char *UserName, int UserIndex, int RunType){ int ret=-1; switch( RunType){ case 1: //Del ret = DelNEWPlayerfromFile( CdKey, UserName, RunType); break; case 2: //Add ret = AddNEWPlayertoFile( CdKey, UserName, strlen( CdKey)); break; } saacproto_ACNewPlayerList_send( fd, CdKey, UserName, UserIndex, ret);}#endif#ifdef _DEFEND_NEWUSERSvoid saacproto_DefendList_recv( int fd, int type, char *data){ switch( type){ case 1: DEFEND_LoadUserForList( data); break; case 2: DEFEND_LoadScoreForList( data); break; case 3: //检查积分 break; case 4: //删除积分纪录 break; }}void saacproto_CheckDefendScore_recv( int fd, int userindex, char *cdkey, char *name){ if( userindex == -1 ) return; if( cdkey == NULL ) return; if( name == NULL ) return; DEFEND_CheckScoreForList( fd, userindex, cdkey, name);}#endif#ifdef _PAUCTION_MANvoid saacproto_ACItemAuction_recv( int fd, char *ITEMNAME, char *data, int itemID, int ret, int flg){ log( "ACItemAuction( %d, %s, %s, %d, %d, %d)\n", fd, ITEMNAME, data, itemID, ret, flg); IAData_ITEM( fd, itemID, ITEMNAME, data, ret, flg);}#endif#ifdef _FIX_WORKSvoid saacproto_WORKLogin_recv( int fd , char* workname, char* workpass, int work_port ){}#endif#ifdef _NEW_PLAYERGOLDvoid saacproto_LoadNEWPlayer_recv( int ti , int charaindex, char* filename){ char Token[256]; if( LoadNEWPlayerListAdd( filename) <= 0 ){ sprintf( Token, "重读新手名单-错误。"); }else{ sprintf( Token, "重读新手名单-完成。"); } saacproto_LoadNEWPlayer_send( ti, charaindex, Token);}#endif#ifdef _DEATH_CONTENDvoid saacproto_PKLISTGETDATA_recv( int fd, int start, int count){ log( "PKLISTGETDATA_recv( %d, %d) \n", start, count); PKLIST_GetPkTeamListData( fd, start, count );}void saacproto_PKLISTGETDATA_send( int fd, char *ret, int endti, char *data){ saacproto_CreateHeader( saacproto.work , "PKLISTGETDATA" ); saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( endti ) ,saacproto.workbufsize ); saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( data ) ,saacproto.workbufsize ); saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( ret ) ,saacproto.workbufsize ); saacproto_Send( fd , saacproto.work );}void saacproto_PKLISTUPDATE_recv( int fd, int menum, char *mecdkey, int tonum, char *tocdkey, int winer, int flg){ PKLIST_UpdatePkTeamList( fd, menum, mecdkey, tonum, tocdkey, winer, flg);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -