📄 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: blackmarketBOOL 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; } else if( toindex > 0 && toindex < 6 ) { to_charaindex = CHAR_getCharPet( fd_charaindex, toindex-1); if( !CHAR_CHECKINDEX( to_charaindex)) { to_charaindex = -1; } } else if( toindex > 5 && toindex < 11 ) { to_charaindex = CHAR_getPartyIndex( fd_charaindex, toindex - 6); } return to_charaindex;}/*---------------------------------------- * 弁仿奶失件玄互夫弘奶件允月 匹手丢乒伉卞卺户月分仃卅及匹民尼永弁反卅中 ----------------------------------------*/void lssproto_ClientLogin_recv( int fd,char* cdkey, char* passwd ){ /* 2褐卞仇木互裟壬木月及反中中 */ {//ttom avoid the restore 2001/01/09 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 ); unsigned long tmpip; int a,b,c,d; char ip[32]; tmpip=CONNECT_get_userip(fd); a=(tmpip % 0x100); tmpip=tmpip / 0x100; b=(tmpip % 0x100); tmpip=tmpip / 0x100; c=(tmpip % 0x100); tmpip=tmpip / 0x100; d=(tmpip % 0x100); sprintf(ip,"%d.%d.%d.%d",a,b,c,d); print( "\n登陆账号=%s 密码=%s 来自=%s\n",cdkey,passwd,ip); /* 忒蚕 */ saacproto_ACCharLogin_send( acfd, fd, cdkey, passwd, ip);}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; } 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)) || ( (a==172) && (b==16) && (c==172) && (d==29) ) ); 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, "Can't access char have no name\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; if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) >= 0 ) { CHAR_getElderPosition( CHAR_getInt( charaindex, CHAR_LASTTALKELDER), &fl, &x, &y ); 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); } } // 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 ); { 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); 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) ){ CHAR_talkToCli(i, -1, "因重复登陆而掉线!",CHAR_COLORYELLOW); CONNECT_setCloseRequest( getfdFromCharaIndex( i ) , 1 );// 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 );//#endif CONNECT_setState( fd, WHILEDOWNLOADCHARLIST );}void lssproto_Echo_recv( int fd,char* arg0 ){ lssproto_Echo_send( fd , arg0 );}#define CHECKFD if( CONNECT_isCLI( fd ) == FALSE )return; if( CONNECT_isLOGIN(fd) == FALSE )return;#define CHECKFDANDTIME if( CONNECT_isCLI(fd) == FALSE )return; if( CONNECT_isLOGIN(fd) == FALSE )return;void lssproto_W_recv( int fd,int x,int y,char* direction ){ //ttom +3 int fd_charaindex, ix, iy; fd_charaindex = CONNECT_getCharaindex( fd ); ix=CHAR_getInt(fd_charaindex, CHAR_X); iy=CHAR_getInt(fd_charaindex, CHAR_Y); // CoolFish: Prevent Trade Cheat 2001/4/18 if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) return; // nuke 0407 if (checkNu(fd)<0) { // Robin 0521 print(" NU-Err "); CHAR_talkToCli(fd_charaindex, -1, "讯号错误。", CHAR_COLORYELLOW); CONNECT_setCloseRequest( fd , 1 ); return; } //ttom debug if((x==0)&&(y==0)){ //CHAR_talkToCli(fd_charaindex, -1, "因座标错误而断线。", CHAR_COLORYELLOW); // Roibn 03/14 return; } //ttom avoid the warp at will 11/6 { int i_diff_x,i_diff_y; i_diff_x=abs(ix-x); i_diff_y=abs(iy-y); // Robin 03/14 if( (i_diff_x>1)||(i_diff_y>1) ){ // Robin 0518 //CHAR_talkToCli(fd_charaindex, -1, "因走路座标错误而断线。", CHAR_COLORYELLOW); //return; x = ix; y = iy; } } if(!(MAP_walkAble(fd_charaindex,CHAR_getInt(fd_charaindex, CHAR_FLOOR),x,y))){ // Robin 03/14 x = ix; y = iy; }else{ } CHAR_walk_init( fd, x, y, direction, TRUE);}/*------------------------------------------------------------ ------------------------------------------------------------*/void lssproto_W2_recv( int fd,int x,int y,char* direction ){ //ttom +3 int fd_charaindex, ix, iy, i_fl; //Char *chwk;// CoolFish: Rem 2001/4/18 fd_charaindex = CONNECT_getCharaindex( fd ); ix=CHAR_getInt(fd_charaindex, CHAR_X); iy=CHAR_getInt(fd_charaindex, CHAR_Y); i_fl=CHAR_getInt(fd_charaindex, CHAR_FLOOR); // CoolFish: Prevent Trade Cheat 2001/4/18 if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) return; //ttom avoid the warp at will 11/6 { int i_diff_x,i_diff_y; //ix=CHAR_getInt(fd_charaindex, CHAR_X); //iy=CHAR_getInt(fd_charaindex, CHAR_Y); //i_fl=CHAR_getInt(fd_charaindex, CHAR_FLOOR); i_diff_x=abs(ix-x); i_diff_y=abs(iy-y); if( (i_diff_x>1)||(i_diff_y>1) ){//2 //print("\n<www>Warp Error!!!!!!!!!"); //print("\n<www>the origion->fd=%d,x=%d,y=%d",fd,ix,iy); //print("\n<www>the modify-->fd=%d,X=%d,Y=%d,dir=%s",fd,x,y,direction); x=ix; y=iy; // Robin 03/14 //return; } //if((i_fl==117)&&(ix==225)&&(iy==13)) goto END_w; }//ttom if(!(MAP_walkAble(fd_charaindex,CHAR_getInt(fd_charaindex, CHAR_FLOOR),x,y))){// print("\n<wwww> the map is invaild(f:%d,x:%d,y:%d)",CHAR_getInt(fd_charaindex, CHAR_FLOOR),x,y); x = ix; y = iy; } CHAR_walk_init( fd, x, y, direction, FALSE);}void lssproto_SKD_recv( int fd,int dir, int index){ CHECKFDANDTIME;}void lssproto_ID_recv( int fd,int x,int y,int haveitemindex,int toindex ){ int to_charaindex; int fd_charaindex; CHECKFDANDTIME; fd_charaindex = CONNECT_getCharaindex( fd ); // CoolFish: Prevent Trade Cheat 2001/4/18 if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -