📄 char_walk.c
字号:
if( CHAR_getFlg( index,CHAR_ISDIE ) )return; CHAR_setWorkChar( index,CHAR_WORKWALKARRAY, dir ); CHAR_setWorkInt( index, CHAR_WORKWALKSTARTSEC , NowTime.tv_sec ); CHAR_setWorkInt( index, CHAR_WORKWALKSTARTMSEC , NowTime.tv_usec ); CHAR_setMyPosition( index, x, y, FALSE); if( mapsendmode ) { int ox,oy; char buf[64]; int len; int i; strcpysafe( buf, sizeof(buf), CHAR_getWorkChar( index, CHAR_WORKWALKARRAY)); len = strlen( buf ); ox = CHAR_getInt(index,CHAR_X); oy = CHAR_getInt(index,CHAR_Y); for( i = 0; i < len; i ++ ) { int dir,mode; int fx,fy; CHAR_ctodirmode( buf[i], &dir ,&mode ); if( mode == 0 ) { CHAR_getCoordinationDir( dir,ox,oy,1,&fx,&fy); ox = fx; oy = fy; } } CHAR_sendMapAtWalk(index, CHAR_getInt( index, CHAR_FLOOR), CHAR_getInt( index, CHAR_X), CHAR_getInt( index, CHAR_Y), ox,oy); } if( strlen( dir ) >= 1 ) CHAR_walkcall( index );}/*------------------------------------------------------------ * 汹五及 赓 * 娄醒 * index int 平乓仿 匹及奶件犯永弁旦 * dir char* 轾 侬 * id int ID * 忒曰袄 * 卅仄 ------------------------------------------------------------*/void CHAR_walk_init( int fd, int x, int y, char *direction, BOOL mapsendmode){ if( strlen( direction) > 32) { print( "walkarray length over\n"); return; } // Nuke +1 : For acceleration avoidance if (checkWalkTime(fd) < 0) { CONNECT_setCloseRequest(fd,1); print("Walk drop "); return; } if( CHAR_getWorkInt( CONNECT_getCharaindex(fd), CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE){ return ; } if( CHAR_getWorkInt( CONNECT_getCharaindex(fd), CHAR_WORKPARTYMODE ) != CHAR_PARTY_CLIENT ){ CHAR_walk_start( CONNECT_getCharaindex(fd), x, y, direction, mapsendmode ); }else { int dir, mode; CHAR_ctodirmode( direction[0], &dir ,&mode ); if( mode == 0 ) { //print( "玩家并非领队也非单人玩家。\n"); }else { CHAR_walk_start( CONNECT_getCharaindex(fd), x,y,direction, FALSE ); } }}void CHAR_sendCharaAtWalk( int charaindex, int of,int ox,int oy,int xflg, int yflg ){ int fd = -1; int i,j,fl, x, y; char introduction[512]; char c_msg[1024*96]; int strpos = 0; int seesiz = CHAR_DEFAULTSEESIZ/2; char cabuf[128]; char myintroduction[512]; int whichtype; whichtype = CHAR_getInt( charaindex, CHAR_WHICHTYPE); if( whichtype == CHAR_TYPEPLAYER) { fd = getfdFromCharaIndex( charaindex ); if( fd == -1 )return; } if( xflg > 1 || xflg < -1 ) { print( "%s:%d: arg err[xflg]\n",__FILE__, __LINE__); return; } if( yflg > 1 || yflg < -1 ) { print( "%s:%d: arg err[yflg]\n",__FILE__, __LINE__); return; } fl = CHAR_getInt( charaindex, CHAR_FLOOR); x = CHAR_getInt( charaindex, CHAR_X); y = CHAR_getInt( charaindex, CHAR_Y); if( of != fl || ABS(x - ox) > seesiz/2 || ABS(y - oy) > seesiz/2 ) return; c_msg[0] = '\0'; if( !CHAR_makeObjectCString( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), myintroduction, sizeof( myintroduction))){ myintroduction[0] = '\0'; } if( xflg != 0) { i = x + seesiz * xflg; for( j = y-seesiz ; j <= y+seesiz ;j ++ ) { OBJECT object; for( object = MAP_getTopObj(fl,i,j) ; object ; object = NEXT_OBJECT(object ) ){ int introlen; int objindex = GET_OBJINDEX(object); int c_index = OBJECT_getIndex( objindex); if( OBJECT_getType(objindex) == OBJTYPE_NOUSE ) continue; if( OBJECT_getType(objindex) == OBJTYPE_CHARA && !CHAR_getFlg(OBJECT_getIndex(objindex), CHAR_ISVISIBLE) ){ continue; } if( strlen( myintroduction) != 0 ) { if( OBJECT_getType( objindex) == OBJTYPE_CHARA ) { if( CHAR_getInt( c_index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { int tofd = getfdFromCharaIndex( c_index ); CDsend( tofd); lssproto_C_send( tofd, myintroduction); } } } if( whichtype == CHAR_TYPEPLAYER) { /* Make C*/ if( CHAR_makeObjectCString( objindex, introduction, sizeof( introduction))){ introlen = strlen( introduction); introduction[introlen] = ','; introduction[introlen+1] = '\0'; strcpysafe( &c_msg[strpos], sizeof( c_msg) - strpos, introduction); strpos += strlen( introduction); } if( OBJECT_getType(objindex) == OBJTYPE_CHARA ) { if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && CHAR_getWorkInt( c_index, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ){ if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTLEADER,1 )){ CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); } } if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER && CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ int tofd = getfdFromCharaIndex( c_index ); if( tofd != -1 ) { if( CHAR_makeCAOPT1String( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), cabuf, sizeof( cabuf), CHAR_ACTLEADER,1 )){ CONNECT_appendCAbuf( tofd,cabuf,strlen(cabuf)); } } } if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ if( CHAR_getWorkInt( c_index, CHAR_WORKBATTLEWATCH) == TRUE ) { if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTBATTLEWATCH, 1)){ CONNECT_appendCAbuf( fd, cabuf, strlen( cabuf)); } }else { int battleno = CHAR_getWorkInt( c_index, CHAR_WORKBATTLEINDEX); int sideno = CHAR_getWorkInt( c_index,CHAR_WORKBATTLESIDE); int helpno; if( !BATTLE_CHECKINDEX( battleno) ) { //print(" %s[%d]: BATTLE_CHECKINDEX( %d) err!!\n", __FILE__, __LINE__, battleno); }else { helpno = (BattleArray[ battleno].Side[ sideno].flg & BSIDE_FLG_HELP_OK) ? TRUE:FALSE; /* HelpNo = 1 反移 */ if( CHAR_makeCAOPT3String( objindex, cabuf, sizeof( cabuf), CHAR_ACTBATTLE, battleno,sideno,helpno )){ CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); } } } } if( ( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER || CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) && CHAR_getWorkInt( c_index, CHAR_WORKACTION ) != -1 ) { if( CHAR_makeCADefaultString( objindex, cabuf, sizeof( cabuf), CHAR_getWorkInt( c_index, CHAR_WORKACTION))){ CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); } }#ifdef _ADD_ACTION else if( CHAR_getWorkInt( c_index, CHAR_WORKACTION ) > 0 ) { if( CHAR_makeCADefaultString( objindex, cabuf, sizeof( cabuf), CHAR_getWorkInt( c_index, CHAR_WORKACTION))){ CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); } }#endif } } } } } if( yflg != 0) { j = y + seesiz * yflg; for( i = x-seesiz ; i <= x+seesiz ;i ++ ) { OBJECT object; for( object = MAP_getTopObj(fl,i,j) ; object ; object = NEXT_OBJECT(object ) ){ int introlen; int objindex = GET_OBJINDEX(object); int c_index = OBJECT_getIndex( objindex); if( OBJECT_getType(objindex) == OBJTYPE_NOUSE ) continue; if( OBJECT_getType(objindex) == OBJTYPE_CHARA && !CHAR_getFlg(OBJECT_getIndex(objindex), CHAR_ISVISIBLE) ){ if(!CHAR_CHECKINDEX(OBJECT_getIndex(objindex))){ printf("自动删除一个问题对象!"); endObjectOne(objindex); } continue; } if( strlen( myintroduction) != 0 ) { if( OBJECT_getType( objindex) == OBJTYPE_CHARA ) { if( CHAR_getInt( c_index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { int tofd = getfdFromCharaIndex( c_index ); CDsend( tofd); lssproto_C_send( tofd, myintroduction); } } } if( whichtype == CHAR_TYPEPLAYER ) { /* Make C*/ if( CHAR_makeObjectCString( objindex, introduction, sizeof( introduction))){ introlen = strlen( introduction); introduction[introlen] = ','; introduction[introlen+1] = '\0'; strcpysafe( &c_msg[strpos], sizeof( c_msg) - strpos, introduction); strpos += strlen( introduction); } if( OBJECT_getType(objindex) == OBJTYPE_CHARA ) { if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && CHAR_getWorkInt( c_index, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ){ if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTLEADER,1 )){ CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); } } if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER && CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE)== BATTLE_CHARMODE_NONE){ int tofd = getfdFromCharaIndex( c_index ); if( tofd != -1 ) { if( CHAR_makeCAOPT1String( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), cabuf, sizeof( cabuf), CHAR_ACTLEADER,1 )){ CONNECT_appendCAbuf( tofd,cabuf,strlen(cabuf)); } } } if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ if( CHAR_getWorkInt( c_index, CHAR_WORKBATTLEWATCH) == TRUE ) { if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTBATTLEWATCH,1)){ CONNECT_appendCAbuf( fd, cabuf, strlen( cabuf)); } }else { int battleno = CHAR_getWorkInt( c_index, CHAR_WORKBATTLEINDEX); int sideno = CHAR_getWorkInt( c_index, CHAR_WORKBATTLESIDE); int helpno = (BattleArray[CHAR_getWorkInt( c_index, CHAR_WORKBATTLEINDEX)].Side[ CHAR_getWorkInt( c_index, CHAR_WORKBATTLESIDE)].flg & BSIDE_FLG_HELP_OK) ? TRUE:FALSE; if( CHAR_makeCAOPT3String( objindex, cabuf, sizeof( cabuf), CHAR_ACTBATTLE, battleno,sideno,helpno )){ CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); } } } if( ( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER || CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) && CHAR_getWorkInt( c_index, CHAR_WORKACTION ) != -1 ) { if( CHAR_makeCADefaultString( objindex, cabuf, sizeof( cabuf), CHAR_getWorkInt( c_index, CHAR_WORKACTION))){ CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); } }#ifdef _ADD_ACTION else if( CHAR_getWorkInt( c_index, CHAR_WORKACTION ) > 0 ) { if( CHAR_makeCADefaultString( objindex, cabuf, sizeof( cabuf), CHAR_getWorkInt( c_index, CHAR_WORKACTION))){ CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); } }#endif } } } } } dchop( c_msg, "," ); if( strlen( c_msg) != 0 ) { CDflush( charaindex); lssproto_C_send( fd, c_msg); }}static void CHAR_sendCDCharaAtWalk( int charaindex, int of, int ox, int oy, int xflg, int yflg ){ int i,j,fl, x, y; int seesiz = CHAR_DEFAULTSEESIZ/2; int fd, tofd; if( xflg > 1 || xflg < -1 ) { print( "%s:%d: arg err[xflg]\n",__FILE__, __LINE__); return; } if( yflg > 1 || yflg < -1 ) { print( "%s:%d: arg err[yflg]\n",__FILE__, __LINE__); return; } fl = CHAR_getInt( charaindex, CHAR_FLOOR); x = CHAR_getInt( charaindex, CHAR_X); y = CHAR_getInt( charaindex, CHAR_Y); if( of != fl || /* 白夫失互啜丹 */ ABS(x - ox) > seesiz/2 || /* 犒互 五中 */ ABS(y - oy) > seesiz/2 ) /* 犒互 五中 */ return; fd = getfdFromCharaIndex( charaindex ); if( xflg != 0) { i = x + (seesiz * xflg + xflg)*-1; for( j = y-seesiz +(yflg*-1) ; j <= y+seesiz +(yflg*-1) ;j ++ ) { OBJECT object; for( object = MAP_getTopObj(fl,i,j) ; object ; object = NEXT_OBJECT(object ) ) { int objindex = GET_OBJINDEX(object); char buf[64]; if( OBJECT_getType(objindex) == OBJTYPE_NOUSE ) continue; if( OBJECT_getType(objindex) == OBJTYPE_CHARA && !CHAR_getFlg(OBJECT_getIndex(objindex), CHAR_ISVISIBLE) ){ if(!CHAR_CHECKINDEX(OBJECT_getIndex(objindex))){ printf("自动删除一个问题对象!"); endObjectOne(objindex); } continue; } if( fd != -1) { cnv10to62( objindex, buf, sizeof( buf)); CONNECT_appendCDbuf( fd, buf, strlen( buf)); } if( OBJECT_getType( objindex) == OBJTYPE_CHARA) { int tocharaindex = OBJECT_getIndex( objindex); if( CHAR_getInt( tocharaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { if( CHAR_getWorkInt( tocharaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ) { tofd = getfdFromCharaIndex( tocharaindex ); if( tofd != -1 ) { cnv10to62( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), buf, sizeof( buf)); CONNECT_appendCDbuf( tofd, buf, strlen( buf)); CAsend( tofd); CDsend( tofd); } } } } } } } if( yflg != 0) { j = y + (seesiz * yflg + yflg)*-1; for( i = x-seesiz + (xflg*-1) ; i <= x+seesiz + (xflg*-1) ;i ++ ) { OBJECT object; for( object = MAP_getTopObj(fl,i,j) ; object ; object = NEXT_OBJECT(object ) ){ int objindex = GET_OBJINDEX(object); char buf[64]; if( OBJECT_getType(objindex) == OBJTYPE_NOUSE ) continue; if( OBJECT_getType(objindex) == OBJTYPE_CHARA && !CHAR_getFlg(OBJECT_getIndex(objindex), CHAR_ISVISIBLE) ){ continue; } if( fd != -1 ) { cnv10to62( objindex, buf, sizeof( buf)); CONNECT_appendCDbuf( fd, buf, strlen( buf)); } if( OBJECT_getType( objindex) == OBJTYPE_CHARA) { int tocharaindex = OBJECT_getIndex( objindex); if( CHAR_getInt( tocharaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ if( CHAR_getWorkInt( tocharaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ tofd = getfdFromCharaIndex( tocharaindex ); if( tofd != -1 ) { cnv10to62( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), buf, sizeof( buf)); CONNECT_appendCDbuf( tofd, buf, strlen( buf)); CAsend( tofd); CDsend( tofd); } } } } } } } CDsend( fd);}void CHAR_ctodirmode(char moji , int* dir , int* mode){ *mode = 1; if( 'a' <= moji && moji <= 'h' )*mode = 0; *dir = tolower(moji) - 'a';}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -