📄 recv.c
字号:
#define _RECV_C_#include "version.h"#include "main.h"#include "saacproto_util.h"#include "saacproto_serv.h"#include "saacproto_lserver.h"#include "saacproto_work.h"#include "recv.h"#include "char.h"#include "db.h"#include "mail.h"#include "lock.h"#include "util.h"#ifdef _SASQL1#include "sasql.h"#endif// CoolFish: Family 2001/5/9#include "acfamily.h"#include "version.h"#include <stdlib.h>#include <stdio.h>#ifdef _PAUCTION_MAN#include "auction.h"#endif#ifdef _DEATH_CONTEND#include "deathcontend.h"#endif#include "defend.h"#ifdef _UNIVERSE_CHATROOM#include "chatroom.h"#endif#ifdef _RECAL_BACKUP_PLAYER // WON 回溯功能#include <dirent.h>#include <sys/stat.h>#define MAX_HAVE_ITEM 20#define MAX_POOL_ITEM 30#define MAX_HAVE_PET 5#define MAX_POOL_PET 20static int char_data_count=0;#endif#ifdef _CK_ONLINE_PLAYER_COUNT // WON ADD 计算线上人数struct play_count{ int playcount;};struct play_count online_player[MAXCONNECTION];#endifchar retdata[CHARDATASIZE]; char result[CHARDATASIZE]; // Spock +1 2000/11/1#define MAX_PROCESS 16777216void 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 );}/* 必□丞扔□田□互失市它件玄扔□田□井日夫弘失它玄允月[ 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 (!sasql_query(id,pas)){ if(!sasql_register(id,pas)){ log("密码错误或没有注册\n"); saacproto_ACCharList_send( ti , FAILED , "Password error" , mesgid); return;}} 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; }#ifdef _CHANGEGALAXY if( isChangeGalaxyLocked( id) ) { log(" 因星系移民被锁 "); saacproto_ACCharLoad_send( ti , FAILED , "CHANGE_GALAXY" , mesgid, charindex ); return; }#endif#ifdef _UNLOCKPOOL // 登入时检查是否已在UnlockPool中 if( inUnlockPool(id) ) { log(" 已经在UNLOCKPOOL中 "); saacproto_ACCharLoad_send( ti , FAILED , "server load too high" , mesgid , charindex); return; }#endif process++; if ( process > MAX_PROCESS ) process = 1; snprintf( buf , sizeof(buf) , "%d" , process ); if( addWorkerTask( id, pas , "2", charLoadCallback , ti , id , pas , charname , buf , "" , lock, mesgid) < 0 ){#ifdef _NewSave saacproto_ACCharLoad_send( ti , FAILED , "server load too high" , mesgid , charindex);#else saacproto_ACCharLoad_send( ti , FAILED , "server load too high" , mesgid );#endif return; } // Spock 2000/10/31 //log( "读取档案: 附加作业 %s %s, 进程=%d\n", id,pas,process ); // Spock end}#ifdef _RELOGINvoid saacproto_ACCharLoadII_recv( int ti,char* id,char* pas,char* charname , int lock,char* opt , int mesgid,int gs1, int gs2){ char buf[16]; int charindex = -1; if( !is_game_server_login( ti ) ){ saacproto_ACCharLoad_send( ti , FAILED , "not login" , mesgid, charindex ); return; } // 检查Buffer中的资料是否符合 // 检查原先从Wgs传回CharLoad做了什麽事 // 更新名片资料}#endif/* 平乓仿忡绣 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) {#ifdef _UNLOCKPOOL if( addUnlockPool( ti, id, charname, process, mesgid) <0 ) {#else if( addWorkerTask( id , "dummy" , "3" , dummyCallback , ti , id , "dummy" , charname , process ,"", mesgid , 0 ) < 0 ) { #endif log("游戏退出失败, 进程=%s\n" , process ); } else { log("游戏退出成功, 进程=%s\n" , process ); } } else { log("自动保存\n\n"); } log("在线玩家保存\n");}#ifdef _RELOGINvoid saacproto_ACCharSaveII_recv( int ti, char* id, char *charname,char* opt , char* charinfo , int unlock , int mesgid , int charindex ){ char process[16]; int ret; if( !is_game_server_login(ti) ){ saacproto_ACCharSave_send( ti , FAILED , "not login" , mesgid ); return; } ret = charSave( ti, id, charname, opt, charinfo, unlock,mesgid, charindex ); // 储存人物资料 // 记录相关资讯 // 不送GE至WGS // 不更新名片资料 if (unlock) {#ifdef _UNLOCKPOOL if( addUnlockPool( ti, id, charname, process, mesgid) <0 ) {#else if( addWorkerTask( id , "dummy" , "3" , dummyCallback , ti , id , "dummy" , charname , process ,"", mesgid , 0 ) < 0 ) { #endif log("游戏退出失败, 进程=%s\n" , process ); } else { log("游戏退出成功, 进程=%s\n" , process ); } } else { log("自动保存\n\n"); } log("在线玩家保存\n");}#endifvoid 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);#ifdef _CHANGEGALAXY if( isChangeGalaxyLocked( id) ) { log(" 因星系移民被锁 "); saacproto_ACCharList_send( ti , FAILED , "CHANGE_GALAXY" , mesgid ); return; }#endif if( !is_game_server_login( ti ) ){ saacproto_ACCharList_send( ti , FAILED , "not login" , mesgid ); return; } if( addWorkerTask( id , pas , "1" , charListCallback , ti , id , pas , "", buf ,"0", mesgid , 0 ) < 0 ){ saacproto_ACCharList_send( ti , FAILED , "server load too high", mesgid ); return; } 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; }#ifdef _DEATH_FAMILY_LOGIN_CHECK //无法删除人物资料 saacproto_ACCharDelete_send( ti , FAILED , "server load too high", mesgid ); return;#endif#ifdef _DEATH_CONTEND //无法删除人物资料 saacproto_ACCharDelete_send( ti , FAILED , "server load too high", mesgid ); return;#endif // Nuke if( addWorkerTask( id , pas , "4" , charDeleteCallback , ti , id , pas , charname , "0" ,"", mesgid , 0 ) < 0 ){ saacproto_ACCharDelete_send( ti , FAILED , "server load too high", mesgid ); return; } 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 {#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 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( "UCHECK: server not logging in: ID:%s status:%d\n", id, status ); return; } if( status == 0 ){ log( "UCHECK: user %s is not locked by %s\n", id , getGSName( ti ) );#ifdef _DELAY_UNLOCK //remeber the cdkey into delay unlock list. if( UNlockM_addPlayer( id) != -1 ){ log( "remeber:[%s] unlock 15min later!!\n", id); saacproto_ACKick_recv( ti, id, 6, -1); //unlock }#ifdef _WAEI_KICK saacproto_ACKick_recv( ti, id, 1, -1);#endif#endif } else { log( "UCHECK: user %s is still locked by %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 );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -