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( "服务器发现账号:%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 charLoadCallback( int ti , int auth , char *c0, char* c1 , char *c2 , char *c3, char *c4, int i0 , int i1 ) { // Spock deleted 2000/11/2 //static int process_id = 0; // CoolFish: Init charindex 2001/10/16 #ifdef _NewSave int charindex = -1; #else int charindex; #endif char loadbuf[CHARDATASIZE]; char infobuf[CHARDATASIZE]; int lock = i0; char *process = c3; char *id = c0; char *passwd = c1; char *charname = c2; int mesgid = i1; char *deadline = c4; // Spock deleted 2000/11/2 //process_id++; if( auth != 0 ){ char data[100]; snprintf( data, sizeof( data ), "%d" , auth ); #ifdef _NewSave saacproto_ACCharLoad_send( ti , FAILED , data, mesgid, charindex ); #else saacproto_ACCharLoad_send( ti , FAILED , data, mesgid ); #endif return; } if( isLocked( id ) ){ int process=atoi(c3); #ifdef _NewSave saacproto_ACCharLoad_send( ti , FAILED , "locked" , mesgid, charindex ); #else saacproto_ACCharLoad_send( ti , FAILED , "locked" , mesgid ); #endif DeleteMemLock(getHash(id) & 0xff, id, &process); // Èç¹ûAPÎÞËøÔòAC½âËø log("\n (%s) ACͬһÐÇϵÖظ²µÇÈ룬ÌßÈË!! ", id ); saacproto_ACKick_recv( ti, id, 1, -1); //ÌßÈË checkGSUCheck(id); return; } charindex = getCharIndexByName( id , charname ); #ifdef _NewSave //log("\nµµ°¸×°ÔØÐòºÅ:%d Õ˺Å:%s Ãû×Ö:%s\n", charindex, id, charname); #endif if( charindex < 0 ){ /* ƽÅҷ»¥Ðå»þØÆئÖм°Æ¥¾Þ·Â¡õئ¼°·Ö */ #ifdef _NewSave saacproto_ACCharLoad_send( ti , FAILED , "char nonexistent" , mesgid , charindex ); #else saacproto_ACCharLoad_send( ti , FAILED , "char nonexistent" , mesgid ); #endif return; } // log( "loadCharOne: id:[%s] char:[%s]\n", id, charname ); if( loadCharOne( id , charindex , loadbuf ,sizeof( loadbuf ))<0){ #ifdef _NewSave saacproto_ACCharLoad_send( ti , FAILED , "cannot load ( disk i/o error?)", mesgid, charindex ); #else saacproto_ACCharLoad_send( ti , FAILED , "cannot load ( disk i/o error?)", mesgid ); #endif return; }else{ #ifdef _CHAR_POOLITEM checkCharPoolItem( id); #endif #ifdef _CHAR_POOLITEM checkCharPoolPet( id); #endif } {//ttom char *c_ptr; c_ptr=loadbuf; while(*c_ptr!='\0'){ if( IS_2BYTEWORD(*c_ptr) ){ if(*(c_ptr+1)==' '){ *(c_ptr+1)=0x41; } c_ptr++; if(*c_ptr=='\0') break; } c_ptr++; } }//ttom if( lock ){ char result[100]; char retdata[100]; #ifdef _LOCK_ADD_NAME if( lockUser( getGSName(ti) , id , charname, passwd , 1 , result , sizeof( result ) , retdata , sizeof( retdata ) , process , deadline) <0 ){ #else // Spock 2000/11/2 if( lockUser( getGSName(ti) , id , passwd , 1 , result , sizeof( result ) , retdata , sizeof( retdata ) , process , deadline) <0 ){ #endif saacproto_ACCharLoad_send( ti , FAILED, "lock FAIL!!" , mesgid , charindex ); return; } } memset( infobuf , 0 , sizeof( infobuf )); getCharInfoFromString( loadbuf , infobuf ); makeStringFromEscaped( infobuf ); #ifdef _NewSave saacproto_ACCharLoad_send( ti , SUCCESSFUL , infobuf , mesgid, charindex ); #else saacproto_ACCharLoad_send( ti , SUCCESSFUL , infobuf , mesgid); #endif #ifdef _WAEI_KICK saacproto_ACKick_recv( ti, id, 10, -1); //ÌßÆäËûÐÇϵ #endif } #ifdef _NewSave int charSave( int ti , char *id , char *charname , char *opt , char *charinfo, int unlock , int mesgid , int charindex) #else int charSave( int ti , char *id , char *charname , char *opt , char *charinfo, int unlock , int mesgid ) #endif { #ifdef _NewSave #else int charindex; #endif char savebuf[CHARDATASIZE]; int ret = -1; memset(savebuf, 0, sizeof(savebuf)); //andy_log if( strstr( charinfo, "DATAEND=") == NULL ){ FILE *fp; if( (fp=fopen( "badpetstring.txt", "a+")) != NULL ){ fprintf( fp, "%s\n", charinfo); fclose( fp); } log( "err add batpetstring.txt:%s[%s] !\n", id, charname); } if( unlock ){ char result[100]; char retdata[100]; #ifdef _LOCK_ADD_NAME if( (ret = lockUser( getGSName(ti), id , "" , "0" , 0 , result , sizeof( result ) , retdata , sizeof( retdata ) , "0" , "0")) < 0 ){ #else if( (ret = lockUser( getGSName(ti), id , "0" , 0 , result , sizeof( result ) , retdata , sizeof( retdata ) , "0" , "0")) < 0 ){ #endif log( "½âËø:%s ʧ°Ü!!\n", id); } } // Nuke *1 add escape if( makeSaveCharString( savebuf , sizeof( savebuf ) , charname, opt , charinfo )<0){ log("\n AC´æµµ:Ì«³¤ "); saacproto_ACCharSave_send( ti , FAILED , "too long" , mesgid ); // Spock fixed 2000/11/1 return ret; } #ifdef _NewSave if (charindex == -1) charindex = getCharIndexByName( id , charname ); #else // Nuke *1- charindex = getCharIndexByName( id , charname ); #endif if( charindex < 0 ){ int blankind = findBlankCharIndex( id ); if( blankind < 0 ){ log("\n ACCharSave:char full "); saacproto_ACCharSave_send( ti , FAILED , "char full" ,mesgid); return ret; } else { charindex = blankind; } } log( "Õ˺Å:[%s] ÈËÎï:[%s]\n", id, charname ); if( saveCharOne( id , charindex , savebuf ) < 0 ){ log("\n ACCharSave:disk I/O error or a bug "); saacproto_ACCharSave_send( ti , FAILED , "disk I/O error or a bug", mesgid ); return ret; } saacproto_ACCharSave_send( ti , SUCCESSFUL , "" , mesgid); return ret; } void charListCallback( int ti , int auth , char *c0 , char *c1 , char *c2 , char *c3 , char *c4 , int i0 , int i1 ) { char listbuf[CHARDATASIZE]; char *id = c0; int mesgid = i0; //log(" µµ°¸Áбí»ØËÝ:%s:%d \n", id, auth); if( auth != 0 ){ char data[100]; snprintf( data, sizeof( data ) , "%d" , auth ); saacproto_ACCharList_send( ti , FAILED , data , mesgid ); total_ng_charlist++; return; } // È¡ÏûÏÂÁÐ unlock ¶¯×÷ if( isLocked( id ) ){ saacproto_ACCharList_send( ti , FAILED , "locked" , mesgid ); checkGSUCheck( id ); total_ng_charlist++; return; } #ifdef _SLEEP_CHAR // Èç¹ûÎÞеµ, ½«¾ÉµµÒÆÖÁеµ { char fn_old[256], fn_new[256]; FILE *fp_old, *fp_new; int i; // ÒÆÈËÎïµµ for( i=0; i<MAXCHAR_PER_USER; i++) { makeCharFileName( id, fn_new, sizeof(fn_new), i); fp_new = fopen( fn_new, "r"); if( fp_new == NULL ) { makeSleepCharFileName( id, fn_old, sizeof(fn_old), i); fp_old = fopen( fn_old, "r"); if( fp_old != NULL ) { fclose( fp_old); rename( fn_old, fn_new); // °áÒÆ //filecopy( fn_old, fn_new); // ¸´ÖÆ log(" ÒƵµ_%s ", fn_new); } } else { fclose( fp_new); } } // ÒƲÖÎïÆ·¿âµµ makeCharPoolItemFileName( id, fn_new, sizeof(fn_new)); fp_new = fopen( fn_new, "r"); if( fp_new == NULL ) { makeSleepCharPoolItemFileName( id, fn_old, sizeof(fn_old)); fp_old = fopen( fn_old, "r"); if( fp_old != NULL ) { fclose( fp_old); rename( fn_old, fn_new); // °áÒÆ //filecopy( fn_old, fn_new); // ¸´ÖÆ log(" ÒƵµ_%s ", fn_new); } } else { fclose( fp_new); } // ÒƲֳèÎï¿âµµ makeCharPoolPetFileName( id, fn_new, sizeof(fn_new)); fp_new = fopen( fn_new, "r"); if( fp_new == NULL ) { makeSleepCharPoolPetFileName( id, fn_old, sizeof(fn_old)); fp_old = fopen( fn_old, "r"); if( fp_old != NULL ) { fclose( fp_old); rename( fn_old, fn_new); // °áÒÆ //filecopy( fn_old, fn_new); // ¸´ÖÆ log(" ÒƵµ_%s ", fn_new); } } else { fclose( fp_new); } } #endif loadCharNameAndOption( id , listbuf,sizeof(listbuf)); // Arminius saacproto_ACCharList_send( ti , SUCCESSFUL , listbuf , mesgid); total_ok_charlist++; }
void charLoadCallback( int ti , int auth , char *c0, char* c1 , char *c2 , char *c3, char *c4, int i0 , int i1 ) { // Spock deleted 2000/11/2 //static int process_id = 0; // CoolFish: Init charindex 2001/10/16 #ifdef _NewSave int charindex = -1; #else int charindex; #endif #ifndef _LOCK_SERVER char loadbuf[CHARDATASIZE]; char infobuf[CHARDATASIZE]; int lock = i0; #endif char *process = c3; char *id = c0; char *passwd = c1; char *charname = c2; int mesgid = i1; char *deadline = c4; // Spock deleted 2000/11/2 //process_id++; if( auth != 0 ){ char data[100]; snprintf( data, sizeof( data ), "%d" , auth ); #ifdef _NewSave saacproto_ACCharLoad_send( ti , FAILED , data, mesgid, charindex ); #else saacproto_ACCharLoad_send( ti , FAILED , data, mesgid ); #endif #ifdef _FIX_MESSAGE // WON ADD 修改WORKER封包內容 // 同一星系重覆登入送 game end if( auth == 204 ){ #ifdef _WAEI_KICK log("\n (%s) AP同一星系重覆登入,踢人!! ", id ); saacproto_ACKick_recv( ti, id, 7, -1); //踢人 #ifdef _UNLOCKPOOL addUnlockPool( ti, id, "", process, ""); // AP解鎖 #else addWorkerTask( id , "dummy" , "3" , dummyCallback , ti , id , "dummy" , charname , process ,"", mesgid , 0 ); #endif #endif }else log("\n (%s) 登入異常!!:%d ", id, auth ); #endif return; } #ifdef _DELAY_UNLOCK if( UNlockM_isBe( id ) ){ saacproto_ACCharLoad_send( ti , FAILED , "locked" , mesgid, charindex ); return; }else #endif if( isLocked( id ) ){ //int process; #ifdef _NewSave saacproto_ACCharLoad_send( ti , FAILED , "locked" , mesgid, charindex ); #else saacproto_ACCharLoad_send( ti , FAILED , "locked" , mesgid ); #endif //DeleteMemLock(getHash(id) & 0xff, id, &process); // 如果AP無鎖則AC解鎖 log("\n (%s) AC同一星系重覆登入,踢人!! ", id ); saacproto_ACKick_recv( ti, id, 7, -1); //踢人 // checkGSUCheck( id); return; } #ifdef _LOCK_SERVER if( CHECK_LS_BEUSE() == TRUE ) { LServer_SACheckLock2_send( ti, id, mesgid, charname, 1, process);//process return; }else { saacproto_ACCharLoad_send( ti , FAILED , "locked" , mesgid, charindex ); } #else charindex = getCharIndexByName( id , charname ); #ifdef _NewSave log("\nCharLoad charindex:%d id:%s charname:%s\n", charindex, id, charname); #endif if( charindex < 0 ){ /* 平乓仿互繡箕仄卅中及匹巨仿□卅及分 */ #ifdef _NewSave saacproto_ACCharLoad_send( ti , FAILED , "char nonexistent" , mesgid , charindex ); #else saacproto_ACCharLoad_send( ti , FAILED , "char nonexistent" , mesgid ); #endif return; } log( "loadCharOne: id:[%s] char:[%s]\n", id, charname ); if( loadCharOne( id , charindex , loadbuf ,sizeof( loadbuf ))<0){ #ifdef _NewSave saacproto_ACCharLoad_send( ti , FAILED , "cannot load ( disk i/o error?)", mesgid, charindex ); #else saacproto_ACCharLoad_send( ti , FAILED , "cannot load ( disk i/o error?)", mesgid ); #endif return; }else{ #ifdef _CHAR_POOLITEM checkCharPoolItem( id); #endif #ifdef _CHAR_POOLITEM checkCharPoolPet( id); #endif } {//ttom char *c_ptr; c_ptr=loadbuf; while(*c_ptr!='\0'){ if( IS_2BYTEWORD(*c_ptr) ){ if(*(c_ptr+1)==' '){ *(c_ptr+1)=0x41; } c_ptr++; if(*c_ptr=='\0') break; } c_ptr++; } }//ttom if( lock ){ char result[100]; char retdata[100]; #ifdef _LOCK_ADD_NAME if( lockUser( getGSName(ti) , id , charname, passwd , 1 , result , sizeof( result ) , retdata , sizeof( retdata ) , process , deadline) <0 ){ #else // Spock 2000/11/2 if( lockUser( getGSName(ti) , id , passwd , 1 , result , sizeof( result ) , retdata , sizeof( retdata ) , process , deadline) <0 ){ #endif saacproto_ACCharLoad_send( ti , FAILED, "lock FAIL!!" , mesgid , charindex ); return; }else { #ifdef _TIMEOUTKICK // #endif } } memset( infobuf , 0 , sizeof( infobuf )); getCharInfoFromString( loadbuf , infobuf ); makeStringFromEscaped( infobuf ); #ifdef _BAD_PLAYER // WON ADD 送壞玩家去關 { extern int MAX_BAD_PLAYER; extern char BadPlayerList[500][20]; // 定義最大 500 名 int i; for( i=0; i<=MAX_BAD_PLAYER; i++){ if( strcmp( id, BadPlayerList[i] ) == 0){ saacproto_ACCharLoad_send( ti , BADPLAYER , infobuf , mesgid, charindex ); #ifdef _WAEI_KICK saacproto_ACKick_recv( ti, id, 10, -1); #endif return; } } } #endif #ifdef _NewSave saacproto_ACCharLoad_send( ti , SUCCESSFUL , infobuf , mesgid, charindex ); #else saacproto_ACCharLoad_send( ti , SUCCESSFUL , infobuf , mesgid); #endif #ifdef _WAEI_KICK saacproto_ACKick_recv( ti, id, 10, -1); //踢其他星系 #endif #endif } #ifdef _NewSave int charSave( int ti , char *id , char *charname , char *opt , char *charinfo, int unlock , int mesgid , int charindex) #else int charSave( int ti , char *id , char *charname , char *opt , char *charinfo, int unlock , int mesgid ) #endif { #ifdef _NewSave #else int charindex; #endif char savebuf[CHARDATASIZE]; int ret = -1; memset(savebuf, 0, sizeof(savebuf)); //andy_log if( strstr( charinfo, "DATAEND=") == NULL ){ FILE *fp; if( (fp=fopen( "badpetstring.txt", "a+")) != NULL ){ fprintf( fp, "%s\n", charinfo); fclose( fp); } log( "err add batpetstring.txt:%s[%s] !\n", id, charname); } if( unlock ){ char result[100]; char retdata[100]; #ifdef _LOCK_ADD_NAME if( (ret = lockUser( getGSName(ti), id , "" , "0" , 0 , result , sizeof( result ) , retdata , sizeof( retdata ) , "0" , "0")) < 0 ){ #else if( (ret = lockUser( getGSName(ti), id , "0" , 0 , result , sizeof( result ) , retdata , sizeof( retdata ) , "0" , "0")) < 0 ){ #endif log( "Unlock:%s FAILED err!!\n", id); } #ifdef _LOCK_SERVER if( CHECK_LS_BEUSE() == TRUE ) { LServer_SAUNLock_send( ti, id, mesgid, 1); } #endif } // Nuke *1 add escape if( makeSaveCharString( savebuf , sizeof( savebuf ) , charname, opt , charinfo )<0){ log("\n ACCharSave:too long "); saacproto_ACCharSave_send( ti , FAILED , "too long" , mesgid ); // Spock fixed 2000/11/1 return ret; } #ifdef _NewSave if (charindex == -1) charindex = getCharIndexByName( id , charname ); #else // Nuke *1- charindex = getCharIndexByName( id , charname ); #endif if( charindex < 0 ){ int blankind = findBlankCharIndex( id ); if( blankind < 0 ){ log("\n ACCharSave:char full "); saacproto_ACCharSave_send( ti , FAILED , "char full" ,mesgid); return ret; } else { charindex = blankind; } } log( "ID:[%s] char:[%s]\n", id, charname ); if( saveCharOne( id , charindex , savebuf ) < 0 ){ log("\n ACCharSave:disk I/O error or a bug "); saacproto_ACCharSave_send( ti , FAILED , "disk I/O error or a bug", mesgid ); return ret; } else { #ifdef _SASQL sasql_save_nm( charindex, id, charname ); sasql_save_opt( charindex, id, opt ); sasql_save_int_info( charindex, id, charinfo ); sasql_save_char_info( charindex, id, charinfo ); #endif } saacproto_ACCharSave_send( ti , SUCCESSFUL , "" , mesgid); return ret; } void charListCallback( int ti , int auth , char *c0 , char *c1 , char *c2 , char *c3 , char *c4 , int i0 , int i1 ) { #ifndef _LOCK_SERVER char listbuf[CHARDATASIZE]; #endif char *id = c0; int mesgid = i0; log(" charListCallback:%s:%d ", id, auth); if( auth != 0 ){ char data[100]; snprintf( data, sizeof( data ) , "%d" , auth ); saacproto_ACCharList_send( ti , FAILED , data , mesgid ); total_ng_charlist++; return; } #ifdef _SASQL1 if (sasql_query(c0,c1)){ log(" 密碼錯誤或沒有註冊 "); saacproto_ACCharList_send( ti , FAILED , "Password error" , mesgid); return; } #endif // 取消下列 unlock 動作 #ifdef _FIX_MESSAGE // WON ADD 修改WORKER封包內容 #ifdef _DELAY_UNLOCK if( UNlockM_isBe( id ) ){ saacproto_ACCharList_send( ti , FAILED , "locked" , mesgid ); return; }else #endif if( isLocked( id ) ){ saacproto_ACCharList_send( ti , FAILED , "locked" , mesgid ); //DeleteMemLock(getHash(id) & 0xff, id, &process); // 如果AP無鎖則AC解鎖 log("\n (%s) charlist_AC同一星系重覆登入,踢人!! ", id ); //saacproto_ACKick_recv( ti, id, 7, -1); //踢人 checkGSUCheck( id ); total_ng_charlist++; return; } #endif // end FIX_MESSAGE #ifdef _LOCK_SERVER if( CHECK_LS_BEUSE() == TRUE ) { LServer_SACheckLock1_send( ti, id, mesgid, 1); }else { saacproto_ACCharList_send( ti , FAILED , "locked" , mesgid ); total_ng_charlist++; } #else #ifdef _SLEEP_CHAR // 如果無新檔, 將舊檔移至新檔 { char fn_old[256], fn_new[256]; FILE *fp_old, *fp_new; int i; // 移人物檔 for( i=0; i<MAXCHAR_PER_USER; i++) { makeCharFileName( id, fn_new, sizeof(fn_new), i); fp_new = fopen( fn_new, "r"); if( fp_new == NULL ) { makeSleepCharFileName( id, fn_old, sizeof(fn_old), i); fp_old = fopen( fn_old, "r"); if( fp_old != NULL ) { fclose( fp_old); rename( fn_old, fn_new); // 搬移 //filecopy( fn_old, fn_new); // 複製 log(" 移檔_%s ", fn_new); } } else { fclose( fp_new); } } // 移倉庫檔 makeCharPoolItemFileName( id, fn_new, sizeof(fn_new)); fp_new = fopen( fn_new, "r"); if( fp_new == NULL ) { makeSleepCharPoolItemFileName( id, fn_old, sizeof(fn_old)); fp_old = fopen( fn_old, "r"); if( fp_old != NULL ) { fclose( fp_old); rename( fn_old, fn_new); // 搬移 //filecopy( fn_old, fn_new); // 複製 log(" 移檔_%s ", fn_new); } } else { fclose( fp_new); } } #endif #ifdef _DEATH_FAMILY_LOGIN_CHECK//無法讀取人物資料 if( loadCharNameAndOption( id , listbuf,sizeof(listbuf)) == 0 ){ saacproto_ACCharList_send( ti , FAILED , "locked" , mesgid ); return; } #endif #ifdef _DEATH_CONTEND //無法讀取人物資料 if( loadCharNameAndOption( id , listbuf,sizeof(listbuf)) == 0 ){ saacproto_ACCharList_send( ti , FAILED , "locked" , mesgid ); return; } #else loadCharNameAndOption( id , listbuf,sizeof(listbuf)); #endif // Arminius saacproto_ACCharList_send( ti , SUCCESSFUL , listbuf , mesgid); total_ok_charlist++; #endif }