?? callfromcli.c
字號:
#include "version.h"#include <stdio.h>#include <time.h>#include <stdlib.h>#include "common.h"#include "util.h"#include "lssproto_serv.h"#include "saacproto_cli.h"#include "net.h"#include "char.h"#include "object.h"#include "readmap.h"#include "addressbook.h"#include "handletime.h"#include "configfile.h"#include "event.h"#include "pet.h"#include "battle.h"#include "battle_command.h"#include "magic.h"#include "petmail.h"#include "item_gen.h"#include "pet_skill.h"#include "log.h" //add this because the second had it#include "map_deal.h" // CoolFish: 2001/4/18#include "trade.h" // CoolFish: Trade 2001/4/18#include "family.h" // CoolFish: Family 2001/5/24#include "item_event.h" // shan: blackmarket#ifdef _PROFESSION_SKILL // WON ADD 人物職業技能#include "profession_skill.h"#endif#ifdef _CHATROOMPROTOCOL // (不可開) Syu ADD 聊天室頻道#include "chatroom.h"#endifBOOL checkStringErr( char * );// shan addextern struct FM_PKFLOOR fmpkflnum[FAMILY_FMPKFLOOR];/* ----------------------------------------------------------------------- * 薊 仄兇 讀及 寞井日平乓仿奶件犯永弁旦毛 月 * ----------------------------------------------------------------------*/static int Callfromcli_Util_getTargetCharaindex( int fd, int toindex){ int to_charaindex = -1; int fd_charaindex = CONNECT_getCharaindex( fd ); /* 憤坌憤褥 */ if( toindex == 0 ) { to_charaindex = fd_charaindex; } /* 矢永玄 1 5 */ else if( toindex > 0 && toindex < 6 ) { to_charaindex = CHAR_getCharPet( fd_charaindex, toindex-1); if( !CHAR_CHECKINDEX( to_charaindex)) { to_charaindex = -1; } } /* 醮棉 6 10 */ else if( toindex > 5 && toindex < 11 ) { to_charaindex = CHAR_getPartyIndex( fd_charaindex, toindex - 6); } return to_charaindex;}/*---------------------------------------- * 弁仿奶失件玄互夫弘奶件允月 匹手丟乒伉卞巹戶月分仃卅及匹民尼永弁反卅中 * 仇木毛裟少午 CLI 卞卅月[ ----------------------------------------*/void lssproto_ClientLogin_recv( int fd,char* cdkey, char* passwd ){ /* 2褐卞仇木互裟壬木月及反中中 */ /* 由旦伐□玉 凳毛仄化岳 分勻兇日瘋太仇木毛裟少儀[*/ {//ttom avoid the restore 2001/01/09 int fd_charaindex; Char *chwk; // CoolFish: +2 2001/4/18 fd_charaindex = CONNECT_getCharaindex(fd); chwk = CHAR_getCharPointer(fd_charaindex); if(CONNECT_isNOTLOGIN(fd)==FALSE){ print("\n the Client had Logined fd=%d",fd); return; } } //print( "CliLogin cdkey=%s\n" , cdkey ); /* connect卞戊疋□允月 */ CONNECT_setCdkey( fd, cdkey ); CONNECT_setPasswd( fd, passwd ); CONNECT_setCtype( fd, CLI ); {//ttom unsigned long ip; int a,b,c,d; int i; ip=CONNECT_get_userip(fd); a=(ip % 0x100); ip=ip / 0x100; b=(ip % 0x100); ip=ip / 0x100; c=(ip % 0x100); ip=ip / 0x100; d=(ip % 0x100); print( "\n登陸賬號=%s 來自 %d.%d.%d.%d \n",cdkey,a,b,c,d); for(i=0;i<getMaxLockip();i++) if(cmpLockip(i,a,b,c,d,1))return; } /* 忒蠶 */ lssproto_ClientLogin_send( fd , "ok" );}void lssproto_CreateNewChar_recv( int fd,int dataplacenum,char* charname, int imgno,int faceimgno, int vital,int str,int tgh,int dex, int earth,int water,int fire,int wind, int hometown ){ char cdkey[CDKEYLEN]; if( CONNECT_isCLI( fd ) == FALSE )return; if( CONNECT_isNOTLOGIN(fd) == FALSE ){ lssproto_CreateNewChar_send( fd, FAILED, "Not NOTLOGIN State\n" ); return; }#ifdef _DEATH_FAMILY_LOGIN_CHECK // pk戰無法創新人物 lssproto_CreateNewChar_send( fd, FAILED, "" ); return;#endif#ifdef _DEATH_CONTEND // pk戰無法創新人物 lssproto_CreateNewChar_send( fd, FAILED, "" ); return;#endif if( strlen( charname ) == 0 ){ lssproto_CreateNewChar_send(fd,FAILED, "0 length name\n"); return; }else if( strlen(charname) >= 32 ){ lssproto_CreateNewChar_send(fd,FAILED, "Too long charname\n"); return; // Nuke start 0711: Avoid naming as WAEI }else if (strstr(charname,"華義") // WON ADD || strstr(charname,"gm") || strstr(charname,"GM") || strstr(charname,"Gm") || strstr(charname,"gM") || strstr(charname,"gm") || strstr(charname,"GM") || strstr(charname,"Gm") || strstr(charname,"gM") #ifdef _UNREG_NEMA || (strstr(charname,getUnregname(0)) && strlen(getUnregname(0))>0) || (strstr(charname,getUnregname(1)) && strlen(getUnregname(1))>0) || (strstr(charname,getUnregname(2)) && strlen(getUnregname(2))>0) || (strstr(charname,getUnregname(3)) && strlen(getUnregname(3))>0) || (strstr(charname,getUnregname(4)) && strlen(getUnregname(4))>0)#endif || strstr(charname,"神秘人物")// WON END ) { unsigned ip=CONNECT_get_userip(fd); int a, b, c, d, ck; a=(ip % 0x100); ip=ip / 0x100; b=(ip % 0x100); ip=ip / 0x100; c=(ip % 0x100); ip=ip / 0x100; d=(ip % 0x100); ck= ( ( (a== 10) && (b==0) && (c==0) ) || ( (a==211) && (b==76) && (c==176) && (d==21) ) || // 臺北wayi ( (a==210) && (b==64) && (c==97) && ((d>=21)&&(d<=25)) ) || ( (a==61) && (b==222) && (c==142) && (d==66) ) ); print(" name_WAEI_IP:%d.%d.%d.%d ck:%d ",a,b,c,d,ck ); if( !ck ) { lssproto_CreateNewChar_send(fd,FAILED, "Invalid charname\n"); return; } } { // Nuke start 0801,0916: Avoid strange name int i,ach; for (i=0,ach=0;i<strlen(charname);i++) { if ((unsigned char)charname[i]==0xff) { ach=1; break; } // Force no 0xff if (((unsigned char)charname[i]>=0x7f)&& ((unsigned char)charname[i]<=0xa0)) { ach=1; break; } // Force no 0x7f~0xa0 if ((unsigned char)charname[i]<=0x20) { ach=1; break; } // Force greater than 0x20 if (ach) { if ((((unsigned char)charname[i]>=0x40)&&((unsigned char)charname[i]<=0x7e))|| (((unsigned char)charname[i]>=0xa1)&&((unsigned char)charname[i]<=0xfe))) ach=0; } else { if (((unsigned char)charname[i]>=0xa1)&&((unsigned char)charname[i]<=0xfe)) ach=1; } } if (ach) { lssproto_CreateNewChar_send(fd,FAILED, "Error in Chinese\n"); return; } // Nuke end } // Nuke end CONNECT_getCdkey( fd, cdkey, sizeof( cdkey )); CHAR_createNewChar( fd, dataplacenum, charname ,imgno, faceimgno, vital, str, tgh, dex, earth, water, fire, wind, hometown , cdkey );}void lssproto_CharLogin_recv( int fd,char* charname ){ char cdkey[CDKEYLEN], passwd[PASSWDLEN]; if( CONNECT_isCLI( fd ) == FALSE )return; print( "\n嘗試登陸: 人物名稱=%s\n", charname); if( charname[0] == '\0' ){ lssproto_CharLogin_send( fd, FAILED, "\n人物名稱含有不能訪問字符\n" ); return; } if( CONNECT_isNOTLOGIN(fd) == FALSE ){ lssproto_CharLogin_send( fd, FAILED, "Already Logged in\n" ); return; } CONNECT_setCharname( fd, charname ); CONNECT_getCdkey( fd, cdkey, sizeof( cdkey )); CONNECT_getPasswd( fd, passwd, sizeof(passwd)); saacproto_ACCharLoad_send( acfd, cdkey,passwd, charname,1,"", CONNECT_getFdid(fd) ); CONNECT_setState( fd, WHILELOGIN );}#ifdef _ITEM_CHECKDROPATLOGOUTBOOL CheckDropatLogout(int charaindex ){ int i; for( i=0 ; i<CHAR_MAXITEMHAVE ; i++ ){ int itemindex; itemindex = CHAR_getItemIndex(charaindex,i); if( ITEM_CHECKINDEX(itemindex) == FALSE )continue; if( ITEM_getInt(itemindex,ITEM_DROPATLOGOUT ) == TRUE ) { return TRUE; } } return FALSE;} #endifvoid lssproto_CharLogout_recv( int fd, int flg){ char cdkey[CDKEYLEN] , charname[CHARNAMELEN]; if( CONNECT_isCLI( fd ) == FALSE )return; if( CONNECT_isLOGIN(fd) == FALSE ){ lssproto_CharLogout_send( fd, FAILED, "Not Logged in\n" ); return; } { int charaindex=CONNECT_getCharaindex(fd); int fl,x,y; // CoolFish: 2001/10/18 if (!CHAR_CHECKINDEX(charaindex)) return;#ifdef _MUSEUM if( (CHAR_getInt( charaindex, CHAR_LASTTALKELDER) >= 0) || getMuseum() )#else if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) >= 0 )#endif {#ifdef _MUSEUM if( getMuseum() ) { fl = 9000; x = 40; y = 40; } else { CHAR_getElderPosition( CHAR_getInt( charaindex, CHAR_LASTTALKELDER), &fl, &x, &y ); }#else CHAR_getElderPosition( CHAR_getInt( charaindex, CHAR_LASTTALKELDER), &fl, &x, &y );#endif#ifdef _CHAR_NEWLOGOUT if( flg == 1 ){//回紀錄點 if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE){ CHAR_talkToCli( charaindex, -1, "戰斗中無法回紀錄點!", CHAR_COLORYELLOW); return; }#ifdef _ITEM_CHECKWARES if( CHAR_CheckInItemForWares( charaindex, 0) == FALSE ){ CHAR_talkToCli( charaindex, -1, "攜帶貨物無法使用。", CHAR_COLORYELLOW); return; }#endif#ifdef _BAD_PLAYER // WON ADD 送壞玩家去關 if( (CHAR_getInt(charaindex,CHAR_FLOOR)==117)||(CHAR_getInt(charaindex,CHAR_FLOOR)==887) ){ CHAR_talkToCli( charaindex, -1, "此處無法使用。", CHAR_COLORYELLOW); return; }#endif if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) != CHAR_PARTY_NONE ){ CHAR_talkToCli( charaindex, -1, "團隊中無法回紀錄點!", CHAR_COLORYELLOW); return; }#ifdef _ITEM_CHECKDROPATLOGOUT if( CheckDropatLogout( charaindex ) ){ CHAR_talkToCli( charaindex, -1, "攜帶的物品使你無法回紀錄點!", CHAR_COLORYELLOW); return; }#endif#ifdef _DEATH_CONTEND/* if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ if( CHAR_getInt( charaindex, CHAR_FLOOR) != 8250 && CHAR_getInt( charaindex, CHAR_PKLISTLEADER) == 1 ){ //andy_log print("PlayerLogout_Exit()\n"); NPC_PKLIST_PlayerLogout_Exit( charaindex ); CHAR_warpToSpecificPoint( charaindex, 8250, 17, 17 ); } }*/#else if( CHAR_getInt( charaindex,CHAR_FLOOR ) != 117 && CHAR_getInt( charaindex,CHAR_FLOOR ) != 887 #ifdef _ADD_DUNGEON //追加地牢 && CHAR_getInt( charaindex,CHAR_FLOOR ) != 8513#endif ){ CHAR_warpToSpecificPoint( charaindex, fl, x, y ); }#endif return; }#else if( CHAR_getInt(charaindex,CHAR_FLOOR ) == 117){ CHAR_setInt(charaindex,CHAR_X,225); CHAR_setInt(charaindex,CHAR_Y,13); }else{ CHAR_setInt(charaindex,CHAR_FLOOR,fl); CHAR_setInt(charaindex,CHAR_X,x); CHAR_setInt(charaindex,CHAR_Y,y); }#endif } // Robin add //CHAR_setInt( charaindex, CHAR_LASTLEAVETIME, (int)time(NULL)); } CHAR_logout(fd,TRUE); CONNECT_setState( fd, WHILELOGOUTSAVE ); CONNECT_setCharaindex( fd, -1 ); CONNECT_getCdkey( fd, cdkey, sizeof(cdkey )); CONNECT_getCharname( fd, charname, sizeof(charname)); print( "Logout cdkey:%s charname=%s\n" , cdkey, charname );}void lssproto_CharDelete_recv( int fd , char* charname){ char cdkey[CDKEYLEN],passwd[PASSWDLEN]; int fdid; if( CONNECT_isCLI( fd ) == FALSE )return; if( CONNECT_isNOTLOGIN( fd ) == FALSE ){ lssproto_CharDelete_send( fd, FAILED, "Already Logged in\n" ); return; } CONNECT_getCdkey( fd, cdkey, sizeof(cdkey)); CONNECT_getPasswd( fd, passwd, sizeof(passwd)); fdid = CONNECT_getFdid(fd); saacproto_ACCharDelete_send( acfd, cdkey,passwd, charname , "" ,fdid );#ifndef _DEATH_CONTEND { char buff[512]; char escapebuf[1024]; snprintf( buff, sizeof(buff), "%s_%s", cdkey, charname); makeEscapeString( buff, escapebuf, sizeof(escapebuf)); saacproto_DBDeleteEntryInt_send(acfd, DB_DUELPOINT, escapebuf, fdid, 0 ); saacproto_DBDeleteEntryString_send( acfd, DB_ADDRESSBOOK, escapebuf, fdid, 0 ); } saacproto_Broadcast_send( acfd, cdkey, charname, "chardelete", 0);#endif CONNECT_setState( fd, WHILECHARDELETE );}void lssproto_CharList_recv( int fd ){ char cdkey[CDKEYLEN], passwd[PASSWDLEN]; int fdid=-1; if( CONNECT_isCLI( fd ) == FALSE )return; if( CONNECT_isNOTLOGIN( fd ) == FALSE ){ lssproto_CharList_send( fd, FAILED, "Already Logged in\n" ); return; } CONNECT_getCdkey( fd, cdkey, sizeof(cdkey)); CONNECT_getPasswd( fd, passwd, sizeof(passwd)); fdid = CONNECT_getFdid( fd ); { int i; int playernum = CHAR_getPlayerMaxNum(); for( i=0; i<playernum; i++){ if( !CHAR_CHECKINDEX( i) )continue; if( !strcmp( CHAR_getChar( i, CHAR_CDKEY), cdkey) ){ lssproto_CharList_send( fd, FAILED, "-1" ); CONNECT_setState( fd, NOTLOGIN ); return; } } }//#ifdef _PKSEVER_VER// saacproto_ACCharList_send(acfd, cdkey, passwd, fdid, star);//#else saacproto_ACCharList_send(acfd, cdkey, passwd, fdid );
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -