📄 recv.c
字号:
#define _RECV_C_#include "version.h"#include "main.h"#include "saacproto_util.h"#include "saacproto_serv.h"#include "recv.h"#include "char.h"#include "db.h"#include "mail.h"#include "lock.h"#include "util.h"#ifdef _SASQL#include "sasql.h"#endif// CoolFish: Family 2001/5/9#include "acfamily.h"#include "version.h"#include <stdlib.h>#include <stdio.h>char retdata[CHARDATASIZE]; char result[CHARDATASIZE]; // Spock +1 2000/11/1#define MAX_PROCESS 16777216#ifdef _VIPvoid saacproto_ACServerLogin_recv( int ti,char* servername , char* serverpas, int checkvip ){ login_game_server( ti , servername , serverpas, checkvip, result , sizeof( result ) , retdata , sizeof( retdata )); saacproto_ACServerLogin_send( ti ,result ,retdata );}#elsevoid saacproto_ACServerLogin_recv( int ti,char* servername , char* serverpas ){ login_game_server( ti , servername , serverpas, result , sizeof( result ) , retdata , sizeof( retdata )); saacproto_ACServerLogin_send( ti ,result ,retdata );}#endif/* 必□丞扔□田□互失市它件玄扔□田□井日夫弘失它玄允月[ int fd : 覆擂socket*/void saacproto_ACServerLogout_recv( int ti ){ logout_game_server( ti );}void saacproto_ACCharLoad_recv( int ti,char* id,char* pas,char* charname , int lock,char* opt , int mesgid){ // Spock 2000/10/31 static int process = 0; char buf[16]; // Spock end#ifdef _NewSave int charindex = -1;#endif if( !is_game_server_login( ti ) ){#ifdef _NewSave saacproto_ACCharLoad_send( ti , FAILED , "not login" , mesgid, charindex );#else saacproto_ACCharLoad_send( ti , FAILED , "not login" , mesgid );#endif return; } process++; if ( process > MAX_PROCESS ) process = 1; snprintf( buf , sizeof(buf) , "%d" , process ); charLoadCallback(ti,0,id,pas,charname,buf,"",lock,mesgid); // Spock 2000/10/31 //log( "读取档案: 附加作业 %s %s, 进程=%d\n", id,pas,process ); // Spock end}/* 平乓仿忡绣 char *id : ID char *pas : 天允歹□升 char *charname : 平乓仿 char *opt : 左皿扑亦件 侬 [ CharList及午五卞丢乒午仄化忒允树 char *charinfo : 白央奶伙卞忡绣允月平乓仿弁正及旦 □正旦树 [ int id : 丢永本□斥id*/#ifdef _NewSavevoid saacproto_ACCharSave_recv( int ti, char* id, char *charname,char* opt , char* charinfo , int unlock , int mesgid , int charindex )#elsevoid saacproto_ACCharSave_recv( int ti, char* id, char *charname,char* opt , char* charinfo , int unlock , int mesgid )#endif{ char process[16]; int ret; if( !is_game_server_login(ti) ){ saacproto_ACCharSave_send( ti , FAILED , "not login" , mesgid ); return; }#ifdef _NewSave ret = charSave( ti, id, charname, opt, charinfo, unlock,mesgid, charindex );#else ret = charSave( ti, id, charname, opt, charinfo, unlock,mesgid );#endif snprintf( process , sizeof(process) , "%d" , ret );// log( "unlock:%d, process:%s\n", unlock, process); if( unlock) { dummyCallback(ti,0,id,"dummy",charname,process,"",mesgid,0); } log("玩家已保存保存\n");}void saacproto_ACCharList_recv( int ti,char* id,char* pas , int mesgid){ static int process=0; char buf[10]; //log(" get_charlist "); process++; if (process > MAX_PROCESS) process=1; snprintf(buf, sizeof(buf), "%d", process); if( !is_game_server_login( ti ) ){ saacproto_ACCharList_send( ti , FAILED , "not login" , mesgid ); return; } charListCallback(ti,0,id,pas,"",buf,"0",mesgid,0); log( "档案列表: %s\n", id );}void saacproto_ACCharDelete_recv( int ti,char* id,char* pas, char* charname , char *option , int mesgid){ if( !is_game_server_login(ti) ){ saacproto_ACCharDelete_send( ti , FAILED , "not login" , mesgid ); return; } // Nuke charDeleteCallback(ti,0,id,pas,charname,"0","",mesgid,0); log( "档案删除: 附加作业 %s %s\n",id , pas );}void saacproto_ACLock_recv( int ti ,char* id,int lock,int mesgid ){ if( !is_game_server_login(ti) ){ saacproto_ACLock_send( ti , FAILED , "not login" , mesgid ); return; } // Arminius 7.25 test unlock log("ACLock recv:%d\n",lock); if (lock==2) { char buf[4096]; if (GetMemLockState(getHash(id) & 0xff, id, buf)) { sprintf(retdata, "USRLOCKED:%s", buf); } else { sprintf(retdata, "USRUNLOCKED:%s", buf); } log(retdata); } else if (lock==3) { int proc; if (DeleteMemLock(getHash(id) & 0xff, id, &proc)) { sprintf(retdata, "GMUNLOCKSUCCESS"); } else { sprintf(retdata, "GMUNLOCKFAIL"); } log(retdata); } else if (lock==4) { DeleteMemLockServer(id); sprintf(retdata, "GMUNLOCKALL"); } else { if ( lockUser( getGSName( ti ) , id , "0" , lock , result,sizeof(result), retdata ,sizeof( retdata ) , "0" , "0") < 0 ) { log( "锁定用户: %s 失败\n" , id ); } else { log( "锁定用户: %s 成功\n" , id ); } } // Spock end saacproto_ACLock_send( ti , result , retdata , mesgid );}void saacproto_ACUCheck_recv( int ti , char *id , int status ){ if( !is_game_server_login(ti) ){ log( "服务器发现账号:%s status:%d\n", id, status ); return; } if( status == 0 ){ log( "用户 %s 在 %s 并未锁定!\n", id , getGSName( ti ) ); saacproto_ACKick_recv( ti, id, 6, -1); } else { log( "用户 %s 在 %s 已锁定!\n", id , getGSName( ti ) );#ifdef _WAEI_KICK saacproto_ACKick_recv( ti, id, 1, -1);#endif }}void saacproto_DBUpdateEntryString_recv( int fd, char* table, char* key, char* value, int msgid, int msgid2 ){ int r; r = dbUpdateEntryString( table, key, value ); if( r != 0 ){ log( "failed: DBUpdateEntryString err !!\n"); }/* 2003/06/26 if( r == 0 ){// saacproto_DBUpdateEntryString_send( fd, SUCCESSFUL,table,key, msgid,msgid2 ); } else {// saacproto_DBUpdateEntryString_send( fd, FAILED,table,key, msgid,msgid2 ); }*/}void saacproto_DBDeleteEntryString_recv( int fd, char* table, char* key, int msgid, int msgid2 ){ int r; r = dbDeleteEntryString( table,key ); if( r == 0 ){ saacproto_DBDeleteEntryString_send( fd,SUCCESSFUL,table,key, msgid,msgid2 ); } else { saacproto_DBDeleteEntryString_send( fd,FAILED,table,key, msgid,msgid2 ); }}void saacproto_DBGetEntryString_recv( int fd, char* table, char* key, int msgid, int msgid2 ){ char output[16384]; int r; r = dbGetEntryString( table, key, output, sizeof( output) ); if( r == 0 ){ saacproto_DBGetEntryString_send( fd,SUCCESSFUL,output,table,key, msgid,msgid2 ); } else { saacproto_DBGetEntryString_send( fd,FAILED,"",table,key, msgid,msgid2 ); } }void saacproto_DBUpdateEntryInt_recv( int fd, char* table, char* key, int value, char *info, int msgid, int msgid2){ if( !is_game_server_login(fd) ){ saacproto_DBUpdateEntryInt_send( fd, FAILED, "","",msgid, msgid2 ); return; } if( dbUpdateEntryInt( table , key , value, info ) == 0 ){ saacproto_DBUpdateEntryInt_send( fd , SUCCESSFUL ,table,key, msgid, msgid2 ); } else { saacproto_DBUpdateEntryInt_send( fd , FAILED , table,key, msgid, msgid2 ); }}#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPCvoid saacproto_UpdataStele_recv( int fd , char *cdkey , char *name , char *title , int level , int trns , int time , int floor ){ int i, min=140, minnum=-1, nameflag=-1; for ( i=0; i<MAX_HERO_LIST; i ++ ) { if( atoi( Herolist[i][6] ) < min ) { min = atoi (Herolist[i][6]) ; minnum=i; } if ( strcmp ( Herolist[i][0] , cdkey ) == 0 && strcmp ( Herolist[i][1] , name ) == 0 ) nameflag = i ; } if( strcmp ( cdkey , "FirstLoad") == 0 && strcmp ( name , "LoadHerolist") == 0 && floor == 999 ) Send_A_herolist( fd ); else if ( nameflag != -1 && floor > atoi(Herolist[nameflag][6]) ) { Send_S_herolist ( Herolist[nameflag][0] , Herolist[nameflag][1] , cdkey , name , title , level , trns , floor ) ; sprintf ( Herolist[nameflag][2] , "%s" , title ) ; sprintf ( Herolist[nameflag][3] , "%d" , level ) ; sprintf ( Herolist[nameflag][4] , "%d" , trns ) ; sprintf ( Herolist[nameflag][5] , "%d" , time ) ; sprintf ( Herolist[nameflag][6] , "%d" , floor ) ; SAVE_herolist( fd ); }else if ( nameflag == -1 && floor > min ) { Send_S_herolist ( Herolist[minnum][0] , Herolist[minnum][1] , cdkey , name , title , level , trns , floor ) ; sprintf ( Herolist[minnum][0] , "%s" , cdkey ) ; sprintf ( Herolist[minnum][1] , "%s" , name ) ; sprintf ( Herolist[minnum][2] , "%s" , title ) ; sprintf ( Herolist[minnum][3] , "%d" , level ) ; sprintf ( Herolist[minnum][4] , "%d" , trns ) ; sprintf ( Herolist[minnum][5] , "%d" , time ) ; sprintf ( Herolist[minnum][6] , "%d" , floor ) ; SAVE_herolist( fd ); }}#endifvoid saacproto_DBGetEntryRank_recv( int fd, char* table, char* key, int msgid, int msgid2){ int rk,c; if( !is_game_server_login(fd) ){ saacproto_DBGetEntryRank_send( fd, FAILED, 0,0,"","",msgid, msgid2 ); return; } dbGetEntryRank( table, key , &rk, &c ); if( rk <0 ){ saacproto_DBGetEntryRank_send( fd, FAILED, -1, -1, table, key, msgid, msgid2 ); } else { saacproto_DBGetEntryRank_send( fd, SUCCESSFUL, rk, c, table, key, msgid, msgid2 ); }}void saacproto_DBDeleteEntryInt_recv( int fd, char* table, char* key, int msgid, int msgid2){ if( !is_game_server_login(fd) ){ saacproto_DBDeleteEntryInt_send( fd, FAILED,"","",msgid, msgid2 ); return; } if( dbDeleteEntryInt( table, key ) < 0 ){ saacproto_DBDeleteEntryInt_send( fd, FAILED, table, key, msgid, msgid2 ); } else { saacproto_DBDeleteEntryInt_send( fd, SUCCESSFUL, table, key, msgid, msgid2 ); }} void saacproto_DBGetEntryInt_recv( int fd, char* table, char* key, int msgid, int msgid2){ int r ; int output; if( !is_game_server_login(fd) ){ saacproto_DBGetEntryInt_send( fd, FAILED,-1,"","",msgid, msgid2 ); return; } r = dbGetEntryInt( table, key, &output ); if( r < 0 ){ saacproto_DBGetEntryInt_send( fd, FAILED, -1, table, key, msgid, msgid2); } else { saacproto_DBGetEntryInt_send( fd, SUCCESSFUL, output, table, key, msgid, msgid2 ); }}void saacproto_DBGetEntryByRank_recv( int fd, char* table, int start, int end, int msgid , int msgid2){ char output[16384]; int r; if( !is_game_server_login(fd) ){ saacproto_DBGetEntryByRank_send( fd, FAILED,"","",msgid, msgid2 ); return; } r = dbGetEntryRankRange( table, start, end, output, sizeof( output )); if( r < 0 ){ saacproto_DBGetEntryByRank_send( fd, FAILED, "", table, msgid, msgid2 ); } else { saacproto_DBGetEntryByRank_send( fd, SUCCESSFUL, output,table, msgid, msgid2 ); }}void saacproto_DBGetEntryByCount_recv( int fd, char* table, int count_start, int num, int msgid , int msgid2){ char output[16384]; int r; if( !is_game_server_login(fd) ){ saacproto_DBGetEntryByCount_send( fd, FAILED,"",table,count_start,msgid, msgid2 ); return; } r = dbGetEntryCountRange( table, count_start, num, output, sizeof(output)); if( r < 0 ){ saacproto_DBGetEntryByCount_send( fd, FAILED, "", table, count_start, msgid, msgid2 ); } else { saacproto_DBGetEntryByCount_send( fd, SUCCESSFUL, output, table, count_start, msgid, msgid2 ); }}void saacproto_Broadcast_recv( int fd, char* id, char* charname, char* message, int flag){ if( !is_game_server_login( fd) ){ log( "Broadcast: no login. id:%s charname:%s message:%s flag:%d\n", id, charname, message , flag ); return; } gmsvBroadcast( fd, id, charname, message , flag );}void saacproto_Message_recv( int fd, char* id_from, char* charname_from, char* id_to, char* charname_to, char* message, int option ){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -